Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Will JavaScript Pass the Test of Time?

DZone's Guide to

Will JavaScript Pass the Test of Time?

After utilizing JavaScript frameworks, Zone Leader John Vester asks the question if JavaScript will pass the test of time.

· Web Dev Zone
Free Resource

Add user login and MFA to your next project in minutes. Create a free Okta developer account, drop in one of our SDKs to your application and get back to building.

For the last four years, I have been working on projects that employ a JavaScript-based client framework and leverage a RESTful API on the backend. With the client frameworks primarily centered around AngularJS and ReactJS, the transition away from MVC-based frameworks (Struts, Spring MVC, and Seam) was a significant change for me. Based upon the challenges and benefits with the current state of JavaScript, I began to wonder if these frameworks will pass the test of time. Then, I decided to take a step back and ask the bigger question, "will JavaScript pass the test of time?"

The Challenges

When I first began using JavaScript and the AngularJS framework, I found some challenges on my journey.

A New Way to Debug Code

During my first Angular project, I remember writing code using IntelliJ and the first time I was ready to debug the client-side code, I realized there was a change in the way I would need to debug. This was before the JetBrains plug-in for Google Chrome and the JavaScript debug option in IntelliJ ... or, at least, before I knew about them.

The inability to set a breakpoint in the .jsp of a .jsf page within the IDE (IntelliJ IDEA, Eclipse, RAD, NetBeans) itself and see the code pause execution - providing insight into all the elements available to the developer - took me off guard during that first week of the project. As a result, I needed to browse the code within my browser (Chrome) and set all client-side breakpoints in the instance of the code the session was using. With the debugger on my API, I now needed to manage two different debugger sessions as part of the development process.

Inability to Use Strict

Prior to JavaScript 1.8.5, the idea of  "use strict"  did not exist - opening the potential for unexpected coding errors to slip passed the developer. Without the enforcement option in place, I could easily forget to initialize a variable prior to use ... or worse yet, introduce a new variable unintentionally through a typo at some point in the code. Fortunately, this example of a world before  "use strict"  was easy to resolve, once I understood the challenge.

Common JavaScript Pitfalls

Then there are the pitfalls many developers (myself very much included) have fallen into, especially when developing in JavaScript after working with other programming languages:

  • Scoping - block level scopes and variable hoisting provided challenges until the let keyword was introduced.

  • Memory Leaks - without an understanding of JavaScript, it is easy to introduce memory leaks into the code - which can have an impact on performance.

  • Which Equals to Use - JavaScript allows comparison via a single, double or triple equals sign - knowing when to use which one is important to get the *right* answer.

  • Reference/Inheritance - the way JavaScript inherits/references values is important to understand - since it may be different than one might expect.

  • Function Creation - understanding how functions are created is important - to avoid having redundant functions generated in the target instance of your program.

The Benefits

JavaScript certainly is not popular because of the challenges noted above. In fact, there are quite a few benefits to note regarding the language. Below are some key benefits that come to mind.

  • Regardless of the back-end API, JavaScript is a standardized language that can be utilized. It does not matter if the team has core expertise in Java, .NET, Ruby, etc., all can leverage JavaScript and a JavaScript-based client framework for their application client.

  • JavaScript is supported by all mainstream browsers - including mobile devices. This dedication has allowed JavaScript to continue to grow in popularity, as devs know that the core language is supported and available for use on virtually every device.

  • The asynchronous abilities within the JavaScript language foster superior communication between the client application and back-end services. This translates into the ability to create powerful applications.

  • JavaScript is simply a powerful language, improving upon the initial release over 20 years ago.

  • JavaScript maintains an immense development community, developing modules and frameworks that build upon the core language.

Conclusion

JavaScript is a powerful language, now a core part of every popular browser in use today. Like many, I started using JavaScript as part of initial web page design, when I wanted quick and easy validation without having to go back to the server. In time, more and more JavaScript frameworks and modules have been developed, contributing to the dominance that exists with the language today.

While solutions like Dart, WebAssembly, and Native Client(NaCI)/Portable Native Client (PNaCI) have been considered replacements for JavaScript, the road ahead for a JavaScript replacement would not be an easy task. Not only does the new solution have to gain momentum from the development community, but each of the browser providers would need to adapt the solution as part of their product. I remember the early days of JavaScript support - which varied across the browser solutions and proved to be a challenge for applications with a user base of more than one browser.

Over time, JavaScript has continued to improve and provide more functionality. With a mindset of continuous improvement, and a robust and dedicated community continuing to leverage the language, I believe JavaScript has already passed the test of time and will continue to do so. The various client frameworks built upon JavaScript will certainly come and go over time, but that is no different than the frameworks which are built on top of languages like Java and .NET.

Have a really great day!

Launch your application faster with Okta’s user management API. Register today for the free forever developer edition!

Topics:
javascript ,angular ,react ,web dev

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}