Xtext 2.0 Released
Eclipse Xtext 2.0 is the new version of the award winning open source framework for developing domain specific languages. It was released today as part of the annual release of Eclipse 3.7 - codename Indigo.
Besides hundreds of bug fixes and significant performance improvements, Xtext 2.0 introduces:
- a refactoring framework and support for rich hover information.
- A new expression language which can be embedded in any DSL and allows users to write computational logic right within their own language.
- A statically typed template language, Xtend, which eases the development and maintenance of code generators, which are now tightly integrated with Eclipse tooling.
InfoQ spoke with Sven Efftinge, creator and lead architect of Xtext.
InfoQ: What is your vision behind Xtext?
Sven: Xtext really is an open framework to implement programming languages. It uses the commonly known and proven ways and means to implement languages, like parsers, symbol tables, compilers, etc. The vision behind Xtext is to bring something like Eclipse’s Java tooling to any language with very little effort.
InfoQ: Amongst the new features of Xtext 2.0, what are the ones that the developers needed or wanted the most? why?
Sven: With this release we’ve put a lot of effort into further improving the overall quality and performance of the framework. In addition we’ve been working on many details, which improve the overall editing experience a lot. Xtext now supports rename refactoring which even works across languages including Java. Also the easy to use hovering support, is something a lot of people will probably like very much.
What really pushes Xtext to a complete new level, is the embeddable expression language library. So far defining structural languages with Xtext had been already really easy. Unfortunately software systems are not only made of structural information but at some point you need to define some sort of behavior or computational logic. While defining structural languages is easy, implementing support for full blown expressions is extremely complicated and a lot of work. So in the past, it was much more practical to add the behavior by extending the generated code somehow, which worked but was far from ideal. With Xtext 2.0 you are not only able to reuse a complete grammar defining expression, but you can also reuse and extend all the necessary infrastructure like the compiler, type system, interpreter and of course the neat Eclipse integration. So finally you can put the behavioral description where it belongs: right into the DSL script.
Xtext 2.0 also comes with the statically typed template language Xtend, which is especially suited for writing code generators. It is in fact also based on the new expression library so while it is a great language to implement code generators it is also a quite advanced example of what kind of languages you can now build with Xtext.
InfoQ: A lot of people have adopted Xtext? What are these people doing with Xtext? what are the sweet spots for a DSL framework like Xtext?
Sven: I’ve seen all kinds of crazy things like languages for knitting algorithms or executable musical scores. There are also commercial products for complex languages, like Sigasi’s VHDL designer, and a lot of other open-source projects using Xtext. Every type of application has it’s own kind of sweet spots for DSLs. If we for instance look at web applications, the domain model is clearly a good aspect to be defined in a DSL. Rails, Grails, SpringRoo and the Play! framework all try very hard to tweak existing languages in order to be able to define entities and the like more concisely. With Xtext you don’t need to push existing languages to its limits, you simple define what your domain models are made of and write a code generator to translate these concepts to whatever application platform you are using. It’s straightforward, doesn’t involve any compromises and you get extremely nice Eclipse tooling on top.
Another very interesting type of applications are data-driven mobile applications. There are many different approaches to tackle the challenges of cross-platform mobile development. The open-source framework APPlause comes with a DSL defined with Xtext, which allows you to easily define a certain kind of mobile applications and deploy them to different mobile platforms, such as iOS and Android.
InfoQ: With the expression language, we are bridging the worlds of GPPLs/3GLs and DSLs, how do you see the evolution of both, in 5 years, in 10 years?
Sven: Martin Odersky, father of Scala, has recently announced that they have won a 5 year European research grant to make Scala more suitable for parallel programming. If you have a look at their proposal you’ll learn that their approach is to allow embedding Scala expressions in DSLs in order to generate application specific code from it, which takes care of the parallelization. Odersky talked about this in a very interesting interview on SE-Radio, where he explained that general purpose approaches for massive parallelization wouldn’t work well, but defining DSLs for special domains is the way to go. They allow to encapsulate the parallelization semantics within domain specific concepts of your language. As you can see Scala seems to evolve into a direction where Xtext with its new expression library already is today.
InfoQ: Code generation seems to have regained in popularity partly because of new frameworks like Xtext and now Xtend, but also because software architectures have become more complex and "polyglot"? Is it just a fad, or do you see a more profound movement towards abstracting complex software architecture behind DSLs and Code Generation?
Code Generation and DSLs have already been a mainstream technique for a very long time. Frameworks like Ruby on Rails and SpringRoo are heavily based on code generation and also every XML schema or DTD is effectively defining a domain-specific language with a very clumsy generic syntax. Xtext and Xtend are tools suited to support this technique better. There are other ways and means to create nice abstractions and for me it is very important that people understand that DSLs and code generation are not going to solve every problem. Like every other technique they have there pros and cons. As a developer you definitely should have something like Xtext and Xtend in your developer’s tool box, but it is even more important to understand when to apply them and when not.
InfoQ: With an increasing number of DSLs somewhat complementary/overlapping, somewhat competing with each other, how can Xtext help developers use different DSLs within their projects?
The main value in DSLs is their high level of abstraction. However, the more you abstract the less you can reuse the same abstractions in other scenarios. So typically people should define their own simple languages tailored to the needs of just one project. Because then you won’t have to put any unused concepts in it. The language can be made as specific as possible. Xtext is specially designed to allow defining and evolving such languages with surprisingly little effort.
Secondly Xtext has been designed from the ground up to allow to have any number of languages integrating with each other and even with non-Xtext languages such as Java. So it doesn’t really feel like different languages, because the tooling works seamlessly across all of them.
Thank you !
Mike Hartington Jul 26, 2015