Give Your Page a Jolt With JavaScript

August 1, 2014

JavaScript (JS) is a dynamic computer programming language. It is most commonly used as part of web browsers (e.g. animation of page elements, interactive content, etc.), but is also being used in server-side network programming (with Node.js - a software platform used to build scalable network applications), game development and the creation of desktop and mobile applications. Often confused with Java, JavaScript copied many names and naming conventions from Java, but the two languages are otherwise unrelated and have very different semantics. JavaScript was originally developed by Brendan Eich and released in the mid-1990s. It has since become one of the most popular Web development languages, but why?

JavaScript was the language for Netscape Navigator back when that was the dominant browser. Specifically, it was the language for dynamic front-end development. If you wanted to do scripting on the web, JavaScript was it. Internet Explorer had (and still has) both JavaScript and VBScript, but if you want to work in more than just Internet Explorer, you have no choice but to use JavaScript. Arguably, JavaScript is a great language, but it would be nowhere near as popular today if it weren't for the fact that it's the only language you can use to script HTML.

That said, JavaScript is a flexible language that is pretty easy to learn and use, although it certainly has its kinks, as does any coding language. And JavaScript is the only language that the most popular browsers share support for, so it has become a target language for many frameworks in other languages, even though JavaScript was never intended to be such a language.

Benefits

User Experience: Users now demand a great user experience, and the overall success and adoption of a site or an app is highly correlated to it. JavaScript's ability to meet the demands of rapid development, while at the same time maximizing the user experience, makes it a natural winner. In addition, JavaScript adds interactivity to a site, as well as flexibility. A programmer can use JavaScript to code small (drop down menu) or large (game) user interaction experiences.

Easy to Learn: Thanks to its simplicity and quick learning curve, JavaScript has seen increased popularity in high school computer courses.

Inexpensive Development: As JavaScript does not require a compiler or special software to launch the code, and is written in a text editor, development (the work involved in developing a web site) is relatively inexpensive.

HTML5 is About JavaScript: HTML5 isn’t really about HTML; it’s about JavaScript. The power of HTML5 lies in what its tags allow you to create in JavaScript, like real-time 3D graphics and geolocation.

Runs Locally: JavaScript runs locally in a user's browser, rather than on a remote server. Browsers launch JavaScript on their own, so JS apps are quick to load and execute, respond to user actions quickly, and can detect user actions (i.e. keystrokes). This all leads to a more responsive application.

Limitations

Security: JavaScript provides the potential for malicious authors to deliver scripts to run on a client computer via the web. However, this risk can be contained using two restrictions. First, scripts run in a sandbox in which they can only perform web-related actions, not general-purpose programming tasks like creating files. Second, scripts are constrained by the same origin policy: scripts from one web site do not have access to information such as usernames, passwords, or cookies sent to another site. Most JavaScript-related security bugs are breaches of either the same origin policy or the sandbox. A recent, although not so malicious, example of this was a hack allowing an Uber user to see their Uber passenger rating.

Browser Compatability: JavaScript runs in widely varying environments, so an important part of testing/debugging is to test and verify that JavaScript works across multiple browsers. In other words, browsers interpret JavaScript differently, so a programmer has to test his/her code on all the major browsers. And not all browsers execute JavaScript. This requires a programmer to use standards-compliant code, code checks, libraries and toolkits so that a larger audience can access the site or application.

Readability: Not a major limitation, but certainly worth considering is that JavaScript is not semantically written, so it's harder to read and follow if you are unfamiliar with the language. And it has small quirks, like not distinguishing between integers (1, 2, 3) and floats (1.0, 2.0, 3.0), although there are built-in methods (e.g., #floor) that a programmer can use to get around most of the quirks.

Is JavaScript worth learning? I'll leave it up to you, but with the app-driven culture that permeates today's Web use, it will definitely come in handy!

← Previous Post
Next Post →