2 Mins Read  March 16, 2015  Cuelogic

How Facebook is not using PHP by still using PHP?

Facebook technology stack consist of application written in many language, including PHP and many others. Facebook still using PHP but it has built a compiler for it so it can be turned into native code on.

Facebook doesn’t use PHP for its core system, at Facebook, they uses C++ heavily on back end system. Apparently Facebook has many things built in PHP. Actually it’s not the real PHP, Facebook has written alternative version of PHP that is, HipHop’s HPHP’c which help to convert PHP code into C++ which shows that FB not using PHP, but by still using PHP.

Why Facebook created HHVM?

Facebook also has created another version the HPHPi and they yet another, the HipHop VM aka HHVM, to simply improve what you have, it is just another implementation of PHP which uses just in time approach. Facebook PHP code is compiled by their Hip-Hop. It transforms code into highly optimized C++ and then use g++ to compile it. HipHop executes the source code in a semantically equivalent manner and sacrifices some rarely use features. Hip Hop includes a code transformer a re-implementation of PHP’s runtime system and a rewrite of many common PHP executions to take advantage of these performance optimization.

Why Facebook created Hack?

Facebook has recently released a new programming Hack language that looks and acts like PHP. Underneath the hood, however, are a ton of features like static typing, generics, native collections, and many more features for which PHP developers have long been asking. Hack runs only on Facebook’s HipHop virtual machine, a competitor to the traditional PHP Zend Engine.

Facebook’s maximum internal code is first written with PHP and most of Facebook’s PHP code is converted to a C derivative before being pushed into production. It shows that Facebook depends strongly on the PHP language, But unfortunately PHP was not able to perform as well as possible at Facebook’s scale. Type-related errors may not be recognized until runtime. So, Facebook wrote more tests early to enforce type checking, or spend more time refactoring runtime errors after launch. To cure this problem, Facebook added strict typing and runtime enforcement of return types to Hack. Strict typing nullifies the need for a lot of type-related unit tests and encourages developers to catch type-related errors in the development process.

They wanted to make the development process and error-catching process even easier, So Facebook included a type-checking server with its HHVM engine. This server runs locally and monitors Hack code as it is written. Developers’ code editors and IDEs can use this type-checking server to immediately report syntax or type-related errors during code development. Hack is good. It has so many useful features that may never make it into traditional PHP. Facebook’s HHVM engine is more performance than the Zend engine, and it has more internal developers, too, dedicated to constantly making the HHVM engine better, but it does not mean that the PHP Zend engine will disappear. Both the Zend and HHVM engines can and will co-exist

It is obvious that Facebook cares very much about Hack and HHVM, if only for its own benefit. Competition is a good thing, but both Zend and HHVM will benefit from each other’s strengths to Facebook.

[wcp-carousel id=”10008″]

Recommended Content

Go Back to Main Page