This episode is for subscribers only. Sign Up or Log in to watch it.

29. Building Command Line Applications with Lumo

Published 24 April 17

JVM based Clojure isn’t very suitable for command line scripting. On the command line you want quick feedback, which is at odds with the time Clojure needs to boot up, and just to run a single source file you need to jump through a few hoops.

Instead you can use Lumo, a ClojureScript runtime environment based on Node.js. In this episode you’ll learn how to write a script in Lumo, and how to make use Node’s built-in libraries, by building your own version of the Unix “tree” command. It’ll also be a handy refresher on recursion.

Show notes

In this episode I’ll show you how you can use Lumo, a ClojureScript runtime based on Node.js, to write command line utilities. While it’s possible to write scripts with JVM based Clojure, it’s not something people do often, mostly because Clojure needs quite a bit of time to boot up.

Lumo’s startup time is measured in milliseconds, rather than seconds, and with the npm ecosystem at your disposal it’s a compelling platform to build upon.

Make sure you have Node.js installed. I’m using the latest long-term-support release, 6.10.2, but older versions should work fine. ClojureScript is compatible with version 0.12 and up. I’ll link to Node’s installation instructions in the show notes.

$ node --version
v6.10.2
$ npm --version
4.5.0

You install Lumo through Node’s package manager, npm. Use the -g flag to install it globally, so you can access it from anywhere.

$ npm install -g lumo-cljs

Now you get the lumo command line utility at your disposal. Invoke it without any arguments to start a ClojureScript REPL.

browse source code

You can browse the code the way it looks at the end of this episode in the ep29-end branch.