September 16, 2016
  |   Technical Development

Isomorphic JavaScript: How One Language Can Rule Them All

The typical web application is built using a few different technologies to accomplish the goal of serving up a web page/application to a user. This process usually involves having client-side rendering code and a server-side logic processing, which allows for communication with a database or return data after intense calculations; something that would be very expensive to do client-side.
For a long time, the application would require different languages to pass data between the client and server, which can cause issues due to formatting differences. In order to do this you would have something like Java based server-side code with a JavaScript library on the client-side communicating with the server. Fortunately, over the past few years a new kind of application architecture has been emerging called Isomorphic JavaScript that removes this need for a separation of logic.

How Isomorphic JavaScript Works

Most developers have likely heard of MVC. Model-View-Controller, where after the initial page load, data is returned from the server and rendered on the page. After that initial page load, a JavaScript library then needs to interact with the application’s API to perform any action beyond simple clicks and selections with the need to refresh the web page from the server to register the changes. With each side running some variation of JavaScript, it allows for putting any part of the applications code, such as business logic or page rendering, on the client or server-side creating a sort of overlap.

What Benefits Can You Expect?

This overlap of client and server brings with it a few new exciting possibilities when designing and implementing features and logic into the application.
One of the biggest is the idea of code reuse between client and server which allows for a reduction in logic redundancy that has been needed in the past. If you needed to have logic data validation on both the server and client-side to maintain the integrity of your application during a transaction, this can now be performed using the same code that is called from multiple places.
Being able to move the code between different sides of the app allows developers to optimize efficiency of functionality by giving them the ability to see which would be better for performance without having to write the same code twice and test it. Using this type of application architecture also provides the ability to easily use server side page rendering which, if used correctly, can increase the speed which the page loads compared to the client side DOM rendering that has been used previously.

What are the Drawbacks?

The main issue is the fact that this concept is relatively new. Because of the unfamiliarity, there may be negative aspects that have not been fully realized; but that is a potential danger in using any newer technology.
Another issue is that while being able to move code between the client and the server is interesting, it makes writing some of the logic difficult since it could be run on both. For example, if there is logic that needs to communicate with the database that used to typically only be viewed as server-side code, now this code could be executed on the client-side. That logic would need some tweaking since there would be issues like the client not having access to the node.js packages that allow for that communication.
A third, and important issue to keep in mind, is the visibility of data. This is because the server/client separation previously helped build a barrier. Exposing sensitive data is a real and growing problem in today’s world, and removing that barrier could make it easier for a developer to accidentally expose the client to data that they shouldn’t be able to access. While this architecture can be exciting to developers, be sure to assess the needs of your application to determine if these issues could be deal breakers.

JavaScript Keeps Evolving

Since its introduction, JavaScript has been evolving into a powerhouse language that does more than just allow a click event to be handled on a web page. Especially over the past few years, the JavaScript scene has exploded with new and exciting technologies that have challenged the typical web application architecture to create new possibilities. If you want to explore one of these exciting changes, Isomorphic JavaScript might be for you. While it does have some drawbacks, the pros can certainly outweigh the cons if the benefits can drastically change the development process as well as improve your application’s performance.

Subscribe to Our Newsletter

Get the latest insights from Blue Acorn iCi

Let's build something together.