5 ms·
Rasmus Lerdorf's analysis of XHP
- nostrademons 17y agoHeh, now I see why they had to invent HipHop. It's an interesting idea - trade off speed for readability and security, and then write a PHP->C++ compiler to recover the speed you've lost. I wonder whether it would've been easier to use a language + templating system that gets security right in the first place, though.
- ashu 17y agoXHP development started very very recently and had absolutely nothing to do with HipHop.
- robryan 17y agoFrom those benchmarks though it seems it would only be really effective with HipHop in a high CPU usage environment.
- jasonlotito 17y agoAs explained in the comments in the article, it is effective even without HipHop. Rasmus explains that as well in his article.
- paul 17y agoHe's benchmarking based off of a 10 line PHP program and then extrapolating that this is why HPHP is needed?
- codexon 17y agoIt's a joke. HPHP's 50% speed boost does not make up for a templating engine that 43 times slower.
- paul 17y agoNo, it's stupid because a 10 line program isn't the least bit representative.
- danudey 17y agoThough he points out that if your PHP script spends most of its time doing algorithmic calculations, waiting on I/O, etc., or if you're using an external template library already, then you might well not notice the difference anyway.
- codexon 17y agoIt doesn't matter if it isn't the least bit representative. Being 43 times slower is going to make a noticeable impact on latency especially when the templates are likely to be larger than the example shown.
- paul 17y agoNo, it's completely meaningless unless your programs are only 10 lines long. You have no idea what part of it is slower.
- rbanffy 17y agoHis benchmark is all about the template engine because that's what XHP changes. The impact of XHP and HPHP depend very much on what you are doing to serve your requests.
- mdg 17y agoThe title of the actual page is called "A quick look at XHP"
- wesley 17y agoI see no reason those XHP templates couldn't just be cached as regular old PHP. It's a nice tool to have during development only.
- rbanffy 17y agoCall me old-fashioned, but I have been weary of source-code transformations since I first touched C++
- flogic 17y agoUnless you code in raw machine code, everything is a source code transformation.
- rbanffy 17y agoYes, but going from one HLL to another is much harder than going from a HLL to machine code. Not that I regard PHP a particularly HL language
- nostrademons 17y agoOnly if you care about the readability and maintainability of the target HLL. Going from one HLL to another if you never plan to look at or change the generated code is significantly easier than going to machine code. Just look at all the compilers that target C.
- encoderer 17y agoAPC is doing that, just one step better, by caching them as PHP Opcodes.
- prodigal_erik 17y agoreturn $this->renderBaseAttrs() . ' />'; No wonder it's expensive. If you serialize a tree of objects by concatenating subtrees into substrings, most values are copied many times depending on the depth of the tree, and you end up doing O(n log n) work. But as for the alternative there was basic XSS filtering in place for the naked $_POST['name'] variable in the plain PHP version isn't knowing you have to encode some but not all of your output worse than just encoding all of it? This is the kind of design mistake that leads to databases accidentally full of HTML entities. Or more likely, half full.
- Daishiman 17y agoWell you know what they say about putting lipstick on a pig...