Hacker News new | ask | show | jobs
by nly 4468 days ago
> This is exactly what the PHP world needed: making its already-fast performance many times faster (amplifying one of PHP’s biggest advantages over other common web languages)

I think PHPs speed is largely exaggerated here. The interpreter always used to be slow, and before the bytecode cache it was plain awful. Im pretty sure it only ever got away with it because so much of the standard library is thin wrapping. Is it really faster than CPython like for like?

3 comments

I should have stopped reading here:

"Most non-PHP developers judge the entire language by bad code snippets 'written' (mostly copied and pasted) by amateurs for PHP 4"

The old "stop hating on the only language I know! It doesn't have flaws, there are just newbies using it!"

There is plenty wrong with PHP, to this day. When people criticize PHP, they're not usually talking about PHP 4. They're talking about 5.4+. There's some seriously lunacy in the core language. Some of it is there for legacy reasons, and some is brand new.

How about providing some examples that aren't obscure edge cases that are easily avoidable?
> Is it really faster than CPython like for like?

It is a mixed bag. There are times where PHP is faster because it is closer to C, where as more python is written in Python. I once ran into a situation where it mattered that PHP's file_exists() is much faster than python's os.path.exists(). I have run into other cases where CPython is much better, such as python's heapq crushes a hand rolled PHP priority queue.

In practice PHP tends to be quite fast, because the standard solutions are pretty unambitious like thin wrappers around CURL, rather than actually implementing HTTP in php.

> pretty unambitious like thin wrappers around CURL

That (specific example) sounds incredibly intelligent to me.

PHP is fast - I've been there, made ~4k RPS websites in PHP & memcache.

There's one big, primary reason for it.

PHP is dumb.

You can't do clever things in PHP with the language, you have to all the clever things in how you design with it.

You can't overload functions or redeclare them later.

You can pretty much resolve a function at call-time, without worrying about decorators around it or about any meta-programming.

This makes for a fast VM in PHP, because it can make assumptions about function call-order much more than something like python.