Xtend: A Java-Compiling Alternative Language for Android
After Apple released Swift and invited iOS developers to muck around on the ground floor of a brand new technology, some Android developers were jealous. After all, where's Dart for Android, or Go for Android, or Groovy for Android? Well, according to Andre Medeiros on the Futurice blog, the answer's already here: Xtend.
The problem with most of the Android Java alternatives that people ask for - Groovy, for example - is that they require additional compilation time to make it to Android's Dalvik bytecode. According to Medeiros:
. . . because Android runs Dalvik bytecode and not Java bytecode, the aforementioned languages must go through an additional compilation step that modifies the program’s bytecode. This normally ends up producing performance drawbacks visible to the end user. Even if this is optimized somehow, Android development tools for these languages (such as debugging) are still far behind Java for Android. These problems make those languages not yet ready for production.
But Xtend, Medeiros says, compiles to Java source code. And given that, the developer-friendly features it offers are even more appealing. For example:
- It kind of looks like Groovy
- Lambdas compile to anonymous inner classes
- Final variables are more prevalent
- '?' characters allow easy Null checks
- It can clean up RxJava boilerplate
Which definitely sounds like a cleaner, simpler Java for Android. Nothing is perfect - Medeiros actually asks that in a header, "is Xtend perfect," and the answer, of course, is no - for a variety of reasons. There's still some delay in compilation, for example, and no support for IntelliJ IDEA (or Android Studio).