ClojureScript saved me 100 hours
Andrew Buntine Jul 28 '15
Five years ago, I started tinkering with Clojure, a Lisp that runs atop the JVM. The language was still somewhat esoteric at the time. It was a Lisp, afterall!
Picking up Clojure wasn't too difficult because I'd already spent a few years playing around with Scheme. Generating fractals, Fibonacci sequences (of course) and working my way through the SICP and Simply Scheme textbooks. Infact, I think I may still be helping some first-year Comp Sci students at Berkeley University through my answers repository to the latter. Hey Berkeley, how about an honorary degree? Oh c'mon...
It was obvious from the get-go that Clojure was going to be a big deal. Although the language designer, Rich Hickey, decided to stick with S-Expressions, Clojure came with a much richer set of data structures than the humble linked list. And they were immutable and persistent, which gave them both the thread safety of immutability and the performance characteristics of mutability. The whole Java interop thing was also very important... It meant that Clojure programmers had access to the plethora of existing Java libraries.
The first non-trivial software I wrote in Clojure was a text-based game called Medieval Alien Massacre. It was inspired by an old game called Dunnet that, funnily enough, still ships as a default package with the Emacs editor today. The game was great fun to write, although I made the mistake of choosing a title and publishing the game before I'd written the story. The finished product did not involve any massacres and did not occur in the middle ages. It did, however, contain aliens so I wasn't completely wrong!
(. Thread sleep 10)
was simply replaced with:
(.setTimeout js/window f 10)
I replaced all IO with a simple HTML
input wrapped in a
form with a submit event attached to it. I'd say about 85% of the core codebase stayed exactly the same. The language parsing didn't change at all!
Oh, and guess what?! You can play it right now directly in your browser!
Happy hacking, people.