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]))
(def element (aget (js/document.getElementsByTagName "main") 0))
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!
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?
React and Reagent: Juho Vähä-Herttua demoed simple but non-trivial Reagent use in Futurice WWWeeklies. The source can be found at https://github.com/jvah/weather-demo. There's also a Leiningen template for Reagent projects.
I did not yet try out Figwheel, but it sounds like the way to go for the best hot-code reloading and REPL experience.
Futu Connect is our semi-regular roundup of all things Futurice. Be in the know about career-changing events, industry-leading content, non-profit passion projects, and an ever-changing job board.
Enter your email address below.