5 ms·
Why hasn't node replaced PHP yet?
by AzzieElbab 8y ago
Why hasn't node replaced PHP yet?
- dcwca 8y agoWhy haven’t electric cars replaced gasoline?
- 2trill2spill 8y agowhy would or should it?
- AzzieElbab 8y agoOne can argue that PHP is the least suitable language to write web servers in, no standard async or multithreading, tones of leaks, and so on. Node asynchronous model is quirky but given js world's "isomorphism" it should have squeezed PHP out of existence by now
- notamy 8y ago> One can argue that PHP is the least suitable language to write web servers in Of course, because you don't write a web server in PHP. You put it behind nginx or apache and those can fork off PHP processes (or you use FPM, or etc.) to do everything for you.
- AzzieElbab 8y agoOh sure, and the only reason one would do this is to keep Aws bills up to Amazon shareholders expectations
- bpicolo 8y agoPHP is roughly the hardest language to experience the effects of memory leaks in because of it's one process per request model.
- goatlover 8y agoYou don't write web servers in JS, either. You use Node.
- hajile 8y agoInertia. It would cost trillions to move all the PHP to JS. In addition, while you'd have a hard time paying me to code PHP, a huge percentage of PHP devs like the language.
- brianmurphy 8y agoSpeaking for myself, I have 20 years of C like language experience and I can't stand the scoping rules or functional nature of javascript. This is why I like PHP. It comes natural when switching between C, bourne shell, perl and PHP. Throw in the ever changing frameworks a casual user encounters and I want to avoid javascript at all costs.
- elyobo 8y agoMmmm, I have a similar background (the C was long ago, the PHP not so long) but love the scoping rules and functional nature. I think that the C background (declaring variables up the top of a function) helped avoid some of the JS pitfalls, and I find the block scoping in JS to be convenient at times, whereas PHP's leaks things in ways that can bite you sometimes (e.g. a for loop in PHP would leak both the iterator variables and variables defined within it, while they wouldn't in JS). The functional stuff was weird for a while but just keeps growing on me.
- goatlover 8y agoWhat's the wordpress/drupal/laravel equivalents in Node?
- dtrizzle 8y agoghost.js
- lucb1e 8y agoI don't like Javascript as a language. Everything from OOP to imports feel hacked in rather than having been supported by the language itself. One can't even add 0.1 and 0.2 together and get what you'd expect. Variable definitions are global scoped by default, semicolons can randomly be omitted, etc. There are just so many things about the language that feel hacky or unpolished. So it's fast these days... great? There's more that I seek for in a language than just speed. PHP7 and Pypy also do a pretty good job, and one can always offload the heavy lifting to some compiled code if it's really that important to squeeze the last few percent of performance out. The only thing unique to JS (afaik) that I really like is addressing dictionary keys as object properties (`a={'test':512}; console.log(a.test);` instead of having to do `console.log(a['test']);`). I'm not sure why that is so oddly satisfying, but it is.
- b2ccb2 8y ago> One can't even add 0.1 and 0.2 together and get what you'd expect. That's floating point math, and persists in many languages [1]. > Variable definitions are global scoped by default, semicolons can randomly be omitted, etc. Nothing random about it, automatic semicolon insertion is well defined/documented [2]. Also let [3] is your scoping friend. [1] https://0.30000000000000004.com/ https://0.30000000000000004.com/ [2] https://www.ecma-international.org/ecma-262/7.0/index.html#sec-rules-of-automatic-semicolon-insertion https://www.ecma-international.org/ecma-262/7.0/index.html#s... [3] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- lucb1e 8y ago> Nothing random about it, automatic semicolon insertion is well defined/documented Figured someone would say that. Yes, of course it's not random: it's a computer, it follows the same instructions every time. What I meant, of course, is that it isn't logical. You can't guess it without having to check the spec. In bash you know that a newline is as good as a semicolon, in C you know you always need a semicolon, and in Python you know you never need it. In JS it's somewhere in between. Reading that spec, it's when the next line would have syntax that is illegal if it were a continuation... so you have to do JS simulation in your head to check if your code could, perhaps, make sense as a line continuation. So I guess you just always have to do it. I'm not saying it's a major issue and this is the one reason I don't use it, but similar to how people criticize PHP for having inconsistent function names (which is also not a bug or broken), it would have been nice if it weren't the case. > let [3] is your scoping friend It's not about it being possible, it's that global scoped default is just asking for abuse of the global scope. Even PHP doesn't do that, and PHP is really made for quick and dirty web development (or at least it used to be, so it supports many things that make that possible).
- crooked-v 8y agoBecause there aren't a bajillion turnkey Node servers available that require zero actual technical knowledge beyond an FTP client (and maybe not even that).
- eksemplar 8y agoHasn’t it? It’s the most utilized language on the web. If you’re asking why PHP hasn’t died...Well, because it’s still useful. In the real world you don’t change your tech just because something better comes along because it’s tremendously expensive to do so. That’s why cobol is still around, and if you want an example of something even worse, it’s also why you still find companies using classic ASP and so on. And PHP isn’t really that bad. Parable is tremendously productive.