Monday, May 23, 2011

Did Don Giovanni want to be a lumberjack?

Just noticed it. Monty Python's Lumberjack song is really similar to Là ci darem la mano from Mozart's Don Giovanni.

take a look:
Here's the lumberjack song:

And here's Pavarotti doing Là ci darem la mano

Friday, May 20, 2011

Darwinian evolution of programming languages

In evolutionary biology, when the environment changes, the flora and fauna changes, this is done by adapting to the change and fitting the specie to the new constraints and new opportunities. This is the essence of Darwin's The Origin of Species - the survival of the fittest.

Same thing happened in programming languages.

During the early days, computation power and memory were scarce and expensive, thus programming languages in use were as close to the machine as possible, to exploit everything from these resources - think of LISP's car and cdr, which are based on specific registers...

After some time, memory was still expensive, but computation power become more available, therefore a new specie evolved - a language that allows to describe the computations done in a more "human" way (i.e., imperative), but still close monitoring of the memory is available. Think of C.

Computation power kept growing, and new programming paradigm evolved - OO, but still, memory is costly, and there was C++.

During the 90's memory became cheap, tight monitoring of it became unnecessary and more could be done with it. The stage was ready for the next languages to rule the Earth, and the era of virtual machines started - most notably Java and its JVM, but around that time also Python, Ruby and others appeared.

Computation power kept becoming more available, as well as memory. But times have changed. Multi-core processors are here, and are here to stay. More power now means more processors, not a stronger, single processor. New languages are now coming out of the primal ocean and taking their first breaths of fresh air (or doing parallel computations). These languages are the functional languages. They were around before, but just like the dolphins that returned to the ocean with enhanced brains and lungs to rule that habitat, It is now their turn to gain dominance.
It is not clear who will win this new race. Some of these languages have the advantage of being able to interact and co-exist with already running software and libraries - such as Clojure with the JVM, or F# with .Net.

Days will tell who will inherit the planet - exciting times ahead.

Friday, May 13, 2011


I've started to write code in Clojure, which is a LISP dialect created for the JVM.

This means that the code has the aesthetics that can only be achieved when doing functional programming, while maintaining the ability to fully interact with existing Java based libraries and code.

More then that, Clojure comes along with a modern (almost futuristic) approach to concurrency, way different then the one Java has.

This is extremely important for a programming language, let me explain why.

A good way to think of concurrency (and especially data concurrency ) in programming  is to think about it as a mine field, where the locations in which the threads are interleaving and handling the same data are mines. Your code is the field.

Java's approach is "I'll give you the ability to place mines and I'll  also give you these small cocktail umbrellas to mark where the mines are". You just have to hope that you placed these little cute umbrellas in the right places and covered with them all the ways to access the mines. This is tough to do right in small scale software (where there are very few developers). Practically impossible to do right in large scale software (where there are too many developers).

Clojure's approach is different. It says "put as many mines as you want, I'll cover it with so much concrete, that it doesn't matter how many users are travelling in the field". The concrete itself is composed of immutable data, actors/agents model and software transaction memory.

(BTW, JavaScript approach can be summed up as "there shell be no mines")

I will not start to explain why concurrency is important, if you don't know, then probably you didn't read all the way up to here...

This is a delightful language to use (higher order function is by far the most beautiful idea in programming). It is powerful, efficient with a "no fluff just stuff" attitude with a potential to take your code to places that OO just can't go.

I guess that this is the reason why one of the first books written about Clojure is called "The Joy of Clojure", not sure that there are such titles about C or Java (a book with a similar title about C++ is probably aimed at the masochist community).

Try it, you will not regret and will not look back.