Eclipse Xtend: Javas equivalent to CoffeeScript
We speak to Sven Efftinge and Sebastian Zarnekow about their new JVM-based programming language that compiles into readable Java code.
the June edition of JAX
Magazine, Sven Efftinge and Sebastian Zarnekow introduce us to
their new JVM-based programming language that compiles into
readable Java code, Xtend.
JAX: Can you give us a brief description of Xtend?
Sebastian Zarnekow: Xtend is a statically typed programming language running on the Java Virtual Machine. It’s designed to jazz up Java a little, to address the weaknesses that Java has accumulated over the years. Our goal is not to abandon Java altogether, but rather to complement it, so that it can be integrated into in any given project. The idea is to make it possible to draw on Xtend in any Java project situation, so that one can find smoother solutions to one’s problems.
JAX: You were just talking about Java’s weaknesses. Can you elaborate on what weaknesses Xtend addresses?
JAX: There are other languages that pursue similar goals, though. What sets Xtend apart from, say, Groovy?
Efftinge: Groovy has a similar thrust, but is a few years older. We adopted many good ideas from Groovy, but also from Scala and from Java. Unlike Groovy, Xtend is statically typed, with the same type system as Java, including generics, which are exactly the same, just as the conversion rules. What this means is that the ten million developers out there who know Java will understand it immediately. In addition, there is much better tooling: you get content assist and compiler checks in Eclipse, all the things you’re used to from Java. The code that is generated is very fast compared to Groovy. A well-known problem with Groovy is that it’s fairly slow.
Compared to Scala – it’s simpler! That’s the most important difference. You can use different IDEs for the language because the type system is not as extreme.
JAX: The two of you are also the key men behind Xtext. What’s the connection between Xtend and Xtext?
Zarnekow: That’s quite an interesting question. Basically, what we did with Xtend was to create a full-blown programming language based on Xtext, in the course of which we developed a reusable expression language for Xtext that is now embeddable into any domain-specific language. It’s now possible to build nice APIs with Xtend and one can generate very readable code by means of concepts such as extension functions, operator overloading etc. In certain situations one might still get to the point where the abstractions are not sufficient, but since Xtend is based on Xtext, it allows for exceptionally good integration with external DSLs, so that one can operate seamlessly between Xtend and Java or Xtend and a DSL within one and the same project. This is another one of Xtend’s unique features.
JAX: Any specific projects you have tackled so far, using Xtend? If so, which ones?
Efftinge: Xtend is still very, very young. We released a preview version as part of Eclipse’s release train last summer (Indigo, editor’s note), followed by a minor release last winter. A really interesting release is coming up in June, as part of the next release train (Juno, editor’s note). It will be very well integrated, and the language will be quite complete already.
So, in general, no big projects so far, but a lot of people have just started experimenting with it, they find it exciting – and I’m curious to see first results. We’re mainly involved in open-source development. We support customers developing languages with Xtext, and when it comes to building things like code generators, Xtend comes in handy. But so far, we haven’t written any big business applications using Xtend.
JAX: The final question’s for you, Sven: You won one of this year’s Eclipse Community Awards. You were honored as Top Committer. What does this award mean to you?
Efftinge: It made me very happy, obviously – especially because the award winners are selected by the community. It’s not like the decision is made by a jury of five people, but the entire community is allowed to vote. It’s a great award. Sebastian won it last year, by the way, so let’s wait and see who’s next.
This interview was originally conducted in German by Hartmut Schlosser and Diana Kupfer at JAX in Mainz, on April 19, 2012. It has also been published in our sister publication, JAX Magazine.