6 ms·
Can anyone suggest anything that is superior to PHP in its development cycle: save file.php = instant result? As far as I've seen, everything else needs to rest
by skor 7y ago
Can anyone suggest anything that is superior to PHP in its development cycle: save file.php = instant result? As far as I've seen, everything else needs to restart a server, obviously much slower.
What about its die-hard intention of fulfilling a request no matter what?
What about autoloading?
And what about the amount of things you can do in vanilla PHP, no libs, no extensions.
Hey i've worked with it for some time and sure, its got its nasty things, like gotos :)
- TylerE 7y agoBasically any other framework/language will have some sort of dev-mode autoreloader that will restart everything faster than you can switch tabs.
- skor 7y agoyeah, 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.
- bishalb 7y agoNot really faster than switching tabs unless you are deploying a hello world app.
- mekster 7y agoTell me how to do that with nodejs. It still takes almost 3 seconds to restart which makes me wait a second or 2 before I can reload. pm2 with ts-node is the best I can achieve so far but not fast enough not to hold for a second.
- earthboundkid 7y agoI like all the replies you get denying the obvious truth. Yes, every modern JS framework has autoreload. Use React, Vue, whatever, and the page will have reloaded between when you save your file and look at the tab. It’s not a secret, PHP heads! Your language is not as good for web development. JS sucked in 2000 but now it’s a way better language than almost anything.
- LittleBobby 7y agoMy workplace has both PHP and Node/React apps. PHP, instant result. The Node/React app takes 10 seconds at minimum to restart. Also, to start it for the first time takes a good minute or two. Annoying. Something no one else ever mentions is router systems. Everything under the sun uses router systems, even the PHP frameworks. Go ahead and benchmark those compared to just saving a file and having Apache or Nginx serve it because it's there. Go ahead, I'll wait. The router system is much slower. Not to mention, it has to be manually configured to even work.
- egeozcan 7y agoPeople use router systems because file system can't map all the routes. Also, your web server also has a router system, it just happens that it, by default, maps /potato to potato.php (I like potato better than foo). Instead of configuring this, people tell the web server to forward all requests to a php based router so people so not have to rewrite routing logic when they switch web servers, and everything is configurable through one language. This applies not only to php of course. Also, I'm one of those guys who was lucky to do enterprise react projects before it was a thing, and even converted a huge react codebase to typescript, and I'm telling you: If it takes 10 seconds instead of 2 for a giant codebase, there's a misbehaving plugin or a misconfugiration. Shed all of them and also explore hot module reloading.
- oaiey 7y agoNo one denies that. But this is another entry burden removed. Routing Systems are important and key to any framework. But explain the concept in the first day of a fresh Web Dev (w/o loosing him).
- Dylan16807 7y ago"This part examines the URL and figures out which code should run in response." Easy.
- mekster 7y agoWhat kind of bloat do you have with your nodejs app? My nodejs app (not react) restarts in about 3 seconds, which is still hugely annoying as I can hit reload after alt-tab in a second and I have to wait a few seconds or else I get "Bad Gateway" errors. It's monitored by pm2 for auto restarting ts-node. I wish there's a better solution that reloads faster than you can alt-tab and reload.
- guggle 7y ago> As far as I've seen, everything else needs to restart a server Everything else as an autoreload of some sort, so you don't have to think about it while developing.
- mnm1 7y agoClojure. Changed namespaces automatically recompile. Instantly reevaluate changes. Never have to restart the server. On the front end you never have to even hit refresh in the browser with clojurescript.
- skor 7y agoThat's cool!! Had a nag for learning lisp/lisp-likes for a while now. My favorite part is the absence of concurrent problems due to immutability. How popular is the functional paradigm for The Web?
- fulafel 7y agoReact has its root in the FP model, and the React ClojureScript binding (Reagent) works really well with it. (reference: "I had implemented several iterations of what eventually became React, in a few languages - one of the first explorations began as a rough implementation of the reconciler and component model in [the functional language] Standard ML (CreateClass was a "module function"). This was really great because SML embraces immutability by default which is natural when building React style components. " - https://www.reactiflux.com/transcripts/jordan-walke https://www.reactiflux.com/transcripts/jordan-walke )
- dmux 7y agoAny language that has an "eval" mechanism makes this really easy. I've used Groovy's GroovyScriptEngine to build something like what you're describing. These scripts are provided with a "Binding" that gives the script access to the HttpRequest and HttpResponse.
- lokedhs 7y agoI've used Common Lisp for this purpose. You get instant results without even having to reload. You can simply compile a single function while the code is running. I did a talk about this a few years back: https://www.youtube.com/watch?v=bl8jQ2wRh6k https://www.youtube.com/watch?v=bl8jQ2wRh6k