Over a million developers have joined DZone.

Xtend: A Java-Compiling Alternative Language for Android

· Java Zone

Microservices! They are everywhere, or at least, the term is. When should you use a microservice architecture? What factors should be considered when making that decision? Do the benefits outweigh the costs? Why is everyone so excited about them, anyway?  Brought to you in partnership with IBM.

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).

Interesting idea, one way or another. Check out Medeiros' full post for all the details on Xtend, or take a look at the documentation to get right into the meat of it.

Discover how the Watson team is further developing SDKs in Java, Node.js, Python, iOS, and Android to access these services and make programming easy. Brought to you in partnership with IBM.

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}