DEVELOPMENT

Posted on October 14, 2014 by: Cory Hudson, Front-End Developer

It’s hard to keep up with the latest news about the Web and technology without hearing something about JavaScript. From its humble beginnings as a way to make web pages interactive, JavaScript has expanded into uses far beyond its creator’s original intentions.

JavaScript was long considered a second-class citizen and was often derided for not being a “real” programming language. Over the past decade, it has gradually been embraced by the general programming community as an important language useful for everything from bringing desktop-style functionality to the browser, running server-side logic and accessing databases, and automating tasks on desktop computers.

Why?

javascript code snippet

Why is there so much interest in JavaScript? While it would be nice to say it’s because it’s such a wonderful language that programmers have fallen in love with using it, the truth is more mundane. JavaScript is everywhere because it’s already everywhere. Nearly every computer is running a web browser capable of running JavaScript. It’s also been getting easier for desktop and mobile applications to include support for running JavaScript within the app itself. That makes it an attractive language to use for delivering functionality to a diverse audience.

JavaScript’s performance is also improving. Google kicked off a race to improve JavaScript performance in 2008 when it developed its V8 JavaScript engine for use in its new Chrome browser. Other browser makers quickly caught up, and web developers and users have benefitted greatly from the increased performance capabilities of JavaScript in the browser.

Despite its shortcomings and misunderstandings, JavaScript is a good language with many excellent features. It’s a very flexible and expressive language capable of supporting several different programming styles. This has made it attractive to a wide variety of different programmers. It’s also attracted a lot of interesting frameworks and tools that have made working with the language easier. There are even a wide variety of tools, such as CoffeeScript and TypeScript, that will turn code written in another language into JavaScript that can run in a web browser. So even when programmers aren’t using it, their code may be turned into JavaScript in the actual application.

New Uses

Many new technologies have begun to be supported in browsers that work with JavaScript to provide advanced features normally only seen in traditional applications. The Web Storage API lets JavaScript store and retrieve data used by a web application inside the browser, allowing for more application-like functionality such as creating and saving custom documents all within a browser. WebGL uses JavaScript to interact with an HTML canvas tag to create 3-D animations that take advantage of GPU hardware acceleration right inside a browser.

Node.js has done a lot to advance the interest in JavaScript over the past few years. Node is a cross-platform environment for writing server-side and networking applications. Node applications are written in JavaScript and embrace the asynchronous and event-based environments that JavaScript developers are used to writing for in the browser. Node uses the unique nature of this asynchronous model to enable fast, high-performance network applications that can handle the large amounts of Internet traffic that are becoming the norm. Node is not a replacement for all types of server-side applications, but it provides incredible performance and has driven a lot of interest in using JavaScript in multiple environments.

Node has also driven an interest in using JavaScript for automating many of the tedious tasks associated with building websites and applications. Tools such as Grunt and Gulp run on top of Node to help developers automate tasks for building websites and other types of projects. These tools allow a developer who’s already used to writing JavaScript for websites and applications to use JavaScript to describe and create tasks that output all the files needed to deploy a web application.

Even Apple has embraced the utility of JavaScript. Apple has long had a language called AppleScript that can interact with applications and perform powerful automation tasks. When OS X Yosemite is released soon, it will include a new feature called JavaScript for Automation. This will allow automation scripts and applications to be written using JavaScript as well as AppleScript.

What It Means

“Write once, run anywhere” has long been the holy grail of software development. The benefits of being able to write software in only one language and then have it run in multiple environments are huge. While this dream will almost certainly never become a reality in its ideal form, JavaScript and its large distribution base make it a good candidate for coming close. At the very least, JavaScript’s ubiquity is making it easier to share code and objects between different levels of software applications. For example, a database could return a JavaScript object in JSON format that the server could pass straight to a browser, which could then format the data visually. The same code for manipulating that data could be running in both the browser and server for use when it’s needed. In the past, the same data coming from a database might need to be converted once or twice as it was sent through the different layers of an application, causing extra work and introducing more chances for bugs.

Developers will be able to use their knowledge and experience with JavaScript in multiple environments, from code running in a web browser to writing scripts intended to run in a desktop environment. While writing in the same language will bring efficiencies, it’s not a free lunch. JavaScript is the language that many of these tools use, but they all provide their own unique environments that will require new knowledge and skills to use effectively.

It’s an exciting time to be a JavaScript developer. Interest in the language is strong and growing, and its uses and applications are growing all the time. JavaScript will never be as fast as the fastest languages, nor will it replace other languages. But its momentum will likely continue to grow, and new uses and tools will continue to be introduced. It’s amazing that a language originally created in 10 days to manipulate web pages has grown up so much and could become one of the dominant languages for writing software.

TL;DR
JavaScript Here, There and Everywhere

Up Next:

End of Summer