Why Facebook hasn't ditched PHP

Have you ever wondered why Facebook is still heavily using PHP instead of just ditching the language at some point in the last eight years? A Facebook engineer recently answered the question.
Written by Emil Protalinski, Contributor

Here's an interesting question I found on Quora: "Why hasn't Facebook migrated away from PHP?" Facebook engineer Yishan Sparklepants Wong worked at the company in various roles between December 2005 and March 2010. Keep in mind that Facebook launched in February 2004 so this particular engineer has been at the company for the majority of its existence.

Without further ado, here's Wong's answer to the PHP question:

The reason Facebook hasn't migrated away from PHP is because it has incumbent inertia (it's what's there) and Facebook's engineers have managed to work around many of its flaws through a combination of patches at all levels of the stack and excellent internal discipline via code convention and style - the worst attributes of the language are avoided and coding style is rigidly enforced through a fairly tight culture of code review (failing to adhere to the style and "going cowboy" by writing sloppy code results in pitiless mockery by one's peers). Engineering management has never had to take a strong hand here; this arose largely due to key internal technical leaders just sort of corralling everyone else along.

There is also a lot of industry precedent indicating that re-writing an entire codebase in another language is usually one of the worst things you can do, so at all levels there is a reluctance to do that. The preferred strategy is to write new components in a de-coupled manner using a better language of choice (C++, python, Erlang, Java, etc); this is easily facilitated by Facebook's early development of thrift, an efficient multi-language RPC framework. This also helps avoid the worst effects of PHP: it can be totally avoided in subcomponents where the language is grossly-unsuitable. The broad effect is that the overall codebase slowly evolves away from depending as heavily on PHP, with the components that are still in PHP being written in tightly-controlled, disciplined ways by veteran members of the staff.

Facebook doesn't just use PHP of course (Facebook may release its core C++ library this year), but it is heavily invested in the language. If you could go back and convince Zuckerberg to use something other than PHP, what would it be?

See also:

Editorial standards