Subscribe / Unsubscribe Enewsletters | Login | Register

Pencil Banner

PHP vs. Node.js: An epic battle for developer mind share

Peter Wayner | Jan. 13, 2015
Here's how the old guard and upstart darling of the server-side Web stack up against each other.

Where PHP wins: SQL
PHP was built to co-exist with MySQL and its many variants, like MariaDB. If MySQL isn't exactly right, there are other great SQL databases from Oracle and Microsoft. Your code can switch with a few changes to your queries. The vast SQL world doesn't end at its borders. Some of the most stable, well-developed code will interface with an SQL database, meaning all that power can also be easily integrated into a PHP project. It may not be one perfect, happy family, but it's a big one.

Where Node.js wins: JSON
If you must have access to SQL, Node.js has libraries to do that. But Node.js also speaks JSON, the lingua franca for interacting with many of the latest NoSQL databases. That's not to say you can't get JSON libraries for your PHP stack, but there's something fluid about the simplicity of working with JSON when using JavaScript. It's one syntax from browser to Web server to database. The colons and the curly brackets work the same way everywhere. That alone will save you from hours of frustration.

Where PHP wins: Speed of coding
For most developers, writing PHP for Web apps feels faster: no compilers, no deployment, no JAR files or preprocessors -- just your favorite editor and some PHP files in a directory. Your mileage will vary, but when it comes to banging a project together quickly, PHP is a good tool to use.

Where Node.js wins: Raw speed
Writing JavaScript code is a bit harder when you're counting curly brackets and parentheses, but when it's done, your Node.js code can fly. The callback mechanism is brilliant because it saves you from juggling the threads. The core is well-built and designed to do all that for you. Isn't that what everyone wants?

 

Previous Page  1  2  3 

Sign up for Computerworld eNewsletters.