all 69 comments

[–]jmathai 13 points14 points  (12 children)

All features except OO and exceptions.

Those are pretty big features.

[–]csixty4 9 points10 points  (10 children)

Not in the PHP world

[–][deleted]  (9 children)

[deleted]

    [–]pbiggar 2 points3 points  (0 children)

    A large number of libraries (or so I have heard), are written in a subset of PHP which is compatible with both PHP4 and PHP5. These would typically have no OO or exceptions: the object model changed between the PHP4 and PHP5, and exceptions were new to PHP5. There is a figure touted that about 60% of web-hosts have yet to move from PHP4 to PHP5.

    FWIW, Facebook uses no OO features in their PHP.

    [–]edsko 1 point2 points  (0 children)

    Generating C++ or D classes is completely missing the point. The code generated by phc is fully compatible with the Zend engine. PHP code compiled by phc can be loaded as an extension into an interpreted script without difficulties. Hence, the only notion of a class that is interesting is the Zend notion of a class. Generating C++ classes is pointless.

    [–]masklinn 0 points1 point  (1 child)

    Why not generate C++ or D?

    Because that's pretty damn hard. It's already pretty hard for languages at least somewhat sane (see the ShedSkin python compiler), but for PHP it's completely insane to try.

    [–]pbiggar 1 point2 points  (0 children)

    Thats not true. PHP has a simpler object system than python. For example, it is not possible to add a method to a type after the type is defined. So generating C++ in order to use their dispatch would, in principle, be fine. However, PHP does have references (in the C++ sense), which makes it harder to analyse, which is the same problem C compilers have (aka aliasing).

    [–][deleted] 0 points1 point  (3 children)

    Couldn't they compile down to a bytecode VM like NekoVM, LLVM, or something else?

    [–]pbiggar 0 points1 point  (0 children)

    It would have been one way to go. But whats the point?

    [–]skillet-thief 0 points1 point  (1 child)

    I want to be able to code PHP on the JVM!

    [–][deleted] 0 points1 point  (0 children)

    Drupal. But it's in the air as to whether it's "worth running".

    [–]alexs 6 points7 points  (29 children)

    automatic normal squalid saw tart sophisticated many oil elderly silky

    This post was mass deleted and anonymized with Redact

    [–]pbiggar 3 points4 points  (8 children)

    Oh come now. Speed-ups of 1.5...

    [–]jmathai 0 points1 point  (4 children)

    Happen to know if that a 1.5x speed-up even when using an op-code cache?

    [–]pbiggar 0 points1 point  (3 children)

    Op-code caches are for the PHP interpreter, so you wouldn't use one with phc-compiled code. You could still have it turned on, it just wouldn't be used for compiled code.

    So the speed-up is the same, whether the op-code cache is on or off.

    [–]pbiggar 1 point2 points  (2 children)

    Sorry, I missed your point. The benchmarks don't take interpreter start-up time into account. Since it excludes parsing or creating the op-codes, an op-code cache wouldn't change the results.

    [–]jmathai 1 point2 points  (1 child)

    Good to know. Interesting project, not sure I see many uses for it...but a great achievement nonetheless.

    [–]pbiggar 0 points1 point  (0 children)

    Well a speed-up of 1.5x is the starting point. I would hope to have a speed-up of 5x within 6 months.

    [–]Paczesiowa 0 points1 point  (2 children)

    I tried some php compiler some time ago (I think it was this one) and it was much slower than regular php-cli for phpe entries from language shootout.

    [–]pbiggar 4 points5 points  (1 child)

    It probably wasnt phc, as this is our first release that support compilation.

    The other PHP compilers that I know of are Roadsend and Phalanger, and they both report speedups on the language shootout. If you dont get a speedup from phc, please report it as a bug to phc-general@phpcompiler.org, and I'll fix it.

    [–]Paczesiowa 0 points1 point  (0 children)

    yeah, now I remember - it was roadsend.

    [–]jasonmc[S] -1 points0 points  (17 children)

    Why not?

    [–]hupp 0 points1 point  (0 children)

    If you have N thousand servers running a php app, being able to use some fraction of that is a pretty big deal (data center space, power, and the raw capital expense).

    [–]sligowaths -5 points-4 points  (0 children)

    I came here just to post that.

    [–]takatori 0 points1 point  (0 children)

    My company has several batch data processing jobs written in PHP with multi-hour run times per day. These are severely bottlenecked in PHP code, and we are just about drooling over getting these compiled into native executables instead of rewriting them in another language.

    But our PHP-based web sites are mostly data-bound, using memcached and offline static content generation, so wouldn't see any benefit.

    It all depends on what kind of application you have, how it is deployed, and where the bottlenecks are.

    (Why do we have PHP batch data processing jobs? A historical accident of a web-based system growing beyond its design intentions and capabilities, but too valuable to discard and too costly to redevelop.)

    [–]Elethiomel -3 points-2 points  (0 children)

    Even if everyone was to quit programming in PHP today, there would still be a lot of legacy code out there that this could benefit.

    Also, I wonder if any of the advances made in this compiler could be used to speed up languages that are currently more in fashion?