DUKE GREENE IS BLOGGING DEV BOOTCAMP

A Walk on the Client Side - Some Thoughts on JavaScript


JavaScript is almowt everywhere online, and it has been for a while. Created by and for Netscape in 1995, its popularity has exploded in the years since. Now it is the de facto browser programming language, used almost anywhere a computer connects to the web. But why is it so popular? And should it be popular? Let's take a look at the reasons behind JavaScript's popularity as well as some pros and cons for those thinking of using it.


"There Goes Java...It's So Hot Right Now"


So why is JavaScript so popular as to be almost ubiquitous? One reason is that it's supported in almost every browser in use. People like programming things that will see the light of day, and programming in such a widely "runnable" language is like throwing the curtains open and basking in the sun. It's also very easy to add JavaScript to a site. You don't need a compiler or add-on to use it, just adding the code to a web page and the browser takes care of the rest. Finally, and possibly most importantly, JavaScript runs on the client side, which means that the browser handles all the code itself. Since the process doesn't require a server, JavaScript runs fast and doesn't clog up server loads. Overall, it's a language that was created with simplicity and ease of use in mind, and its popularity seems to imply that it's fulfilling its mission.


Pros and Cons of JavaScript


There are lots of good things about JavaScript, and a few bad things too. First, the good. With its client side structure, JS is built for speed and responsiveness. It's also a language that can work on multiple device types right out of the box, which makes responsive design a cinch. Since the language uses the DOM model, it comes equipped to handle itself in an HTML environment, able to handle page elements with ease. It's so versatile that you can plug a JS snippet into a page's code, reload it, and extend the page's functionality immediately. And it even works offline.


Now, the bad. Since JS works on the client side and can be plugged in at a whim, it's possible for malicious code to mess up a user's system. (When I go around looking for JS snippets online, I need to be careful lest I copy-paste a code bomb into my browser!) Another downside of the client-side aspect is that not all browsers handle the code the same, and so it can be harder to write code that works on all major browsers. Testing can prevent issues with this, but if you forget to test, you might end up with angry customers asking you why your code made their browser look funny. One more small gripe is that semicolons are optional unless they're separating statements on the same line. This sneaky exception can be the cause of hair pulling and headaches.


Overall, the benefits greatly outweight the drawbacks. With the rapid rise of HTML5 and the continued JS compatibility that most browsers boast, this is a language that won't go anywhere anytime soon.