It's been nearly a decade since Mark Zuckerberg launched what would become the world's largest social network. Since those early days, Facebook's infrastructure and code have evolved, with some of it collecting dust over time. On Friday, the company took a small step in a new direction when an engineer added 5,112 lines of code written in the D language to Facebook's repository. So what's all the fuss about?
For a member of this family of object-oriented programming languages, D is a relative youngster. The language was created in 2001 as a sort of re-imagined version of C++ by Walter Bright, a programmer coincidentally known for creating Empire, one of the first war-simulating computer games.
"It's the first battle signaling the end of Middle Earth, and the rise of the Age of D," Walter Bright writes with geeky optimism. "The old guard will be sailing to the Grey Havens soon."
Explaining the impetus behind the creation of D, my colleague Kit Eaton writes:
It's been created because C++ had to maintain backwards compatibility with C, and that as C++ itself has expanded the language's new features have simply added to the complexity of the standard--a document that's now over 750 pages long. Hence the goal was to take the core powers of C++ and reshape them into a language that's simpler, better, makes the most of modern programming habits, is highly portable between different compilers, and can be aggressively optimized in a way that C++ just can't. D looks a lot like C, in layout, syntax, and more, but the language also takes ideas from Python, Java, Ruby, C#, and others.
As the official Dlang.org site asks in its overview of the language, "Can the power and capability of C++ be extracted, redesigned, and recast into a language that is simple, orthogonal, and practical? Can it all be put into a package that is easy for compiler writers to correctly implement, and which enables compilers to efficiently generate aggressively optimized code?"
This is the idea behind D. The result, its proponents say, is cleaner, more efficient code that's more portable and easier to deal with than C++, which has been in use since 1983. It also offers advantages like better memory management through garbage collection and a short learning curve for those well-versed in C++.
“Having D used in production in a big company like Facebook is a big deal,” writes Hacker News user jmdavisProg in a lengthy thread on the topic. “No, it doesn't mean that D has taken over the programming world or anything like that, but it shows that the language is maturing and that real companies are now willing to use it in the real world--and it's a pretty major company at that. So, this is just one step forward, but it's a big one and exciting to the folks who are fans of D--especially those who have put a lot of time and effort into it.”
Although D isn't without its detractors (see these lively threads on Google Groups and Stack Overflow for the finer points of the debate over the language's merits), there's plenty of excitement among developers over Facebook's adoption of the language, even if it is in the earliest of stages.
That D is creeping its way into Facebook's code repository should come as no shock. That's because Andrei Alexandrescu, the research scientist who compiled the first D language commit at the company, is the guy who wrote the book--literally, the preeminent textbook--on the D language. Alexandrescu follows in the footsteps of Bright as the de facto lead developer and authority on D. And now he's working at Facebook.
So, what's the advantage for Facebook here? As Alexandrescu writes, "We've measured massive wins in all of source code size, build speed and running speed" on a "project [that] is in heavy daily use at Facebook." He doesn't specify exactly what D is being utilized for within the company, but Facebook is said to use C++ very extensively within its backend systems (even converting some of its beloved PHP code into C++ using HipHop For PHP).