WordPress Announces Migration to Node.js

Matt Mullenweg, the CEO of Automattic, the parent corporation of WordPress, generated a lot of excitement when he announced recently that WordPress.com was beginning to migrate away from PHP to JavaScript and Node.js in particular. Why would the No. 1 content management system in the world make such a major change? Could this negatively affect the more than 74 million WordPress websites on the Internet?

What Is Node.js?

Node.js is a single threaded, non-blocking, open-source JavaScript runtime environment. It is also one of the fastest-growing projects on the Internet, and it was originally created in 2009 by Ryan Dahl and a team of developers at Joyent. It is powered by Google Chrome’s V8 JavaScript runtime and uses a non-blocking, event-driven I/O that lets you rapidly create fast, efficient and scalable applications.

Node.js is particularly well-suited for real-time applications that are data intensive. It also plays well across distributed devices. With Node.js, you can create applications for the server and JavaScript, much like you would in other programming languages like Python. JavaScript is ideal for this environment because it is already well-known to client-side developers, and it handles I/O applications with aplomb. Currently, JavaScript is primarily used as a lightweight language interpreted by browsers once a Web page loads.

Why Go From PHP to Node.js?

If PHP has been rock solid for so many years, what specific things does Node.js do for WordPress that prompted the change? Specifically, it offers these advantages:

  • Node.js is fast because it is asynchronous and non-blocking. Synchronous systems that use blocking are slower because each request must be served in turn.
  • Node.js was built around modern computing architectures. It is not hampered by decades-old legacy code.
  • JavaScript is a modern language that can be molded and extended in a myriad of ways.
  • Node.js “speaks” JSON, allowing developers to use a single syntax from the web browser through the server to the database.
  • Node.js makes event loops available on the server. You can quickly write applications to do things like connecting databases to powerful Web APIs.

Node fits the needs of a fast-changing Internet that is increasingly mobile. The Web is becoming ubiquitous, as we see it implemented in everything from appliances to clothing. Node.js is more suited to that environment than PHP.

Two Major Challenges

When Matt Mullenweg became CEO of Automattic in January of 2014, he realized the WordPress project had two major challenges:

  • Lack of capital
  • Limits of current technology

It was the second reason that led him and the Automattic team to consider new approaches. The current codebase has helped the platform grow rapidly–currently, 25 percent of websites on the Internet are powered by WordPress. It is powerful, flexible and cheap to run.

Backward Compatibility

However, one of the downsides has been the area of administration. Mullenweg felt the strengths of WordPress were also creating weaknesses for wp-admin–the administration section of WordPress–and they needed a new plan for the future.

One of the main challenges was that they needed to step away from backward compatibility to get a fresh start, yet one of the platform’s strengths has always been that it was compatible with every release. In contrast, some other popular content management systems like Drupal routinely broke backward compatibility to be able to use the latest technology bells and whistles. It didn’t always make users happy, but it kept the platform on the cutting edge.

Worldwide Contributors

More than 120 contributors combined efforts over many months to meet this challenge, and the result is Calypso. Project Calypso was in-house effortat Automattic to rethink the WordPress codebase and see where it could be improved. Adding Node.js was a natural fit, yet few of the team members in the organization were strong JavaScript coders. However, through trial and error, they began to succeed, and the original handful of developers grew to 127 with more than 26,000 commits.

100 Percent Open Source

Calypso is 100 percent open source, written using libraries from Node.js and React.js. React.js, originally created by developers at Facebook to build user interfaces that worked across many platforms, is used for the user-facing front end.

Node.js is used to make the back end. It is entirely driven by open APIs available to everyone. A single-page application (SPA) runs in the client, taking advantage of multiple JavaScript modules.

REST APIs

Calypso is entirely driven by open representational state transfer (REST) APIs that are available to everyone. The open API means you can manage any of your sites through Calypso. It is blazing fast with pages that load almost instantly, and you can now employ social features like statistics and notifications.

Multi-Site Management

One of WordPress’ strengths is the ability to run multiple sites off the same database. However, managing many blogs can be daunting. Calypso lets you manage many WordPress sites from one administration screen off of any desktop computer, smartphone or mobile device.

Currently, Calypso is deployed on WordPress.com, the site that hosts many free WordPress blogs. Just how big is WordPress.com? Consider these numbers. In 2014:

  • More than 18 million new blogs were created–that’s about 50,000 per day
  • More than 550 million posts were published–that’s the equivalent of 1.5 million per day
  • 47 million posts were originated from mobile devices

Self-Hosted WordPress Sites

If you have a self-hosted WordPress site, you can still take advantage of Node.js developments through the Jetpack plugin. To make it work, you must have a WordPress.com account. Jetpack connects to WordPress.com, which allows you to:

  • Edit and administrate all of your blogs
  • Manage pages, posts, themes, menus, plugins and various settings
  • Write and edit posts very quickly

There is also an application available for Macintosh OS X, with other platforms like Windows to be released soon.

Uncharted Waters

Is WordPress moving into uncharted waters? Not entirely. There are blogging platforms that already use Node.js extensively. One example is Ghost, called by some enthusiastic backers the “WordPress killer,” when it was released in 2012. Ghost was originally built with Backbone, a lightweight JavaScript framework that uses Underscore.js as its single JavaScript library, and the Handlebars semantic templating engine. The developers then transitioned to the Ember.js platform for the client-side and Node.js for the server, while retaining SQL for databases.

First Step Forward

Calypso is the first step in what many see as a continuing move of WordPress.com from the safe harbors of PHP and MySQL. In effect, the site is becoming a client for the API, similar to any application that uses the API. That makes it speedier and lighter for the mobile computing environment that is taking over the world.

With Calypso and Node.js, end users can expect a better experience with WordPress–pages will load faster and respond snappier. Users that also function as webmasters on their own blogs will benefit from new tools for:

  • Multi-site management
  • Desktop blogging
  • Statistics and analytics
  • Website security
  • Site monitoring
  • Image delivery via CDN
  • Stunning Slideshows
  • Improvements in sharing capability

Although these features will allow a significant percentage of general users running self-hosted blogs to use Jetpack to replace much of their current plugins, power users will demand more power and the ability to tweak settings and configuration. For that reason, advanced users will more than likely stay with the majority of their plugins.

The Future of PHP and Node.js

The vast world of WordPress wondered if Calypso was a harbinger of things to come. Would all of WordPress eventually run on Node.js? According to Mullenweg, Calypso shows what is possible. In an interview with Venture Beat, he said he thinks the technology behind the server side and the client side will probably split. PHP is still dominant on the server side, but Calypso and JavaScript, much like Node.js, is the way of the future for the client side.

Does the implementation of Node.js mean the death knell of PHP? If so, it will take some time. PHP is a tough racehorse and has been carrying WordPress around the track for 13 years.

Eventual Takeover

Node.js may take over PHP eventually — it has made huge inroads:

  • After a successful Black Friday test, Walmart began moving their mobile traffic to Node.js.
  • Early on, Yahoo started to migrate to Node.js for their Web stack.
  • LinkedIn reported giant performance gains when they began implementing Node.js.

At this point, Calypso is an administration area with a dashboard. It’s really a combination of React.js with Node.js sitting on the server to generate the Web page. It then talks to the WordPress site through a REST API, and the site is still written in PHP.

However, the future of computing is mobile, and Node.js is a clear winner on distributed devices and the Internet of Things. The way forward isn’t entirely clear, but you can expect Node.js to be in the driver’s seat for a very long time.

Top 6 Database Performance Metrics to Monitor in Enterprise Applications

A Technical Deep Dive into Python