[Haskell-cafe] Language simplicity

sylvain sylvain.nahas at googlemail.com
Tue Jan 12 18:35:54 EST 2010


Le mardi 12 janvier 2010 à 21:25 +0000, Andrew Coppin a écrit :

Hi Andrew,

> As you can see, this conclusively proves... something.

What, exactly?

Take Eiffel in its last version: I have identified 11 keywords that are
either used for Design By Contract or source-code documentation. These
are software engineering tasks that in the other languages you cite are
not supported at the grammar level and, if ever, fulfilled by enriching
the code using comments, annotations or compiler extensions. Removed,
this make Eiffel the less "verbose" object-oriented language of your
list, excepted Smalltalk. In any case the less verbose statically typed
compiled OO language.

One factor is how rich is the set of OO constructs supported by the
language. Visibility rule keywords may shrink or extend the list of
reserved words. Same for math or logical operators: some languages
define as keyword what belongs to libraries in another. Same for
exception mechanism.

Some languages defines the code block constructs using keywords while
other use tokens that are not considered reserved words. 
Contrast for example the following Ada code (4 keywords):
procedure Hello is
begin
...
end Hello;

against the equivalent C (1 keyword):
void HelloWorld()
{
...
}
or the equivalent Haskell (0 keywords):
helloworld = ...

Ada in its 71 reserved words features keywords for concurrent
programming that doesn't exist at the same level in the other languages
in your list, and an explicit "pragma" keyword to allow the programmer
to specify things like the alignement used in the generated binary. So a
significant factor in programming language "verbosity" is how much
control the language intends to give to the programmer on the
implementation level - or said otherwise how abstracted is the language
from its run-time environment. 

Let me order your list:
Smalltalk: 0
Lisp: 0
Tcl: 0
Haskell: 21 *
Python: 31
C: 32 *
JavaScript: 36
Ruby: 38
---
Borland Turbo Pascal: ~50
Java: 53
Eiffel: 59
C++: 62

Interestingly enough, interpreted languages tend to need less keywords,
which support my observation above. 

Let ignore C. Noticeable is Haskell, with little reserved words while
being efficiently compiled. It reflects the fact that it does not have
elaborated object-oriented constructs, that code is structured using
layout rules, that the exception and concurrency mechanisms are provided
at the library level, that there is no way to control the code
generated, and that there is no built-in support for software
engineering like the sort Eiffel provides. It reflects as well the
"expressiveness" of Haskell and how good at abstracting the description
of a computation from its run-time environment it is. But if you really
wanted to compare apples to apples you would, for instance, add GHC
pragmas and "magic" things like `par` to the mix. I wonder if the
picture would change much?

> Hmm, I wonder if there's some way to compare the size of the language 
> specification documents? :-}
Maybe comparing the grammars in a standardized form (BNF) ?

Cheers,
Sylvain





More information about the Haskell-Cafe mailing list