|
|
|
|
|
by streety
5723 days ago
|
|
Until recently, an ignoring a brief foray into Limbo, I've been a PHP only/focused programmer. I've been working with python more in the past year as I've been doing more work with data processing and statistical analysis for which PHP really doesn't have the tools. Having said that I wonder if missing the 'beauty' of async I/O etc has more to do with the projects people take than the language. Would a python or ruby developer who focuses on creating web apps have any more familiarity with those concepts than a PHP developer? |
|
One of the reasons for this is because PHP was designed to quickly handle single HTTP requests. The scaling is ment to be done on the app-server side and that single request that your script is serving at a given time will take as long as it will take anyways.
So you don't really need the async I/O (in theory).
Python and Javascript (and to some degree ruby) rely on their own web servers implemented in their own language, in many cases with no or bad (GIL) concurrency at which point it gets more interesting to move into an event based model where it becomes imperative that operations don't block.
There async I/O becomes important.
So: PHP: concurrency by firing off another apache/fastcgi process or thread. Don't worry about blocking on I/O.
node.js and some python/ruby frameworks: concurrency by using an event based system. Because one operation blocks the whole server, they need to be quick. async I/O becomes important.
Of course the evented model has huge advantages too: You worry much less about races, you get huge performance with a simple architecture and you can potentially handle much more concurrency (because each thread/process consumes resources that your one evented process does only once).
Both paradigms are interesting, but having first-class functions certainly makes an evented model more convenient to work with.