View Full Version : HipHop for php
keyboard
10-19-2012, 03:00 AM
From what I understand of it, HipHop for php (developed by facebook) converts php to c.
Because php has to be interpreted each time it is run (c is already compiled) doing so should increase the speed of your site.
Now to my question -
Has anyone used HipHop?
How much trouble is it to set up and use (and so forth) and are the speed increases notible?
I've read several articles about HipHop (this is a good example (http://www.brandonsavage.net/hiphop-for-php-who-benefits-who-doesnt/)), and they mostly reach the same conclusion: the majority of PHP users - coders, hobbyists, small-site developers - won't see a significant improvement. The reason is that, while C++ is much much faster than PHP, the majority of your time is not spent running PHP: it's spent on external things, like database calls. (Even FB admits that HPHP only sees a 6x improvement, while good C++ executes up to 500x faster than good PHP.)
Other major concerns:
...because your server becomes a single executable, you can only run one web app (site) at a time
...(and therefore, it's not even an option for most people who use shared hosting)
...HPHP isn't currently compatible with PHP >5.2
...(that's pretty far behind, imo... I *love* 5.4, and I won't set a client up with less than 5.3)
...(they're planning on supporting 5.3, and I don't know how long till that happens,
......but they'll always be at least one release behind no matter what)
djr33
10-19-2012, 04:43 AM
Hm. Why isn't facebook written in C# instead then? I don't really get it. PHP is great for the average web developer without a giant site. But facebook is big enough that they should do whatever works best, even if that's using C# to create a webpage... right?
Major parts of it are written in C++ (not C#). They're kinda quiet on exactly *how much* of the site is written in PHP, but the common conclusion is that it's mostly the front-facing parts (i.e., the UI, not the DB handling/caching/data aggregation/etc.). On top of that, it's all HPHP'd and opcode-cached. Doesn't really resemble your typical PHP.
djr33
10-19-2012, 05:12 AM
Hm, ok. I suppose that makes sense. But you'd think that converting everything to C++, if it really is still something like 100x faster would save them thousands in server costs each year...
On a somewhat unrelated note, I didn't actually realize that C++ and C# are different. I don't use either, though. But aren't they equivalent in casual usage? I thought it was just a short way to type it... ha. That's my new fact for the day (looking on wikipedia for a bit more info....).
I don't know how different, but enough. I've studied C, and I want eventually learn C++, but I got sidetracked by python (and then PHP 5.4 was released)
keyboard
10-19-2012, 06:48 AM
THey didn't program fb in C because they didn't want to have to teach all their engineers C (In their opinon php is much easier for them to use/learn)
bernie1227
10-19-2012, 07:10 AM
But then again, php is much harder to maintain on a large scale than something like say, python. They're requirments for jobs, here (http://www.facebook.com/careers/department?dept=engineering), for some of their jobs, include technologies such as c++, java, perl, php, python, mySQL, Oracle SQL and C to name a few, so it's obviously going to be built on a lot more than some php, I'd hedge my bets for c++ and python being used a fair bit in the site.
front end is the LAMP stack.
originally, the whole kit was php and the back end was a LAMP stack.
djr33
10-19-2012, 04:07 PM
THey didn't program fb in C because they didn't want to have to teach all their engineers C (In their opinon php is much easier for them to use/learn)That's what I don't understand-- they have more money than they can count, right? So why not hire experts to design the best system?
Or is it really so much easier to learn PHP that it's cheaper to use PHP in the design than to save money on servers by using C? If so, that says something in favor of PHP even if C is "better"!
keyboard
10-19-2012, 09:55 PM
I think a lot of the engineers they hire already have experience with php, but not c.
But as bernie pointed out, they use a pile of different languages... (even some really obscure ones) and a lot of custom built solutions (cassandra)
bernie1227
10-19-2012, 10:47 PM
They do actually hire people to write C for them, so I don't think the case is that they don't want to train people. Another thing worth mentioning, is that they also hire people for their objective-c and java abilities, for mobile platforms.
@keyboard, none of them are particularly obscure....
keyboard
10-20-2012, 01:02 AM
The chat system is programmed in Erlang (I think)... that's obscure! :P
djr33
10-20-2012, 01:42 AM
Hm. So is it true then that they believe they are saving money by using less-trained programmers? That's interesting if so.
Do you see what I mean?
1) Everything being equal, it sounds like it would be best (=server efficiency) to program the whole thing in C++.
2) Everything being equal, it sounds like it's best (=cheapest for paying employees) to hire PHP programmers.
It sounds like they're focusing on (1) over (2), and therefore, logically, getting more servers must be cheaper than getting better programmers.
I'm a fan of PHP so I don't mind one way or the other. I'm just trying to understand their business model.
bernie1227
10-20-2012, 03:14 AM
Speaking of the Facebook business model:
http://www.modir21.com/wp-content/uploads/2009/10/facebook_business_model.pdf
the Facebook business model
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.