“One ring to rule them all, one ring to find them, One ring to bring them all and in the darkness bind them.” – J.R.R. Tolkien’s Lord of the Rings
I’ve blogged quite a bit in the past about the rise and importance of Javascript in modern day development.
When I found this recent Wired article, it convinced me I was right about Javascript.
The article talked about how one of the most popular blogging platforms on the planet, WordPress, went through a major refactoring of its core architecture. When I say WordPress is one of the most popular blogging/content management systems on the planet, I’m not kidding. According to recent web statistics, there are roughly 75 million websites on the internet powered by WordPress.
Seeing how wildly popular and widespread WordPress has become these days, it stands to reason the company responsible for the commercial version of WordPress would think long and hard before deciding to make any major architectural changes to their wildly popular product.
Yet that’s exactly what happened, according to the article.
The company behind the commercial version of WordPress, decided to completely refactor the core technology that runs WordPress. Specifically, they replaced the server-side programming language, PHP, with Javascript.
To understand why they changed the server side language, it’s necessary to understand the basic architecture of every web application since the birth of the web.
Every web application has two major components
1. The client layer
2. The server layer
The client layer is what you actually see inside your web browser when you type a valid URL address in your browser’s address bar.
Where does the browser get all the client files from? The browser retrieves these files from the server layer, which is the actual remote computer server host.
In the early days of the internet, the client layer was typically written with the help of Javascript, a scripting language that was developed by Netscape, the creator of the world’s first commercial web browser.
Javascript was originally designed to work in the client layer. That is, the Javascript code would actually run on the client computer in the same space as the web browser.
Javascript helped to make static HTML websites more dynamic. With the power of Javascript code, you could do useful things like validating client-side data forms before the browser has to initiate a full round trip to the remote web server and back.
Over time, the Javascript language has evolved and grown more powerful over time. It started as a small scripting language to add a little more dynamic functionality to a static HTML web page, but it’s truly grown and evolved into a full blown, bona fide programming language.
One of the major Javascript evolutionary breakthroughs was the advent of AJAX (Asynchronous Javascript and XML), which is a way to update a PORTIONS of a web page, without needing the browser to perform a new complete round trip to the web server.
If you use Google Maps or Google Mail, perhaps you’ve noticed that once your web browser loads either of those applications for the first time in your browser, anything you do inside those apps, like drag the map or zoom in, or move messages from one e-mail folder to another, never causes the browser to do that annoying refresh action, where the page sort of blanks out, while the browser waits to reload the entire web page from the remote server and back to your client’s browser.
Suddenly static HTML websites, thanks to AJAX technology, acted and behaved a lot more like traditional client desktop shrink wrapped software.
Javascript, which powers AJAX, proved to software developers worldwide, that it was a powerful enough programming language for creating powerful internet based applications.
Of course, technology like AJAX wouldn’t be possible without corresponding server-side programming language code running on the remote server, to do things like connecting to a database to retrieve data, or web remote HTTP calls to other systems, or any number of things your web application needs from a remote web server to bring back down to the client web browser.
And for many years, you needed to use a programming language other than Javascript, to live on the web server, to do your bidding. In the early days, it was UNIX based scripting languages like perl, python or ruby, but first class programming languages got on the web programming bandwagon, like Sun’s Java programming language, and Microsoft’s Visual Basic and later, their C# programming language.
But then in 2009, a technology called NodeJS, allowed a web developer to use Javascript as a server side programming language.
Before NodeJS, I would typically write all my client-side code with Javascript, and use a Microsoft based programming language like Visual Basic or C# to run on the remote web server.
As a software developer, it was a little tedious having to mentally switch gears between using one programming language for all client side code that lived in the user’s web browser and then switch to a DIFFERENT programming language for all the stuff that had to run on the SERVER.
NodeJS allows a web developer to use Javascript on the client AND server.
No more mental “context” switching as you force your brain to switch from one programming language to another language.
Now I’m not saying it’s this Herculean task for a software programmer to make the switch. For the most part, other than syntax differences, most programming languages share the same basic constructs like looping, if-then branching logic and object oriented features.
That said, there ARE significant advantages to using a single programming language for a web applications.
Say you’re an organization looking to hire a team of software developers to build out a major new greenfield enterprise web application.
Before the advent of NodeJS, your Human Resources department would have to place different kinds of job postings to the public at large, to find the necessary set of programmers needed for a web application.
You’d need Javascript developers to handle the client side code that need to run in the user’s web browser.
Then you’d need to hire a different programmer to handle the server side code that needs to run on the web server. Maybe a Java programmer. Or a C#, Ruby or Python programmer.
It creates additional overheard from a human resources perspective, to have to worry about hiring different kinds of programming with specialized language skillsets.
I distinctly remember a hiring manager telling me how much easier it was to ramp up formerly client-side Javascript developers, and apply their same Javascript skills for server side programming. It was relatively painless for these developers to work on the server.
The cost savings of avoiding the need to hire a new developer to handle server-side programming is HUGE … the company is eliminating the need to hire a full-time salaried engineer to handle server programming.
Javascript has plenty of libraries to give you the ability to connect to and query the database layer of an application. So we’re really talking about the ability for Javascript to work across the CLIENT, the SERVER, and the backend DATABASE layer of a web application.
I am confident these are some of the reasons why WordPress went through a major architectural facelift to use Javascript to power al their programming needs.
Like it or not, there is no question we’re moving to the world of isomorphic Javascript for web application development.