Kornea Bauble

JavaScript vs PHP

I have yet to work with Node.js. When it first came out, I thought it was philosophically brilliant: Since we're stuck using JavaScript in the browser anyway, we might as well use JavaScript consistently. I now argue the opposite like so: we don't *have* to be stuck with JavaScript on the server-side. JavaScript was an initially flawed language intended to be used for client-side scripting, and it has been evolving at a snail's pace. I had to support IE7 as recently as 2015. JavaScript vices: ambigous '+' operator; no multiline strings PHP was an initially flawed language written specifically for server-side scripting, and it has been evolving rapidly ever since. Modern PHP is a phenomenal language for its purpose, and its basic syntax is the same as JavaScript (it's also inspired by some features of Linux shell scripting such as variable names starting with $). PHP virtues: associative arrays, type hints, array destructuring, interfaces, traits, and other tools of semantic clarity In an MVC pattern, I find it best to use PHP for models and controllers, and JavaScript for views. There is no way to make a language better at server-side programming than JavaScript, without making it different from JavaScript. That's basically what PHP is. If the first web programming language to ever come out were Node.js, PHP would be hailed as the more modern approach, because it makes it so we don't have to be stuck with JavaScript on the server-side. Because PHP syntax is similar to JavaScript, it is easier for a JavaScript developer to pick up PHP than an unrelated language like Python and Golang. So the argument that using Node.js means one less language to learn is an exaggeration. It's more accurate to say that using Node.js or PHP means one less language to learn, compared to using Python or Golang.
Copyright Val Kornea