I kept hearing about Clojure so I decided to have a look. I followed a few links on reddit and ended up watching:
Keep in mind, these videos run for 89 and 59 minutes, respectively. By all means, start watching and stop when you’ve had enough. I know I couldn’t – I had to watch until the end.
Clojure is a Lisp on the JVM. The J in JVM is the least interesting part of the JVM (in fact, it would probably be a good idea to rename it completely) but the JVM technology itself is amazing. You can read up about it here or here. Targeting the JVM as a platform means getting garbage collection and the other JVM performance optimizations for free. After reading about the technology, it seems silly to waste time reinventing the wheel and creating your own virtual machine / environment for your new language.
Yes, Clojure is a Lisp and that means parentheses. But, in many ways, the Lisp part of Clojure is the least interesting part. With Clojure, it feels like you’re getting the best part of Haskell, Erlang, Java and Lisp! Clojure gives you functional programming (Haskell), immutable data structures that are thread safe (Erlang), a dynamic language that integrates with Java (at Java performance), and the best features of Lisp without a lot of the annoying/legacy baggage.
I started doing my programming exercises and I was very impressed with the performance. A 23 disc tower of Hanoi was taking ~30 seconds in Ruby. It took ~3 seconds with Clojure with the java -client JVM. And it was down to ~0.8 seconds with the java -server JVM. I love it when my code feels fast. I love it even more when I get it 3 times faster by adding a command-line flag. :)
Finally, today, the Pragmatic Programmers announced: Programming Clojure. Read the bullet points and try not getting excited.
I remember reading once that Erlang was really great but that it would probably not be the next big thing. However, the next big thing would incorporate the lessons learned by other languages into a new form. Ruby felt like that … taking the best from Smalltalk and Perl and making something new and beautiful.
I have great hopes for Clojure – it looks like a winner.
IMO it will be another niche language, but I’m okay with that. Anything that furthers JVM ecosystem options is a Good Thing, and it’s a great environment.
Do you have a link to your Clojure and Ruby code for the tower of Hanoi problem? Thanks!
ruby code: http://gist.github.com/16645
clojure code: http://gist.github.com/16646
I used another (much) slower computer to quote my numbers above. On this computer, I increased the number of rings to 25.
ruby: ~28 seconds
clojure: ~1.2 seconds
I also removed the I/O which was dwarfing all other operations.
it is Prolog I’d like to see ported into Clojure instead of Lisp. any volunteer?
give me Clojure s ideads/power + ruby syntax and we have the last best thing :)