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).
You can generate tooling for this language:
You can implement a code generator for this language:
And generate code for programmes written in this language:
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.
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:
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: