Reviews of the language

What I think

What others say

Apps using it

Articles

How do you support 450 million users with only 32 engineers? For WhatsApp, acquired earlier this week by Facebook, the answer is Erlang, a programming language developed in the '80s that is finally having its moment in the spotlight.

But with other languages starting to co-opt its ideas, does Erlang have a future?

Erlang was developed by Swedish telecom giant Ericsson over 25 years ago, and now it's finding a home at messaging apps like WhatsApp and TigerText. Even Facebook was singing the language’s praises when it used Erlang to launch Facebook Chat back in 2009—the same year it turned down the job application of WhatsApp cofounder Brian Acton.

CONCURRENCY IS THE NEW BLACK

"With Erlang you could build a messaging app with many connected users and not worry about how they communicate," says Chad DePue, CTO of Whisper, an app for anonymous posts that has opted to use the language. Instead, he says, "You can worry about creating a great app."

Ericsson engineer Joe Armstrong developed Erlang with the logic of telecommunications in mind: millions of parallel conversations happening at the same time, with almost zero tolerance for downtime. Other programming languages can only give the illusion of managing all those conversations—some have gotten very good at keeping up appearances, but they aren't natural "multi-taskers." Erlang, in contrast, loves to multithread or "juggle" in this way—got a another spinning plate? Toss it over!

"The language is very expressive," says Igor Clark, a creative technologist. "You can talk at a high level and do quite a lot with its few key concepts."

In practical terms, that initially made Erlang very good at efficiently executing commands across processors within a single machine. Fast-forward to 2014, and it’s making Erlang very good at executing an even more bewildering volume of commands across the global networks of servers we have come to know as "the cloud." For use cases in gaming, financial services, and anything that mimics the behavior of a real-time auction, that speed and reliability, at massive scale, is absolutely essential.

Equally attractive to engineering teams, and highly unusual, is the way that Erlang allows for bug fixes and updates without downtime. In effect, you can change the lighting on your set or execute a costume change without a pause in the action. This Erlang property is a legacy of the telecom imperative: As DePue says, "When you're on the phone, you can't have someone hang up on you because they're upgrading the system."

TURNING THE TABLES ON TELECOM

Today the industry that open-sourced Erlang in 1998 is feeling less than generous. As WhatsApp, WeChat, Line, and other startups have blossomed, the messaging fees that telecoms once relied on have been rapidly eroding. KPN, a Dutch telecom, tried to block the upstarts from its network after seeing a drop in SMS revenue, but lost a battle in court over the practice.

Some established players, such as Vodafone, have tried to build messaging services of their own, with little success. Nearly all have been tinkering with the mix and pricing of SMS and data in their users’ contracts.

While the telecoms were busying themselves with payment plans, WhatsApp was focused on product. Its engineering team has repeatedly wowed the Erlang community with feats of scale and speed, jumping from 10,000 to over 2 million connections per server in just a few short years.

Those achievements rest on the shoulders of Armstrong, whose signature project for Ericsson, AXD301, achieved a "nine nines" reliability (99.9999999%). But for now, at least, the young challengers are keeping the aging telecoms on their heels.

TO ERLANG, AND BEYOND?

With such a strong track record, you might think that Erlang is poised for breakout adoption. The reality is a bit more complicated.

Until now, the developer community around Erlang has remained small, and largely concentrated in Europe. The language’s syntax is admittedly "weird." And if you need to analyze complex data or prototype a simple web app, there are better tools. Moreover, newer languages and variations have been borrowing from Erlang principles, leading to an increasingly cluttered landscape, from Google’s Go toDocker.

There’s hope for Erlang in Elixir—Armstrong recently bestowed his blessing—which normalizes the Erlang syntax and could help the language take off in the same way that Rails did for Ruby. Projects like Chicago Boss are also aiming to make the language more user-friendly. If a broader community does coalesce around Erlang, they will discover OTP (open telecom platform) libraries that more than make up for the language’s limited presence on GitHub.

"They abstracted patterns from the software they were writing and made bulletproof libraries that you can piggyback on," Clark says. "It’s the glue between the small parts and the top level."

The tipping point for adoption could be the one ecosystem with enough scale to dwarf mobile as we know it: the internet of things. Smart object hobbyists have been experimenting with Erlang as part of MQTT, a lightweight protocol for transferring messages between sensors. If you can SMS your thermostat, surely you can WhatsApp it, too?

EARLIER THIS MONTH, in a post to his Facebook page, WhatsApp CEO Jan Koum announced that his company’s instant messaging service is now used by more than 900 million people. And then Facebook CEO Mark Zuckerberg promptly responded with two posts of his own. One said “congrats,” and the other included a cheeky photo Zuckerberg had taken of Koum as the WhatsApp CEO keyed his 900-million-user post into a smartphone. “Here’s an action shot of you writing this update,” Zuckerberg wrote.

