Last year back when Quora was beta, someone pointed this Quora entry out. I explained why this guy was mistaken and let it lie. But, since a friend sent it to me recently, I guess people are actually using Quora (or something) and this deserves a response

PHP has some inherent advantages as a programming language for web development.

PHP has some disadvantages (for Facebook). The biggest are:

High CPU

High Memory usage

PHP components are not easy to integrate from outside

Extensions writing is not the same as PHP coding

There were multiple attempts at Facebook to migrate from PHP but they failed: Mainly because an re-architecture team cannot keep up with the new code that is being written by the rest of Facebook—mostly writing new PHP code. The year before the presentation alone had 4 attempts at internal migrations

Improving the PHP core was done at Facebook and, in fact, received a lot of mileage, but this was not felt to be sustainable vs. HipHop solution.

For those of you who don’t have time to read the rest, here is what HipHop for PHP is:

HipHop is a PHP-to-C++ cross-compiler. What this means is it takes PHP code and translates it into C++ code for further compiling. It is not another language. It is not a just-in-time compiler (JIT).

HipHop will be open-sourced by Facebook under the same licensing as the respective PHP codebase it sets to mirror. Facebook hopes that the community will improve HipHop and add extensions to HipHop that mirror PHP functionality. Also, it hopes that future PHP core development will code features that would be more amenable to optimizations that HipHop does.

HipHop was the current survivor of a number of projects over the years at Facebook to improve the performance of the site. Facebook, as the second largest trafficked website in the world, is built mostly on PHP. HipHop is currently running side-by-side next to many LAMP PHP servers at Facebook and they are claiming an average of 2x increase in performance on those machines.

HipHop accomplishes this by surveying the entire codebase of your PHP-based application with a parser and then building out a C++ project based on it. The C++ project then compiles and runs as its own web server. Because of this, Apache and the PHP Zend engine are completely bypassed.

In order for this to work, some features of the PHP language are no longer supported. Also, C-specific PHP extensions will need to be translated to HipHop C++ extensions in order for them to run.

The benefit in speed is mostly due HipHop’s static analyzer which parses your PHP code looking for ways to optimize dynamic parts into static maps. Because of this, your performance gain may vary — more structured code is rewarded with larger performance boosts.

What HipHop means

If you use some open-source PHP applications on your hosted website, the answer is nothing. You don’t have the ability to compile HipHop, you don’t have access to server restricted ports, etc.

If you are developing a PHP application that currently can be run on two servers or less (or virtual servers in the cloud) the answer is nothing. You don’t have the scale for this to be worth your time.

If you do not have a separate development and deployment environment, don’t have a developer who knows C/C++, or use any PHP libraries where the source is not available (thankfully the encoded scripting market is small to non-existent in the PHP world), then the answer is nothing. You don’t have the development model that can support HipHop. Also note, HipHop has bugs, and—given the state of APC development as a model—will never have true compatibility with PHP. You’ll need some resources to either recode around those bugs or fix HipHop.

If you are a developer of an open-source PHP application, then the answer is not much. Most PHP applications will be deployed in a shared-hosted environment. They won’t be using HipHop.

If you are a shared hosting company, the answer is not much. This is because the HipHop parser needs access to all the PHP in an application in order for it to create a working project. The exception is if you provide software as a service that you maintain (say a static build of WordPress, or a custom site tool written in PHP). You can have HipHop optimize this and get the performance increase.

If PHP is not the operational bottleneck of your web application (your app spends a lot of time waiting on the database, disk, a 3rd party Web API call, etc.), the answer is not yet. At this time, there’s no point in getting a performance gain in PHP. If you don’t know what I’m talking about, your bottleneck is the database. 😉

If you have an application already scaled across many machines, a significant number of them running PHP in processor-intensive tasks, have separate development/deployment, have your entire PHP source code, have modest C/C++ resources, then the answer is possibly. It wouldn’t hurt for a developer there to try a hand at cross-compiling the PHP into HipHop and seeing if it runs. An operational deployment will return about 50% of those machines to a pool for other uses or future growth—or, put differently HipHop will basically double that processing on the same hardware/power.

If you make a turnkey application based on PHP, the answer is somewhat. These are rare, but now you can shrink-wrap PHP into a binary. This isn’t the intended use of HipHop, so some development might have to be done to get this fully supported. Also this is a true binary, not an op-code compile—it cannot run across platforms.

If you are developing a PHP framework, the answer is some. If your framework can compile and run successfully in HipHop, then it should be a good selling point to enterprises in case their application becomes bottlenecked on performance.

If you have highly-cohesive parts of your architecture that fall into above requirements and those parts are weakly-coupled (via API?) to the rest of the system, then the answer is a lot. Those parts can probably benefit from HipHop, and it should be relatively easy to try it.

