Eclipse.org's Xtend language is all about modernizing Java apps. At least that's the view of Xtend advocates, who say that the statically typed language, which runs on the JVM (Java Virtual Machine), removes unnecessary syntactical noise, is easy to learn, and lets developers enhance existing Java APIs through extension methods and lambda expressions.
InfoWorld Editor at Large Paul Krill talked with Xtend co-architect Sebastian Zarnekow about Xtend following Zarnekow's presentation at the JavaOne conference last week in San Francisco. The senior software architect at Itemis, which specializes in model-based software development, expanded on the benefits of Xtend, including why it is less complex than Scala, the increasingly popular statically typed JVM language that Zarnekow called "scary."
[ JavaOne also featured a surprise appearance by Java founder James Gosling, as well as Oracle heralding upcoming Java upgrades. | Think you know Java? Test your programming smarts in InfoWorld's Java IQ test. | Master the latest in Java development with our JavaWorld Enterprise Java newsletter. ]
InfoWorld: What was the genesis of Xtend?
Zarnekow: We started the Xtend project as a proof of concept that real programming languages can be created with the Xtext framework [for domain-specific languages]. The vision was having something that simplifies the life of a Java developer while being able to address the issues that Xtend [the previous language of the same name] and Xpand [template language] addressed.
InfoWorld: What's the difference between the old Xtend and the new Xtend?
Zarnekow: The old Xtend was the brother of Xpand, so it only provided extension methods, whereas the new Xtend is a complement to Java and the successor of Xpand and the old Xtend.
InfoWorld: The old Xtend didn't run on the JVM, did it?
Zarnekow: No, it was an interpreted language.
InfoWorld: You mentioned that Xtend is similar to but not as scary as Scala. What's scary about Scala and why isn't Xtend scary?
Zarnekow: The Scala type system is quite complicated for most developers. [It is] so complicated that it's even hardly possible to create a reasonable IDE for that. Even though Scala is statically typed, there are so many implicit things going on that a developer has a really hard time to understand what happens there.
InfoWorld: For what type of applications is Xtend best suited?
Zarnekow: Basically, everything that you would otherwise do with Java can be done with Xtend.
InfoWorld: What is the main advantage of Xtend compiling to Java source code and not to Java byte code?
Zarnekow: The Java compiler does a lot of checks for us that otherwise would happen at runtime only, so it helps. It's far more complicated from a given viewpoint to create source code, that's true. But on the other hand, for the end-user it's far easier to understand what happens under the hood, so being able to look at the result of compilation is a benefit that cannot be overvalued.
InfoWorld: You say Xtend has exceptional DSL support and offers annotations on steroids. Can you elaborate on those two concepts?
Zarnekow: Exceptional DSL support is mainly about being able to use other languages that are built with Xtext on the one hand side, so [it is about] interacting with external DSLs. But more importantly, [Xtend has] a syntax that is so flexible that an API can be created in order to directly express the intent of the code without leaving encapsulation or static typing. That is possible with Xtend. By combining orthogonal concepts such as overt overloading or extension methods in combination with the support for lambda expressions and type inference, one can achieve quite readable and remarkable APIs for specific use cases.
InfoWorld: What about annotations?
Zarnekow: Annotations support is something that we have in the pipeline for the next release. What you can do is develop the client of an annotation and the annotation processing itself side by side and without having to deploy something, you can live-influence the way that Xtend is compiled to Java source code. There's again an advantage in compiling to source code -- you immediately see what your annotation processor does by simply looking at the resulting Java code. You can write annotations in order to validate the structures of your Xtend classes in a domain-specific manner.
InfoWorld: What's the status of Xtend? How old is it and what's the next step for it?
Zarnekow: Xtend 2.3 [akin to a 1.0 release] was released this summer. The plan is to have a new release at the end of this year. Annotation processing will be more mature in summer 2013.
InfoWorld: When you say Xtend supports extension methods, could elaborate a bit on that?
Zarnekow: Extension methods are a means to extend types of the Java VM in a lexically scoped way. So without altering the class, you can make functionality methods syntactically available. That is comparable to what other JVM languages do as well, or what C# did. But Xtend goes one step further. We allow [developers] to write extension methods as instance methods, so you can leverage all these things like polymorphism. Combined with dependency injection, you can create a quite extensible API based on extension methods.
This article, "Eclipse Xtend on JVM: Not as 'scary' as rival Scala," was originally published at InfoWorld.com. Follow the latest developments in business technology news and get a digest of the key stories each day in the InfoWorld Daily newsletter. For the latest developments in business technology news, follow InfoWorld.com on Twitter.