Why Facebook hasn't ditched PHP
Summary: 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.
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:
- Facebook lists supported and deprecated SDKs
- Facebook tries to appease frustrated developers
- Facebook launches improved Auth Dialog
- Facebook bans browser plugin FGS, and its developer
- Fbootstrapp: Bootstrap for Facebook apps
- Facebook Comments go mobile
Kick off your day with ZDNet's daily email newsletter. It's the freshest tech news and opinion, served hot. Get it.
Talkback
If'n I culd go back...
Not sure how useful this speculation is
So you realistically had a choice between ASP or PHP. Pre-.NET ASP was a mess, so realistically PHP was the right tool for the job.
I have to laugh at the notion of "migrating" like it's something to do on a Saturday afternoon when you have nothing else to do. That's like your neighbor asking you why you haven't changed your car's color yet? Yeah... I'll get some masking tape and get right on that!
.NET is a mess too, and will never be able to scale up
What are you based on?
During the last years, .NET got one by one the missing components - ASP.NET web forms vs MVC vs Sharepoint enterprise portal, presentation on desktop via WPF/WinRT on Win 8, powerfull (and scalable) services via WCF, integration, workflow, powerfull database, event processing, master data management, and much more. And I can say that when you put this on paper, the overall costs for the .NET implementation are lower, at the end, than any other choice.
And as a suggestion for replacement, if desired: ASP.NET MVC on Azure Web Roles.
Support your statements
As if it was a bad choice?
PHP is slow in larger applications
PHP
sometimes people should just mind their own business
don't rock the boat.
if it aint broke, don't fix it.
I totally agree
Are there any good reasons
'Leave it be' sounds good.
37signals just redesigned Basecamp...
PHP likely isn't a huge bottleneck; it's more and more on the client side (though it might be a different game on the mobile app side, where the UI is 'there' and it's all small data requests).
http://37signals.com/svn/posts/3112-how-basecamp-next-got-to-be-so-damn-fast-without-using-much-client-side-ui
Nothing wrong with PHP
However, if they really wanted to stuff it up and make it around 200% slower then they could try Java ;-)
That's (A bit) wrong
Wow
PHP WHY NOT
Have you read this?
tldr: PHP started as a quick-n-dirty web scripting language. It originally stood for "Personal Home Page." It was never designed to be a scalable general-purpose programming language which is what I would think would be required at a place like Facebook. It's sort of like starting with a wooden shack and then building more and more rooms on top of it as you need them, instead of just tearing it down a building a proper house.
Hello? Is this thing on?
Another problem moving from PHP