What Node.js means for WordPress

Node.js_graphic_Dave_s[1]

(Cross-posted from my blog on http://evangelists.intel.com)

If you are a fan of PHP for developing web applications (as I am), you could feel the world shift a bit as it was announced that WordPress was switching from PHP to Node.js. 

Don't think of WordPress as a blog engine. Think of it as an open source Content Management System (CMS). As such, it provides the code for a significant part of the web. I've heard that anywhere between 25 and 30% of the world's websites are powered by WordPress. So a serious change to WordPress means a significant change to the web.

WordPress also sets the standard for PHP performance. There is an open source benchmark available for different releases of WordPress which works for both PHP and Facebook's open source PHP alternative, HHVM. The PHP and HHVM open source communities compete on who has the best performance on this WordPress benchmark. It's not the only comparison, but it's one that gets noticed.

Upon further reading it turns out that only the WordPress administration interface has been changed to Node.js from PHP.  The WordPress core engine remains in PHP and is unlikely to change soon.  This is because of a rich ecosystem of WordPress plug-ins, which have maintained compatibility for something like five years.

What does Node.js have going for it which makes it attractive for WordPress as an alternative to PHP? I talked with our Node.js lead, Uttam Pawar, who has worked on both PHP and Node and he gave up a list of advantages:

  • Pages are rendered on the client rather than the server. This is particularly noticeable for an interactive page like the administration interface of WordPress. So as one clicks around in the web interface, you don't need a network round trip with the server to get a response to clicks.
  • Code is cached on the client.  Communication between client and server can be with JSON objects. This means that on a slow network connection you should see better performance. I'm writing this blog entry on an airplane with a typically slow wifi connection. However the WordPress.com administration interface is noticeably faster than it would have been otherwise.
  • Server code in Node.js is written in JavaScript. This means that code on the server primarily takes advantage of the V8 JavaScript engine, which has been shepherded very well by Google and the community. Significant community contributions by Intel and others have improved V8's performance which benefits Node.js users. Note that most of Intel's work has focused on client JavaScript performance. Our studies have shown some interesting opportunities in the server space for V8, which Intel is investing in now.
  • The new Node.js WordPress code can take advantage of the V8 JIT. This "Just In Time" compiler https://software.intel.com/en-us/blogs/2015/09/10/the-jitter-conundrum-just-in-time-for-your-traffic-jam  means that JavaScript code which is run frequently is translated into native code. Interpreted languages, such as Python, Java, PHP and JavaScript will typically run much faster if so-called "hot" code paths are translated into native instructions and executed. The open source HHVM interpreter for the PHP language also has a JIT which benefits performance, so this is not unique to Node.js.
  • Users still get a choice of implementations. One of the coolest aspects of WordPress (and a number of other major PHP web apps) is that you can choose from more than one implementation of PHP to run it. Facebook has developed HHVM to run its massively popular website, and WordPress runs on HHVM as well as the original PHP project. Both are open source and actively maintained and developed. (And we are huge fans of both).  Microsoft recently submitted a patch to Node to enable it to run Chakra, their competing JavaScript engine.  Although the patch is frankly enormous (over 14,000 lines!), once it goes through the review process it will enable a second choice for Node users

Will the core of WordPress ever move from PHP to Node.js? They would certainly need to figure out a way to support the WordPress plugin legacy. But a future RESTful API for the WordPress core might constitute a further move away from PHP.

For more complete information about compiler optimizations, see our Optimization Notice.

3 comments

Top
erwin s.'s picture

yes I totally agree about this integration . still use wordpress , because I think this platform has been very frienly . Any application that created the system , we have to adjust the demand and the development of market segments

David S. (Intel)'s picture

You make a very good point - the internet is all about rapid innovation. Anyone stuck in the old paradigm of software development methodology will be left behind as their competitors race ahead. 

That said, I like the approach that WordPress has taken, which I would call "use the right tool for the problem. PHP language is fantastic for dynamic web content delivered through web pages; Node.js is ideal for the backend for mobile devices, what I call "Mobile Backend as a Service."

Jorge V. (Intel)'s picture

I think even when this is a very aggressive but somehow "natural" change that kind that represents how the WWW is evolving. Nodejs was built while thinking in creating real-time and very connected applications with it, in a way this is how modern web applications are intended to be, and WordPress is no exception, it has to adapt to this evolution. I completely agree that WordPress's engine(built with PHP) is not likely to be replaced soon, however the first step in switching to Nodejs is just the tip of the iceberg, who knows what will happen in the future, not just for WordPress, but perhaps more applications, it is something interesting to think about.

Add a Comment

Have a technical question? Visit our forums. Have site or software product issues? Contact support.