O'Reilly logo

Implementing Domain-Specific Languages with Xtext and Xtend by Lorenzo Bettini

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Xtend – a better Java with less "noise"

Xtend is a statically typed language and it uses the Java type system (including Java generics). Thus Xtend and Java are completely interoperable.

Most of the linguistic concepts of Xtend are very similar to Java, that is, classes, interfaces, and methods. Moreover, Xtend supports most of the features of Java annotations. One of the goals of Xtend is to have a less "noisy" version of Java; indeed, in Java, some linguistic features are redundant and only make programs more verbose.

Let's write a "Hello World" program in Xtend:

package org.example.xtend.examples

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

You can see that it is similar to Java, though there are some ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required