Hacker News new | ask | show | jobs
Getting started with Erlang: a new way to look at Erlang's syntax (medium.com)
54 points by kansi 3903 days ago
3 comments

I never understood why Erlang syntax has been so commonly maligned. I had no trouble getting through Joe Armstrong's Programming Erlang in less than a week, and the syntax never required any conscious moment to "click," it just flowed right past. The only exception at first was the operator precedence rules inherited from Prolog, but those are memorized quickly.

I also didn't have in-depth prior experiences to non-ALGOL languages all that substantively. I had experimented with Scheme, OCaml and REBOL (and read documents on Prolog, but barely typed much of it) before, but nothing fancy.

I think I may be more representative of the camp complaining about erlang's syntax. My background is as a sysadmin without CS training, with only prior experience using ruby, python, and shell scripting.

It took me about four months of hard studying for erlang to click. I think it was due to learning some CS fundamentals (e.g. had never heard of a tuple before, never seen multiple dispatch), learning functional programming fundamentals (had never used a purely functional language before - unless you count bash), and had never looked at prolog. Finally, I was simultaneously exposed to new concepts of concurrency, pattern matching, etc.

I think what happened was that the unusual syntax is the easiest thing to blame for the resulting confusion, because it's the surface layer you engage with.

Ah, that would make sense. I already had some knowledge of general computing "culture" before learning Erlang, so I did not stall much on the broader concepts. Erlang is more heterodox, so it's likely the ideas could be an initial obstacle.
> e.g. had never heard of a tuple before

You never encountered tuples in python?

I think that generalizing from your own personal experience is probably a bad idea here. I personally learn syntax very easily probably because I place very little emphasis on syntax and far more on semantics. However I have met people who place a lot of emphasis on syntax. For them the syntax of a language is a large hindrance.

I suspect there are people for whom syntax has a large impact on productivity. Especially when first getting familiar with a language. I don't think downplaying that is wise.

It's much more complex than that. Learning new syntax, for example, is completely different beast than actually using the syntax. Syntax has non-trivial - and rarely understood - influence on code readability and language idioms. Constructs with syntactic support tend to see more usage than the "bare" features - it takes a language as impoverished as JavaScript to convince people that they don't need syntactic sugar to use those features. Language syntax affects tooling to a great extent. And so on.

So, in short: syntax does matter, although in a different way than most people think.

On the other hand, people who are fixated on some syntax should just stop. Writing a couple of lexers/parsers helps here. Knowing different kinds - of flavours - of syntax helps even more. Syntax does matter, but not nearly as much as such people seem to think.

The point is Erlang's syntax is something of a joke for whatever reason, so I figured I'd offer a counterexample.

Honestly I see it as just slightly less juvenile than "Lost In Stupid Parentheses".

It's funny, I set out to learn Erlang this year, but ended up learning Elixir first. A lot of people go to great lengths to assure that Elixir is not the "CoffeeScript of Erlang" (which I do understand refers to more than just syntax improvements), but I found the opposite. After getting used to Elixir syntax, Erlang seems aesthetically much more elegant.
Well it isn't just the CoffeeScript of Erlang for reasons like having better string implementation, macros, subjectively better additions to standard library, protocols, etc...

Whether those reasons are significant enough for you to use Elixir over Erlang are another matter, but it wouldn't be classified as just another CoffeeScript when compared honestly.

Basically this happened to me as well. I was interested in learning Erlang just because it was something different then the plethora of common languages we see and use everyday. But when Phoenix v1.0 was released I jumped on that. It was an interesting experience; I felt like I was working with Rails even though I wasn't. Needless to say, it completely distracted me from actually learning Erlang.
Opposite experience here. Having learned Erlang first, I find Elixir's syntax to be a false friend for the semantics of the ERTS. Erlang's syntax also seems to me much better at getting out of your way and focusing on the primacy of patterns.
I have been learning and using Erlang for quite sometime and it's syntax was one of the attractive part for me, short and concise. But it has always confused me why people keep praising Elixir for the break through they made with its syntax !
Erlang's syntax really is really really easy... its just different enough that it causes fence jumping when switching languages
2nded. IMO, Erlang the language is really really simple and easy and the basics can be learned in a few days, though it helps to have been exposed to Lisp, PROLOG, or various functional languages.

What I find far more challenging is catching up with the myriads of libraries & frameworks that are used to build real applications. Oh, and finding compatible versions of these can also be an unwanted adventure at times.