[erlang-questions] DRY principle and the syntax inconsistency in fun vs. vanilla functions
Fri May 20 01:57:13 CEST 2011
On Fri, 20 May 2011 09:20:52 +1000, Frédéric Trottier-Hébert
> I don't agree with complaints either -- I have no issue with Erlang's
> syntax, lisp/scheme/racket's syntax or any other language. The reality,
> however, is that while programmers can pick up Erlang's syntax quickly,
> there's still an initial struggle to break what has been committed to
> muscle memory by many of the people I have taught it to.
> The syntax might be the scapegoat of the difficulty in learning foreign
> concepts like functional paradigms, concurrent ideas or pattern matching,
I have a more cynical view: I think programmers just like to whinge. On
average, more than other people. Syntax just happens to be the first thing
you can complain about when someone says to you "learn Erlang." (not
referring to Mr Turner or his proposal here but rather the usual
superficial general complaints about Erlang.)
> but in any case, it is a hurdle that newcomers have to step over. It's
> not because they can beat challenges that we have to make it harder on
> purpose by introducing new elements like the alternative function syntax.
Oh, I certainly wasn't arguing for this change. I personally don't see the
added benefit (but I haven't been using Erlang that long, so I'll defer
the opinions of the more experienced.) The syntax argument against Erlang
(and python, and C++, and BASIC, and ...) has always really bugged me,
- Edmond -
> Fred Hébert
> On 2011-05-19, at 18:49 PM, Edmond Begumisa wrote:
>>> People already complain that Erlang's syntax is too ugly or complex;
>> I've always found this complaint to be rather quibble.
>> Programmers have brains that are extremely well adjusted to parsing new
>> syntax. This is one thing all programmers are inherently good at. Yet
>> when asked to put this skill towards learning a new language, they
>> complain. "No" they say, "give me a syntax I'm already familiar with.
>> Why are you trying to be different?" they ask.
>> I learned Erlang by reading Joe's book. Within half an hour I wasn't
>> seeing the syntax anymore. My brain, quickly made the necessary mental
>> mappings. I strongly believe this to be the case with all programmers
>> when encountering an unfamiliar syntax -- rapid adjustment with
>> relatively little effort.
>> Other professions are not so lucky. I once witnessed two
>> non-programmers trying to learn HTML at the same time. One a medical
>> doctor, the other a graphic designer. Both got the concepts down very
>> quickly (links, images, tables, etc), but both really struggled with
>> syntax. "How can one possibly read this?" they kept asking.
>> Yet most programmers learn HTML/XML syntax in a matter of minutes while
>> watching TV. Gut give them Erlang and they groan and complain loudly.
>> IMHO, complaints about Erlang's syntax being "too weird" are completely
>> unwarranted. A programmer could learn a language written using Klingon
>> symbols in a unbelievably short period of time. Just look at all those
>> non-English speakers who program in languages heavily biased towards
>> English. And many of them come from languages using non-latin scripts!!!
>> - Edmond -
>> PS: The exception is Lisp. All those parentheses are just obfuscating :)
>> On Thu, 19 May 2011 21:41:50 +1000, Frédéric Trottier-Hébert
>> <> wrote:
>>> I would rather have one clear but slightly verbose way of doing things
>>> rather than two potential ways to do the same thing in slightly
>>> different manners prompting religious wars to get the same result I
>>> already have.
>>> The idea to revisit the syntax isn't bad in itself, but looking at the
>>> examples Steve Davis provided, I can only see your concept being
>>> useful for very short functions.
>>> When it comes to learning Erlang, I can tell you that in my
>>> experience, new users struggle a lot more with clause separators (;),
>>> expression separators (,), form terminators (.), records, 'if' or funs
>>> (in concept) than they do with function syntax. They do not seem to
>>> see the current way to write function heads as problematic. Then, all
>>> Erlang users are also used to it.
>>> Adding more ways to do things that currently have a single way to be
>>> done is a net loss in my opinion. People already complain that
>>> Erlang's syntax is too ugly or complex; I do not think that adding
>>> more syntax is the way to solve that. It would not benefit new users
>>> and it would not benefit the majority of all users, only increase the
>>> ways they can read code and get confused.
>>> In the other thread, someone called it 'syntactic salt', and I think
>>> this is a good way to describe how things are right now. It's not a
>>> bad thing in my opinion.
>>> On 2011-05-19, at 06:47 AM, Michael Turner wrote:
>>>> "But how interesting is whether existing code would break or not?"
>>>> Not very. I mean, who uses Erlang for anything important? Hardly
>>>> anybody, right?
>>>> "It would, as others have pointed out, also be much harder to jump
>>>> into a module and _know_ what the clause does since the function's
>>>> name can be pages away."
>>>> It would only be harder ("much"??) if you *chose*, in such cases, to
>>>> use the syntax I propose to bring over from multi-clause funs. In the
>>>> case you bring up, it might be wiser not to. And what I propose
>>>> clearly allows everyone to continue with the present syntax. So your
>>>> argument for readability in this case comes down to "somebody might
>>>> not use this language feature wisely." (*facepalm*).
>>>> -michael turner
>>>> erlang-questions mailing list
>>> Fred Hébert
>> Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
More information about the erlang-questions