WhatsApp is owned by Facebook, after Zuckerberg and company paid $19 billion for the startup a little more than a year ago. That means Facebook now runs three of the most popular apps on the internet. Its primary social networking service is used by more than 1.5 billion people worldwide, and Facebook Messenger, an instant messaging service spun off from Facebook proper, spans 700 million. But the 900 million-user milestone announced by Koun is very much a WhatsApp achievement, not a product of the formidable Facebook machine.

One of the (many) intriguing parts of the WhatsApp story is that it has achieved such enormous scale with such a tiny team. When the company was acquired by Facebook, it had 35 engineers and reached more than 450 million users. Today, it employs only about 50 engineers, though the number of WhatsApp users has doubled, and this tiny engineering staff continues to run things almost entirely on its own. In a world where so many internet services are rapidly expanding to millions upon millions of users, WhatsApp shows the way forward—at least in part.

WhatsApp doesn’t talk much about its engineering work—or any other part of its operation, for that matter—but yesterday, at an event in San Jose, California, WhatsApp software engineer Jamshid Mahdavi took the stage to briefly discuss the company’s rather unusual methods. Part of the trick is that the company builds its service using a programming language called Erlang. Though not all that popular across the wider coding community, Erlang is particularly well suited to juggling communications from a huge number of users, and it lets engineers deploy new code on the fly. But Mahdavi says that the trick is as much about attitude as technology.

Mahdavi joined WhatsApp about two years ago, after the startup was up and running, and its approach to engineering was unlike any he had seen—in part because it used Erlang and a computer operating system called FreeBSD, but also because it strove to keep its operation so simple. “It was a completely different way of building a high-scale infrastructure,” he said on Monday. “It was an eye-opener to see the minimalistic approach to solving … just the problems that needed to be solved.”

Code in Parallel

In using Erlang, WhatsApp is part of a larger push towards programming languages that are designed for concurrency, where many processes run at the same time. As internet services reach more people—and juggle more tasks from all those people—such languages become more attractive. Naturally.

With its new anti-spam system—a system for identifying malicious and otherwise unwanted messages on its social network—Facebook uses a language called Haskell. Haskell began as a kind of academic experiment in the late ’80s, and it’s still not used all that often. But it’s ideal for Facebook’s spam fighting because it’s so good at juggling parallel tasks—and because it lets coders tackle urgent tasks so quickly. Meanwhile, Google and Mozilla, maker of the Firefox browser, are striving for a similar sweet spot with new languages called Go and Rust.

Like Haskell, Erlang is a product of the ’80s. Engineers at Ericsson, the Swedish multinational that builds hardware and software for telecom companies, developed the language for use with high-speed phone networks. “Instead of inventing a language and then figuring out what to do with it, they set out to invent a language which solved a very specific problem,” says Francesco Cesarini, an Erlang guru based in the UK. “The problem was that of massive scalability and reliability. Phone networks were the only systems at the time who had to display those properties.” (NW: Lesson: Keep your eye out for tech being developed by the big guys!)

Erlang remains on the fringes of the modern coding world, but at WhatsApp and other internet companies, including WeChat and Whisper, it has found a home with new applications that operate not unlike a massive phone network. In essence, WhatsApp is a replacement for cellphone texting services. It too requires that “scalability and reliability.”

What’s more, Erlang lets coders work at high speed—another essential part of modern software development. It offers a way of deploying new code to an application even as the application continues to run. In an age of constant change, this is more useful than ever.

Keep It Simple, Smarty

The language does have its drawbacks. Relatively few coders know Erlang, and it doesn’t necessarily dovetail with a lot of the code already built by today’s internet companies. Facebook built its original Facebook Chat app in Erlang but eventually rebuilt so that it would better fit with the rest of its infrastructure. “You had this little island that was Erlang, and it was hard to build enough boats back to the island to make everything hook in,” says Facebook vice president of engineering Jay Parikh.

Of course, WhatsApp didn’t have to integrate with an existing infrastructure in this way. And Mahdavi believes the relative scarcity of Erlang coders isn’t a problem. “Our strategy around recruiting is to find the best and brightest engineers. We don’t bring them in specifically because the engineer knows Erlang,” Mahdavi said on Monday. “We expect the engineer to come in and spend their first week getting familiar with the language and learning to use the environment. If you hire smart people, they’ll be able to do that.”

The company has succeeded by hiring engineers who are adaptable—in more ways than one. Asked to explain the company’s secret, Mahdavi’s response seems far too simple. But that’s the point. “The number-one lesson is just be very focused on what you need to do,” he said. “Don’t spend time getting distracted by other activities, other technologies, even things in the office, like meetings.”

At WhatsApp, employees almost never attend a meeting. Yes, there are only a few dozen of them. But that too is the point.


Related websites

How to learn it

Books

Tutorials


Elixir