6 ms·
I use PHP only for hobby project nowadays, since that what I used in my last web dev job 10 years ago. So I'm much more comfortable with it than with Python or
by roel_v 16y ago
I use PHP only for hobby project nowadays, since that what I used in my last web dev job 10 years ago. So I'm much more comfortable with it than with Python or Rails or any other language in that class, but I don't care one way or the other really - I use C++ in my job nowadays. Just to say, I don't take offense - I have passed the days where I took the software tools I use for a fundamental aspect of me as a person.
(That said, full disclaimer: I'm writing a PHP extension in a hobby project for a popular library to use that library from PHP, so in that sense I've moved closer to it again over the last 2 months).
Anyway, my main point was that you said "to point out that PHP's interpreter is in fact rather slow compared to pretty much everything else", which I still don't agree with. On straight pass-through to C calls, the overhead is a lookup in a hash table for the function name, and some wrapping of arguments into a union if need be. Arrays are slow because they're also implemented as hash tables; for high performance, one can use structures with iterators that can skip this step. But these are all just single data points; I haven't looked into the implementation of the tests you linked to, but I guess it's not that hard to find counterexamples. That's the nature of tradeoffs you make.
Your comment seemed to imply that the runtime is somehow deficient, compared to others; I'm still not convinced that is really the issue, especially since PHP is really just C with some wrappers around it. Whereas for example Python apparently does (used to do maybe, I don't know) much more bookkeeping etc for the dynamic features that enable its syntactic niceties. Advances in VM precompilation may catch up with that, but how would it make such progress that it would be faster than the straight-to-C equivalent?
Also your mention of hiphop I don't understand. When hiphop compiles something to C++, and then into machine code, it can only be slower than the original PHP code if it changes the algorithms - which are hiphop issues, not related to the speed of the runtime.
Anyway I wasn't claiming that PHP is the fastest or best documented; I just don't accept at face value your claim that PHP is significantly slower than other languages in its class on a sufficiently wide range of real-world use cases.
(for the documentation, I always liked it - most of it lists the parameters, a simple example and some corners cases, and the comments are great, of course for people who are capable of separating the chaff from the wheat. Actually I think there is still a script in the php source tree written by me that transformed the docbook docs into man page format, so that I could open the docs of the function under the cursor in a split window in vim with a single keystroke; that was in 1999 though and 'parsed' the docbook with regular expressions, so if anyone in their right mind had a look at it in the last 10 years they would've deleted it).