r/developersIndia • Junior Engineer • Dec 24 '23

General Opinions on technologies like WASM.

I recently came across Photopea an was surprised by its usability and perfomance that too in a browser.I'm curious to hear the thoughts and experiences of developers here regarding Technologies like WebAssembly (WASM) and Google Native Client (NaCl). These technologies have been gaining attention for their ability to execute high-performance code in web environments.

​

  1. Have any of you worked with these techs in your projects? What was your experience like, and do you see any specific advantages or limitations compared to other technologies?
  2. Are there any specific applications or use cases where you believe NaCl or WASM particularly shine? Whether it's gaming, computational tasks, or other areas, I'm keen to learn about real-world scenarios where these technologies excel.
32 Upvotes

33 comments sorted by

19

u/BhupeshV Dec 24 '23

WASM is the only thing I have been intrigued about amongst all the random stuff that catches on in our industry.

  • Last I checked only Figma was using WASM (big product). Would love to try it someday.

  • Dart also rolled out support for WASM.

  • I was playing with ebitengine in Go. All examples are loaded in WASM

4

u/exequias-ulqui Dec 24 '23

Adobe's new revamped UI for Photoshop on the web heavily uses WASM, or so I've read.

1

u/BhupeshV Dec 24 '23

Adobe's new revamped UI for Photoshop

Didn't know about this

For others: https://medium.com/@addyosmani/photoshop-is-now-on-the-web-38d70954365a

-3

u/alex_ken_101 Dec 24 '23

Webassembly can be used instead of docker . It is better .I have heard on some old talk on YouTube about it.

5

u/BreadfruitRich2175 Dec 24 '23 edited Dec 24 '23

Webassembly code is built using super optimised llvm compiler (ahead of time compilation) Docker is glorified package container manager supporting many configuration, languages and bash; saving us useful time but docker doesn’t usually deal with compilation so they are two completely separate technologies

11

u/BreadfruitRich2175 Dec 24 '23 edited Dec 24 '23

Webassembly(wasm) was initially designed and implemented by Mozilla developers and later open-sourced. I was one of the early adopters for wasm in India to apply machine learning and deep learning models on browser.

Emscripten helps you port the c++ applications to webassembly. Webassembly code can run as fast as native applications .

Remember that browser only understands js or html but Vanilla js is slow hence converting existing c++apps to wasm(js)was the most effective way to get desired speed and performance boost at cost of some security concerns.

Emscripten now supports other popular languages such as go and rust . Webassembly is like ChatGPt for FE developers. They are the biggest losers out of it, Now companies can hire a smart developer and use legacy code

2

u/alex_ken_101 Dec 24 '23

Nowadays browsers shipped with webassembly core right ?

1

u/BhupeshV Dec 24 '23

Interesting, would you be interested in hosting a WASM workshop on our discord (like a virtual talk)?

1

u/exequias-ulqui Dec 24 '23

Hey, can you count me in for the talk as well?

1

u/BhupeshV Dec 24 '23

As in, you want to join as a host/speaker?

1

u/exequias-ulqui Dec 24 '23

Lol no, I'm nowhere near as qualified to present a talk for this matter. But yeah, I wanted to be present in the talk.

9

u/AnonymousD3vil Dec 24 '23

I know this is bit of self promotion, but I've recently built a JS library that can run LLM models on browser: https://github.com/rahuldshetty/llm.js

It uses emscripten project to target C/C++ to WASM binaries. See a lot of great potential and can improve the whole web frontend development

4

u/elekktronic Dec 24 '23

Blazor is also using WASM, but the JavaScript is still required to dynamically update content in a webpage when using WASM in modern browsers, it increases overhead and reduces performance. So, I think JavaScript getting replaced by WASM is still quite not possible, maybe they'll complement each other.

1

u/[deleted] Dec 24 '23

but the JavaScript is still required to dynamically update content in a webpage when using WASM in modern browsers

Umm...what?

2

u/elekktronic Dec 24 '23

1

u/[deleted] Dec 24 '23

I have worked with blazor. I know what js interops does. We don't necessarily use js interops calls everytime and tend to avoid it. Unless the requirements are such that direct dom manipulation is needed, there is no need to use js just to update a component.

1

u/elekktronic Dec 24 '23

So that is what stopping WASM from replacing JavaScript completely right?

3

u/[deleted] Dec 24 '23

As per my benchmark with Assemblyscript, it took ~480ms for a simple for loop for a billion iterations, almost half a second and ~80ms when done in wasm. I'm using it for a simple image processing tool on web

2

u/Whatisanoemanyway Dec 24 '23

Practically the final nail in the coffin for software that runs locally

1

u/AutoModerator Dec 24 '23

Namaste! Thanks for submitting to r/developersIndia. Make sure to follow the subreddit Code of Conduct while participating in this thread.

Recent Announcements

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/puninspiring Dec 24 '23

Web animation is a huge area that'd benefit from wasm. Unfortunately there aren't many popular frameworks utilising it for that purpose.

If webgl could switch all it's mathematical stuff to wasm, I'd love to see that

2

u/BreadfruitRich2175 Dec 24 '23

Webgl is a different backend and wasm is another backend. On the contrary Webgl is 10x faster for complex mathematical and graphical operations.

0

u/exequias-ulqui Dec 24 '23

Yeah, I saw the video where someone tried to use WebGPU for complex calculations and then try to use it in JS. But, the cost of calling the code in JS land (via a "portal" as he said) was so much, that it wasn't worth it.

I have also read a few blogs where OpenGL code in C++ is run in browser via WASM using emscripten.

1

u/BreadfruitRich2175 Dec 24 '23

WebNN is future of web. It combines wasm and Webgl seamlessly. Large deep learning models such as transformers will be easily accessible to edge computing applications on browsers

1

u/BreadfruitRich2175 Dec 25 '23

Wasm runs on cpu and webgl uses small computing threads on gpu. Gpu is more efficient for parallelism of small complex computing workloads so as to achieve much higher throughput. CPU are efficient for solving super heavy traditional computing tasks

1

u/exequias-ulqui Dec 25 '23

Indeed. That is why it's difficult to go from traditional synchronous programming to GPU programming, where you have to think about each pixel at the same time, no top-bottom data flow.

1

u/akash_kava Dec 25 '23

WASM is great, and we are using it for many things today, most of JavaScript packages are getting converted to WASM. For example we are using WASM for md5 hash etc, face recognition - tensor flow, ocr - tesseract. Somehow it is the best technology today as any native code can easily fit into JavaScript and we can interact it easily without having to go through install/setup.