Lumo

The fastest Clojure REPL in the world – Lumo (by António Nuno Monteiro)

From its announcement

Lumo is a fast, standalone ClojureScript REPL that runs on Node.js and V8. Thanks to V8's custom startup snapshots, Lumo starts up instantaneously, making it the fastest Clojure REPL in existence.

Command prompt

Ideally suited to be used instead of e.g. Bash or Perl, for scripts executed from the (Linux in my case) command prompt. Plus Lumo is multi platform!

Example (an HTTP server for IP logging)

 1#!/usr/bin/env lumo
 2;;
 3;; Adapted from: https://mmcgrana.github.io/2011/09/clojurescript-nodejs.html
 4;;
 5;; Twitter: @maridonkers | Google+: +MariDonkers | GitHub: maridonkers
 6;;
 7
 8(def http (js/require "http"))
 9(def process (js/require "process"))
10
11(defn handler [req res]
12  (let [dt (.toISOString (js/Date.))
13        ip req.connection.remoteAddress]
14    (println (str dt " - " ip))
15    (.writeHead res 200 (js-obj "Content-Type" "text/html"))
16    (.end res (str "<html>"
17                   "<header><title>IP logger</title></header>"
18                   "<body><H1>" ip " was logged at " dt "</H1></body>"
19                   "</html>\n"))))
20
21(let [host (nth (.-argv process) 3)
22      port (nth (.-argv process) 4)
23      server (.createServer http handler)]
24  (.listen server port host)
25  (println (str "IP logging server running at http://"
26                host ":" port)))

Make the file executable and execute with host and port parameters, e.g. as follows:

1./http-ip-logger localhost 8000

And navigate to http://localhost:8000.

Posts in this Series