Let’s distinguish between PHP and Node.js. PHP is a programming language that powers most of the websites on the world wide web. That’s 244 million websites  or 81.7% of websites that use server-side scripting ! Note that PHP is only one of the components of the AMP stack (Apache-MySQL-PHP), a suite of software that collectively provide an environment for web services. Node.js, on the other hand, is a run-time environment. The table below (Figure 1) somewhat illustrates the ‘layers’ of a web application based in either PHP or Node.js.
|PHP libraries||Node.js||NPM libraries|
|Apache / Nginx / Lighttpd||Google V8 Engine|
|Operating system on host server (Linux, Windows, etc.)|
PHP – The All-Time Favorite?
PHP is built directly into the web server . In only a handful of lines of code, you read data, process data, and display the results as part of a dynamically generated web page. PHP is the most popular and widely used platform for a number of reasons; you could write a simple procedural program in PHP with a few lines of code (no strong type checking), or build an enterprise-level application with all the properties of a C-style object-oriented language. In other words, it is very flexible, scalable, and the entry barrier is very low. It is also cheaper to produce web applications in PHP. There are plenty of hosting solutions, content management systems, and open source frameworks & libraries available for applications written in PHP.
Rasmus Lerdorf, the creator of PHP, started work on the language because he wanted to spend less time writing CGI programs for web services [5, 6]. He used to write his CGI programs in C and Perl, and these programs also contained HTML code, and writing all this code made the work cumbersome. Apparently, this was the structure of an early version of PHP (Figure 2):
|PHP (binary executables)||C program for HTML templating|
|C library for CGI|
|NCSA HTTPd web server|
Because PHP is built on C and PERL, it can leverage the powerful capabilities it inherits. However, this is also why the language is so syntactically inconsistent. This language inconsistency has drawn a lot of criticism, and it’s an issue Lerdorf himself is aware of. He does, however, make the fair argument that PHP maintains great documentation .
Node.js – The Dark Horse
The motivation for Node.js, as described by its creator Ryan Dahl, was to make web servers faster, less resource intensive, and provide improved file IO capabilities . In fact, it was the Flickr file uploader and its RESTful progress bar that inspired Dahl to create Node.js . Dahl believed that because some web servers, the likes of which Ruby and PHP run on, were inefficient because they used separate threads for every task, and requests were blocked until the server responded (Figure 3). Node.js is different than PHP in that it uses only a single thread to process all of the server requests (Figure 4) and is non-IO blocking – and this is the fundamental reason why Node.js performs better than PHP virtually in all server-side operations .
Although small in size, Node.js is modular and can include components that allow it to perform tasks much like PHP; listening to HTTP and TCP ports, making server requests, and accessing file systems . The Node Package Manager (NPM) includes modules for database connections and operations (Express.js, for example).
Figure 4 
- Node.js is compiled with Just-in-time approach. In Just-in-time compilation, there is a slight delay in the initial execution of a program.
- B. Terkaly, & R. Villalobos, 2013, Azure Insider – Real-World Scenarios for Node.js in Microsoft Azure, Retrieved from
- phxtagsoup’s channel, 2011, History of Node.js, Retrieved from https://www.youtube.com/watch?v=SAc0vQCC6UQ
- PHP usage stats, Retrieved from
- Usage of server-side programming languages for websites, Retrieved from http://w3techs.com/technologies/overview/programming_language/all
- fwdays, PHP Frameworks Day 2013, Retrieved from https://www.youtube.com/watch?v=anr7DQnMMs0
- ieeeComputerSociety, Computing Conversations: Rasmus Lerdorf Interview on Creating PHP, 2012, Retrieved from https://www.youtube.com/watch?v=YIGRXEzjE6c
- PHPNW, PHPNW14: Davey Shafik – PHP: Under the Hood, Retrieved from https://www.youtube.com/watch?v=CYfpfAt0pU8
- P. Simons, & R. Babel, 2002, FastCGI — The Forgotten Treasure, Retrieved from http://www.nongnu.org/fastcgi/
- I. K. Chaniotis, K. D. Kyriakou, & N. D. Tselikas, 2014, Is Node.js a viable option for building modern web applications? A performance evaluation study