Skip to content

Instantly share code, notes, and snippets.

Last active July 6, 2022 15:52
Show Gist options
  • Save ericnormand/aefbaace9b3731b26dd4dff770565271 to your computer and use it in GitHub Desktop.
Save ericnormand/aefbaace9b3731b26dd4dff770565271 to your computer and use it in GitHub Desktop.
Apropos Clojure - July 28, 2021

Show notes - July 28, 2021

We are no longer publishing to YouTube! We have a site now:

Domain coming soon!

Show page:

Discord - Join if you want to watch us live or chat!

Follow us on Twitter for updates -


Building a mobile app in Clojure with GraalVM

Summary from @borkdude

You compile a Clojure project to a binary like you would normally do with GraalVM, similar to what babashka does, but you compile specifically for iOS, using some LLVM stuff that GraalVM supports (this part Adrian knows, I really don't).

This library exposes some native functions. You can use these functions from a native UI, just like any C library. So you can write the UI in Swift, or whatever is the trend these days. But you can't use any Clojure evaluation anymore, since Clojure = bytecode emitter and you can't eval new bytecode in GraalVM. But you can ship Small Clojure Interpreter (SCI) to interpret some Clojure. This is exactly what babashka does as well: It's a binary with pre-compiled libraries and at runtime you can use interpretation to glue the libraries together.

So what Adrian has done in the shared library is expose an eval function so you can send expressions from the front-end to this library and it will do stuff. And there is also an nREPL implementation for SCI-based projects (same as what ships with babashka), so you can include that as well. The nitty gritty of the UI stuff is what Adrian has figured out, using Skia. He has a library called membrane which is an abstraction over all kinds of UI frameworks like Reagent/React, but also native ones like Skia.

It's still quite experimental, but Adrian managed to get something into TestFlight which I downloaded on my phone and posted on Twitter about. The really hard problem is finding a problem to write an app for 😛. But this is pretty exciting since you can now use Clojure JVM code on your iPhone.

Mobile app repo:

Example ants demo (from Rich Hickey):

Join the TestFlight test group on your iPhone:

#graalvm-mobile Clojurians slack channel:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment