[erlang-questions] A style question

Michael Turner leap@REDACTED
Mon Feb 15 07:59:21 CET 2010


I wrote:
>> ...  For example, you [Richard] characterized F
>> as "opaque".  Fair enough, but it's at least allusive in the right
>> ways.

Richard replied:

>It's about as helpful as calling a number N or an atom A.

In the case of N, at least, it actually *can* be a little helpful. 
Quick, which is idiomatic in C:

  for (n = 0; n < i; ++n)

or

  for (i = 0; i < n; ++i)

And why do you think your choice became the idiom?

>I don't know what "middle school" is, but you'll often find
>f, g, h used as function names, which only leaves 23 letters
>of the alphabet.  I'm pretty sure I met that at high school.

About g and so on: I was attempting humor.  Always a risky business.  And
I thought "middle school" was more universally understood by native
English speakers than "junior high school."  Clearly I'm wrong there.

>Fortran has allowed functions to be passed to functions for over
>fifty years.....

Not the point.  I discovered this fact about Fortran early on, and
delighted in it.  But passing of functions to functions is relatively
infrequent in most non-lambda-supporting languages.  I've met people
who have been programming in C for years without learning how to write
the declaration for pointer to function, and who were faintly in awe of
me that I could do it with my eyes closed.

>The function in question has only one parameter.
>What's to be reminded of?  And I fail to see how "F" is a better
>indication of function-ness than 'fun'.

I see it as better in some ways, worse in some others, and in certain
repeated patterns, better for *some* people, if that's what they've
gotten used to.  So much so that they'll even use the pattern where
it's less applicable, as when passing a function argument to a
single-argument function.

Look, in a sense, programming languages are a user-interface issue (the
language is your interface to the processor-memory switch and ultimately
to something happening at the level of electrons and holes in doped
silicon crystal lattices).  People's judgments of user interface issues
often come down to what they think is "intuitive".  Studies of what's
intuitive in user interfaces have come up with a shrug: the intuitive is
what's familiar to you, period.  You write enough code with funs
directly supplied as arguments, and look at enough code like that, and
it's more familiar to you.  So you think that's "intuitively
obvious" way.  But I'll probably have to write the keyword 'fun' in
Erlang 500 more times before I'll fully quell my mind's natural
impulse to read it as the English word "fun".  It's a mild
distraction, but a little bit of cognitive load each time.  In some
ways, I wish the designers of Erlang chosen "function", or even
"lambda".

I've been living in Japan almost 15 years, and I still do things wrong
because I'm following intuitions developed from the 38 years before I
came here to live.  There's so much in almost everything we do that's
little more than a matter of what we're used to seeing and doing.

>> And, of course, the whole thing is easier to indent prettily.
>
>Not with decent tools.

Not everyone has those, Richard.  Just recently, there was a thread here
about how Emacs gets it wrong.  But most Erlang hackers use Emacs
anyway, I bet.  I use vim.  Vim gets it wrong, too.  But vim is
basically vi, which is, well, intuitively obvious to me.  Maybe I'm
crippled by a whole adult lifetime of editing habits.  (Maybe I can sue
Bill Joy for damaging my productivity?  I hear he has a lot of money.)

-michael turner


More information about the erlang-questions mailing list