[erlang-questions] Erlang vs Clojure

Ciprian Dorin Craciun <>
Sat Nov 24 22:53:47 CET 2007


On Nov 24, 2007 11:28 PM, Kostis Sagonas <> wrote:
> Ciprian Dorin Craciun wrote:
> > On Nov 12, 2007 7:35 PM, Torbjorn Tornkvist <> wrote:
> >> Ciprian Dorin Craciun wrote:
> >>
> >>>     Just a some minor complaints (so they can be ignored :) I would
> >>> gladly use Erlang for most projects I am working on -- which usually
> >>> reside on server side -- if:
> >>>     -- I would have a nice macro system that blends into the normal
> >>> syntax -- for example in Common Lisp 'or' is implemented as a macro,
> >>> but you don't notice it...
> >>
> >> I don't think Erlang has got (big) 'problems' in these areas.
> >
> >     Please don't understand me wrong. I am not overlooking the power
> > of Erlang, and also I am not minimizing the importance of all the
> > systems built in Erlang. I am just pointing some areas where some
> > improvements would make a difference -- at least for me.
>
>
> Can you please elaborate on what you want to see?  Are you claiming that
> because Erlang does not have a nice macro system, it really hinders your
> application development?
>
> In what areas/applications the macro system is not doing what you want
> it to?  Some examples would help (at least me).
>
> Kostis
>
> (Btw, there are people in this list that claim - often with very good
> arguments - that the Erlang preprocessor should be taken out and/or
> replaced and that macros are the sort of all evil.)

    "It really hinders application development" is a little to much.
Everything that could be achieved by using a macro system, can also be
achieved by hand-writing the code... Not having macro system doesn't
mean you find roadblocks in development. But having one could make
your life easier.

    First of all please note that when I say macro system, I am
reffering to that used by the Lisp family, and not to the one we can
see in C/C++ or Erlang. So I am reffering to a macro system that
allows me parse tree transformations instead of string manipulation.
    Also I would like to point out that in order to have a powerful
and usable macro system there is a need to have a certain syntax...
And therefore imagining new macro constructs in the current language
syntax is a bit hard -- at least for me.

    A macro system is useful when you find yourself writing the same
code again and again with only minor differences. In this case you
could create a function, but there are times when the code pattern is
closer to a new control structure.

    For example if I would like to execute a piece of code if a
condition is true and do nothing otherwise I have to write:
    if
        guard -> {do something}
        true -> false
    end

    So instead of introducing a new control structure, I could define
a macro that would be used like you can see bellow, but is expanded
like the code above:
    if_ guard -> {do something} end

    I hope this is a good example even if it is a trivial one.

    Ciprian.



More information about the erlang-questions mailing list