3 ms·
I maintain a mountain of PHP. What attracts me to JavaScript is its syntax: PHP: $fruit = array('apple', 'banana', 'orange'); $fruit_colors = array(
by combatentropy 9y ago
I maintain a mountain of PHP. What attracts me to JavaScript is its syntax:
PHP:
$fruit = array('apple', 'banana', 'orange');
$fruit_colors = array(
'apple' => 'red',
'banana' => 'yellow',
'orange' => 'orange'
);
JavaScript:
var fruits = [ 'apple', 'banana', 'orange' ],
fruit_colors = {
apple: 'red',
banana: 'yellow',
oranage: 'orange'
};
That's like 20,000 fewer keystrokes and much easier to read. My favorite new feature in PHP is the short array syntax.
Even those less minimalistic than me, I think the draw to Node is the language, the consistency of having the same language front and back.
Much ado is made about which one is faster. But I would say roughly 99% of web apps are CRUD apps, with a few users per hour, and the bottleneck would be the database anyway.
For me what PHP has going for it is my familiarity with it. Plus, despite all the nitpicking articles, it is rock solid, especially compared to Node. And compared to Node, PHP is a hyper-organized library of everything you need, just an arm-length away.
- jbrooksuk 9y agoPHP has had square brackets for arrays since 5.4.0 $array = []
- dagn 9y agoA few months ago I was tasked with porting an internally used Node.js script to PHP 5.6. The code made heavy use of nested async callbacks and other patterns frequently only seen in Javascript codebases. I thought I'd have to rewrite most of it from scratch, but the PHP code ended up nearly identical to the original Javascript. Line-for-line, ignoring minor syntactical differences (like the $ in vars), these two ~400 line scripts ended up being 98% identical. Anonymous functions, closures, async calls, syntax short-hands... PHP has it all.