4 ms·
I love Python. But for web projects, PHP has a massive upside over Python: You don't need to restart your application when you change the code. I know people r
by TekMol 5y ago
I love Python. But for web projects, PHP has a massive upside over Python: You don't need to restart your application when you change the code.
I know people run monitoring scripts on their development systems that automatically restart Apache or whatever server they use every time they change a line of code. Still this is a cludge.
Development in PHP is:
- Change a line of code
- Alt+Tab to switch to Firefox
- F5 and see the result
So I still enjoy PHP development more when it comes to the web. Even though PHP's namespaces are crap compared to Python's module system.
- foxfluff 5y agoRight now I have gunicorn running with --reload. Change a line of code, refresh/rerun client and see the result.
- ktpsns 5y agoLive/hot reloading is a thing in various web frameworks and supported by various ecosystems, from Java over Python up to Nodejs. Funnily, development with hot reloading systems is: - Change a line of code - Alt+Tab to switch to Firefox - No need to press F5 because site already updated.
- berkes 5y agoAnd so does Rails and Sinatra in Ruby land. I have encountered very few development servers that lacked hot-reloading in decades. Many such stacks will even inject some JS or headers to automatically refresh the browser for you on detected changes. I think OP may have an outdated or skewed experience of web-development stacks. Where PHP through apache+mod_php had "instant code refresh" back in early 2000s, and other stacks (Beans, CGI, etc) required a manual reboot everytime you'd want to check your changes in a browser. But this hasn't been true since Rails was released in 2004~5. Ironically the most difficult one I recently encoutered was a PHP-FPM with APC, that required a "manually" restart of nginx and php-fpm in the right order after every code change. But this really is not suited as "development" server, as shown in this anecdotal issue.
- thraxil 5y ago> and other stacks (Beans, CGI, etc) required a manual reboot Hey, now! Don't go lumping CGI in with those. :) CGI had the same "instant code refresh" as PHP since before PHP even existed. It even had a better "shared nothing" approach since you were guaranteed to start an entirely new process for every request.
- berkes 5y agoSorry. CGI is a bit unfair. I recall it refreshed fine with Perl, but CGI wrapping compiled languages (I did some C webdev back then) was a bit more involved. It's vague, but IIRC, that had more to do with the compiler than the CGI, indeed.
- thraxil 5y agoFair. My main experience with CGI was bash, Perl, and Python so I tend to think of compiled languages in a completely different context.
- IshKebab 5y agoI hate PHP too but you have to admit that its execution model is way simpler and more reliable than any hot reloading system. In my experience hot reload saves you a bunch of time when it's working, and then costs you the same amount of time when it randomly breaks and you spend half an hour getting confused about what the hell is going on before realising that a simple refresh fixes it. The only really good hot reload system I've seen is Flutter's.
- thraxil 5y agoYeah, I never have to manually restart my Django development server though. When I hit save in my editor, the runserver process restarts itself. At this point, I don't even know off the top of my head which part of the stack is doing the watching and restarting. It's just not something I've had to think about in like a decade.
- sergiomattei 5y agoElixir doesn’t even blink. Make a change in a file and it’s immediately live, without even restarting the process.
- heavenlyblue 5y agoIt's even more fun when you upload your code directly to an FTP server and some of the customers load their page to see hundreds of lines of stack traces because when the script was executed it only saw half of the uploaded files at the same time.
- streamofdigits 5y agothe real advantage of php seems to me is not in "generic" web projects that start from scratch but the very popular domain specific frameworks that have been build on php (blogs, wikis, etc) while python is gaining ground on such specialized areas (e.g things build on top of django) it is still very far behind in terms of adoption
- hk__2 5y ago> PHP has a massive upside over Python: You don't need to restart your application when you change the code. I see this as a downside: hot-reloading is something that should be part of your developer toolbox, not a feature of the language runtime itself. Otherwise, deployments are harder because by the time you’ve completely uploaded all your updated PHP files, the server already started to execute the code in the ones uploaded so far. Also, I hope you have a caching mechanism otherwise this "read the code from disk every time you want to execute it" must be a performance nightmare.
- moojd 5y agoNone of this is a problem in modern PHP. In production you flip a flag to turn on operation caching. You can also tell it to preload all of your code. You can then deploy the app and then clear the cache once all the files are there.
- tomc1985 5y agoIs there an implementation out there of hot reload that doesn't simply automate hitting the refresh key in the browser? Because if not then this vaunted 'hot-reload' feature is a joke. Some of the JS kiddos from my previous org were pushing this crap on me from some random React module that I can't remember and it was terrible. We had to run a second server that proxied our personal dev webserver just so the thing could send window.reload()
- hk__2 5y ago> Is there an implementation out there of hot reload that doesn't simply automate hitting the refresh key in the browser? Yes, there are some setups where the code reloads but the state stays there. I’ve worked like this with Clojure/ClojureScript in the past; for example if you’re working on a pop-in that appears after a click on a button, with window.reload()-based hot reloads you have to click on the button each time you reload the code, whereas with a state-preserving hot reload you don’t. It’s very useful on SPAs.
- black3r 5y agoI first develop backend APIs using TDD without even opening a browser. Then I develop frontend using React/Vue with hot reload and don't even need to press F5.
- phplovesong 5y agoThats a solved problem, even for non web related programming. I save in vim, and autorun my binary (multiple languages) in under 1 sec, and see the result an a vim split. For web dev, there are countless "watchers" that auto restart on a file change. I pick any other language then PHP, on any day. Its a hot mess, and even now in PHP8.X multiple things are still broken (and will probably always be), its just a sad language to work with.
- lvass 5y agoDoes it work like Erlang: The movie, though? I.e. change the code without losing any connection or state.