Programming Erlang: Software for a Concurrent World
| 2007-07-11 00:00:00 | | 0 | Programming
Erlang solves one of the most pressing problems facing developers today: how to write reliable, concurrent, high-performance systems. It's used worldwide by companies who need to produce reliable, efficient, and scalable applications. Invest in learning Erlang now.
Moore's Law is the observation that the amount you can do on a single chip doubles every two years. But Moore's Law is taking a detour. Rather than producing faster and faster processors, companies such as Intel and AMD are producing multi-core devices: single chips containing two, four, or more processors. If your programs aren't concurrent, they'll only run on a single processor at a time. Your users will think that your code is slow.
Erlang is a programming language designed for building highly parallel, distributed, fault-tolerant systems. It has been used commercially for many years to build massive fault-tolerated systems that run for years with minimal failures.
Erlang programs run seamlessly on multi-core computers: this means your Erlang program should run a lot faster on a 4 core processor than on a single core processor, all without you having to change a line of code.
Erlang combines ideas from the world of functional programming with techniques for building fault-tolerant systems to make a powerful language for building the massively parallel, networked applications of the future.
This book presents Erlang and functional programming in the familiar Pragmatic style. And it's written by Joe Armstrong, one of the creators of Erlang.
It includes example code you'll be able to build upon. In addition, the book contains the full source code for two interesting applications:
A SHOUTcastserver which you can use to stream music to every computer in your house, and a full-text indexing and search engine that can index gigabytes of data.
Learn how to write programs that run on dozens or even hundreds of local and remote processors. See how to write robust applications that run even in the face of network and hardware failure, using the Erlang programming language.
User review
good topic, terrible writer :(
I bought it as one of my course books. The language itself has some pretty cool things that makes distributed programming easy. The book, however, is quite poorly written. If I had to buy an erlang book again (and its not a mandatory course book), I wouldnt buy it again. Look online for better help with Erlang.
User review
A good introduction to Erlang
I am currently in the process of learning Erlang for a personal project. These books both measures up to the high expectations I have come to expect from Pragmatic Programmers Publishing.
Erlang is a difficult language to `sell`, and is a challenge to learn.
This book assumes you have decently good programming skills, and don't need your hand held too much about the idea of programming, and instead show you how Erlang is different, it's unique and interesting features, and some of `how to think in Erlang`.
I wish there was more on `how to think in Erlang`, especially since most programmer's intuitions about multiprocessing and concurrency, born of battle scars with multithreaded programming in C/C++, will be wrong.
User review
not a good book writer
yes, the author invented the language and there is few choice of erlang books.
but I do not believe Joe is a good book writer, it does not cover anything deep enough as I could expect. As an introduction level book, it is not well organized at all.
Most of The Pragmatic Bookshelf books are outstanding, this is an exception.
User review
Good enough
As of 2009 there are not many alternatives to learn the powerful programming language Erlang and the OTP (Open Telecom Platform). This is THE book written by the designer and implementor of Erlang, Joe Armstrong and he seems to know what he is talking about. High quality humour may not be one of Armstrong's strengths but when it comes to finding attractive examples he shines using his favorite language and platform.
This may not be the perfect book, it has its problems such as promising that some things will be pointed out but the chapter ends without fulfilling it. A few minor frustrations aside the book provides a very good overview of the most important points of Erlang with enough breadth and depth. The chapter where Armstrong talks about a simple then adding transaction semantics, fault tolerance, hot code swapping, etc. is a kind of tour de force. Another good application is a Shoutcast server implementation in just a few lines of code. It would be very good to compare this example to Peter Seibel's Practical Common Lisp [1].
If you want to learn more about this kind of programming, I'd definitely suggest reading 'Concepts, Techniques, and Models of Computer Programming' [2] which shows the Oz programming language and the Mozart platform and teaches the fundamentals of message-passing concurrency and network-transparent distributed programming.
Finally it must be repeated that Erlang has a very high-quality VM along with mature libraries for concurrency and reliability. If you want to experience industrial-strength distributed and / or multicore applications that scales well then it would be only wise to follow the advice of Joe Armstrong.
Warning: If you are not exposed to Lisp, Prolog, Haskell, Oz, etc. beforehand be careful for a different kind of syntax and semantics. You'll have unlearn a few concepts to understand the power of new concepts.
[,,.]
User review
Finally! Functional Programming Makes Sense
This is the definitive book on Erlang, written by Joe Armstrong, the creator of the Erlang language. The book is clearly written, with lots of small examples, and paced for the beginning Erlang programmer.
Erlang takes a little getting used to. It is a functional language, meaning that functions in general are unable to cause side-effects. For example, 'variables' are in one of 2 states: their initial state is 'unbound', their final state is 'has some value that can never change'. Attempting to place a value into a variable that already has a value causes an exception. This aspect of functional programming makes it possible to write multi-threaded/multi-process applications without the problems inherent in multi-threaded applications in non-functional languages.
The basic data types in Erlang are functions, atoms, numbers, lists, tuples, and strings (which are actually lists of integer numbers). List manipulation in Erlang is similar to that in Lisp: lists are generally treated as a head and tail. This is used by the Erlang way of defining functions: functions are defined as a set of pattern-matched expressions with code associated with each expression. For example, a simple accumulator in Erlang might look as follows:
total([H|T:]) -> H + total(T);
total([:]) -> 0;
total([1,10,20,5).
====> 36
This just says that to sum the values in a list, you add the value of the head of the list to the sum of the values in the tail, and that the sum of an empty list is zero.
Functions (lambdas, really, or 'funs' as they are called in Erlang) are first-class objects in Erlang, meaning that they can be members of tuples and lists, can be passed as parameters to functions, and can be returned as a value by functions. So, for example,
Double = fun(X) -> ( 2 * X ) end.
Double(5).
====> 10
Erlang was designed from the beginning to make it easy to write concurrent programs. Erlang process creation is very efficient, and there is no great difference between running such a program as many threads on one box or many processes on multiple boxes. A new process is created with the spawn function, which takes a fun (a lambda) as a paramter. The spawn function returns the process id (pid) of the new process, which may then be used to communicate with that process. The book shows a couple simple examples of distributed programming by way of illustration: a simple name server, and a stripped-down IRC server and client.
The book continues with details on how to interface C and Erlang software, how to communicate over TCP and UDP, the Erlang large-data storage mechanisms (ETS an DETS), and the Erlang database (mnesia).
There is a nice example of implementing map-reduce for disk indexing with Erlang on a multicore system.
Finally, there are a number of appendices including a large reference listing of the standard Erlang modules and functions.