Erlang - overhyped or underestimated?
sacharya.com
sacharya.com
> I can’t imagine how you can organize large code-bases in Erlang or even work as team, and this doesn’t feel right to any OO programmer.
Well, yeah, but neither would Clojure or Haskell or a host of other interesting and useful languages. Functional programming is a completely different paradigm, and if you come into with an OO mindset the results will not be good. But that's more a fault of the programmer than the language.
It's more like "I know how OO allow teams to work together. I don't know how functional programming does that".
What would be the answer to that?
erlang is designed around intercommunication, there was some rule about how a team of 3 would make a 3 pass compiler, in erlang everything is explicitly isolated and you have to design specifically how the various parts of the system communicate with each other
http://www.sics.se/~joe/bluetail/vol1/v1_oo.html
Erlang is closer to original Smalltalk than most of current OO languages: there are processes (objects) which communicate by messages (messages).
I also should mention OOHaskell: http://homepages.cwi.nl/~ralf/OOHaskell/ "In the second and major phase, we systematically substantiate that Haskell~98, with some common extensions, supports all the conventional OO features plus more advanced ones, including first-class lexically scoped classes, implicitly polymorphic classes, flexible multiple inheritance, safe downcasts and safe co-variant arguments. Haskell indeed can support width and depth, structural and nominal subtyping. We address the particular challenge to preserve Haskell's type inference even for objects and object-operating functions. Advanced type inference is a strength of Haskell that is worth preserving. Many of the features we get ``for free'': the type system of Haskell turns out to be a great help and a guide rather than a hindrance."
So everyone "can has" his OO everywhere, in case one needs it.
[1] http://en.wikipedia.org/wiki/Specification_and_Description_L...
At the end of the day, if you're happy with the results you're getting with Erlang (and you can get great results), who cares if the rest of the world thinks Erlang has no fashion sense? Erlang is still beautiful.
10.3 Where does Erlang syntax come from?
Mostly from prolog. Erlang started life as a modified prolog
Maybe this means Prolog syntax isn't really that weird?The ";" vs "." thing is also on Erlang. Prolog has a function to read the next clause (much like Lisp's read parses the next sexp), and Prolog clauses end in ".". The Erlang interpreter seems to have been implemented so it read every alternative for a pattern in one step, so it ended all except the last with ";". ";" is Prolog's "or" operator, "," is "and". Prolog just ends every pattern with ".".
That said, you get over those minor syntactic issues pretty quickly, and I'll take a language with ugly syntax but beautiful semantics over one with ugly semantics any day.
Sadly the erlang semantics aren't all beautiful either, at least for the things that most people would use it for today.
This quote that I picked up on the erlang mailing list was an eye-opener to me (from memory):
Erlang wasn't designed to make easy things easy.
It was designed to make hard things possible.
This explains a lot about the erlang mindset. Things like the obscure syntax or the abhorrent string handling are simply not very high on their priority list.For example, strings weren't used much in the telecom projects that erlang was original conceived for - hence they didn't get much love until recently.
Similarly the syntax seemed like a good fit for the problems that erlang was looking to solve, because it makes the expression of very complex, concurrent constructs comparably sane.
The problem for us "normals" is that in our codebases we very rarely need that kind of expressive power (and the associated learning curve). We tend to need it in 2-3 critical spots, the remaining 99% is best solved by a general-purpose language that allows for quick iteration.
Introducing the behemoth of erlang to a project only for these 2-3 spots very rarely passes a cost/benefit analysis.
That's why we hack shoddy, slow and fragile bandaids in our go-to languages, instead of using erlang.
* Except for the bit syntax, but that's more for binary data.
The language moved on and dropped some of the defining features of Prolog (such a backtracking), but the syntax still resembles Prolog.
This is similar to the syntax in haskell, F# and ocaml, so it may look weird at the outset but it's not an isolated weirdness, and it quickly becomes a natural way to read code.
http://www.rabbitmq.com/resources/RabbitMQ_Introduction.pdf
http://en.oreilly.com/mysql2011/public/schedule/detail/17618
Huh? And...huh? It's not prolog like, and it's not like anything mainstream from the 80s and 90s. What am I missing here?
It was kind of sad, actually, to hear Jonas Boner talk about Erlang at one of the Bay Area Scala group meetings. He said he fell in love with the language but realized it was too hard to get people to deploy Erlang so he's trying to build the same functionality in Scala with the Akka library.
Friendlier macros is a win at the very least!
Unfortunately, the release notes are enormous docs.
Fortunatley, each reflects a huge number of new features, bugfixes and enhancements.
Off top of my head:
- continuing work on tools like Dialyzer, McErlang, quickCheck
http://erlangotp.com/wiki/analysis/
- new SSL module
- NIF's
- Ericsson puts the repo onto github, starts pulling patches
- "erl +native" / HiPE
- schedulers for SMP processing
- large shared data structures passed as messages:
- from Basho: riak, rebar and Nitrogen
- Oreilly and Manning books (Cesarini/Thompson an outstanding book; archaelus and Gerakines were writing books also,hope they get published)
- learn you a erlang, erldocs.com,
http://learnyousomeerlang.com/
- the community has not changed. Beginner questions are still enthusiastically answered on IRC, the google group and stackoverflow (by Armstrong, Virding and the Ericsson core team, among others)
Well thats just not true...
1. Erlang has a funky syntax; deal with it. If you can't or won't learn the language b/c of the syntax that is your loss. I'm sorry, but I can't really find this a valid argument as it basically sounds like "Erlang syntax scares me. Me no likey".
2. Documentation on Erlang libraries is a bit weak in some areas, but all the source is there and since it is functional, the ability to decipher the methods is really great. However, if you are looking for a 'mysql tutorial' with a 1000 hits on Google to show you the way, you won't find it. Frankly, you will have to exert some effort with Erlang.
3. This is wrong. I realize that this is 2008, but even in 2008 you had huge Erlang systems at Akamai, Mochi and many European telecoms. Since then (when I have picked it up) there is Basho, XMPP implementations, trading systems and, of course, Facebook chat.
4. Again, fear basically. The code base likely will never grow as big as a .NET or JEE code base simply b/c the code is functional.
5. The numbers are the numbers and they speak for themselves. You can't really understand the benefit you can get from Erlang until you try it for yourself on a multicore system and see it fly, watch it in a multi-noded system and watch it grow and see how it handles failures w/ ease. Traditional OO developers (.NET and Java) just won't "get it" until they try it.
6. Red herring. Erlang is NOT a web language. But, since this article was written many have emerged. Chicago Boss, Nitrogen, Erlang-web. I still think of Erlang has mostly an way to (coupled with Webmachine) expose some endpoints as services for me to talk to.
7. Yeah, this one is true. String manipulation sucks. Binary manipulation, however, is awesome. Tradeoffs. Remember what Erlang is good for and what it is not good for and you will be quite happy with it!
Erlang, in general, takes some time to learn. It is well worth the time if you need infrastructure that can scale massively.
Lastly, I would like to say this...functional programming in general is coming back in vogue at the moment and for good reason. Working on this system using Erlang has really reshaped my thoughts on programming in the past two years and I have to say that all my code is cleaner, my code base is smaller I have started to really take a critical look at my OO code as heavy weight and not worth the overhead in many cases. FP also seems to map better to my way of thinking....but that might just be me.
[EDIT] - Clarifying 6 a bit. I think that holding the web framework argument against Erlang is unjustified. Even so, web frameworks have emerged. I find they don't map very well and I feel there are better solutions than using Erlang web frameworks.
And this is invalid, how?
A well designed syntax is a must for a good language.
If Erlang has a "funky syntax" (your words), then that is a real disadvantage that should raise concern. Syntax affects code readability, maintenance, etc.
erlangs syntax is very well thought out, I would even agree it is ugly at times, but it very purposefully avoids any fancy contructs choosing readability every time, erlang (imo) is by far the most readable language around, it is very very hard to find a piece of erlang code that is hard to follow because it only has primitive constructs
Well designed and 'understandable at first sight' are not synonymous. If they were, C would not be a good language. Many C programmers tend to forget how alien the syntax looked to them when they first met 'Hello, world!' in C, with its '#include' 'char * * argv', and braces for blocks.