4 ms·
yeah, I know, but PHP does not even need that. That's the point.
by skor 7y ago
yeah, I know, but PHP does not even need that. That's the point.
- TylerE 7y agoIt's not an actual advantage, and PHP's "throw the world away" execution model is so so dumb.
- skor 7y agoI see your point, it makes sense to me in application development. However, regarding a web request, for me it's totally fine to throw it away :). Same as the statelessness of REST.
- TylerE 7y agoWell, I don't what to tell you except that that is a very shallow view. Every non-trivial web app I've ever worked with has tons of persistent state. DB connection pools. Translations. Configuration. Recreating that on every request is just wasteful.
- jimbokun 7y agoFor a quick and dirty proof of concept, do these things really matter? Have you measured the overhead and impact on performance compared to other development stacks?
- FpUser 7y agoWhat happens when your "quick'n dirty proof of concept" has to become production? Rewrite? As for the other stacks: I do what everyone says not to do. I write stateful servers in native compiled languages with no GC. So far I've yet to encounter any scalability problems. They simply do not exist when said servers are runninig on 32 core monsters with gobbles of RAM and not slowed down by interpreters, garage collection and bazillion of abstraction layers. Sure I could not serve Facebook using this, but hey it works just fine for the 90% of the rest and that is where I make my money ;)
- wolco 7y agoPHP's caching system doesn't make it recreating from nothing on every request. PHP can take advantage of connection pools but rarely does it make sense to hold a connection open.
- justapassenger 7y agoIt adds a lot of complexity to write performant code (you basically need another middle layer), yes. But it also has some security benefits - with that model it’s harder to have exploits (as in your request you don’t carry over any other state), session swaps, no need to care about concurrency, locks, etc. It’s by accident, but it’s a real benefit of php.
- stickfigure 7y agowith that model it’s harder to have exploits The PHP community's track record on security is abysmal compared to all those other environments that don't throw away the world.
- justapassenger 7y agoSecurity record is due to enormous popularity, low barrier to entry and some questionable/archaic design choices. But clean state at start of each request is clear security advantage. I can have a car with super safe airbags, that does horrible in crash tests. That doesn’t make those airbags bad.
- egeozcan 7y agoIt pushes people to find hacky solutions when they need "just this memoization for this simple use case" and years later when you take over the project you see it's been dumping request data to a publicly accessible folder. Luckily PHP is very damn fast so you don't see it often, but you'll start questioning the whole industry if you are hired as consultant into many middle-to-large-sized projects and see the hacks people have come up with.
- tylerjwilk00 7y agoIt's an advantage and stateless is great for scaling[1]. Loading configuration is a pathetically small sliver of your execution time budget. [1] https://12factor.net/processes https://12factor.net/processes
- freehunter 7y agoI would argue that PHP does need it, it just ships out of the box while other languages need a “npm install” step first.
- wolco 7y agoHot reloading is very different but cool because it could involve rebuilding assets. But slower and not really the same.