InfoQ HomepageNewsUsing Clojure to Build Native Android Apps
Using Clojure to Build Native Android Apps
This item injapanese
Aug 26, 20151min read
Write for InfoQ
Feed your curiosity.Help 550k+ globalsenior developers
each month stay ahead.Get in touch
Clojure development on the Android platform has been progressing remarkably in the last few years, allowing developers to use it infully fledged apps such asSwiftKey’s Clarity Keyboard. Here we will review the current status of tools that support Clojure on the Android platform.
Historically, Clojure on Android has suffered from slow startup, which could lastup to 4–10 times longer than Java’s when using standard upstream Clojure. This issue is addressed bySkummet, a Clojurefork that optimizes Clojure’s compiler so that it produces more compact, faster-to-load bytecode. Besides providing an optimizing compiler, Skummet also includes an optimized version of Clojure’s runtime that is built by the former.
Skummet aims to ensure maximum compatibility and, although there could be issues with code that relies on referencingVars directly, most Clojure code should be compatible out of the box, according to Skummet’s creatorAlex Yakushev.
Overall, Skummet is able to bring a 4x reduction in load time on a simple benchmark app’s first launch, and 2x shrinking in both APK size and heap usage. According to SwiftKey’s Adam Clements and Ben Leavett, using Skummet has allowed them to keep Clarity Keyboard’s loading time around 1.5–2 seconds, and further improvements are possible.
Other useful tools for Clojure development on Android are packed under the umbrella project ofClojure-Android Initiative and include:
- lein-droid: a Leiningen plugin that works as a build tool for Clojure-Android projects and deals with the process of packaging resources, creating an APK file, signing it, etc.
- Neko: a toolkit that wraps some parts of Android’s Java API to make them more idiomatic to use from Clojure.
Zach Oakes, author of theNightweb app for Android,says that Clojure can make an app’s codebase “shockingly” smaller by enabling terse idioms, as well as improve the app responsiveness by making it easier for the programmer to run asynchronous tasks.
According to SwiftKey’s engineers, the use of Clojure to build an Android app can have a huge impact on the app design. Specifically, in Clarity Keyboard’s case, it made it possible to adopt a fully “event driven” design, which coupled with the use of immutable data structure allows to easily store and “replay” any user actions. Using immutable data also helped build a highly modular app and make every operation asynchronous by default.
This content is in theMobile topic
Related Topics:
Related Editorial
Related Sponsor
%2ffilters%3ano_upscale()%2fsponsorship%2ftopic%2f772620d3-fb6d-4710-9a7b-d6234d3d92c1%2fScyllaDBLogoRSB-1753175770245.png&f=jpg&w=240)
ScyllaDB is the database for data-intensive apps requiring high throughput + low latency. Achieve extreme scale with the lowest TCO.Learn More.
The InfoQ Newsletter
A round-up of last week’s content on InfoQ sent out every Tuesday. Join a community of over 250,000 senior developers.View an example