Adventures with ClojureScript
Since Clojure is one of my favourite programming languages, I took a chance and used the brand new ClojureScript on a small project.
Working with ClojureScript
ClojureScript is very young, so there is hardly any tool support at this point. Neither Maven nor Leiningen can build ClojureScript projects, so I wrote a good old Makefile.
Functions and properties
This is how you would normally execute a function of an object:
And this is how you execute a function and get it’s return value in ClojureScript:
(. someObject (someFunction))
I couldn’t find any documentation on working with properties in ClojureScript, so I’ll share what I figured out:
Get a property:
Set a property:
(set! (.someProperty someObject) newValue)
Working with Google Closure
To make things worse, the documentation isn’t up to Google standards, but I guess that would change as the library becomes more popular. If it does.
ClojureScript is interesting, but apparently not intended for production use yet – there hasn’t even been a release. It needs to mature, providing a stable REPL and a nice functional layer above the Google Closure Library (or some other library, or something written in ClojureScript).