Mozilla has developed a version of JavaScript called asm.js that they claim will offer performance near that of native code, which will allow a web browser to run almost any application, reports Ars Technica.

Historically, JavaScript has been inefficient when compared to languages like C and C++, which offer high performance after a program is compiled, but limit flexibility because classes cannot be changed thereafter. Conversely, JavaScript is a just-in-time (JIT) compilation language that gets compiled more or less on the fly by the CPU, which allows for much greater application flexibility, but generally lower performance. Fundamentally, JavaScript isn’t designed for high performance optimization.

Alternatives to JavaScript have cropped up in recent years, such as Google’s Dart, which avoid some of the pitfalls of JavaScript while enhancing performance. But, due to the popularity and ubiquity of JavaScript, it’s not going anywhere anytime soon. So, Mozilla set out to do something about these inherent performance limitations via asm.js.

asm.js is a derivative of JavaScript, containing a pared down and very limited subset of the language. For example, Mozilla removed JavaScript’s object-oriented constructs, which consequently removes many of JavaScript’s dynamic features that are difficult to optimize. Object-oriented functionalities such as objects and classes are not completely eliminated when using asm.js, but “they must be implemented and used by asm.js programs in the same way that C++ compilers implement and use them,” explains Ars’s Peter Bright.

mozilla web javascript performance asm.js

So what does all of this mean for the future of the web? Presently, it’s often necessary for software developers to code and compile applications for specific platforms, as browsers are simply incapable of running them. This further decreases the flexibility of applications by limiting them to one operating system, or requiring the developer to write and compile the software for multiple systems, which greatly increases overhead. One alternative is to use a language like Java, which is platform independent, but still requires installation of a local runtime environment.

With the advent of asm.js, large-scale and robust applications may be able to operate efficiently enough to run from within a browser, offering platform independence, and extremely flexible software deployment.

Graph image credit: Ars Technica.