Use Ocaml, save the world


(Note: this post is written in a tongue-in-cheek manner; take it too seriously at your own peril).

Since this blog is syndicated in the Ocamlcore Planet, readers may be wondering about the implications for our favourite language of the coming energy crisis I just wrote about. And in general, just how well are different computer languages adapted to an energy-constrained economy?

There are two different factors to consider: a) how efficient is the language at converting CPU cycles into useful work, and b) how efficient is the language at converting programmer time into useful programmes.

The importance of the first factor should be self-evident. If not, note that computers consume an increasing percentage of our energy, and that data centres all over the world also require a significant amount of power. Moreover, there is a wide disparity in the amount of time different languages require to complete the same task. This difference boils down to different approaches to programme execution (compiled languages tend to be more efficient than interpreted ones) and the quality of the code generated by compilers. The Computer Language Shootout, though not without its flaws, provides some ballpark figures on the efficiency of different languages. As you can see, Ocaml fares very well on the existing benchmarks.

The second factor, though it may not be obvious at first sight, may indeed be even more relevant to this discussion. Programmer time requires energy not only to sustain the Homo sapiens specimen that does the programming, but also because programming is to a large extent done in front of an energy-hungry computer. Therefore, by making the programmer more productive, a computer language can result in significant energy savings.

Measuring language productivity is a difficult task. Nevertheless, I would like to posit that the availability of a strong static type checker such as Ocaml's — one that catches most common mistakes at compile-time — is a plus in this regard. Even more so if we consider runtime errors as a loss of productivity. Another good proxy for language productivity is indicated by the terseness of its programmes. Again, the Computer Language Shootout may be of assistance.

So, how well does Ocaml fare when these two factors are taken into account? Very well, I am pleased to say. In fact, using some reasonable parametrisation, the results of the Shootout show Ocaml as the top rated language. We can therefore conclude that Ocaml will also have a role to play in saving civilisation from an energy crisis.

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this entry.
Comments

Leave a comment

 Enter the above security code (required)

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.