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.
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.
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/
[2] https://www.ecma-international.org/ecma-262/7.0/index.html#s...
[3] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
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).
const/let is the way of doing javascript, setting global will raise an error (click "run with js" http://jsbin.com/hogegikipo/edit?html,console,output). This is true for ES5 strict mode, ES2015 modules and anything you will transpile from ES2015 modules.
The functional stuff was weird for a while but just keeps growing on me.
In addition, while you'd have a hard time paying me to code PHP, a huge percentage of PHP devs like the language.
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.