[erlang-questions] Reassigning variables

Ulf Wiger ulf@REDACTED
Thu Mar 19 18:14:34 CET 2009


2009/3/19 Michael Radford <mrad-direct-erlang@REDACTED>:
> I totally agree about readability, but I think we need to distinguish
> "readable" code from "elegant" (or aesthetically pleasing) code.
>
> It's similar to the difference between newspaper writing vs. writing a
> novel, or poetry.  Most of the time, commercial software should be more
> like the former -- state the facts in a way that most people can
> understand easily, and get out of the way.  Occasionally, this sort of
> code might turn out to be elegant, but that's not the primary goal.

The primary goal of commercial is always to do its job well enough.
Elegance is seldomly achieved, but in my experience, if you try to
implant the /idea/ of elegance in the minds of commercial software
teams, readability might be achieved, at least some of the time.

Then of course, there's the question of what one finds elegant.
The most aesthetically pleasing Erlang program I've seen was
probably Urban Boquist's Soduku solver, which won 2nd prize in
the 2005 Obfuscated Erlang competition, but as a program, it was
largely unreadable.

http://www.erlang-consulting.com/obfuscatederlang2005.html#secondPrize

So for clarity's sake, let's define as elegance in the realm of
software as a program satisfying the first of Sir Tony Hoare's
alternatives below:

“There are two ways of constructing a software design;
one way is to make it so simple that there are obviously
no deficiencies, and the other way is to make it so
complicated that there are no obvious deficiencies.
The first method is far more difficult.”

I used to use this quote when discussing coding style
in my previous job. Whether it had any effect, I will let remain
a closely guarded secret.

BR,
Ulf W



More information about the erlang-questions mailing list