Forgot your password?
typodupeerror
Facebook PHP Programming

Facebook Releases JIT PHP Compiler 244

Posted by Unknown Lamer
from the history-repeats-itself dept.
angry tapir writes, quoting a Techworld article: "In its continuing endeavor to serve its 800 million users as quickly as possible, Facebook is once again revamping the way it handles its PHP-based Web pages. Facebook has posted ... its HipHop Virtual Machine (HHVM), which the company's engineers call a just-in-time PHP compiler. According to Facebook, this PHP execution engine is 60 percent faster than its current PHP interpreter and uses 90 percent less memory." Facebook has a weblog post with a more technical description.
This discussion has been archived. No new comments can be posted.

Facebook Releases JIT PHP Compiler

Comments Filter:
  • Re:Mixed feelings (Score:5, Interesting)

    by trawg (308495) on Monday December 12, 2011 @11:13PM (#38351440) Homepage

    I disagree that it promotes bad coding practices. I read that as a bit of a tongue-in-cheek comment that actually encourages people to use it the right way, while at the same time drawing attention to the fact that you can swap parameters and you might get unexpected results (i.e., the function working even though it should throw some sort of type error).

    Sometimes mistakes are made in libraries and terrible ugly hacks have to be made to work around them so as not to destroy many hours of work. Whether or not PHP has its share doesn't mean the blame for writing terrible code should be laid entirely at its doorstep.

    Certainly a few crappy library functions hasn't soured Facebook on PHP; I for one am glad to see their continued investment in it and - more importantly - their continued practice of open sourcing new and innovative ways of dealing with PHP.

  • Re:So True. (Score:2, Interesting)

    by fsckmnky (2505008) on Monday December 12, 2011 @11:15PM (#38351450)

    (It's good enough for Java, anyway.)

    Which is at least 50% slower on its best day, than C/C++ on it's worst day.

    As for JIT, it's a non-issue. Anyone could make .c or .cpp files executable, by passing them through the linux kernels MISC binary capability. [see "Kernel support for MISC binaries" under "Executable file formats / Emulations"].

    It's the VM part that kills performance. The Java VM, and presumably, the PHP VM, do not execute native machine instructions, but instead, use an intermediary format, as opposed to, native cpu instructions. This is what kills performance.

    If one wanted both JIT and a "virtual environment" ( for security reasons ) ... one could use the misc binary feature of linux, combined with "linux resource containers" to achieve a virtualized environment ( machine ), isolated for security purposes, which executes native code, with almost 0 overhead.

    Maybe they'll figure it out, but I doubt it, because they are already heavily invested in PHP. Bleh.

    Combine that with the remarkable similarity between PHP syntax and C ( but without the speed ) and maybe you understand why I say ... congrats, they've re-invented C. They've just done it without the last 40-50 years of iterative performance enhancements that have been applied to C/C++ compilers already.

  • Re:So True. (Score:5, Interesting)

    by PCM2 (4486) on Monday December 12, 2011 @11:25PM (#38351512) Homepage

    Which is at least 50% slower on its best day, than C/C++ on it's worst day.

    Got any numbers to back that up, or are you just pulling it out of thin air?

    It's the VM part that kills performance. The Java VM, and presumably, the PHP VM, do not execute native machine instructions, but instead, use an intermediary format, as opposed to, native cpu instructions.

    You don't seem to understand how a JIT works. Many portions of Java programs are indeed executed as native machine instructions.

    Combine that with the remarkable similarity between PHP syntax and C ( but without the speed )

    I wouldn't call the similarity "remarkable." "Superficial" might be a word I'd use, in the sense that Java syntax is also similar to C.

  • by PCM2 (4486) on Monday December 12, 2011 @11:39PM (#38351610) Homepage

    The Zend Engine license [zend.com] seems contradictory to me. On the one hand, Clause 3 says you're forbidden from using the terms "Zend" or "Zend Engine" to endorse or promote your product. On the other hand, Clauses 5 and 6 say you're absolutely required to use the term "Zend Engine" to endorse and promote your product. Seems like someone took the classic BSD license and bolted a commercial land grab onto it, which seems to honor neither the letter nor the spirit of the original.

  • Re:Mixed feelings (Score:5, Interesting)

    by cshark (673578) on Monday December 12, 2011 @11:50PM (#38351678)

    You know, you hear that kind of weird argument a lot from people who don't realize they've been framework programming on Microsoft platforms. They are always complaining about how primitive PHP is because it doesn't have any "built in" separation between the various heavily abstracted but highly arbitrary layers, and that they don't understand the way PHP abstracts logic, variable classes, magic methods, lambada syntax, etc. They're always pointing to perceived shortcomings in PHP, like the one data interchange layer they know about, or the fact that PHP doesn't pass complete classes as strings. The list goes on for fucking ever. The intentional ignorance of these people annoys the holy shit out of me. Or, well... it used to.

    You know, by the same criteria these "evangelist" idiots are using to judge PHP, and failing to apply their idea of "modern", they would be sorely disappointed with any number of other languages. PHP is C++ script. Plane and simple. So if you hate PHP, or you simply can't bring yourself to understand it, it's fair to assume you wouldn't like like C++ either. And for that matter, you certainly wouldn't enjoy Perl, any version of C (other than the sharp kind), Python, Ruby, Java, or any other modern language not developed by our friends in Redmond. None of them would be "modern" enough for you. Or maybe, you're just not skilled enough at your chosen craft. Nobody will ever appreciate the artist who refused to paint because he didn't like the brushes.

    PHP isn't the only language that people have written mountains of bad code on either. If you could even begin to understand the mountain of truly nightmarishly bad .net code I've had to wade through over the last decade, you would give me a fucking medal. In fact, I would wager to say that it's easier to write a large, poorly architected application in C# than it is to write one in PHP. Why? Easy. Because Visual Studio doesn't require you to actually think a whole hell of a lot about what you're coding.

    When you write something in PHP, it's a direct reflection of your ability to code. That's all it is. Code. Start to finish. You think out a problem, and then you write the code to do it. If you want to seperate it into objects, classes, or layers, you're entitled to. If you have another way to do it, that's also fine.

    PHP gives you absolute control and power over whatever it is you want to create. If you're not used to it, or ready for that kind of responsability, it can be frightening.

    So I totally understand why lesser programmers hate it.
    Personally, I like having options.

  • Re:Mixed feelings (Score:4, Interesting)

    by aztracker1 (702135) on Tuesday December 13, 2011 @03:00AM (#38352568) Homepage
    Honestly the syntax of the language doesn't bug me nearly so much as the inconsistancy_in TheApi andItsCommonLibraries. Some use pointers/handles as psuedo classes, or just plain poorly conceived and inconsistent string and array handling. I know there are frameworks on top of PHP that sterilize a lot of this, it just feels like building a house on sand. There are honestly very few web frameworks I really like, and I've worked with many of them. C# + MVC is a fav, but I've seen some wretched code in C# as well. Usually derived from "software architects" who will abstract everything out ad infinitum and sometimes to no point at all. I'm all for IoC and other abstractions and models when they serve a purpose. when you only need 5-10 method calls for a very simple web-app, it's overkill.

    C#'s greatest downfall is those developers/architects that will over-engineer what can be a simple system. PHP's greatest downfall is the sheer popularity in un-trained, or ill-thinking programmers that give the same level of bad taste VB did in the 90's for a lot of people. Bad code can indeed be written in any language, but when a language's core functionality is so poorly conceived, it's harder to write good code. For the record, not very fond of C/C++, but do like Perl okay (for text processing).

If at first you don't succeed, you must be a programmer.

Working...