Last updated: December 12, 2018
Erlang Programming Introduction and Resources
Erlang is a general-purpose programming language designed for building concurrent applications.
Originally developed for telecommunication applications, it is a highly-scalable, functional language that is ideal for telecoms, web applications, distributed computing, instant messaging, e-commerce, and other services that require a constant connection and need to handle simultaneous input from a large number of sources.
Some of the features that make Erlang attractive to modern programmers include:
Concurrency, allowing Erlang programs to accept input from multiple sources and function in the distributed environment.
Fault tolerance, allowing systems to continue operating even when some elements of the program fail or are at fault, making it a highly useful language for always-on environments, such as a web community or telecommunications platform.
Hot code loading, allowing code to be modified and programs updated without needing to stop or reboot the system.
Message passing rather than shared variables, allowing processes to communicate with a higher-degree of concurrency.
Garbage collection, providing automatic memory management for improved speed and performance.
Erlang is not as easy to jump into as some programming languages, as it’s syntax and functional design are highly unique and create a sharp learning curve for new programmers.
The Erlang language was first developed in 1986 by Ericsson employees Joe Armstrong, Robert Virding, and Mike Williams.
The language was designed to improve existing telephony applications, and was highly influenced by the PLEX language.
The first version of Erlang was implemented in Prolog, but this proved too slow for telephone exchanges. To solve that, the team developed the BEAM virtual machine in 1992.
BEAM compiled the Erlang code to C at a much faster rate, allowing Erlang to quickly move from a prototype language to real applications. In 1995, Erlang was implemented into the ATM exchange, AXD.
In 1998, however, Ericsson Radio Systems banned the use of Erlang within any new products as it attempted to move all products to non-proprietary languages.
The new policy prompted Joe Armstrong, amongst other Erlang programmers, to resign, and ultimately led to the team releasing Erlang to the open-source world later that year.
No longer a proprietary product, and gaining traction in the telecommunication world, Ericsson later reversed its stance on Erlang and rehired Armstrong.
Erlang is now actively used by telecommunications companies worldwide, including T-Mobile, Whatsapp, Ubiquiti, and IDT Corp. Ericsson continues to maintain the language and uses it in Ericsson’s support nodes and mobile networks, including their LTE networks.
Given the incredible need for concurrent programming, with web-based and mobile technologies expanding all the time, Erlang continues to grow in popularity, and many serious developers are making the switch.
As a result, there are plenty of free, online resources available to help you get started and provide assistance along the way.
Erlang.org: the official site of Erlang, this page includes software downloads, documentation and user guides, links to online resources and communities, and information about recent news and upcoming Erlang events.
Erlang Central: this community-driven site has everything you need to get started with and keep building your Erlang knowledge. It hosts tutorials, videos, a Wiki, job board, and a community forum.
Mostly Erlang: A regular podcast dedicated to all-things Erlang. They discuss basic programming concepts, interview key innovators, and offer advice to new and experienced Erlang programmers.
Erlang Factory: this annual technical conference brings together Erlang developers from across the world to discuss new innovations and theories, and offers a series of optional 3-day intensive training courses.
Erlang is quite different from most languages, and even experienced programmers may want to have a handy guide available to keep track of some of its eccentricities. Whether you’ve been programming for years or you’re throwing yourself into designing the next big mobile app, there’s an Erlang title out there for you:
Programming Erlang: Software for a Concurrent World by Joe Armstrong: written by one of the original authors of Erlang, this is the definitive guide to the language and its usage in concurrent environments such as cloud applications, multi-user games, and community-based web sites. The book is designed for individuals with little previous experience in functional or parallel programming, and teaches these concepts through tutorials and real-world examples.
Building Web Applications with Erlang by Zachary Kessin: designed for experienced web developers with basic Erlang knowledge, this book walks programmers through a series of simple web service programming projects, preparing them to build their own web applications and get them online.
Learn You Some Erlang for Great Good! By Fred Herbert: as the humorous title suggests, this book happily admits that Erlang’s syntax is unconventional, it’s data structures are unusual, and its type system is generally off-putting to many newcomers — which is exactly why you need a guide to its unusual, yet powerful, conventions. It starts out slow, with very basic techniques, and builds into more complex programming concepts as the reader becomes adjusted to the intricacies of the new language. If you don’t need a physical copy, the author has also made the book available for free online.
Introducing Erlang: Getting Started in Functional Programming by Simon St Laurent: This book devotes a lot of time on installation and Erlang’s shell, making sure new programmers (or those new to Erlang) are completely comfortable with its command line interface, and then moves on to break down the language into very basic concepts and demonstrates them through the creation of simple programs.
Designing for Scalability with Erlang/OTP by Cesarini and Vinoski: this book is intended for experienced Erlang programmers looking to expand their understanding and utilize the Open Telecom Platform (OTP) to design and build commercial-grade systems that are both complex and scalable.
Beyong Erland: Elixir
Elixir is a relatively new language, but it has a long history. And it all started with Erlang.
Since the mid-1980s, Erlang had been doing a good job of what it was designed to do, mostly designing telephony applications. But fast forward three decades, and think about the needs of highly scalable web applications.
Pinterest, for example, delivers 14,000 notifications per second. Facebook needs to receive updates from and push messages back out to 1.6 billion (With a B!) active users. This kind of high concurrency and high availability is exactly what Erlang was designed for.
And so this old warhorse telecom language has suddenly become trendy and popular again. Except in a new form.
It turns out that Erlang is really hard to read and write. This isn’t surprising since it was developed decades ago. This was before “fun to use” was an important consideration in language design.
Valim was a part of the Ruby on Rails development team, and even authored a book on Rails development. The Ruby on Rails team takes the developer experience very seriously, and that concern influenced the design of Elixir.
The syntax is very similar to Ruby, and is much more readable than Erlang. Besides the easier syntax, Elixir extends the capabilities of Erlang to include (among other things) metaprogramming, polymorphism, and inline documentation.
Brief Introduction to Functional Programming
Elixir, like Erlang, is a functional programming language. This is a bit different from most other languages, which are almost all imperativeand usually object oriented.
Most programming languages have some kind of code-block syntax called a “function”. Or, in some object-oriented languages they are called “methods,” but everyone knows that a method is just a “function” attached to an object.
But is a function really a function?
In software development, we’re used to functions doing something. We call these somethings “side effects.”
But in mathematics, functions don’t have side effects. You don’t define a circle with a function that plots all the points of a circle and also changes the course number for Intro to Hypothetical Geometry.
In math, a function is deterministic; given any particular input
x, it will always return the exact output
y and not do anything else.
By admitting side effects into programming, we introduce state — the current condition of the running program environment. And the problem with state is that it can change over time.
A variable might mean one thing now, and something else ten minutes from now. And that means that a particular function call with input
x might return two different values of
y at two different times.
Is that a problem? That depends. None of the most popular development languages are purely functional, so it is clearly possible to build all sorts of things (or, just about everything) using languages that rely on side effects and global state.
However, in a highly distributed, always-on system, this can be a problem. If a system is spread over several dozen (or several thousand) physical computers, how do you propagate changes to the global state to all of them?
If a system does go down, how do you quickly restore global state? If a function call might return different values at different times, how can you be sure that the test you run today will still pass tomorrow?
Functional programming seeks to avoid all these problems by being stateless. A functionally-designed program is a collection of functions which are completely deterministic, which means that the system as a whole is deterministic. Given any particular input, the output is guaranteed.
This sort of mathematical purity has long been of interest to academic computer scientists, but the real-world of software development has been largely uninterested — until suddenly, because of the needs of the internet, everyone has become interested.
Functional programming is one of the most important current trends in web application development.
Functional Programming Resources
If you really want to get your head around Elixir, you’ll need to get your head around Functional Programming. Here’s where to start.
Functional Programing Article at Wikipedia: a very in-depth overview of the subject.
There are many resources in many forms to help you master Elixir.
The first place to start looking into Elixir online is the official Elixir language site.
Elixir School: Lessons about the Elixir programming language.
Awesome Elixir: community-curated list of awesome projects for Elixir.
Community and Continued Learning
Books on Elixir
Should I Learn Elixir?
If you are interested in working on cutting edge web applications, particularly those that serve large numbers of concurrent users, Elixir is definitely worth knowing.
While still a relatively rare programming language, the Erlang community is growing quickly, particularly as demand for mobile solutions, web applications, and seamless online collaboration increases.
Though unconventional in many ways, the built-in support for concurrency and distribution, high-scalability, and fault-tolerance make Erlang a highly-attractive language in our constantly connected world.
But it might be better to focus on Elixir. It depends on exactly what you want to do. Regardless, they are both great languages.