If functional languages are really concise, why don’t they have a better rank in the language shootout game

code-sizecomparisonfunctional programmingprogramming-languages

I compared the languages at the language shootout game by their code size only. Here is a summary of what I got (shortest first, grouped by similar score).

  1. Python, Ruby, JavaScript, Perl, Lua, PHP, Mozart/OZ
  2. OCaml, Erlang, Racket, Go, Scala, F#, Smalltalk
  3. Pascal, Clean, Haskell, Common Lisp, C#, Java, C
  4. C++, Ada, ATS

I wonder why. The winners seem to be plain old dynamic languages. Erlang, Racket (née PLT Scheme), and F# are doing OK. Haskell and Common Lisp don't look more concise than claimed-to-be-verbose Java.

UPDATE:

I've found an insightful post on this topic with charts. I also found a similar comparison of languages for a larger program (a simple ray tracer). Altogether, I wouldn't say I got "the" answer, but I got some food for thought.

Best Answer

If functional languages are really concise...

1 - Programming in the large is different than programming in the small.

Nothing about those tiny benchmarks game programs should be taken as an example of how the abstractions and modularisation provided by each language would apply to programming in the large.

2 - Most of what you see in the benchmarks game summary pages only refers to the fastest programs contributed for each language implementation (slower programs are usually removed from the website after a while - when and which slower programs are removed is mostly arbitrary).

{edit: Adam, as you don't wish to take my word for it that the summary pages only refer to the fastest programs - look at the script that filters data rows for the "Which programming language is best?" page. Look at line 80 and line 82 in function ValidRowsAndMins in lib_scorecard.php - Alioth issue their own security certificate so your browser will complain.}

So to take Haskell as an example, you're looking at code size of the fastest Haskell programs that have been contributed.

3 - None of the meteor-contest programs have been removed, and meteor-contest is a programming contest without restriction - the smallest meteor-contest Haskell program is the slowest meteor-contest Haskell program.

Related Topic