Win a copy of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Piet Souris

WebAssembly in Action: Which is faster?

Ranch Hand
Posts: 88
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which is faster WebAssembly or JavaScript?on the same token
will WebAssembly replace JavaScript in the future as the preferred web Language?

Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello satya Priya Sundar!
There are some information in WWW about.
So I am not experienced in it, but read about WebAssembly and I can say that it looks like a future because there are some new features like multithreading and already compiled sites by server, wherefore WA is much faster than JS.
P.S. my understanding can be wrong
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In general, Wasm is faster to download and start executing because of its smaller file size and because it can skip steps that JS needs to make. It can also be compiled as it’s being downloaded.

There are flags with toolchains like Emscripten where you can tell it how to optimize the code (optimize for speed or for size for example). These ahead of time optimizations give Wasm an advantage compared to JavaScript which will be just-in-time compiled (if possible) and optimized on the fly.

WebAssembly gives consistent and predictable performance.

Browsers have put a lot of effort into making JS faster over the years so JS execution speed is pretty good especially if the code has been optimized. Execution speed will depend on the browser. From what I’ve seen Wasm is usually faster but, in some browsers, not by much.

If a developer isn’t aware of certain things, the initialization time of a module can be slowed down. One way to do that is if you ask for a lot of pthreads. Threads use web workers under the hood and, with the Emscripten toolchain anyway, these need to be spun up into a thread pool when the module is instantiated. Web workers are not light weight and, if there are enough being spun up, it’s noticeable.

Speaking of web workers, if a module isn’t needed right away, they can be used to download and compile a module. The module can then be instantiated to run in the worker or the compiled code can be passed to the main thread and instantiated there.

WebAssembly has other features coming soon to improve performance further like SIMD and bulk memory operations.

Aside from plugins, up until now the only language available across all browsers has been JavaScript. Some developers really love JS but others are only using it because there wasn’t anything else available. With Wasm, those developers will now be able to write their code in a language of their choice.

I think the number of JS developers will drop some because people will switch back to their preferred language but both tools have a use so I don’t see JS going anywhere for a while.
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. WebAssembly in Action: Which is faster?

hello, satya Priya Sundar!
Wasm is faster for executing web application
Wasm is improve the re-usability of the code. Wasm there’s only one step to complete the running your app in any browser
with Web-Assembly there’s only one step to complete — the compilation step — for running your app in any browser as well as mobile portability is one of its main strengths
Web-assembly's built as a target for writing in-browser software.
In short think of all those use cases where JavaScript would usually struggle to reach the needed level of performance.

If tomatoes are a fruit, then ketchup must be a jam. Taste this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!