Facebook's HipHop - What's it for?
Asked Answered
G

5

5

The news in the PHP world today is Facebook's HipHop, which:

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.

My question is, what type of web applications is this actually useful for?

Seems like typical database-bound web apps may not be greatly served by this, but rarer CPU-bound apps would.

Gibbs answered 2/2, 2010 at 20:23 Comment(4)
Related (but not dupe): #2056375Anderaanderea
I have been reading the rumors about this all week I am glad it is finally out! I am working on a social network and performance is always the biggest thing with those type of sitesKeramic
It is a compiler, no? It compiles PHP to C++.Aye
While everybody is focusing on speed, there are actually other reasons to use HipHop. The most fascinating to me is to use it as a precursor to "find / -name *.php | xargs rm -f". It appears that the C++ code generated by HipHop may be clean enough for that purpose.Farnese
V
7

Web applications that do a lot of processing and/or use a lot of memory. Apparently this HipHop will reduce CPU usage by around 50% and also reduce memory usage (I didn't see how much the memory usage would be reduced by mentioned anywhere). This means that you should be able to serve the same number of requests with fewer servers.

An added benefit may be that there will be some basic type checking to ensure that the code is consistent before it is compiled. This should help to locate the type of bugs that PHP currently tends to ignore as a result of its weak type system.

The downside appears to be that it might not support some of PHP's more dynamic features such as eval (though arguably that's a positive too).

Visby answered 2/2, 2010 at 20:31 Comment(0)
F
4

Well it "transforms" PHP into C++ to help performance of a largely scalable website.

So, HipHop is for when you have a website that you started at Harvard that you quickly grow into a billion dollar company and that people are making a movie about starring Justin Timberlake. When you have such a website and want to save CPU cycles, but don't want to rewrite your codebase, you use HipHop.

If you are just starting out, unless you are trapped on a desert island with only PHP programmers that refuse to learn a more scalable language, you don't use HipHop.

Fleshings answered 3/2, 2010 at 6:36 Comment(4)
It's a bit unfair to say PHP doesn't scale. Though this project doesn't help the stereotype!Apostolic
TBH I don't even know if it scales or not - Digg uses it, so it must scale pretty well, eh? I was just going by whatever findings Facebook has apparently made.Fleshings
Facebook do have the problem of being the #2 most visited website to contend with!Apostolic
"PHP doesn't scale" is quite wrong, imo. What prevents scaling is bad design, not choice of programming language. More on this very topic in this this book - which uses PHP to illustrate its points.Utley
N
2

Running machine code over interpreted code is faster. This is useful in one sense, but also reduces the amount of machines you require, as each processor has less work to do.

This is good for a company like Facebook, in that they can cut the amount of machines they need.
In terms of why it's useful for them, they probably run a lot of sorting and indexing, on the large amounts of data they have.

Nonary answered 2/2, 2010 at 20:32 Comment(0)
D
0

You can think of it as some sort of compiler that takes in a bunch of .php files, and generate a bunch of c++ files for which you can then compile using g++ (Not sure if other compilers are supported). The resulting exe is your web application with a web server included. That means you could run the exe and you are good to go. The web server is based on libevent and supposedly pretty efficient.

Delvalle answered 5/2, 2010 at 16:19 Comment(0)
A
0

Hip Hop is essentially pointless to everyone except Facebook and other gigantic PHP-based sites. I'm sure many people will jump on the bandwagon due to "it's fast" but how many PHP based apps use whole server farms? Just because you are working on a social network site, doesn't mean you should consider using HH.

Aye answered 5/2, 2010 at 16:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.