If you are making a decision on which web language to build your site in, the answer is a heck of a lot. Arguing against PHP for performance reasons no longer holds water. PHP under HipHop will probably now out-benchmark Perl, Python, Ruby and possibly even Java and C#. In practice, you can get the advantages of having a scripting language without operational costs. Moreover, because the target is C++ which is more easy to integrate as a library, if you have a multi-language support, you can now provide C++, Python, and other languages with access to components that have before only been written in PHP (without resorting to a web API).

If you are making an argument to recode your entire site from PHP to some other language, the answer is you just lost that argument. (I never bought the argument of recoding an entire site from another language to PHP.)

There are language features, for better or for worse, that PHP must support and HipHop must not. Because of it’s unique approach to compiling, HipHop will never replace the Zend Engine. Because it doesn’t supersede PHP user-space syntax, HipHop does not and will never change PHP development (much).

HipHop is a showcase. With it the PHP world can point to Facebook as being the busiest site built in a scripting language in the world.

I got an e-mail from a recruiter at Bebo looking to hire me into the same position I had at Tagged. This caught my eye:

ABOUT BEBO:
Bebo (www.bebo.com), Located in San Francisco; with over 40 million registered members viewing billions of pages monthly, it is the largest social networking site in the UK, Ireland, and New Zealand, and the third largest behind MySpace and Facebook in the US. Officially launched in July 2005, received the 2006 Webby Award People’s Vote as the best social networking site in the world.

Our people can boast demonstrated records of success in viral online marketing and social media, having come to us from such companies as Google, Ringo, Tickle, BirthdayAlarm, Friendster, Organic, Yahoo, and MTV.

From its $15M initial round of funding back in early 2006 (from Benchmark Capital) Bebo has enjoyed positive cash flow since day one.

Our recent merger with AOL will bring tremendous opportunity by combining Bebo’s fast growing user base with the social graph of AIM and other assets.

Hmm, Tagged passed Bebo just after they got bought out by AOL for $850 million (and while I was working there) and Friendster right before I left. Given that Friendster passed on hiring me twice—that’s the sweet taste of satisfaction! 😀

Depending on the metric, you might make a case for it being #4, but to displace Tagged? Really? Not to mention, completely pissing on the hard work I did there. 😉 Besides this slight isn’t exactly going to make me jump ship from my new job back to my old one—just with a different color scheme.

This marks the first time (to my knowledge) that SixApart is embarking on a free hosted blogging service, so it was definitely worth a look, especially given some of the things we’ve worked on, have recently got working, and will work on at here at Automattic. Besides, free is the price I like 🙂

Registering for a new account (especially with the Facebook Connect integration) was so easy, I thought, “Wait! Where is my Staples button?”

The blog, though there is some confusion as to the URL, has an aesthetically pleasing layout. It certainly seems to share a lot of influences from Twitter, WordPress P2, Pownce, etc. but the biggest influence has to be Tumblr.

Vivanista is a social network for women focusing on philanthropy. Even if you don’t have a passing interest in such things, the website deserves a look, it’s quite an attractive website and built in record time—a couple of months.

I think it’s instructive how companies like Slide and RockYou could have been so slow to capitalize on game designs that date back to 1980’s bulletin board systems. Perhaps they’ll study that in b-school. With 20-20 hindsight, this model does complete sense—interaction and bandwidth limitations are pretty much the same relative to the existing technology in each time period are strikingly similar in both BBSs and social networks. And just to further emphasize that it was not first mover that defined success, but rather failure to capitalize, I’ll remind the audience that neither FarmVille nor Mafia Wars were original ideas on Facebook—both were swiped from competitor products.

I will give Zynga (and the others) this. They have a far more mature understanding of social virality than the days of Plaxo, Tagged, or even RockYou/Slide. Earlier social gaming (like the first such app, Zombies) used traditional models based on optimizing signups and invites, but the Zynga model is optimizing views and clicks and they’re doing a good job. Remember, FarmVille only launched in June and now is all over the Times.

This is Mafia Wars, Zynga’s copy of Mob Wars. Note the use of various promotions to cater to instincts of people to bring their eyeballs here daily — gambling with daily chance, limited time offers and jobs, cross selling their other applications like Farmville, etc.On this screenshot showing a fold and a half of content, you only see one “social” touch point (at the bottom). That’s because the social aspect is only used like e-mail for messaging—and even then, only for notifications because real interaction like in Diplomacy or Chess would need much more brainpower than simply clicking.

Clicks are optimized here; social interaction is minimal here.

Trust me, they make a lot of money off of this.

Before any of us start rationalizing, part of learning is admitting when someone does it better than you. Hats off to Zynga.

“One involved the creation of mock Facebook profiles. Researchers learned that while people perceive someone who has a high number of friends as popular, attractive and self-confident, people who accumulate “too many” friends (about 800 or more) are seen as insecure.”

High number of friends == attractive? Score! And what happens at 800? Does the Facebook CS team come and beat you with an ugly stick? I thought you’re supposed to troll their tagged pictures to decide about this one. And now that they’ve ajaxified the photos page, it’s oh so easy to do!