3 ms·
We keep on making fun of php, but it had this problem solved in the 90s. Hit F5 in the browser, get the latest version of your software. No waiting 30s for a re
by nikanj 4y ago
We keep on making fun of php, but it had this problem solved in the 90s. Hit F5 in the browser, get the latest version of your software. No waiting 30s for a rebuild, no stale versions in caches, no headaches.
- tonetheman 4y agoPHP was and still is great. Make a change and hit refresh. Simple and easy.
- cutler 4y agoThe Clojure repl allows you to eval changes within a live application. Try that in PHP and I don't think you'll get very far.
- cess11 4y agoWhat do you mean by "live application"? Is a PHP application under nginx "live" or not? If it is "live", changing a file will immediately be reflected in the application on the next "eval", i.e. require or execution by the interpreter.
- klibertp 4y agoNope. That's not what the GP means. I'm not sure how it works currently with PHP, but what was meant was a long-running process that can change its behavior/be updated by evaluating new code without ever being restarted. Think of it like this: you have a page that never stops rendering, ie. you send some HTML but instead of finishing processing, you go into an infinite loop. "Live" system, in that situation, would still be updatable - you could change the body of the loop and make it produce another bit of HTML, without reloading the page. Again, I'm sure modern PHP was already optimized far from the initial "execute all the code on each request" model, but unless there's a long-running process that can be updated in memory without restart (and I don't mean doing `exec` on itself, that's cheating!) - it's not "live" by this definition. It's not that clear-cut a distinction, either. For example Elixir and Phoenix are definitely live, in that there's a process that responds to requests on one hand, and can be updated without restarting it on the other - but page reload is still required in many cases, even if triggered via websocket. This idea of liveness predates both PHP and the Web by 2 decades at least and comes from Lisp and Smalltalk. It's been incorporated by Erlang and later Elixir, and by Clojure. Other than that, some embedded scripting languages support this kind of development, for example Awesome WM is scripted in Lua, and you can evaluate arbitrary Lua code while it's running. Emacs is another system that is meant to be used this way. Good to read: https://gbracha.blogspot.com/2020/01/the-build-is-always-broken.html https://gbracha.blogspot.com/2020/01/the-build-is-always-bro...
- mm007emko 4y agoI upvoted your comment but I only partially agree. PHP is great in some ways and totally atrocious in other ways. It put bread on my table in the 2000s but I am not looking back. The language is horribly designed. Writing AJAX calls before Google Chrome was even released (let alone its V8 Engine which made JavaScript fast) was no fun either. Any non-trivial web app we developed was slow (everything had to start from scratch with each request) and flooded with a couple of layers of caching which often didn't get invalidated properly. Now I am a purely backend&desktop developer, I leave web frontends to people who are willing to live in the JavaScript world where if no big framework is released every 5 minutes you have an impression that the Earth stopped spinning. I learnt the basics of React.js the other year and it's a far cry from what we had 20 years ago. ClojureScript+React even with its difficulties must be an ivory tower of modern web frontend development. I want to remember the good parts of PHP, frameworks Nette and Symfony with nostalgia. But I never want to re-live it again. I mean Request/Response websites with a bit of AJAX still work today, I even develop one as a side project since I am part-time involved in academia (neural networks & nature-inspired algorithms simulator, in Common Lisp with cl-who, Parenscript and a couple of custom components based on HTML5 Canvas). But modern development? When you need to keep up with the latest trends? No way it can work.
- freedomben 4y agoModern PHP can be like the REPL experience though depending on situation. Half the time the new code loads, the other half the time it serves from cache (opcode cache?). I'm not a PHP person so I'm probably doing something dumb, but I've found that inserting a `systemctl restart php-fpm.service nginx.server` into my test workflow avoids that problem.
- cess11 4y agoThese days we also have psysh.org which is a pretty sweet interactive PHP shell. Doesn't have the sophisticated halting and rewinding and redefining that Common Lisp and other image based REPL:s do, but it allows for very rapid development in a similar way.
- iLemming 4y ago> Hit F5 in the browser, get the latest version of your software. What about the state though? If I'm building a sophisticated app, let's say an e-commerce thing, imagine having to develop a shopping cart experience, where a user has to make multiple choices before getting to the shopping cart view. Every time you hit F5, you'd have to click a bunch of buttons, fill out fields, etc. Or you're gonna have to write a script that takes you there and restores the state, which is still time-consuming and annoying to have to do. With Clojurescript, I can change things in the code, eval it and the change would be reflected in the app immediately, without having to reload the entire app. > it had this problem solved in the 90s We weren't building many complex web apps back in the 90s, so the problems associated with hot-reloading weren't so apparent back then.
- cess11 4y agoYou could put some state in the session to keep it persistent across page reloads and get a result similar to continuations or however you're keeping that state on the JVM.
- agumonkey 4y agophp exchanged restart time for debugging time