Monday, March 21, 2011

A rough performance comparison between Xpand and Xtend 2

Xtend 2 is still in an early state. It works quite well, but there are still some issues and we haven't even started measuring and improving performance yet. Although I was pretty sure that Xtend 2 would easily outperform Xpand, I was curious how much.

Today, I wrote a small code generator (the traditional domain model to Java Beans stuff) in Xpand and Xtend 2 and compared the execution time with different numbers of model elements, just to get a first impression.
Disclaimer: Doing benchmarks is hard and I don't claim that do a fair comparison here, although I tried.

The Xpand version


The Xtend 2 version

Generating files for 1000 entities (1 file each) containing 20 properties and 5 operations each took (on average exec. the generator 10 times) :

Xtend 2 : 663 ms
Xpand : 4254 ms

If I remove the actual file writing and only do the in memory string concatenation the result was (again on average exec. the generator 10 times) :

Xtend 2 : 247 ms
Xpand : 3302 ms

So it seems as if the computation and string concatenation in Xtend2 is roughly 10 times as fast as in Xpand. As we haven't yet profiled Xtend 2, there should be room for improvements.

On a side note, I have also implemented the quicksort benchmark you can find here with Xtend 2, and found that the Java version was only twice as fast as Xtend. Compared to Groovy which was 20 times slower than Java it's quite good. It is mostly slower than Java, because we do a lot of conversion between ints and Integer (auto boxing) when using operators, so some special treatment in this area should make that even faster. Anyway, sorting int arrays is not the main focus of Xtend ;-).

If you are doing code generation or are interested in it and you are visiting EclipseCon, you should definitely come to our tutorial on Thursday. There is much more to Xtend 2 than just the improved execution performance.
And don't be afraid about missing the lunch, attendees get served a delicious, warm, and freshly prepared lunch after the tutorial :-).

A Guice Modules DSL

[Update] The code is available at github

Yesterday Sebastian and I were attending GuiceCon. A nice little get-together with the Guice developers and some very smart Guice users. As Guice is key in Xtext's architecture we took the opportunity to show the people what we do with it. The first idea was to just explain how we use Guice, but while we travelled across California last week a better idea came up : We could develop a Guice Modules DSL using Xtext.

So we did and we did it from scratch right in front of the audience without any tricks or shortcuts. The good thing was that everyone in the room knew the domain very well, so we didn't need to explain anything about the domain of the language.
First I defined the grammar and a first shot on the code generator and then Sebastian added type conformance checks and improved content assist. Today I've spent another two hours on it. The screencast below demos the status quo.

Note that there will be an extended tutorial at EclipseCon this Thursday, where you can learn how to create such things yourself in no time. Not to forget the short talk on "What's new in Xtext 2.0", Tuesday 2 pm.

Have fun!

Monday, March 07, 2011

Xtend Screencast Part 3 - Rich Strings (i.e. Codegeneration)

Xtend is a programming language with special support for code generation and traversing typed object graphs (like EMF models). It is developed with Xtext 2.0. So the question is what is so special about code generation, that we need special support in a language? Well it's mostly string concatenation, and the most readable way of doing string concatenation is using a template syntax.

Today's screencast covers rich string expressions. It resembles the basic template syntax known from Xpand but in Xtend they are expressions, so you can use them everywhere a normal expression is expected. The new and unique aspect about Rich Strings is their intelligent whitespace handling system, including nice tool support. See it yourself:



You can get your hands on this at EclipseCon in just two weeks and/or at JAX in two months.
The final release of Xtext 2 and the new Xtend language is June 22nd (Eclipse Indigo).

Friday, March 04, 2011

Xtend Screencast Part 2 - Switch Expression

In this part I show and explain the switch expression, which is defined in Xbase, so you can also have that in you Xtext DSL if you want :-)
In the tutorial at EclipseCon on Thursday we will show how to embed Xbase expressions in a simple DSL.

Here again I use Xtend for the demo:

Wednesday, March 02, 2011

Xtend Screencast Part 1 - Basics

Only three weeks till EclipseCon!
I can't tell how excited I am. Sebastian and I are going to Los Angeles in just two weeks in order to travel up the Highway 1 to EclipseCon for one week. I know the weather will be great :-)
At EclipseCon we finally can show people what we have been working on the last two months and what kind magic can be done with Xtext 2.0 in such a short time frame.

In the meantime we (Jan, Sebastian and I) want to help you get into a similar mood :-).  Sebastian already blogged about it and Jan will definitely do so very soon. I decided to record a series of screen cast.
The screen casts are not edited at all, because I thought it would be more authentic and trustworthy that way.

The first screen cast covers the basic concepts. I hope you like it:



[1] The Xbase development is sponsored by itemis and the Federal Ministry of Education and Research.