There are many languages you can use to make Android apps, from the obvious/boring Java to the more interesting Kotlin, Clojure, Scala.
Using a different language from the platform's standard usually introduces an amount of impedance mismatch between the layers, and there are some slightly annoying practical consequences:
- you can no longer follow the documentation without having to mentally translate from the API examples language to the language you are using
- if something fails, it's liable to fail in any layer, you have to be fluent both in Java and in the language you're using to interoperate with it
That said, there are benefits to using a different language than Java, in our case today, Clojure:
interactive dev: the Read Eval Print Loop workflow for your mobile development.
One of the most soul wrecking things in mobile dev is having to compile and deploy to test your app after any change, however small.
The simulator in Android isn't as helpful as it is for iOS, so in practice you usually want to deploy on an actual device, which slows your iteration time even more.
Clojure (and LISPs in general) are based around the concept of a REPL. Your program is a dialogue, that develops interactively, and you can see the changes you make immediately.
concise: Android development has a proliferation of different files, using different languages, that you have to edit to achieve something, namely the horror of XML layouts.
Thanks to the clever design of neko, the idiomatic Clojure wrapper for the Android API, you can avoid having to edit XML files to create your views, I'll show you in later articles how.
- slow startup times, though thanks to project Skummet they are getting better
- aforementioned failures in the layers needing proficiency in both Java and Clojure
That said, I hope you do believe the benefits are worth the trouble, because we're embarking into a series of posts that will guide you from the setup of your development environment to having a publishing-ready Android app written in Clojure.
The Clojure Android project
Thanks to GSoC, and the work of Alex Yakushev, and the other contributors, Clojure Android is in healthy shape, including many tools that should make your developing experience pleasant:
- lein-droid: automated tools for setting up and deploying your project.
- neko: idiomatic Clojure wrapper for the Android API
- skummet: an experimental compiler that cuts Clojure loading times
- cider: Emacs editor tools and REPL support
Where you can keep up to speed with the Clojure Android community:
clojure-android on freenode
- The Clojurians Slack has a Clojure Android channel
- Clojure Android mailing list
- Clojure Android website
In the past years there have been various talks and tutorials published, here's a probably incomplete list:
- Talk: Clojure on Android - Alexander Yakushev - EuroClojure 2015
- Talk: Clojure and Android - Daniel Solano Gomez - Clojure Conj 2011
- I did a talk at my local Clojure Dojo in 2013: slides blog post
- Kris Calabio's excellent app tutorial, updated 2014
Proof that Clojure Android is usable to get an app on the Play Store:
- Clarity Keyboard Beta: An experimental keyboard
- 4Clojure: the 4Clojure code challenges on your Android device
- Figurehead have root on your Android device, with Clojure