The use of Erlang in Facebook chat
Erlang is a general-purpose concurrent, garbage-collected programming language and runtime system. It stays strong while building concurrency programs. Erlang provides language-level features for creating and managing processes with the aim of simplifying concurrent programming. It has large application in many chat service well known now such as Whatsapp and initial version of Facebook chat.
Previously we have written an article Use of Erlang in WhatsApp. In this post, we will talk about the story about use of Erlang in Facebook chat. The initial version of Facebook chat is developed by Adam D'Angelo, an early Facebook employee.
While Adam was in college he made a prototype of a chat website with Erlang because it seemed like the ideal language for the task and also it was a chance to have fun learning a new language according to him.
Later , and Adam worked on the initial Facebook chat prototype as part of a hackathon project in early 2007. Some of the Erlang code were pulled from his personal project while in college. When they decided to make it an official project and productionalize the server code, the team decided to stick with Erlang and took over the code from there.
The rationale was something like:
- They already have a working prototype to start from.
- Erlang is good at holding a ton of open connections, which is the hardest part of a chat service.
- Erlang is easy to learn, even though very few engineers already know it.
The last point, lack of expertise, is a real weakness of the language, but it was outweighed by other factors at the time. Ultimately it contributed to Facebook's decision to move the service to C++, though even with the knowledge that it would eventually be rewritten, It was the right choice to use Erlang for the initial version because of the limited resources they had at the time. It was probably also the right choice for WhatsApp for the same reason.
You can read for more details about why Facebook later switched.
While writing asset management code...Programmer 1: Can I name my variable ass?Programmer 2: Is it a private variable?Programmer 1: YesProgrammer 2: Then name it - myAss