Hacker News new | ask | show | jobs
by gridmaths 4768 days ago
Can we compare PHP and node.js without it appearing as bashing ?

Im critical of PHP, my impression is it has no advantages apart from being more established. I've written code in both, to do similar tasks so feel I can compare them fairly.

My impression is PHP is more messy, with no real advantages to balance out what I would call 'legacy syntax cruft'. I really see node.js as a natural evolution from PHP.

To be fair, its well known that Javascript has some bad parts, some of its own legacy syntax crud, but you can write in a modern style that avoids most of that - so I think its an order of magnitude less cruft in practice than PHP, and small code size reflects this assertion.

I know modern PHP in OO style can be more readable, more amenable to programming in the large than old-skool top-to-bottom PHP... but I think the lispy functional features of Javascript lead to more readable 'code as thought' : map/reduce, passing functions in variables in practice is more useful to me than OO is, it leads to simpler code.

A lot of people feel emotional attachment to PHP, if you love it use it. But all the things I do love about PHP, I love more about the node.js/javascript combination. You might like it too.

2 comments

Sure we can. And Node.js definitely shows off some functionality that PHP should be jealous of (referring to that 'PHP is meant to die' article). I am probably going to experience it myself soon when tapping into Node.js territoriers. But it's not a proper comparison if you put plain old basic PHP up against an ExpressJS project instead of using a current PHP framework such as Laravel 4.
Having worked with both php and javascript I can definitely see how the syntax alone with node.js would be a breath of fresh air to someone used to PHP. Modern frameworks like Laravel do a lot of good to smooth things out but PHP's implementation of anonymous functions, for instance, feels like such a kludge compared to javascript.