What's all this fuss about Erlang? (2007)
pragprog.com
pragprog.com
I hate this kind of marketing trick.
So let me add: And here's the bad news, your Erlang program can be much slower than a C program on one core: for example in the alioth 'benchmarks' Erlang run between 3X and 30X slower than a C program on one core ( http://benchmarksgame.alioth.debian.org/u64/benchmark.php?te... ) so you may have to throw MANY core at it before the Erlang program is faster than the C program.
So beware! YMMV.
That said, I hope that Elixir will improve Erlang's adoption as the high availability feature are the big deal IMHO.
What would be dishonest would be "here's the good news for C programmers: Your C program should just run N times faster on an N core processor if written in Erlang".
To your point though, Erlang gives you scalability. Yeah, on a single core, the C program will be faster. On multiple cores, multiple processors, multiple -machines-, idiomatic Erlang should scale. C code will not. You have to tear it apart, rewrite it, figure out a distribution model, code that or find a good library, fix the bugs in your own code or work around the caveats of that library, etc etc.
Ok anyway,now that you've asked the question, maybe elaborate a bit why you think your program is slow and how do you think you can make it "go fast".
It's what I consider to be a core problem with the dynamic languages, which Erlang technically is... you take such a single-core hit that it's essentially impossible to gain the performance back on multithreading. It's one of the reasons to be taking a serious look at Go; while it is far from the first "modern threading" system, it's one of the first to be combined with simple near-C performance. (Emphasis carefully chosen.) Java arguably has some solutions though I've not yet taken a close look at Akka performance. Erlang doesn't have near-C performance. Haskell can only get near-C performance with a lot of work and care. (They're still working on it, but it's still non-trivial.) The scripting languages are laughably far away from near-C performance and you take such a performance hit that it doesn't matter how easy they make multiprocessing after that.
I've still used Erlang for things that are truly IO bound. It's great for that and a very solid VM. But don't fool yourself into thinking Erlang is a performance solution for anything else. (And I find people yell "IO bound!" a bit too readily sometimes. That's really in the class of things you should profile before being sure.)
For example: http://benchmarksgame.alioth.debian.org/u64q/benchmark.php?t...
"Erlang FAQ 1.4 What sort of problems is Erlang not particularly suitable for?
The most common class of 'less suitable' problems is characterised by performance being a prime requirement and constant-factors having a large effect on performance. … Most (all?) large systems developed using Erlang make heavy use of C for low-level code, leaving Erlang to manage the parts which tend to be complex in other languages…"
Erlang is optimized for latency.
OpenCL is optimized for t-put.
Everything else (including C) is in between.Too short: for latency with multiple simultaneous users. If you have a 'one shot' program or one user at a time, you'll probably get better latency with C than with Erlang.
However, if you are writing something that needs massive scalability, the number of machines necessary and the management of it all starts to eclipse engineering cost. Then you need to drop down to a lower level language, or at least something more runtime optimized (like java) for the heavy lifting. Then the costs and frustration of debugging across two languages becomes burdensome.
If you are building a competitive commercial product that will be deployed to many customers, the economics start to swing away from Erlang. Customers don't care you needed 1/3 the engineers and testing (or whatever) to get it working. They don't care about how much time and money you saved writing it. They care their EC2 bill is low, or the number of machines in their data center is reduced. A competitor who writes in C might have longer time to market, but they will clobber you when customers see they need 1/4 the machines to support the same workload.
Erlang will NEVER be fast. The reason has little to do with the language semantics, and everything to do with it's lack of widespread adoption and therefore lack investment in compilers, runtimes and debugging tools, etc. It's slow because the syntax is ugly and thwarts adoption. If you are a badass VM/complier/JIT/etc engineer, you'll apply your skills to something like Javascript, Java, Python, Ruby, etc and affect a much larger audience.
Also the lack of adoption makes Erlang a hard sell in a corporate environments. Sure you might get something up and running much faster, but if your erlangers leave, finding replacements engineers to maintain the system will be tough. I've lived this.
I wish I were wrong about it, but 9 years of watching Erlang on the verge of mainstream has jaded me.
I don't need to know Java to write Scala for example -- I just need to know the relevant semantics of Scala's object system and interoperability.
I expect what is going to be more of a dynamic where Elixir will grab a bunch of new developers, some of which will go to the Erlang side of thing eventually, whereas Elixir had its jumpstart by draining some of the Erlang developers who were unhappy with the language.
If Elixir does catch on, it could have a spectacular rise, but I'd only expect it to trickle more people into Erlang, which already had its newcomer wave many years ago and has stabilized since then.
I ask because my experience (and as always, YMMV) was that in languages that had 'familiar' syntax, new paradigms and concepts were a lot harder to pick up. I tried to learn functional programming in Scala, but it didn't take; I could still write things in a Java like way, which was what I was accustomed to, and it took a lot of extra effort to try and write them idiomatically.
As a for instance, one of the most confusing (and thus, unused) structures in Erlang is the if structure. Why? Because it looks like something every developer already understands, while behaving in a completely different manner. That tinge of familiarity is a detriment for it.
I don't think I'd ever set out to write a new project in Erlang: for me Elixir has all the advantages and none of the drawbacks. There's nothing you can do in Erlang that you can't do in Elixir, and you get the benefit of a much more expressive syntax and powerful metaprogramming. But there are a lot of quite mature Erlang libraries out there, and I don't see the point of replicating them all in Elixir, so I can see myself contributing patches to Erlang projects.
Have a play with both, stick with whichever one feels better to you. Since you're just learning, you want whichever one will make you more excited about learning, and make it quicker to pick up the concepts. Once you've got a solid grasp of it, you can familiarize yourself with the few syntactic differences and make a more informed decision about which one you want to keep working with.
Try http://learnyousomeerlang.com/ that is a fun and great resource. Joe's books are great.
But Elixir is fantastic too. You can call into Erlang from it. But it is still a bit new. Maybe spend a couple of hours with both or pick a small project and try to do it in both and see how you like the feel of both.
I'm interested in the language design process.
edit: if you look at the timelines, the thesis was presented in 2003, and is the result of stuff that started off in 1981. pretty cool (fwiw)
So in way it was created from scratch. It has a Prolog like feel but that is superficial only. Prolog was used as the original implementation platform.
It is also interesting they didn't explicitly indent to make a "functional" language or use "actor programming" or "CSP" and so on. Those things fell out of the original requirements of fault tolerance and concurrency.
There has been progress in cleaning up syntax, library and package management cruft that have helped ease adoption. Elixir (a new lang built on erlang) seems to be coming along well.
For most types of webapps, erlang has all the batteries included. The problem is that for many mainstream types of webapps, getting v1 out the door quickly in Rails/Django works well. I think that may be part of the adoption problem...if the problem domain doesn't clearly require erlang to get v1 out the door, many will use Rails/Django and never look back.
Couldn't you imagine a language with data structure that are mutable from within a same single thread only and requires message passing when communicating between threads ?
Now that i think of it, I wonder if golang isn't doing just that.
Rust, on the other hand, is much closer to what you're describing.