Login
Sign In or Register
Avatar
Not Registered Yet?

Join Now! It's FREE. Get full access and benefit from this site

Reset My password - Remind Me My username

Username
Password
Remember Me

Facebook Hopes to Revolutionize PHP with “Hip Hop”

Tuesday, 02 February 2010 23:45 PDFPrintE-mail

Facebook Hopes to Revolutionize PHP with

Little did we know that, for the last six months, Facebook has made use of a custom compiler for PHP that they refer to as “Hip Hop.” Essentially, it takes your PHP source code, and converts it into C++, and is then compiled with G++. As a result, they’ve managed to reduce their CPU usage by 50%. This project has apparently been in development for the last two years, but has only today been released to the community.

“HipHop for PHP isn’t technically a compiler itself. Rather it is a source code transformer. HipHop programmatically transforms your PHP source code into highly optimized C++ and then uses g++ to compile it. HipHop executes the source code in a semantically equivalent manner and sacrifices some rarely used features — such as eval() — in exchange for improved performance. HipHop includes a code transformer, a reimplementation of PHP’s runtime system, and a rewrite of many common PHP Extensions to take advantage of these performance optimizations.”

The Announcement

“Scaling Facebook is particularly challenging because almost every page view is a logged-in user with a customized experience. When you view your home page we need to look up all of your friends, query their most relevant updates (from a custom service we’ve built called Multifeed), filter the results based on your privacy settings, then fill out the stories with comments, photos, likes, and all the rich data that people love about Facebook. All of this in just under a second. HipHop allows us to write the logic that does the final page assembly in PHP and iterate it quickly while relying on custom back-end services in C++, Erlang, Java, or Python to service the News Feed, search, Chat, and other core parts of the site.”

The Problems Facebook Faced with PHP

  • Can’t reuse PHP logic in other systems
  • Extensions are harder to write for PHP developers
  • High CPU usage; can’t be as efficient as something like C++
  • Fully impractical to completely rewrite Facebook with a new language

How They Improved It

Sponsers

Follow us on!

  • Facebook Page: 55916823107
  • Twitter: edesignerz

Links