Language, Expression and Design



May 2016

live documentation with klipse

by Chris Zheng,

I've been in Tel Aviv for the last 3 weeks and have been lucky to be hanging out/hacking with some amazing clojurists - i.e danielsz of system fame, madlan and the klipse project.

Now that cljs-in-cljs is a reality, klipse is a real treat to work with. I really like this project because it's essentially a repl in the browser. Well... it's alot more than that but what these guys plan to do is to create a no-install environment for clojurescript evaluation.

I worked with cljs-build in the past and was severely traumatised by the development experience as well as the constantly changing landscape of cljs at the time. A lot has since changed since I wrote purnam. That project mentally castrated me because back then, it was so horrible to work with and I felt like this guy, shuddering with trauma everytime the word "clojurescript" was mentioned.

Time heals all wounds and I'm well in to my recovery phase. Watching the things that are being done with figwheel, plank, replumb, klipse and all the cool apps that have been built, I've been so overwhelmed with the simplicity of development experience that its again time to take small steps back into the clojurescript fold.

Yehonathan, Raphael and Elyahou have been patient enough to hear my ideas and help with something that's been very close to my heart - Documentation.


I'm experimenting with having live documentation on the blog. The script that needs to be added to make everything work is:

<link rel="stylesheet" type="text/css"  

        window.klipse_settings = {
            selector: 'code.clojure'

<script src=""></script>  

and voila - it takes my markdown examples and turns it into live, editable code:

(map inc [1 2 3])

beginner's mind

Let's start off again and have a play with the most basic cljs tutorial. Whilst most clojurescript projects these days talk mostly about setting up the project, lets just play around with the language itself. Please feel free to edit the examples and watch the outputs change:


(conj [:bar 3.14 "hello"] "world")

map (associative arrays)

(assoc {:msg "hello" 
        :pi 3.14 
        :primes [2 3 5 7 11 13]}
       :foo "bar")


(disj #{"hello" 3.14 :baz} :baz)


Defining functions:

(defn add-ten
  ([] 10)
  ([x] (+ x 10))
  ([x y & more]
    (apply + 10 x y more)))

[(add-ten 1)
 (add-ten 1 2 3 4)]


okay... maybe this needs a bit of work... but it's so cool to have something that it live, that I can play with and to interact with without worry of environment. I just want it to be mindlessly easy to use and play with. That is all.


(defmacro doseq-indexed [index-sym [item-sym coll] & body]
  `(doseq [[~item-sym ~index-sym]
           (map vector ~coll (range))]

  ( i [x [10 100 1000]]
                 (println "i: " i "x: " x)))

Many more live examples can be seen here:

This article especially blew my mind:, especially when I realised that code itself can be used to change the hosted environment - in realtime. The smalltalk way of working is more or less becoming a reality with all the tools that are coming up. I am excited for the future of clojurescript... reek!

comments powered by Disqus