Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Facebook's HipHop Also a PHP Webserver

kdawson posted more than 4 years ago | from the carbon-footprint-reducer dept.

PHP 304

darthcamaro writes "As expected, Facebook today announced a new runtime for PHP, called HipHop. What wasn't expected were a few key revelations disclosed today by Facebook developer David Recordan. As it turns out, Facebook has been running HipHop for months and it now powers 90 percent of their servers — it's not a skunkworks project; it's a Live production technology. It's also not just a runtime, it's also a new webserver. 'In general, Apache is a great Web server, but when we were looking at how we get the next half percent or percent of performance, we didn't need all the features that Apache offers," Recordon said. He added, however, that he hopes an open source project will one day emerge around making HipHop work with Apache Web servers.'"

cancel ×

304 comments

Sorry! There are no comments related to the filter you selected.

GUI applications (5, Interesting)

sopssa (1498795) | more than 4 years ago | (#31003174)

While theres already several libraries intended for creating windows and interfaces with PHP, and to put them together into an executable file, this might greatly improve that area in PHP too. While being faster as well, being machine code it protects your code too.

Along with making it work with Apache Web servers I hope someone works on this aspect too. PHP is really nice and fast to write. *ducks from the c/c++ coders*

Definitely interesting project.

Re:GUI applications (0, Troll)

Anonymous Coward | more than 4 years ago | (#31003274)

Seriously, why would anyone use PHP to develop non-web apps, when there are so many significantly better alternatives?

Python, Perl and Ruby are the big three alternatives that run on more platforms than PHP, offer much better and more mature languages, and have far better standard libraries. Haskell and Erlang are much better functional equivalents.

Even then, we still have Tcl, C, C++, Java, C#, and many other languages available to use.

PHP isn't really that useful for web development any more. The only reason it still hangs on is because so many companies and individuals screwed up and chose to use it in the first place.

Re:GUI applications (1)

toastar (573882) | more than 4 years ago | (#31003388)

Seriously, why would anyone use PHP to develop non-web apps, when there are so many significantly better alternatives?

Python, Perl and Ruby are the big three alternatives that run on more platforms than PHP, offer much better and more mature languages, and have far better standard libraries. Haskell and Erlang are much better functional equivalents.

Even then, we still have Tcl, C, C++, Java, C#, and many other languages available to use.

PHP isn't really that useful for web development any more. The only reason it still hangs on is because so many companies and individuals screwed up and chose to use it in the first place.

Meh,

I prefer php because it's a nice compromise between being easy to read, and being easy to find code to copy.

Re:GUI applications (2, Funny)

FooAtWFU (699187) | more than 4 years ago | (#31003444)

I prefer php because it's a nice compromise between being easy to read, and being easy to find code to copy.

Congratulations. You have just explained half the code snippets on The Daily WTF [thedailywtf.com] .

Do you use the for-case [thedailywtf.com] paradigm too?

GNAA's HipHop Also a Jew Sex-slave (-1, Troll)

Anonymous Coward | more than 4 years ago | (#31003718)

With jews, you lose. Join the GNAA Today!

Re:GUI applications (1)

toastar (573882) | more than 4 years ago | (#31004012)

Do you use the for-case [thedailywtf.com] paradigm too?

That should take about 20 lines not 60... Is that what you were trying to say?

Re:GUI applications (1)

Snarf You (1285360) | more than 4 years ago | (#31004224)

Hopefully he has upgraded to the "once in a while" [thedailywtf.com] switch replacement technique.

Re:GUI applications (2, Interesting)

ls671 (1122017) | more than 4 years ago | (#31003774)

> and being easy to find code to copy.

Some use Joomla for the same reasons...

I set up only 1 site with Joomla in order to try it. I guess it is OK if your site doesn't have sensitive data and that you do not mind having your site defaced once in a while ;-))

I had the admin password changed by a remote attacker on the Joomla site. The attacker couldn't deface the site although because I filtered admin access at the reverse-proxy level, thanks god ;-))

Anyway, I wouldn't use Joomla for any sensitive site and I am tempted to say the same about PHP. I figure that it should be possible to write PHP in a secure way but I haven't seen it yet. Default session handling is a joke in PHP with files in the /tmp directory (session hijacking). There is also many other aspects that are handled in a way that often makes me smile ;-))

 

Meh Filter (2, Insightful)

Gary W. Longsine (124661) | more than 4 years ago | (#31003830)

Please, Slashdot Gods, give me a preference filter to hide all comments which begin with "Meh".

Re:GUI applications (1)

MightyMartian (840721) | more than 4 years ago | (#31003566)

Um, how about bash? It may not have all the tricks of the big boy scripting languages, but goddamnit, I can run a script I wrote twenty years ago and the odds are very favorable that the damned thing will work. Compared to any php or any you list, it's light weight, has decades worth of samples and resources (if you consider its forbearer; sh and ksh), and runs on pretty much any modern platform out there (even Windows).

Re:GUI applications (1)

dgatwood (11270) | more than 4 years ago | (#31003694)

Yeah, and you can write some pretty powerful^H^H^H^H^H^H^H^Hinsane stuff with shell scripts.

*points to sig*

Re:GUI applications (1)

ls671 (1122017) | more than 4 years ago | (#31003846)

> or any you list, it's light weight,

I use bash scripts everywhere for "run once in a while" tasks but...

1) Bash scripts are usually heavy weight with regards to resources needed (creating many processes on the system. etc...).

> and the odds are very favorable that the damned thing will work.

2) Java is backward compatible since the very first version. For me, this tells something about the qualification of the people creating/maintaining ANY language or OS, etc.

Re:GUI applications (2, Interesting)

FooAtWFU (699187) | more than 4 years ago | (#31003282)

Fast to write, sure, but "nice"? The language is a mess, its metaprogramming is weak, and its packaging system is almost as bad as C. If you want a "nice" language go for Ruby or even Python something. (I do Perl myself, which has its share of cruft and hacks, but at least I have a decent package/namespace system.)

Re:GUI applications (0, Troll)

LOLYouAreWrong (1724080) | more than 4 years ago | (#31003496)

WRONG

Re:GUI applications (4, Insightful)

dgatwood (11270) | more than 4 years ago | (#31003562)

What makes PHP nice is that it is so close to C. For people who are comfortable working in C, PHP is just a few dollar signs away.

Re:GUI applications (5, Funny)

MightyMartian (840721) | more than 4 years ago | (#31003632)

What makes PHP nice is that it is so close to C. For people who are comfortable working in C, PHP is just a few dollar signs away.

Which is like saying an anus is almost like a vagina...

Feel free to take that analogy the distance.

Re:GUI applications (0)

Anonymous Coward | more than 4 years ago | (#31003836)

Feel free to take that analogy the distance.

<duffman>OOOOOOoooooooohhhhh yeah!</duffman>

Re:GUI applications (1)

linumax (910946) | more than 4 years ago | (#31004098)

Which is like saying an anus is almost like a vagina...

Feel free to take that analogy the distance

Distance or depth? You decide.

Re:GUI applications (2, Insightful)

shutdown -p now (807394) | more than 4 years ago | (#31003638)

What makes PHP nice is that it is so close to C. For people who are comfortable working in C, PHP is just a few dollar signs away.

Well, JavaScript is even closer, then - not even dollar signs needed.

In truth, however, it may be a curse rather than a blessing. The syntax looks deceptingly familiar, but semantics are anything but. C is a language where things are generally unambiguous and straightforward, even when syntax is cryptic. PHP is the opposite - seemingly simple syntax can have a lot of subtle ambiguities. See my other comment [slashdot.org] to this story for an example.

Re:GUI applications (1)

dgatwood (11270) | more than 4 years ago | (#31003898)

A significant percentage of JavaScript stuff is done with dot notation and classes. So I'd say its closer to a subset of C++, really. It's also a pretty awful language, mainly because of the debugging environment. (Don't get me wrong, the new debuggers make it a heck of a lot better than it used to be, but that's like saying death by a million paper cuts is better than death by a million razor blades.)

Regarding the issue of array indices in PHP, it is a little ugly, but you can generally cast such a string to an integer (assuming that's what you want) just by saying $foo = $bararray[(int)$indexvalue];. And thankfully, IIRC, you can't access the non-numeric keys using numeric indices like you can in JavaScript. Now *that* is one unholy, ugly mess of an associative array design....

Re:GUI applications (0, Troll)

mabinogi (74033) | more than 4 years ago | (#31003896)

The number of people who chose PHP because it has a superficial syntactic resemblance to C (actually it looks more like Perl than C) must be vanishingly small.
No one(*) develops in C any more, being C-like is no longer a benefit.

(*) Ok, I know that _some people_ do - I do myself, for a job even, but it's very rare to find new developers that know real C, compared with Java, C# or C++. And the number of people who profess some level of PHP proficiency dwarf all of them.

Re:GUI applications (1)

Korin43 (881732) | more than 4 years ago | (#31003928)

Why don't you just use Java? It's more like C++, and has the advantage of having a standard library that isn't a huge mess (it's also much faster).

Re:GUI applications (0)

Anonymous Coward | more than 4 years ago | (#31004154)

Because its java.

Re:GUI applications (4, Funny)

shutdown -p now (807394) | more than 4 years ago | (#31003418)

PHP is really nice and fast to write. *ducks from the c/c++ coders*

You should duck from Python and Ruby coders. The C++ guys are too busy beating up Java schmucks. ~

Re:GUI applications (1)

rockNme2349 (1414329) | more than 4 years ago | (#31003778)

Sorry, get ready for a beatin!

I tried to post a reply but I segfaulted, bad string handling. I had to wade through fields of ampersands and asterisks to get here.

-C guy.

Re:GUI applications (1)

ls671 (1122017) | more than 4 years ago | (#31003922)

This happens sometimes when I screw up doing pointer arithmetics or when I do not check array bounds.

To cure this, I started designing a system were I will abstract pointers with my own custom library. It will also automatically free the memory from unused objects. I will call it "memory recollection".

I am also designing my own custom third party library to automatically check array bounds ;-))

Re:GUI applications (2, Informative)

jfim (1167051) | more than 4 years ago | (#31004202)

This happens sometimes when I screw up doing pointer arithmetics or when I do not check array bounds.

To cure this, I started designing a system were I will abstract pointers with my own custom library. It will also automatically free the memory from unused objects. I will call it "memory recollection".

I am also designing my own custom third party library to automatically check array bounds ;-))

You mean like boost::shared_ptr [boost.org] and std::vector::at() [cplusplus.com] ?

nginx (1, Interesting)

Anonymous Coward | more than 4 years ago | (#31003208)

How does this compare to nginx i wonder?

Re:nginx (1)

Lennie (16154) | more than 4 years ago | (#31003346)

That's like comparing apples to oranges. One is a language used to generate HTML, do database queries, talk to memcached, etc. The other is a webserver.

Re:nginx (1)

Neil Hodges (960909) | more than 4 years ago | (#31003834)

I think GP was asking how HipHop, with its built-in PHP webserver, compares to nginx with FastCGI/PHP when it comes to serving up PHP pages.

Re:nginx (1)

sopssa (1498795) | more than 4 years ago | (#31004062)

But most likely wasn't serious. Theres lots of these short nginx one-liners in other stories too.

A stupid question... (3, Insightful)

creimer (824291) | more than 4 years ago | (#31003276)

For all the trouble you're going through to convert PHP into C++ (300,000 lines and 5,000 unit tests), wouldn't programming in C++ in the first place be easier?

Re:A stupid question... (2, Insightful)

Lennie (16154) | more than 4 years ago | (#31003336)

Because it's really easy to create memory leaks and similair bugs in C++.

Re:A stupid question... (4, Informative)

Cyberax (705495) | more than 4 years ago | (#31003616)

An experienced C++ programmer rarely creates memory leaks, and they are easily detected by a variety of tools.

Also, for PHP-style programs it might be easier to just restart a child server process each N requests. So memory leaks are of even less concern.

The main problem is compilation speed. C++ compilers are just plain slow.

I guess I got it reversed (1)

ClosedSource (238333) | more than 4 years ago | (#31003716)

"The main problem is compilation speed. C++ compilers are just plain slow."

You do go to the bathroom or have some coffee or tea once in a while don't you?

Re:A stupid question... (1)

maxume (22995) | more than 4 years ago | (#31003868)

Considering that they are compiling/translating PHP code into C++ code and then compiling that code, I don't think the speed of their C++ compiler was a major contributor to the choice.

Re:A stupid question... (1)

dgatwood (11270) | more than 4 years ago | (#31004008)

Actually, it is. Your compiling and translation happens at deployment time (or at staging time, hopefully), not during development. With native C++, you pay that penalty over and over again. With PHP and a translator, you develop the thing using normal PHP/Apache and pay that compilation penalty only near the end of the process.

Re:A stupid question... (0, Troll)

ls671 (1122017) | more than 4 years ago | (#31003984)

> An experienced C++ programmer rarely creates memory leaks,

An INEXPERIENCED java programmer NEVER creates memory leaks,

An experienced java programmer could manage to create memory leaks using threads but you almost have to do this on purpose ;-))

Re:A stupid question... (1)

ls671 (1122017) | more than 4 years ago | (#31004026)

> The main problem is compilation speed. C++ compilers are just plain slow.

Are you saying C++ doesn't have development platforms that compile your code in real time as you modify it ?

I haven't been coding in C++ for a while but I assumed something similar to eclipse was available for C++ developers. Heck, C++ must be supported by eclipse so doesn't it compile the code in real time as you modify it.

I am just curious, maybe it is harder to acheive this with C++,

Thanks for answers everybody. ;-)

Re:A stupid question... (4, Insightful)

shutdown -p now (807394) | more than 4 years ago | (#31003720)

Because it's really easy to create memory leaks and similair bugs in C++.

It's very easy to get rid of memory leaks in C++, as well. A very simple rule: never, ever write a type declarator with a * in it. In other words, no raw pointers - use Boost/TR1 shared_ptr, or roll out your own, it doesn't matter - just use it consistently. At that point, you can still get reference cycles (which are also leaks), but you can do that in PHP 5.3 - which also uses reference counting with no GC for cyclical references - just as well. And the usage of 5.3 so far is minuscule.

Alternatively, just use any of third-party tracing GCs, such as Boehm.

By the way, from personal experience, I find that languages with built-in reference counting and no cycle detection (those I know of are VB6 and PHP) are actually more prone to memory leaks when coding that languages with explicit memory management. The reason is that, in, say, C++, coders are actually aware of issues such as memory allocation, and view smart pointers as convenient helpers, not as some kind of magic fairy dust. Because of that, the question of "what happens if two smart pointers reference each other" is a rather obvious one, and the issue is noticed and rectified early on. In contrast, in VB6 and PHP, you don't have to deallocate explicitly, so refcounting is magic - many people don't even understand how the algorithm works! - that is, until you run into a cyclic reference that leaks...

duration of leak (4, Interesting)

pikine (771084) | more than 4 years ago | (#31003854)

We're talking about C++ as a CGI script. Who cares about memory leaks that only last for the duration of an HTTP request, which is a fraction of a second? The real problem with memory leaks is when you have a long-running process like single-process web browsers.

Re:A stupid question... (1)

sopssa (1498795) | more than 4 years ago | (#31003340)

PHP is a lot better environment to develop new features quickly and doesn't get you into so many security pitfalls. And they're already using C++ for some parts of the site:

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 common suggestion is to just rewrite Facebook in another language, but given the complexity and speed of development of the site this would take some time to accomplish.

As a programming language, PHP is simple. Simple to learn, simple to write, simple to read, and simple to debug. We are able to get new engineers ramped up at Facebook a lot faster with PHP than with other languages, which allows us to innovate faster.

And I agree with them on those aspects.

Re:A stupid question... (4, Insightful)

shutdown -p now (807394) | more than 4 years ago | (#31003582)

As a programming language, PHP is simple. Simple to learn, simple to write, simple to read, and simple to debug.

PHP is not a simple language. A keymark of a simple language is consistency, and PHP is anything but - I won't even touch on the mess that is the standard function library, but just the language itself. For example, this gem, taken directly from the language spec [php.net] , regarding array indices/keys:

A key may be either an integer or a string. If a key is the standard representation of an integer, it will be interpreted as such (i.e. "8" will be interpreted as 8, while "08" will be interpreted as "08"). Floats in key are truncated to integer. The indexed and associative array types are the same type in PHP, which can both contain integer and string indices.

This is awesome on many levels. The obvious fubar is the treatment of "8" vs "08" (and note that, while it is clearly obvious when a string literal is used in the source code, how about a string variable, or other expression computed at runtime?). But the bit about silent float->int truncation is also interesting, especially the "silent" part. Combined with rounding errors and the overall non-obviousness of binary floating-point arithmetic (especially to a typical PHP coder), this design decision is just hilarious.

I've long held the opinion that C/C++ rules on mixed signed/unsigned arithmetic and comparisons are a good example of awful language design, but PHP beats that by a margin so large it's not even funny.

Oh, I also don't know of any other language that has what effectively amounts to synactic sugar for try/catch with an empty catch block [php.net] . Good programming practices FTW!

I find it curious, by the way, that PHP coders like to compare the language to C++ or Java - where it actually has some subjective advantages, such as dynamic typing - but very rarely to Perl, Python or Ruby, where all such advantages disappear, but design flaws immediately stand out.

Re:A stupid question... (1)

abulafia (7826) | more than 4 years ago | (#31003888)

Oh, I also don't know of any other language that has what effectively amounts to synactic sugar for try/catch with an empty catch block [php.net] . Good programming practices FTW!

Oh, good lord. I didn't know about that one. Every time I think I know just how awful PHP is, I learn something like that.

I find it curious, by the way, that PHP coders like to compare the language to C++ or Java - where it actually has some subjective advantages, such as dynamic typing - but very rarely to Perl, Python or Ruby, where all such advantages disappear, but design flaws immediately stand out.

I think it is a bit like penis envy. Not all of them, but a lot of PHP monkeys like to think imagine they're much more hard-core than they are, so they compare what they do to what they perceive as a "real" language.

If they took the time to actually understand what makes Perl, Python or Ruby so superior, well, it is unlikely that they'd still be happy with PHP.

Re:A stupid question... (3, Informative)

dgatwood (11270) | more than 4 years ago | (#31004094)

The @ syntax is not a try/catch. PHP doesn't stop execution when it encounters errors opening files and stuff. It merely blasts a warning message to the output stream (web client). The @ operator suppresses that output. It's equivalent to sending the perror() after a failed fopen() call to /dev/null. Whether the command succeeds or fails, control still returns to your code after the statement. The @ operator merely suppresses the error message generated by PHP so that you can display a more appropriately formatted and/or more useful error message (or not display a message at all if the failure is expected). In a production environment, most people disable the warning output from PHP anyway, making it basically a no-op except during debugging.

If you folks want an argument against PHP, you're all going about it wrong. Probably the best argument against PHP is that it makes it easy to design yourself into a corner---putting code into the middle of HTML templates that suddenly needs to be able to set a header field and "whoops, that has already been sent", putting code into the middle of templates that needs to change the content up a level, and "whoops, have to add a hack over here to fix that", etc. The result is that for really simple sites, PHP is awesome, but it has real problems scaling to more complicated designs without dropping the templates (or at best, including them on the back end after you do a lot of compute processing up front to set things up, choose a template programmatically, etc.).

Or you could simply attack it for being a lot slower than C and leading to design patterns that waste lots of memory. For example, associative arrays are simple and easy to use, but 90% of the time, there are much simpler data structures that can do just as well. If your data structures are small, no problem. If you deal with something big, the difference in memory pressure between a clean, lightweight binary tree (even without balancing) and an associative array can result in an order of magnitude impact in performance (or two or three).

Re:A stupid question... (1)

amicusNYCL (1538833) | more than 4 years ago | (#31003944)

and note that, while it is clearly obvious when a string literal is used in the source code, how about a string variable, or other expression computed at runtime?

It should be clearly obvious that if you want to use a string as an integer, you use intval to convert it first. Programmers who know the difference between strings and integers know that. Don't take that personally, that comment isn't aimed at you, there are many, many PHP "programmers" who really don't know anything about data types (as a question answerer on the w3schools forum, I can readily attest to this; the level of inexperience people have when trying to tackle major projects is staggering).

It's difficult to fault a language just because it's easy to learn though. PHP is easy to learn, because it does a lot of stuff automatically (casting, error suppression, etc, like you said). So that means a lot of people copy and paste, go through quick tutorials, etc, and try to write code in it. You end up with a lot of crappy code, but that's not the fault of PHP, that's the fault of the people who are trying to write code without learning any theory at all (literally). Any decent programmer would be pretty surprised that a large portion of people asking PHP questions on w3schools are developing on a server with error message display disabled, errors are routed to a log file instead. They don't know that, and don't know how to change it, so they never even see error messages, just a blank page when they get a fatal error. I sometimes wonder how those people ever manage to debug, then remember that's why they're posting on the w3schools forum.

Oh, I also don't know of any other language that has what effectively amounts to synactic sugar for try/catch with an empty catch block

C'mon, if you want to cherry pick examples you can claim whatever you want.

The error suppression operator is for suppressing errors. The die/exit statements are for quitting execution and optionally printing a message. Some functions return false if they fail, so you can do something like this:

mysql_query($sql) or exit(mysql_error());

to print a specific error message for a specific situation. It should be obvious that's equivalent to this:

if (!mysql_query($sql)) exit(mysql_error());

That's what your example shows, printing an error that a file couldn't be opened if the file wasn't able to be opened. If you want exception handling and try/catch blocks, here you go:

http://www.php.net/manual/en/language.exceptions.php [php.net]

Re:A stupid question... (1)

LordLucless (582312) | more than 4 years ago | (#31004014)

@ predates PHP exception handling, and was used for the old method of error handling.

That said, PHP's error handling in general is annoying, as the built-in functions generally raise errors instead of throwing exceptions. That's an artifact of the way the language changed over time, rather than that it was poorly designed.

Re:A stupid question... (1)

gnud (934243) | more than 4 years ago | (#31004162)

The weak typing is your main concern with PHP? You can make arguments that strong/explicit typing is better, but weak typing is NOT php's problem. The behaviour of array keys is completely consistent with the type system everywhere else in the language, any scalar value can be an array key. By the way, later in your own post you point at dynamic typing as an advantage. Please make up your mind?

Re:A stupid question... (3, Insightful)

MightyMartian (840721) | more than 4 years ago | (#31003594)

PHP is a lot better environment to develop new features quickly and doesn't get you into so many security pitfalls. And they're already using C++ for some parts of the site:

Except for the problem that, historically, PHP is been one big vast security pitfall.

Re:A stupid question... (1)

maxume (22995) | more than 4 years ago | (#31003356)

Um, they say that they don't think it would in one of the articles.

Re:A stupid question... (0)

Anonymous Coward | more than 4 years ago | (#31003360)

According to Facebook it would not be. I'm bound to agree. They committed one guy for 8 months and then three guys for 10 months to this product. It's doubtful they could have rewritten all of Facebook in that time.

Additionally, there's the cost of good C++ developers being more expensive than mediocre PHP developers. Their new approach allows them to churn out code hiring the latter while getting close to the the performance benefits they would see if they only hired the former.

Re:A stupid question... (1)

tomhudson (43916) | more than 4 years ago | (#31003730)

If you read the article, you'd see that they wrote a program to convert the php - they didn't do it by hand.

Re:A stupid question... (1)

larry bagina (561269) | more than 4 years ago | (#31003796)

Yeah, this gem stood out when I read about this earlier:

We are able to get new engineers ramped up at Facebook a lot faster with PHP than with other languages, which allows us to innovate faster.

What kind of experience and intellect do they have -- or not have -- if that's an issue?

Re:A stupid question... (0)

Anonymous Coward | more than 4 years ago | (#31003400)

No. If the developers find C++ to be more difficult than PHP, or slower to write than PHP, then Facebook should not switch to C++, because it will get less out of their developers than PHP. With Facebook's current system, the developers can continue using their fast, familiar PHP, while getting the performance of C++. The trick is that the computer does the conversion automatically, not the developer, so programming it in C++ in the first place is no longer necessary.

Which you would have known if you read the article.

Re:A stupid question... (2, Informative)

bill_mcgonigle (4333) | more than 4 years ago | (#31003408)

For all the trouble you're going through to convert PHP into C++ (300,000 lines and 5,000 unit tests), wouldn't programming in C++ in the first place be easier?

They address this specifically in one of the articles. They want their whole team (many of whom are not C++ developers) to contribute.

Re:A stupid question... (1)

mystikkman (1487801) | more than 4 years ago | (#31004146)

Were they born PHP coders and can't learn??? Is a language like a race, encoded in you DNA?

Re:A stupid question... (0)

Anonymous Coward | more than 4 years ago | (#31003424)

For all the trouble you're going through to convert PHP into C++ (300,000 lines and 5,000 unit tests), wouldn't programming in C++ in the first place be easier?

FTA:
"HipHop programmatically transforms your PHP source code into highly optimized C++ and then uses g++ to compile it."

Well, I Guess "HipHop" Is the New Champ! (5, Funny)

RobotRunAmok (595286) | more than 4 years ago | (#31003304)

And here I never thought that anything could ever take the award for "Most Stupidly Named Software" away from the Ubuntu distros.

Congrats again, HipHop! Can I get a Fist-Bump?!

Re:Well, I Guess "HipHop" Is the New Champ! (2, Funny)

Anonymous Coward | more than 4 years ago | (#31003358)

I made the mistake of installing HipHop. I should have known something was wrong when the server started wearing pants hanging down so low that its anus was sticking out. Then eventually the thing ran away and now spends its time at the local Popeye's and makes money stealing people's hubcaps.

Re:Well, I Guess "HipHop" Is the New Champ! (2, Funny)

Anonymous Coward | more than 4 years ago | (#31003474)

My friend, if someone's anus is sticking out, they have far more problems than oversized pants!

Re:Well, I Guess "HipHop" Is the New Champ! (4, Insightful)

NevDull (170554) | more than 4 years ago | (#31003548)

My guess is that it was probably a progression from "Haiping's PHP" to HPHP to HipHop.
Two syllables vs four or more... looks like they're not just computing more efficiently, but also speaking more efficiently!

Re:Well, I Guess "HipHop" Is the New Champ! (1)

Garble Snarky (715674) | more than 4 years ago | (#31003626)

Not that it makes the name any better, but I think its a sort of "expanded acronym", from Hyper-PHP.

Re:Well, I Guess "HipHop" Is the New Champ! (1)

aldld (1663705) | more than 4 years ago | (#31003684)

Most stupidly named software? What about Scrotwm?

Re:Well, I Guess "HipHop" Is the New Champ! (0)

Anonymous Coward | more than 4 years ago | (#31003826)

HPHP

Ambitious (1)

meza (414214) | more than 4 years ago | (#31003312)

They wrote their own webserver/php-interpretor to increase the performance with "half or [one] percent"? Wow, that's quite daring I'd say. Note I did not RTFA so probably they saw more performance increase or some other use, otherwise it seems like a likely miss-directed investment.

Re:Ambitious (1)

bill_mcgonigle (4333) | more than 4 years ago | (#31003370)

Yeah, the article would help you there.

Even if it were only half of one percent, that's still 150 machines to Facebook. I understand they put a patch up for memcache that "only" reduced their need for 60 machines (some synchronous lock got made async IIRC).

Re:Ambitious (3, Insightful)

sopssa (1498795) | more than 4 years ago | (#31003372)

He said they were struggling just to get half a percent more performance with Apache. That had nothing to do with "HipHop".

In reality their CPU usage dropped average 50%

With HipHop we've reduced the CPU usage on our Web servers on average by about fifty percent, depending on the page.

Re:Ambitious (1)

meza (414214) | more than 4 years ago | (#31003456)

Ah thanks, that explains it. Either I'm just tired or the summary makes the quote easy to miss understand.

Re:Ambitious (3, Informative)

PhiberOptix (182584) | more than 4 years ago | (#31003428)

sure, hardwares cheap, but when you have over 30k* servers, a 1% saving on them might be worth their coders time.

* http://www.datacenterknowledge.com/archives/2009/10/13/facebook-now-has-30000-servers/

Re:Ambitious (3, Interesting)

shutdown -p now (807394) | more than 4 years ago | (#31003604)

They wrote their own webserver/php-interpretor

They didn't write a PHP interpreter. They wrote a PHP-to-C++ translator.

Also, I presume that "one-to-half percent" refers to further optimization opportunities after they've done that.

Re:Ambitious (0)

Anonymous Coward | more than 4 years ago | (#31003614)

Plus, this probably explains why FacePlant has been so damn slow lately. They must have some kinks to work out yet in the software.

i can hear it now (0)

Anonymous Coward | more than 4 years ago | (#31003324)

i can hear both sides now:

the php lovers: "look how awesome php is, you can use it for really large scale deployments!"

the php haters: "look how awful php is, you need to convert everything into c++ before you can use it in really large scale deployments!"

Re:i can hear it now (4, Insightful)

bill_mcgonigle (4333) | more than 4 years ago | (#31003490)

the php haters: "look how awful php is, you need to convert everything into c++ before you can use it in really large scale deployments!"

"Look how awful C++ is, you have write bits in assembly to get it to really run."

"Look how awful assembly is, you really optimize when you can write machine opcodes."

And the microcode guys just glare out from their caves with their glowy little eyes in incredulity.

Elsewhere is heard, "You guys still use CPU's? It's the GPU decade, dude."

And somebody down the hall builds an ASIC to solve a specific problem and thinks he's so smart.

But, the analog EE understands his elegant circuit doesn't enable a team of 200 developers to build the top social networking site.

Re:i can hear it now (1)

pdusen (1146399) | more than 4 years ago | (#31003588)

You've killed me with wisdom, sir.

Re:i can hear it now (4, Interesting)

ancientt (569920) | more than 4 years ago | (#31003692)

I'm both sides.

I love PHP when I need to throw something together fast (like today) but don't expect a lot of heavy use. I love PHP when I want to get some handy tools that I can easily hack into doing what I really want. Still, when I have a significant project, and server load starts to matter, I loathe trying to use PHP and would usually rather write it as Perl, sometimes even compiling (gasp) Perl into something about as efficient and a whole lot more reliable than if I tried to write it in C. If I were really serious, I'd write it in C, but a day's work in C is 30 minutes in Perl or 10 in PHP.

Choice of language for me is about return on investment. I'm not a grand programmer, I don't have the luxury of getting comfortable programming, if I'm programming it means that I'm not spending time on the dozens of other issues confronting our IT department. Most of the time if we're doing any sort of serious project, we're buying service from somebody who does it better than I have time to, probably better than I could.

If this HH thing (no, can't stand to type the real name) gets momentum then it could be really good for shops like ours. We could turn the tools we don't have time to do well into things that don't suck so much and the tools that we wouldn't think were worth the hardware into things we can afford to run.

Re:i can hear it now (1)

ducomputergeek (595742) | more than 4 years ago | (#31003930)

We developed a solution in PHP because that is what the servers we had two years ago supported, I knew it fairly well, and things had to be done quickly to get a product out to market. As we went back and started to rebuild the product we ended up choosing Perl because Perl wasn't changing much, already had a module that supported almost anything we wanted to do, and we could compile it and increase the load our servers could take by a good 20%.

Ah ha! (3, Funny)

bernywork (57298) | more than 4 years ago | (#31003384)

This explains a lot, a couple - few months ago, I started getting complaints about "potentially virus infected" / "unscanable" zip files when being served content from facebook.com and fbcdn.net etc.

They probably changed at this point how they were sending data out of the web server with zip compression and it all started falling over at this point....

I was wondering what the change was....

Facebook Still Runs Terribly Slow (3, Funny)

ztransform (929641) | more than 4 years ago | (#31003398)

Chat routinely freezes up the browser, and people appear offline when they are online.

I frequently get error messages from pages that won't dynamically load (there is something wrong with the server, or such message).

Facebook doesn't need a half percent increase in performance, they need a lot more!

Re:Facebook Still Runs Terribly Slow (1)

kyoorius (16808) | more than 4 years ago | (#31003808)

I have found the chat to only freeze up when there are multiple FB windows open.

More speed ... thttpd (0)

Anonymous Coward | more than 4 years ago | (#31003442)

If you need more speed than apache, you run thttpd [acme.com] . I'm assuming they didn't test it.

From TFA... (3, Funny)

BitHive (578094) | more than 4 years ago | (#31003462)

As a programming language, PHP is simple. Simple to learn, simple to write, simple to read, and simple to debug. We are able to get new engineers ramped up at Facebook a lot faster with PHP than with other languages, which allows us to innovate faster.

hahahahahhahahahhahahahahhahahahahhahahah

hahahahahhaha (0, Troll)

BitHive (578094) | more than 4 years ago | (#31003492)

*learns PHP as a new hire at Facebook*

"Look, ma, I'm an engineer!"

*writes shitty php code*

"Look, ma, I'm innovating!"

Yup, those PHP organizations sure are dumb (2, Insightful)

SlappyBastard (961143) | more than 4 years ago | (#31003584)

What with their stupid success and their stock options growing in value. Man, what a bunch of fucking retards.

Re:Yup, those PHP organizations sure are dumb (2, Interesting)

FooAtWFU (699187) | more than 4 years ago | (#31003630)

That just goes to show that with enough resources, you can brute-force anything.
The question for you and me is: do you want to be the brute?

Re:Yup, those PHP organizations sure are dumb (1)

CannonballHead (842625) | more than 4 years ago | (#31003780)

I'm not sure the originator of Facebook had "enough resources."

Re:Yup, those PHP organizations sure are dumb (1)

enoz (1181117) | more than 4 years ago | (#31003894)

That just goes to show that with enough resources, you can brute-force anything.

Pretty sure Google proved this long ago.

Re:Yup, those PHP organizations sure are dumb (1)

jjohnson (62583) | more than 4 years ago | (#31004116)

Wouldn't you?

Re:Yup, those PHP organizations sure are dumb (1)

gmhowell (26755) | more than 4 years ago | (#31004144)

The question for you and me is: do you want to be the brute?

If the check doesn't bounce, hell yeah!

Re:Yup, those PHP organizations sure are dumb (1)

iggymanz (596061) | more than 4 years ago | (#31004192)

The question for you and me is: do you want to be the brute?

silly question, if it involves much resource$ going into my pocket, fuck yeah

Great story (2, Insightful)

BitHive (578094) | more than 4 years ago | (#31003676)

Yeah I think I'm going to go buy stock in companies because they use PHP. Take that! hurrrr

Re:Great story (1)

LordLucless (582312) | more than 4 years ago | (#31004052)

Yeah, I think I'm gonna make investment choices based on their choice of development language rather than, you know, the product they make with it. Hurrrr.

Re:Great story (1)

SlappyBastard (961143) | more than 4 years ago | (#31004082)

A lot of publicly traded companies use PHP. You've clearly put me in my place.

Re:Yup, those PHP organizations sure are dumb (1)

Dunbal (464142) | more than 4 years ago | (#31004006)

What with their stupid success and their stock options growing in value. Man, what a bunch of fucking retards.

      If they ever do go IPO, I will certainly be there to short their stock... WHAT was their business model again?

Re:From TFA... (1)

oldhack (1037484) | more than 4 years ago | (#31003536)

Us in the software ghetto completely destroyed the word "innovate". Sorry.

===E (0)

Anonymous Coward | more than 4 years ago | (#31003798)

===E

You've been forked.

CPU usage... (1)

Trieuvan (789695) | more than 4 years ago | (#31003858)

Webservers are mostly IO bound, why do they need to improve cpu usage ?

Re:CPU usage... (1, Interesting)

sopssa (1498795) | more than 4 years ago | (#31004120)

Because they have already optimized most of the IO and DB related things. Since Facebook is one of the largest sites in the world, even small changes make huge changes with what infrastructure and server amounts they need. And in this case the improvement is 50%.

What about Flooz? (1)

rudy_wayne (414635) | more than 4 years ago | (#31004096)

I heard that PHP is good for Flooz.

There's a difference? (1)

michaelmalak (91262) | more than 4 years ago | (#31004174)

There's a difference between beta and production code when it comes to the code that runs Facebook?
Load More Comments
Slashdot Login

Need an Account?

Forgot your password?