3 ms·
> PHP is really fast when you use it as a straight templating system, but once you start writing real applications in it, writing your own high-level PHP inside
by zmimon 18y ago
> PHP is really fast when you use it as a straight templating system, but once you start writing real applications in it, writing your own high-level PHP inside PHP, it is the slowest thing around.
This is what I find most people underestimate about PHP - it scales badly in a slightly unique sense: it scales badly with application size. The problem is incremental and therefore hard to deal with.
You start off with one small PHP file. It's wicked fast! 3 months later you have a dozen PHP files and most of them include some common library scripts that are shared between them. It's still fast. A year later your library scripts have grown and grown. Each PHP file is now including 4 - 5 library scripts and those themselves are getting up to thousands of lines long. You try to refactor things but the problem is PHP is such a dynamic and loose language and has such poor abstractions that it's really hard to do that successfully. So soon just to spit some HTML on the page your poor application is interpreting thousands of lines just to render some simple HTML. You look at FastCGI but your cheap web host doesn't support it and then you realize that there are a host of compatibility issues on top that you never thought about when you started that will cause problems.
By the time it is mature your PHP application is slow because it is spending all its time parsing the thousands of lines of poorly structured PHP and very little actually rendering HTML.
Finally, you look at PHP accelerators like Zend etc. and realize that you're going to have to pay for a commercial solution and the free stack you thought you were building with is not actually free any more and you see that even then there are a bunch of compatibility problems. And then you wish you had built with python ... or java ... or groovy ... or ruby ... or anything else but PHP.
It's the poor support for modularization and abstraction combined with the interpreted nature of the language that leads to this.
- thomasmallen 18y agoThat's a load of FUD and a fabricated horror story. Computationally intensive business logic should be implemented as a C/C++ extension in any case because PHP is still essentially a web language and a glue language. Rasmus Lerdorf, PHP's creator, has stated as much. Any claim that PHP can't scale is at this point a dead letter, as are more dated claims that Java is too slow, etc.
- zmimon 18y agoWell, I think you completely missed my point, since I didn't anywhere say that PHP can't scale in the sense you are talking about.
- thomasmallen 18y agoWhile we're at it, PHP is pretty bad for desktop GUIs and artificial intelligence...
- blasdel 18y agoBut as soon as you get into building extensions to mod_php, you've lost everything that's great about PHP: the deployment story / execution model.
- thomasmallen 18y agoAnd if you have the capability and good reasons to build your own extensions, deployment probably isn't much of a concern. But building and loading extensions into PHP is not very difficult, assuming dependencies are already met.