Hacker News new | past | comments | ask | show | jobs | submit login
Damien Katz: What Sucks About Erlang (damienkatz.net)
52 points by nickb on March 9, 2008 | hide | past | favorite | 13 comments



Why write this:

  f(X) ->
    X1 = foo(X),
    X2 = fab(X1),
    X3 = bar(X2),
    baz(X3).
When you can write this? (I assume this is legal)

  f(X) ->
    baz(bar(fab(foo(X)))).


I think this is just toy-example syndrome. In my experience the real-world example looks more like this:

  f(X) ->
    X1 = foo(X, "Blah blah blah", true, :definitely, :ack),
    X2 = fab(X1, X, sizeof(X), X-1, bar(X, "martini"), :with_bells_on, :pdq),
    X3 = bar(X2, "fim tim lim bim whim bim bus stop"),
    baz(X3).
Try chaining that and see how readable it is.


Touché.


Sometimes shorter lines are easier to read. But in most of the cases you should be right. You can even be more consice by using point-free form:

  f = baz . bar . fab . foo
[Haskell syntax - sorry, I do not know enough about Erlang - but something like this should be possible.]


I also dislike =:= for equals (and I forgot the difference to ==, it wasn't clearly understandable for me from the book). =:= is hard to type, why not just use === like Javascript?


There's a thought I've had in the back of my mind for quite some time but it seems so obvious that I think there must be a glaring flaw I'm not seeing otherwise it would already have been done extensively:

Whenever a language has a burdensome and rigid syntax, isn't there almost necessarily a way to make a good s-expression syntax to substitute it? You'd get macros free!


If by "good s-expression syntax" you mean a representation suitable for embedding into a Lisp, then yes: it's obvious, there's no glaring flaw, you get macros for free, and it is done extensively. There's an s-expression representation (or several) for pretty much anything you'd want to integrate with a Lisp program. Examples of common ones are HTML, SQL, and Javascript.

Where you don't see this done much is with general-purpose programming languages. This is probably because people who find s-expressions useful are already using Lisp as their general-purpose language. So it's mostly done for interoperability with other, pre-existing systems, like web browsers or C libraries. (You can see an example of the latter on slides 15 and 16 of http://www.xach.com/lisp/lispvan-2008-02-28.pdf.)

Erlang is a fascinating intermediate case. The distinctive value of Erlang is arguably not in the language, but in its runtime and libraries (including Mnesia). For this reason, the "general-purpose" caveat doesn't apply, and it's easy to see why someone might want to build a Lisp program on top of the Erlang runtime via embedded s-expressions. I seem to recall that there was a game company already doing this. If anyone knows about that or other examples, please post them here.


robert virding (of "hello, robert" erlang movie fame) released "lisp-flavoured erlang" recently. Haven't played with it yet... http://groups.google.com/group/erlang-questions/browse_threa...


Hello, Dave.


Aren't all languages sexps at the parse tree level? Lisp is basically a language without the syntactic top layer.


You could go further and say that all languages are lists of characters and wish for a language without the lexical top layer.


You basically shouldn't be using 'if' in Erlang - it's very rare that a pattern match wouldn't be a better option.

That said, I agree with him:

http://journal.dedasys.com/articles/2007/09/22/erlang


Most of those are minor nit-picks, but I do agree with him about string handling. Strings should be tagged. "dog" should be equal to {string, [100, 111, 103]} or something.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: