Node.js vs PHP – which solution adds more value to early stage startups?

The background story

Long, long time ago in a galaxy far, far away… JavaScript and PHP ruled the internet together. PHP handled server-side tasks and JS managed details in the browser. This non-aggression pact supported pillars of the internet and lasted for years. Everything changed when Node.js emerged, and suddenly, there was no longer need for the sole usage of PHP in building next generation of server stacks. JavaScript everywhere. Long live the JavaScript king, ruling now both domains, including the client-side.

From that point on, the previous comrades in arms constantly gear up and improve themselves, as if engaged in an endless war for the ultimate power over the internet. To be precise, PHP released in 1995 is like an older brother to Node.js, which was released in 2009. For years on, they both served mostly as server-side scripting languages in developing web-based applications. PHP was primarily a quite basic programming language, with its first assignments being updating HTML pages with a Perl-like syntax. Time passed, and more advanced features, like the object-oriented programming model and package management, were added. Node.js spawned from the well-established JavaScript and became a new development platform, powered by the V8 JS engine. Recently, Node.js started turning into a desktop application development platform.

Is there a possibility to clearly state which one is better? Both technologies have their advantages and disadvantages and are to a far extent interchangeable. Was everything already said in the which is better debate, or can we come to any new conclusions? In this article, we’ll take a look at this clash of titans and find out which solution may be more benefitting for an early stage startup.

To Node or to PHP?

Node.js

Pros:

  • easy to learn for JavaScript developers due to similar syntax
  • fast, thanks to the innovative Chrome V8 JavaScript Engine developed by The Chromium Project
  • a good framework for real-time apps (chats, games) due to the event loop and sufficient service of multiple requests
  • has a wide range of hosting options and built-in server support
  • efficient reusability of code due to a single syntax for client and server sides on the website
  • great choice of open-source scripts, libraries and applications
  • work with large files made easier due to stream modules

Cons:

  • lack of maturity
  • potentially hard to comprehend without an in-depth knowledge of JavaScript
  • difficulties in handling relational databases

Although Node.js is a younger technology and is still less commonly used than PHP, it is already used by big enterprises like eBay, Netflix and Yahoo, as well as a range of successful startups, including Trello. Thanks to the V8 engine and Just-in-Time compilation, it can transform JS into native code, boosting the development process, also, being a versatile solution is usable on a wide range of devices. Node is great for developing highly scalable and interactive server-side solutions. As a real-time web development solution, Node makes developing chatbots or instant messenger easy. Many startups choose Node over monolithic stacks (like PHP) mostly because of the ability to scale Node apps on multi-core systems, the significantly higher speed obtained due to the event callback mechanism and the possibility to use it as a multi-threaded application. There is a variety of ready-to-use packages written for the Node.js so we can easily connect to almost any service or database, but most common Node integration dialect is JSON, which speaks well with the NoSQL databases. The community behind Node.js is large and getting bigger each day. The bigger the community gets, the easier it is to get support.

PHP

Pros:

  • mature (24 years on the market) but still actively developed
  • there are many out-of-the-box solutions well known among the internet, like the prominent WordPress blogging platform, CMS like Joomla and CMF like Drupal
  • is supported by most internet hosting services, especially shared hostings
  • an interpreted language, meaning no compilation is required
  • running nearly 80% of the internet
  • wide choice of free frameworks, libraries and packages

 

Cons:

  • requires extensions (CGI executable) for a web server to handle PHP code
  • threaded execution
  • stateless nature
  • interpreted and not compiled language (combined with the stateless nature means that application needs to be built and ran each time there is a need to handle the request)

 

PHP is a scripting language widely used for server-side web development, with a strong emphasis on compatibility with relational databases like MSSQL, MySQL, Oracle (thanks to PDO – built in SPL library to handle databases). We could say that PHP is great in the working with strings, filling arrays and reading files – all basic operation that every server-side application does while handling the incoming request. The speed of coding in PHP is related to lack of compilers, preprocessors or need to build JAR files. PHP code can be mixed directly with HTML (but we strongly do not recommend such way of doing web applications). The language itself is accessible, available for free and independent from managing companies. Perceived as a better solution for medium-sized projects, especially content management applications or online shops. PHP community is extensive and provides thorough guidance due to a long development era, making the search for solutions almost pain-free.

And the winner is…?

At this moment, believing that Node.js is already established enough to replace PHP may be a bit of a stretch, but all the signs indicate that in the future it may become the ultimate solution for backend development. Current PHP 7.2 is a worthy opponent and won’t go down lightly, however, Stack Overflow tag trends show its slow decline. Node.js is more commonly used by startups, as the CodingVC report shows. The current trend for RTA (real-time applications), interacting with users in the immediate sense, might be the field where PHP loses to Node.js in the long term. Node has everything that an early startup needs, using the event-driven, object-oriented model that enables best performance in eg. e-commerce websites and other real-time mobile or web applications.


Taking all of the above into account, you may still not be sure what will be better for your projects. If the Node.js/PHP fight is too aligned, and the benchmarks do not give you a simple answer, think in the bigger picture. If the flexible simplicity of the MEAN (MongoDB, ExpressJS, AngularJS and Node.js) stack works for you, go with the newer solution. If you happen to find more adequate technologies in the LAMP (Linux, Apache, MySQL and PHP) stack, pick the more seasoned technology. After all, the choice needs to be done to select the adequate tool to solve certain problems and not based on a subjective opinion on the “best” technology. When in doubt what technology will be most suitable for your startup, consider workshops that will help find the right stack.

Need a hand with Node.js development?
What types of applications can you build with Node.js?

Node.js is a JavaScript runtime environment and it’s built on Chrome’s V8 JS engine. Is known for its efficiency and scalability. Netflix, Uber, LinkedIn, Trello, PayPal, and even NASA (among others) are already enjoying its benefits. Read more

Famous apps built with Node.js

Node.js is gaining more and more popularity.Node is most commonly used in web app development, with 85% of respondents indicating they use it for this type of work. 43% of respondents indicate they use Node for enterprise applications. Read more

Why Poland is one of the best places to outsource your software development

Eastern Europe provides five of the top 20 countries listed in AT Kearney’s 2016 Global Services Location, and it’s becoming one of the most attractive destinations for companies which want to outsource their software development. Read more

Share the article with your friends!

Written by:

Copywriter and part-time bat-girl. Working with words, ensuring that the software house speaks human, not only tech. Writer, baker, costumes maker.