Looking in to Erlang
July 9, 2008
I’ve putzed around with it before, went through some example code, etc., but yesterday picked up the “Programming Erlang” book from Pragmatic Programmers. Might still return it if its too dense, but doesn’t seem to be so far.
The biggest takeaway I have is that Erlang is good for concurrent programming because of it’s ’shared nothing’ approach (my words, not theirs). Actually, there’s quite a bit on Erlang at Wikipedia. For example: “Process communication is done via a share-nothing asynchronous message-passing system: every process has a “mailbox”, a queue of messages sent by other processes, that are not yet consumed.“ What does that sound like? How can I tie this in with PHP?
PHP and Perl for sure (and I believe Python and Ruby, though I’m not sure) use the “shared nothing” approach in web development (for the most part, mod_perl notwithstanding). This has demonstrated that it’s very easy to ’scale out’ web sites that need it usually by simply adding more front-end web servers. Scaling out the database does become a more difficult bottleneck problem, but it’s not impossible. Contrasting this with the complexities that Java has when trying to ’scale out’ applications. This isn’t saying Java apps can’t scale. However, specifically in the web domain, the Java code I’ve come across has tended to use threads for many problems, and threadded applications are harder to ’scale’ across multiple machines. Again, not impossible, but harder to manage.
Should the VMs just get more advanced and manage the threads across multiple cores (or multiple physical machines) for you behind the scenes? Or should programmers be required to think about app design fundamentally differently than the traditional ’spawn multiple threads’ approach that Java (and others) take?
This is not me necessarily saying that PHP is the be-all and end-all. It’s not - it certainly has its share of problems. But I’m finding it interesting that one of the key tenets of Erland - shared nothing processes - has been a key factor in what’s allowed PHP to become as dominant as it has. This is also what allowed Perl CGI apps to become as popular as they did in the mid-to-late 90s as well. Process and queue management in PHP6 would, imo, make it a viable contender to Erlang for the ‘concurrent processing’ market. The ‘o’ in the ‘imo’, however, is based on a very early understanding and basic experience with Erlang - that ‘o’ may change in the next several months.
What are your thoughts regarding the pros and cons of PHP compared to other languages/platforms?
Did you like this post? Buy me a hot chocolate!
Posted in




July 9th, 2008 at 7:49 am
All I’m gonna say is that Yaws looks pretty kick-ass. And if I ever do set out to build a site for many, many users (Twitter-esque) or for simulations, I’ll take a long, hard look at Erlang. I’ve fiddled with it before, and it’s a nice little language. It’s just not necessary for the sort of stuff I’m working on at the moment.
July 9th, 2008 at 9:03 am
@Thomas: take a look at twoorl (http://twoorl.com) - erlang twitter-like site.
July 9th, 2008 at 9:19 am
Erlang is a slightly bit more than “shared nothing”. It’s more about parallel programming. A “soon to be more famous” project that uses Erlang is CouchDB, definetly worth a look.
http://www.infoq.com/presentations/erlang-software-for-a-concurrent-world is another very interesting source for erlang … it’s also a very good starting point for Erlang. The language itself has a very diffent approach than PHP has.
July 9th, 2008 at 9:54 am
The major difference with the share-nothing behavior of PHP and erlang is the the erlang process is share-nothing but yet long lived. Python, Ruby, Perl when using the more common web frameworks use a long lived instance of the interpreter to serve requests.
But erlang’s strength is not the shared nothing behavior itself, its the other benefits it brings with it - like transparent preemptive parallelization. In erlang, you dont think of threads at all, leaving all the complexity associated with it.
Erlang is useful when you need massive concurrency, services that never shut down (the OTP libraries), and need hot code loading (think MMORPG game servers that need to be upgraded without disconnecting users).
July 9th, 2008 at 7:07 pm
Just out of curiosity, what’s the difference between Haskell and Erlang with respect to this? Both seem to be very similar languages and Haskell seems to be a bit more efficient with respect to concurrency, at least when you look at the Computer Language Shootout.
July 10th, 2008 at 9:15 am
We need to see hosting providers that have nothing but erlang… or lighthttpd, or RoR by default for every vhost.
Right now, any erlang app is going to be highly specialized since the deployment opportunities are so specialized (i.e. not cheap hosts). Even if you have access to your own server, you have to kick off apache, or use some complex work arounds to dodge apache.
When are the hosting companies going to provide niche hosting platforms? I would even be okay with it if they wanted to call them “micro-platforms” or something dumb like that.
When are hosting control panels going to let go of LAMP… or at least recognize other forms of hosting besides LAMP?
July 17th, 2008 at 5:40 pm
From my perspective, it seems that shared hosting is slowly losing ground to VPS systems. Virtualization is gaining wider adoption and seems to be the way of the future with the advent of cloud computing. As such, I’d expect that it’s going to become more common for you to be able to run whatever you can administrate on your own virtual server in the coming years. I’ve used A Small Orange for hosting in the past any they offer VPS service now for what I think is a reasonable price. http://www.asmallorange.com/services/vps/