Xtext / Xtend, Top Eclipse Juno Feature #3

Eclipse Juno, the simultaneous Eclipse release for 2012 will be available in 3 days. Three days left until Juno means that I’m into the Top 3 Eclipse features in my Juno Top 10 List. During the past week I’ve talked about how Eclipse can be classified as ‘top-notch Java tooling‘, a ‘general purpose tooling platform‘, a ‘runtime technology stack‘, and really a ‘platform for everything and nothing in particular‘. There is another very important classification for Eclipse technology, Eclipse as a vast array of powerful modelling tools and technologies.

The Eclipse Modelling Project was born out of the Eclipse Modelling Framework (EMF).  Dr. Ed Merks, who was awarded with an Eclipse Lifetime achievement award in March 2012, envisioned a comprehensive suite of modelling technologies and worked tirelessly to bring this vision to the Eclipse eco-system.  One of the most exciting projects in this space, and number 3 on my Juno Top 10 List, is: Xtext / Xtend.

Xtext is a text-2-model and model-2-text framework.  This means that using Xtext you can define how text can be transformed to models and how these models can be transformed back to text.  Why is this interesting, because this is exactly the steps you need to design programming language, This is why Xtext classifies itself as a framework for developing programming languages and DSLs.

With Xtext I can define a simple grammar (Here’s an example grammar for scripting Eclipse installs).

Screen Shot 2012 06 24 at 10.40.47 PM Xtext / Xtend, Top Eclipse Juno Feature #3

You can generate tooling for this language:

Screen Shot 2012 06 24 at 10.52.13 PM Xtext / Xtend, Top Eclipse Juno Feature #3

You can implement a code generator for this language:

Screen Shot 2012 06 24 at 10.55.18 PM Xtext / Xtend, Top Eclipse Juno Feature #3

And generate code for programmes written in this language:

Screen Shot 2012 06 24 at 11.00.12 PM Xtext / Xtend, Top Eclipse Juno Feature #3

A number of new and exciting features were added to Xtext this past year.  In particular, you can map your DSL to Java constructs enabling other Java programmes to directly invoke methods in your DSL and vice versa.  You can also leverage the Xbase expression language.  Xbase is a predefined set of expressions that you can embed into your DSL (including a compiler, interpreter and Eclipse tooling).  You can also make use of the exiting Eclipse debugger to strep through your DSL.

Screen Shot 2012 06 24 at 9.31.02 PM1 Xtext / Xtend, Top Eclipse Juno Feature #3

Finally, the Xtend language, which was originally used as a templating language for code-generation, has been enhanced and promoted as full JVM language in its own right.  Xtend is a statically typed functional and object-orient language.  It automatically compiles to readable Java code.  It’s an excellent example of what can be built using Xtext.

Compiles to readable Java:

xtend and java Xtext / Xtend, Top Eclipse Juno Feature #3

 Lambda Expressions

Screen Shot 2012 06 24 at 9.24.50 PM Xtext / Xtend, Top Eclipse Juno Feature #3

Operator Overloading

Screen Shot 2012 06 24 at 9.27.31 PM Xtext / Xtend, Top Eclipse Juno Feature #3

You also get excellent Eclipse tool support for the language, full access to the Java type system, and much more. Checkout all the detail at xtend-lang.org.

Sven Efftinge leads both the Xtext and Xtend projects.  There is also a number of active committers dedicated to both projects, including: Dennis Huebner, Holger Schill, Jan Koehnlein, Knut Wannheden, Michael Clay, Moritz Eysholdt and Sebastian Zarnekow.

For more Eclipse Tips and Tricks (and the annual Top 10 List), why not follow me on twitter:


5 Responses to “Xtext / Xtend, Top Eclipse Juno Feature #3”

  1. [...] a solid foundation, then others could help drive innovation forward – and we all benefit.  Number 2 on my Juno Top 10 List — code recommenders — is an example of great innovation on top [...]

  2. Andi says:

    This is no lamda expression

  3. Ian Bull says:

    Andi, oh sorry, you’re right. That’s not even an Xtext screenshot. Sorry about that. Here is a link for information on Lambda expressions. I’ll update the post.

    http://www.eclipse.org/xtend/documentation.html#lambdas

  4. Lorenzo Bettini says:

    The DSL about Eclipse installs looks nice!
    Is it available somewhere?

  5. Muhammad Khojaye says:

    Nice feature to have. Thanks for sharing.

5 responses so far

Written by . Published in Categories: EclipseSource News, Planet Eclipse

Author:
Published:
Jun 25th, 2012
Follow:

Twitter LinkedIn Google+ GitHub