[erlang-questions] Erlang and syntax.
Loïc Hoguin
essen@REDACTED
Sat Feb 22 21:50:30 CET 2014
On 02/22/2014 09:33 PM, Maxim Velesyuk wrote:
> >Sure macros allow you to write less code. But I spend 90% of my time
> reading code, so I like programs that are optimized for my reading. If I
> always need to refer to some other source file or document to understand
> what the code is doing, then I am not going to be using your program
> very long.
>
> But when you see unknown function you still have no idea what it does
> and you have to figure it out. Any abstraction works in same way.
I beg to differ. file:read_file/1 is pretty obvious. So is lists:map/2.
So is most of the functions you can read in your code. You don't need to
know the internals of a function or even the full spec when you are
reading code, you know that you are reading a file, or mapping a
function over a list. When you have macros, you don't even have any idea
whether what you are calling is a function or something else entirely.
And when you have macros that are being used to create new syntax? Then
it is completely alien to all the code around it.
> >And then one person creates maps, another creates frames, both with
> the same or similar syntax but with different semantics, both get used
> in the same system, and the code is completely unreadable. No thanks.
>
> Macros are dangerous as much as powerful. If programmer does not use
> them correctly its a programmer's fault. In the end who is the target
> audience of a programming language for concurrent, fault tolerant
> systems? Probably the programmer who understands what he does. Should
> language designer force programmer to write code in 'correct' way? I
> don't know, but valuable spaces and programming patterns appeared from
> such ideas.
Hello elitism! I mean, seriously? You aren't using Erlang because you
are a better person. You are a better person because you are using
Erlang, because it gives you the tools to do things that are difficult
to do in other languages. Don't dismiss other people simply because they
don't have the chance to work with Erlang.
I will point out though that the target audience of any code, regardless
of the language it is being written in, is the *reader*. It's not the
programmer who wrote it. It's not the compiler. It's the many guys that
will come afterward, read the code, fix bugs, maintain it. If your code
is just using Erlang, then it's pretty easy for them to see what is
going on. If you have changed all the rules using macros, then they need
to learn more things before they can become productive with your code.
They will not like you for it, especially if the production system is
down and they have to fix the bug quickly.
> >You don't need it.
>
> Who but the particular programmer can decide what does he need and what
> doesn't ?
You don't decide what you need. You need it. That's it. If you can do
without and still meet your requirements and deadlines, then you don't
need it, it's just luxury. Except in this case it's luxury similar to
having snakeskin boots, you get what you want, but at the cost of the
blood of the people that will come after you.
--
Loïc Hoguin
http://ninenines.eu
More information about the erlang-questions
mailing list