[erlang-questions] Erlang and syntax.

Loïc Hoguin <>
Sat Feb 22 18:46:00 CET 2014


On 02/22/2014 10:14 AM, Maxim Velesyuk wrote:
> Often when I feel I need to change ast I remember how clumsy and
> uncomfortable parse transform is, so I overcome myself and make workarounds.

Why do you even feel the need to change the AST? Don't do that.

> But macros are still useful, programmers use parse transform when they
> have no other choice, and projects like merl appear.

Macros are not useful. Macros are what makes a perfectly readable 
program into the worst spaghetti code you have ever seen. Even EPP 
macros, which look pretty harmless as they have very limited 
capabilities, can make things a lot worse than it needs to be.

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.

Macros make your programs worse than PHP and Java combined.

> List and zip comprehensions could be implemented as macros, ets and
> mnesia query language is actually prefix-notation language with code
> quoting, even pattern matching and so long expected maps could be just a
> libraries.

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.

> Take a look at c++ and java, how they suffer from inventing new syntax.
> Hopefully Erlang will not turn in such syntax-monster. It has syntax for
> many things, but it still not as flexible as it could be.
> This forwards me back to my first question, why?

You don't need it.

Loïc Hoguin

More information about the erlang-questions mailing list