Why JavaScript on the server

?

Replace PHP with JavaScript, are there any good reasons for this?

Same language on server and client

It's not just the simplicity or ease of learning. It is a fact that the transition from one language to another makes it easier to make mistakes, but the advantage of one language goes beyond. This allows you to transfer processing to a client or server selection. Same functions with same libraries .
You can put code on the client to ease the load on the server, since the client has unused resources. On the contrary, we will pass the code to the server to protect the source if it is the owner, or to reduce the download time by sending only the results to the client.

Evolution des voitures Sedan: Tucker, Cadillac, Tesla pour illustrer le passage de PHP à JavaScript

Performance (compare Node.js and PHP)

JavaScript and PHP are dynamic and interpreted languages. But the former has a very successful JIT compiler. I don't need to run tests to prove it, others have already done so, and research has shown that Node.js can be fifty times faster than PHP (SHIFT 06/2014: the site is now closed). That's fine, JIT is infinitely faster.
The gap is certainly narrowing with Facebook's HHVM, a JIT virtual machine. But this is not PHP, which can be found on all servers.

Unrestricted libraries without compilation

One advantage is the number of libraries that can be included in a project, especially on GitHub. They can be written in any language (export commands are added) and are associated with JS with the require command.
PHP also allows you to bind libraries written in C, but you need to enable extensions in the INI file, which is redundant for distribution to non-programmers.

Dynamic Web Application

If you want to use a content manager for a portal site or blog, PHP remains indispensable. JS has managers, but they are not at Wordpress or Drupal level. On the other hand, there are frameworks for the online application made for HTML. For example, Angular, Ember, which offer two-way data binding.
The difference is that CMS treats HTML as code to create, and frameworks as an interface with which to interact.
Thus, while CMS in PHP is suitable for editorial content, for the original application with new features, the framework gives more freedom.
But CMS in JavaScript will evolve in turn.

Offline and mobile

I've never seen a Wordpress or Joomla site go offline. In theory, a PHP program can run on a client computer, as Java does with its applets (this is not a good link), but it assumes a PHP interpreter. There is no such restriction for JS, it is present on all posts in the browser.
Offline mode is especially welcome on mobile devices to avoid time-consuming loading during each session, as well as save limited bandwidth on these devices.

In conclusion, the LAMP model (Linux, Apache, MySQL, PHP) was developed and popularized for the era of desktop computers and software and a network of static pages, supplemented, of course, by Ajax, but this is just a dynamic rustine on a static system.
This is not necessarily optimal for modern devices, mobile devices, and online offline applications.

Updated May 11, 2013: Changes to the paragraph about libraries. As a result of user comments on the English version of the article, I need to clarify something. PHP had a dl command to enable external libraries, which was removed along with version 5.3. Includes or requires that other PHP sources be included in the current file.
The require command from Node.js allows you to associate a program with external libraries in JS or another language, this does not compare .

May 13, 2013 update: After reading readers' comments (in English and HN), I realize that JS's real advantage over PHP is not in the list of features, but in the experience they provide. I made some online PHP apps (though we think) and now regret not executing them in JS with Node because things would have been much easier and the result better. This was the reason for this article, and it requires others.

The second part: CMS in JavaScript on the server. Comparison of Ghost (JavaScript) and Worpdress (PHP ).