[Haskell-cafe] Shootout rankings

Jared Updike jupdike at gmail.com
Sun Jan 15 18:04:55 EST 2006

> > Maybe we finally have enough motivation to move to
> > some other measurement of program volume :-)

> I'm not sure how you could do this better, though... Maybe counting
> the number of "tokens" (not sure how you'd define that though)

I was thinking the same thing for the past few weeks: that lexemes or
lexical tokens would be the ideal unit of conciseness in a programming
language. This is revealing:

>From the shootout, for ackermann (counted by hand, given the benefit
of the doubt (i.e. to yield shorter count), excuse any mistakes):
language         lines   lexemes (non-whitespace, non-comment tokens)
Haskell          7        78
Python           10       79*
OCaml            6        87
Standard ML      4        88
Tcl              12       89**
Nice             7        93
Perl             9        95***
c/gcc            8       100****
Java             7        109
D Digital Mars   9        113
Scheme           11       113
* python: 82 if you count string interpolation
** Tcl: 95 if you count string interpolation
*** perl: 109 if you count sigils ($num = 2, $_ = 2) and string
interpolation. note that $_ is a lot harder to type than, say, x.
disclosure: I hate sigils.
**** c: 102 if you count string interpolation

Notice how the number of lines of code is very misleading. Now with
tokens you can't cheat by putting too much code on one line. In fact,
the only way to "cheat" is to redesign the language and make it so you
can say "map" (1 token) instead of "for (int x = 0; x < N; x++)" (14

I think that token counts would be a beautiful way to measure the
language itself and not the coder: if you can write a more concise
program in that language, then do it! Nothing is stopping you but the
language's expressiveness itself. Plus I'm convinced that it would be
even more telling for larger programs, where line counts can vary even
more. I'll parse a larger set of programs (nbody, for example) soon
(but not by hand) if anyone is as interested as I am.


reverse ")-:"

More information about the Haskell-Cafe mailing list