At Pinterest, that company with a popular app for pinning images and other content to boards, much of the source code is written in the longstanding Python programming language. But in the past year, a few of the company’s software engineers have called on a young language called Elixir.

Pinterest’s notification system now uses Elixir to deliver 14,000 notifications per second. The notification system runs across 15 servers, whereas the old system, written in Java, ran on 30. The new code is about one-tenth of the size of the old code.

“These are heavy requests, to find out your notifications,” Steve Cohen, a software engineer on Pinterest’s product platform team, told VentureBeat in an interview. “It’s not like these are lightweight things that just read a little bit of data.”

The rate-limiting system for Pinterest’s core application programming interface (API) and Ads API is also now written in Elixir, providing faster response times than its Memcached-based predecessor.

Today, Pinterest is releasing two tools for Elixir under an open source license: the Elixometer logging library and the Riffed implementation of Apache Thrift for Elixir. Like other web companies, Pinterest regularly contributes open source code. But today’s move is especially interesting because it demonstrates Pinterest’s belief in the promise of Elixir and, more broadly, Erlang.

Meanwhile, the use of Elixir in the first place shows that Pinterest is keen on improving its technical operations. Even incremental efficiency gains can make a difference for a company that’s trying to keep costs in order as it grows internationally. Pinterest had more than 100 million monthly active users as of September, and the San Francisco-based company currently employs more than 300 engineers.

A new language based on an old language

This might sound like a brave initiative for Pinterest. After all, Elixir is not even 5 years old, having made its debut on GitHub on January 9, 2011. But Elixir has roots. It’s a new language that’s based on an old language.

The Brazilian software engineer José Valim, a core developer of the Ruby on Rails web application framework, started building Elixir in order to make the peculiar 30-year-old programming language Erlang more accessible. But he didn’t leave Erlang behind completely. If you want to run Elixir, you need to have Erlang installed on your machine.

And that’s not necessarily a bad thing. Despite the shortcomings of Erlang, at least one highly regarded web service uses it. The canonical example is Facebook-owned messaging app WhatsApp, which does only one thing — send and receive messages — but does it very well at scale. How well? Only 50 engineers support 900 million users.

Drinking the Elixir

Cohen was a Ruby programmer for years. In 2013, he stumbled across Valim’s frustration with Ruby and his work on Elixir. By that point Cohen was at Pinterest, and he had given up Ruby for Python. But in his free time he started reading about Erlang and familiarizing himself with Elixir. In one experiment, he did load tests on a server written in Elixir.

“I thought, ‘Wow, it’s as fun as Ruby, but it has some chops — it actually performs really well,'” Cohen said.

He used Elixir to rewrite the logic of Pinterest’s notification system, and he used it again to rebuild the rate limiter.

Image Credit: Jordan Novet/VentureBeat

This past April, while Valim was in town for the Erlang Factory conference, Pinterest invited him to come by the office, and he gave a tech talk to employees. Not surprisingly, some of Cohen’s colleagues have picked up the language.

“Two of them hadn’t written a line of Elixir a month and a half ago. Now they’re contributing to the open source project,” he said.

Erlang has a reputation for being difficult to read and write. But Elixir is different. For Cohen, the code is easy to understand when you look at it — so easy, in fact, that documentation can feel unnecessary. Plus, brevity is on Elixir’s side. “I have messed-up hands. I don’t like to write a lot of code,” Cohen said.

Beyond Pinterest

Pinterest’s interest in languages other than, say, GitHub’s top 10, is fascinating. But other major web companies have explored lesser-used languages in the past. For instance, Facebook has worked with D, and some data scientists at Facebook use Julia. And Pinterest is not (at this point, anyway) charging ahead with its own home-brewed programming language, as Mozilla is with Rust and Apple is with Swift.

While Elixir has gained adoption among developers around the world, it’s been somewhat difficult to document deployments at scale. But here and there, they are happening.

Anonymous social network Whisper uses Phoenix, a framework based in Elixir. Fantasy sports league app FanDuel, video hosting service Brightcove, and home-selling app OpenDoor are using Elixir in production, too, Valim told me in an email.

Of course, other languages have been shown to support concurrency well, including Go, which started at Google in 2009. Nowadays Go is used in production for the Chrome Data Saver’s compression proxy, Chrome’s download server dl.google.com, and the Vitess program that handles every single search on YouTube, Google principal engineer and Go tech lead Russ Cox told me in an interview.

Go is written in such a way that you can run many processes called “goroutines” at once, while keeping memory usage low. (Elixir, for its part, deals with parallelism and concurrency by using many lightweight “actors” that can talk to each other.) Doing many things at the same time is crucial if you have thousands or even millions of requests coming in at any given second, and minimizing hardware demands also counts for a lot.

“We want to build things that make concurrency easier and more lightweight for people,” Cox said.

But Erlang has Go beat when it comes to history. It’s a “battle-proven environment for building scalable and fault-tolerant applications,” as Valim put it in an email. And if Elixir doesn’t have what a developer is looking for, the developer can always resort to Erlang, which is rich with third-party tools. Elixir can understand raw Erlang.

“It’s a fantastic blend of old and new,” Pinterest software engineer Jon Parise wrote about Elixir in an email.

Image Credit: Screenshot

And the resonance certainly goes beyond Pinterest. Andrei Soroker, founder and chief executive of Sameroom.io, a tool that connects people across many messaging apps, waxes poetic about the importance of Elixir.

“Erlang is an old and very powerful technology, but for years it has remained out for reach for all but the most adventurous developers,” Soroker explained to me in an email. “Imagine, on top of a majestic mountain, a utopian city-state, where everything is perfect: wealth all around, everything free-range and organic, no diseases, and no crime. One problem: to live there, you have to learn to speak a language so esoteric and weird, it’s just not worth it.

“The Elixir programming language was the first step in making the world of Erlang much more accessible. The utopian city-state’s senate passed a law allowing a dialect of English to be used for official business. Now, when you ascend the majestic mountain for a visit, you can read the street signs and can place an order at a utopian coffee shop.”

Cohen’s praise for Elixir is less metaphorical but no less enthusiastic.

“It’s small, it’s elegant, it’s thoughtful, it’s fun, and it’s very, very, very readable once you flip over into functional programming mentality, which took my intern a week,” Cohen said.

Check out Cohen’s full blog post for more detail on his affinity for Elixir and the Elixometer and Riffed libraries.