“WebAssembly is a new type of code that can be run in modern web browsers and provides new features and major gains in performance.” — Mozilla developers network.
WebAssembly acronymed
WASM, is a way of taking code written in non-JavaScript and running that code
in the browser. It resides in the JavaScript runtime sandbox (JavaScript executes in the browser in a
secure sandbox environment called ‘JavaScript runtime’) which
provides it with same security and execution as JavaScript. Its represented as
a Abstract Syntax Tree (AST) and built into binary format that the JavaScript
Runtime can understand without interpreting the language. WebAssembly also has
access to WebAPI, which can access things like DOM, Audio and Web Sockets.
Necessity they say, is the mother of invention –We all need WebAssembly
Since Web
Assembly modules are in the same sandbox as JavaScript why then was it created?
Well, WebAssembly was created with
capabilities that will change the way we've built web applications up until now
and in no particular order, they include:
- Performance
boost: Using WebAssembly gives applications a performance
boost which we never had before from JavaScript. This actually comes from
the use of features available in high level languages like C/C++ etc.
because WebAssembly abstracts away the need to compile or transpile to
JavaScript and go to a really low-level system, which in itself is,
WebAssembly.
·
Cross-Language compilation: Code written
in other high-level languages like C and C++ can be compiled into WebAssembly. This
means that You'll
be able to cross compile your existing games and software written in other
languages and run them in your browser and
even use different languages in the same project.
·
Speed: Application
startup speed is faster and optimization way better than JavaScript. As
WebAssembly already is in a binary format with no additional interpretation
needed which leads to much faster code execution compared to JavaScript modules
with your code running at near native speed.
·
JavaScript code can run WebAssembly
modules: Many think, that JavaScript
will go extinct, with existing JavaScript modules and applications rendered
useless but shockingly! WebAssembly is not to replace JavaScript but rather it
co-exists with various existing JavaScript frameworks which can be imported and
with WebAssembly modules included in JavaScript modules.
·
Mobile friendly: WebAssembly
asides the JavaScript runtime also has its own runtime (WebAssembly runtime)
which means mobile devices like Android or IOS can easily provision this
runtime and that would give WebAssembly modules access to the APIs available.
· Browser Support: Every major browser supports WebAssembly already without
requiring the installation of any plugin or extension.
And according to Lin Clark: “Now, I don’t want to imply that it’s an either/or situation — that you’re either using WebAssembly or using JavaScript. In fact, we expect that developers will use both WebAssembly and JavaScript in the same application.”
No comments :
Post a Comment