Catch up on stories from the past week (and beyond) at the Slashdot story archive


Forgot your password?
PHP Programming Social Networks Apache

Facebook's HipHop Also a PHP Webserver 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.'"
This discussion has been archived. No new comments can be posted.

Facebook's HipHop Also a PHP Webserver

Comments Filter:
  • by bill_mcgonigle ( 4333 ) * on Tuesday February 02, 2010 @08:29PM (#31003408) Homepage Journal

    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:Ambitious (Score:4, Informative)

    by PhiberOptix ( 182584 ) on Tuesday February 02, 2010 @08:30PM (#31003428)

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


  • by Cyberax ( 705495 ) on Tuesday February 02, 2010 @08:47PM (#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.

  • by dgatwood ( 11270 ) on Tuesday February 02, 2010 @09:44PM (#31004094) Homepage Journal

    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:GUI applications (Score:3, Informative)

    by jfim ( 1167051 ) on Tuesday February 02, 2010 @09:56PM (#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 [] and std::vector::at() []?

  • by unformed ( 225214 ) on Tuesday February 02, 2010 @10:00PM (#31004228)

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

    Wrong. You an have memory leaks in Java just as well. It's just more difficult.

    I'd even go as far to say that experienced people are more likely to cause a Java memory leak, because they'll be doing unusual things for optimizing/caching and what not.

    Usually, this involves Swing and dialogs that were closed and forgotten about, and not properly dereferenced.

  • Re:GUI applications (Score:3, Informative)

    by Yold ( 473518 ) on Tuesday February 02, 2010 @10:36PM (#31004568)

    No, its closer to Lisp/Scheme; it has been called "Lisp in in C's clothing". The keywords and syntax is somewhat C-like, but once you get beyond the basics you'll understand what I'm talking about... but here is a simple example (styled for brevity):

    function func(){
      var foo = "bar";
      return (function(){alert(foo);}); }

    function bazz(arg){
      alert(foo); //error
      arg();} //alerts foo


    Javascript doesn't allow you to access Objects (aka Associative Arrays) via numeric indexes, if you have found a way to do this you are doing in wrong... And have you tried Firebug?

  • by ls671 ( 1122017 ) * on Wednesday February 03, 2010 @12:05AM (#31005486) Homepage

    > It keeps track whether an object can be reached my the main program or not.

    Not really the main program but more precisely a running Thread.

    A running Thread might be unreachable from the main program which could potentially cause memory leaks as I have mentioned in another post.

    To cause memory leaks in Java: Fork some Threads which use a bunch of objects and do not keep any reference to the Threads in the main program.

    The correct way to do this is to keep references to the running Threads in the main program and to cause them to terminate when the main program wishes them to.


  • php-eaccelerator (Score:3, Informative)

    by hey ( 83763 ) on Wednesday February 03, 2010 @11:18AM (#31010076) Journal

    Since php lives in Apache which is always running it makes sense to cache the compiled byte codes.

    I like the approach of this: []

e-credibility: the non-guaranteeable likelihood that the electronic data you're seeing is genuine rather than somebody's made-up crap. - Karl Lehenbauer