4 ms·
"I love Erlang but I cannot get the past the syntax." I cannot understand this hangup about syntax. Syntax is the easiest thing to learn with a new language, y
by rvirding 14y ago
"I love Erlang but I cannot get the past the syntax."
I cannot understand this hangup about syntax. Syntax is the easiest thing to learn with a new language, you just look it up. It's the semantics and usage where the real problems are.
Erlang doesn't have static typing, it is dynamically typed. It has always been dynamically typed.
And however you look at it doing highly concurrent systems with processes is much easier. And who says that processes imply "parallel access to shared memory"? Quite the opposite actually.
- ches 14y agoFWIW I believe "Maybe you don't care about Erlang's syntax or static typing" was referring to his earlier mention of Go as statically typed. A comma would have improved the clarity :-)
- zem 14y agosyntax is the user interface of the language. it is one of the parts you have to deal with on a constant basis, both writing and reading code. i can well see how an unpleasant syntax can be a constant, grating annoyance when dealing with a language. (i happen to really like erlang's syntax, but it definitely has very different aesthetics from javascript's)
- KirinDave 14y agoHonestly? Erlang's syntax is not that bad. It's not great in that it has prolog legacy with uncanny valleys to C-legacy left and right, but it's effective. Really the only really tricky thing for a newbie is strings.
- zem 14y agothese things are very much a matter of taste. what does "effective" mean with respect to syntax? for instance, lispers will argue that their syntax is effective because of the things it lets you do, but that's orthogonal to whether it's actually a pleasant syntax to program in, which comes down to personal taste[1]. likewise, i love mlish syntax, but opa, a language steeped in ml semantics, nonetheless switched to something more javascripty for their main syntax because it proved more popular[2]. and read through the wrangling over ruby versus python sometime - the two languages are very similar under the hood, but their respective syntaxes are one of the things proponents of each language complain about when they have to use the other. [1] as larry wall famously said, "lisp has all the visual appeal of oatmeal with fingernail clippings mixed in." [2] http://blog.opalang.org/2012/02/opa-090-new-syntax.html http://blog.opalang.org/2012/02/opa-090-new-syntax.html
- silentbicycle 14y agoIt takes a lot of chutzpah for Larry Wall to say anything critical about Lisp syntax. Larry Wall. Come on. I'm not the author of the comment above, but I think Erlang's syntax is effective in that it strongly emphasizes computation by pattern matching. If you write very imperative code in it (as people tend to, coming from Ruby or what have you), yes, it will look gnarly. Good Erlang code looks qualitatively different. There are pretty good examples of hairy, imperative Erlang code being untangled in this blog post: http://gar1t.com/blog/2012/06/10/solving-embarrassingly-obvious-problems-in-erlang/ http://gar1t.com/blog/2012/06/10/solving-embarrassingly-obvi... The . , ; thing is a bit of a hack, admittedly -- I suspect that comes from using Prolog's read function to do parsing for the original versions of Erlang (which was a Prolog DSL), and reading every clause of a function definition at the same time. Prolog ends every top-level clause with a period, not "; ; ; ; .". (Not sure, but a strong hunch, supported by Erlang's history.) I got used to it pretty quickly, though.
- rvirding 14y agoAs in Prolog ',' and ';' are separators: ',' behaves like an and, first do then and then do this (as in Prolog); while ';' is an or, do this clause or do this clause (again as in Prolog). '.' ends something, in this case a function definition. Erlang's functions clauses are not the same as Prolog's clauses which explains the difference. It is very simple really, think of sentences in English and it all becomes trivially simple.How many sentences end in a ';'?. And you almost never need to explicitly specify blocks. Here http://ferd.ca/on-erlang-s-syntax.html http://ferd.ca/on-erlang-s-syntax.html are some alternate ways of looking at it.
- silentbicycle 14y agoIndeed. It makes sense to me. Are my intuitions about the origins of ;s separating top-level clauses accurate? (Hello, Robert! :) )
- rvirding 14y agoSort of. The syntax evolved at the same time we were moving from Prolog onto our own implementation, which forced us to write our own parser and not rely on the original Prolog one. The biggest syntax change came around 1991, since then it has been mainly smaller additions and adjustments.
- rvirding 14y agoI think it would be dangerous if Erlang's syntax were to resemble that of another language like Java or C. Especially for beginners. That is because if things look the same you expect them to behave the same, and Erlang's semantics is very different from those languages whose syntax people think it should be like. There is no getting around the difference in semantics. For this I think that having a different syntax is actually better. Also there are things in Erlang which are hard to fit syntactically into the syntax of OO languages, for example pattern-matching.