When I first heard about Erlang, I read about the article in Wikipedia. It states that Erlang is a “general-purpose concurrent programming language and runtime system”. While most of the phrases in that definition are pretty easily understandable on the first read, the word concurrent got my attention. I won’t go through the reasons of why concurrency is a bullshit-bingo phrase at the moment. Just slap google with multi-core and you’ll know why.
So what makes Erlang a concurrent programming language? I first tought that the langauge itself was designed in a way so that it was easy for the compiler to parallelize things because of const-correctness etc. etc. Well, as it turned out, Erlang is not able to do this. Erlang is even better.
- Erlang makes it easy to use multiple processes within a program. It makes it easy to send and receive messages between processes. Not that Erlang calls them processes. Processes do not share memory. Side-note: there are some tricks you can use to share memory using ETS tables, but you better know what you are doing!
- Erlang’s runtime system makes process spawning and message passing efficient. On process spawning there are some numbers in Joe Armstrong’s book stating that on his 2.4 Ghz Celeron notebook with 512MiB of memory and Ubuntu installed it takes 3.5 microseconds of CPU time (micro not milli) to spawn a process when spawning 20.000 processes and 9.2 microseconds of elapsed wall-clock time.
- When programming Erlang you design your methods to be side-effect free, meaning that multiple calls to the same function don’t influence each other (there’s a better definition here). Now because you do this (yes you do!) you can turn a loop that does some expensive operation for every member of a list into a loop that spawns a process for every member of a list and collect the result. Not that this can (and is) encapsulated into a function in the Erlang modules. You don’t have to do any process spawning, message sending, receiving, collecting, etc. All you have to do is to use a pmap (parallel map) instead of map. Side-note: map applies a function to every member of a list.
- Because Erlang already has built-in mechanism for sending and receiving messages between processes they extended it to allow processes to be on different Erlang nodes (different running instances of the Erlang runtime system). This includes Erlang nodes being on different machines being connected trough a network. Do you get the point ? Distributed programming made easy!
What do we do about shared resources? Easy. We write a server that makes sure access to the resource is sequential and atomic. A server is a process that receives messages from other processes, performs and operation and returns the result. Simple enough. I recommend you start reading up on Erlang and get addicted as well!
Side-note: I’m not a highly-experienced Erlang programmer. I am reading Joe Armstrong’s book at the moment and am solely expressing my comments on this. If I get something wrong please contact me and correct me.
You should check this out…
[...] Wonderful story, reckoned we could combine a few unrelated data, nevertheless really worth taking a look, whoa did one learn about Mid East has got more problerms as well [...]……
Recommeneded websites…
[...]Here are some of the sites we recommend for our visitors[...]……
Sources…
[...]check below, are some totally unrelated websites to ours, however, they are most trustworthy sources that we use[...]……
Check this out…
[...] that is the end of this article. Here you’ll find some sites that we think you’ll appreciate, just click the links over[...]……
Awesome website…
[...]the time to read or visit the content or sites we have linked to below the[...]……
Recommeneded websites…
[...]Here are some of the sites we recommend for our visitors[...]……
Awesome website…
[...]the time to read or visit the content or sites we have linked to below the[...]……
Recommeneded websites…
[...]Here are some of the sites we recommend for our visitors[...]……
Check this out…
[...] that is the end of this article. Here you’ll find some sites that we think you’ll appreciate, just click the links over[...]……
Links…
[...]Sites of interest we have a link to[...]……
Online Article……
[...]The information mentioned in the article are some of the best available [...]……
Gems form the internet…
[...]very few websites that happen to be detailed below, from our point of view are undoubtedly well worth checking out[...]……
Awesome website…
[...]the time to read or visit the content or sites we have linked to below the[...]……
Recommeneded websites…
[...]Here are some of the sites we recommend for our visitors[...]……
Visitor recommendations…
[...]one of our visitors recently recommended the following website[...]……
Visitor recommendations…
[...]one of our visitors recently recommended the following website[...]……
Sources…
[...]check below, are some totally unrelated websites to ours, however, they are most trustworthy sources that we use[...]……
Great website…
[...]we like to honor many other internet sites on the web, even if they aren’t linked to us, by linking to them. Under are some webpages worth checking out[...]……
Gems form the internet…
[...]very few websites that happen to be detailed below, from our point of view are undoubtedly well worth checking out[...]……
Check this out…
[...] that is the end of this article. Here you’ll find some sites that we think you’ll appreciate, just click the links over[...]……
Websites we think you should visit…
[...]although websites we backlink to below are considerably not related to ours, we feel they are actually worth a go through, so have a look[...]……