Being a jack of all trades fits pirates like a glove

Eclipse Xtend — Compact, static, perfect for code generation [Pirates of the JVM]

JAX Editorial Team

When we launched the Pirates of the JVM series, we promised we would put the spotlight on each and every programming language in the JVM universe so here we go. Next stop: Xtend. We talked to Sven Efftinge, ‎co-founder at TypeFox and project lead of Eclipse Xtend about the advantages and disadvantages of this language, its core principles and more.

The JVM landscape is truly unique — the variety of programming languages, the fact that you don’t have to leave the Java ecosystem and the flexibility to juggle with countless programming paradigms — that’s what makes this universe one-of-a-kind.

There are countless programming languages that combine different concepts and typologies such as Scala, Kotlin, Golo and Xtend. The latter is a general-purpose high-level programming language for the JVM with roots in Java.

Unlike other JVM languages, Xtend has zero interoperability issues with Java, which means that everything you write interacts with Java exactly as expected. It provides a modern Eclipse-based IDE closely integrated with the Eclipse Java Development Tools (JDT), including features like call-hierarchies, rename refactoring, debugging and many more.

Click on the map to see the entire infographic

Xtend — Background information

JAXenter: What was your motivation for working with Xtend? What does Xtend have to offer that other languages fail to provide?

Sven Efftinge: We developed Xtend within the context of Xtext, especially with the purpose of a code generator and for model transformation. Before, these tasks were solved with domain specific languages, since Java was highly unsuited as a code generator. Xtend finally provided us with a compact, static typed JVM language with a first class integration with Eclipse. And of course, Xtend offers features like template expressions and extension methods, which you don’t want to miss out on when you implement code generators.

Today, Xtend is being used for a lot of different use cases. The one thing I want to mention as a unique selling point, besides the templates and extension methods, is definitely represented by the active annotations. Xtend is not translated into Java bytecode directly but into readable Java source code. This makes it easier for developers to understand the concepts.

Xtend is not translated into Java bytecode directly but into readable Java source code.  

The active annotation enables developers to take part in the translation and to modify the generated Java classes and interfaces. Active annotations are a very handy and simultaneously powerful macro system. Today, we often prefer to use active annotations for very structural code generators, instead of an external DSL.

JAXenter: Can you describe the core principles of the language?

Sven Efftinge: During the outline of the language, it was important for me to have a seamless compatibility with Java, besides a very compact syntax and an easy way to add features. We didn’t want a new language with library and ecosystems but a more powerful syntax for Java. All Java libraries had to be functioning as well as with Java itself. As a matter of fact, Xtend is working better in most cases, since we incorporated existing Java idioms during the design.

For example, we introduced the concept of functional interfaces before it was even considered for Java 8. Also, Java Bean properties are being supported by Xtend natively: For example,  I can declare an immutable class with properties, hashcode/equals etc. with help of the @Data annotation.

@Data class Person {
    String name
    int age

By the way, @Data is an active annotation, which means that, contrary to other languages like Scala, and Kotlin, Xtend can solve such issues with the help of libraries.

Hello World example

JAXenter: What would a typical program with Xtend look like?

Sven Efftinge: Xtend basically looks like Java — most notable is the ‘def’ keyword for methods which is required because Xtend has a very broad type inference support. This is a Hello World example:

class HelloWorld {
    def static void main(String[] args) {
        println("Hello World")

JAXenter: For what kind of applications/use cases is Xtend well-suited? For which ones it is not?

Sven Efftinge: There is hardly a better alternative for code generators and model transformations but in principle, users benefit in all use cases in which concise and readable code is important. Xtend offers a handful of features that allow defining very declarative APIs.

We introduced the concept of functional interfaces before it was even considered for Java 8.  

If it is about bytes and bit shifting, I wouldn’t use Xtend.

What’s next for Xtend?

JAXenter: What is the current state of the language?

Sven Efftinge: The language is mature and is being used around the world.

JAXenter: How about your plans?

Sven Efftinge: The Xtend compiler has been developed with Xtext and supports the Microsoft Language Server Protocol. We want to prepare Xtend for that, and thereby make an integration into other tools outside of Eclipse possible.

JAXenter:  How can people interested in Xtend get started?

Sven Efftinge: The easiest way is to install the Xtend plug-in into an up-to-date Eclipse installation and after that, to create a Xtend file within an optional Java project, or to convert existing Java files automatically (right click –> convert to Xtend).


Sven Efftinge is a passionate software developer and co-founder at TypeFox (, a young company specialized in the development of software tools. In his free time, Sven likes to spend time with his family and is an enthusiastic kitesurfer.


Pirates of the JVM — The series:

Are you familiar with all the programming languages from the JVM universe? Have you discovered them all?

If the answer is “no”, we’ll leave no stone unturned in the search for knowledge. Therefore, the Pirates of the JVM infographic is accompanied by a series of articles in which we put the spotlight on the languages you may or may not know.

Don’t forget to check out the Pirates of the JVM series.

comments powered by Disqus