The Christmas holidays are a perfect time to try and learn new things. A few weeks ago, I helped organize a Code Club session with my colleague Tiina Romu at the English School. She had created an exercise to draw snowflakes in the Python in Browser environment. I thought it would be fun to experiment my own implementation as well.
Derek Slager’s recent, nice presentation ClojureScript for sceptics had made me thinking that the time is ripe to start learning ClojureScript as well. Here’s what I learned:
- After you have set up your build process, you’ll want to build changes automatically to skip the JVM startup time hit. If you’re using lein-cljsbuild, use:
$ lein cljsbuild auto
The ClojureScript platform is developing fast, so make sure you are using the newest version of both Clojure and ClojureScript languages and tools.
- Check the Differences from Clojure. Not all Clojure features are available in ClojureScript. Some examples
- One cannot e.g. require all functions from another namespace with
(ns some.ns (:require [some.dep :refer :all]))
- E.g. Ratio, BigDecimal, and BigInteger literals are currently not supported.
(def element (aget (js/document.getElementsByTagName "main") 0))
- You have all the Clojars libraries in your fingertips with an easy build tool
- Once you get the compiled code running in the browser, the source mapping works nicely and you can check the errors right from the browser’s development console!
In the end, I got my Christmas greeting done. You can find it at http://ykarikos.github.io/cljs-flake/. The source code is shared at https://github.com/ykarikos/cljs-flake.
I really like functional programming in LISP syntax and thus it has been a pleasure to learn Clojure. However, at the same time I haven’t had the time to learn the tooling and frameworks needed for modern Javascipt development. However, it seems that ClojureScript will be – at least for me – an easier way to start building modern web frontends. The platform has advanced a lot this year. David Nolen has listed the highlights in ClojureScript Year In Review.
So, what might I try next?