
Understand WebAssembly in 5 Minutes - jesuisundev
https://www.jesuisundev.com/en/understand-webassembly-in-5-minutes/
======
dccoolgai
It's important to note that WASM doesn't immediately deliver the speed
benefits you'd think in all cases right now. Especially when you have to cross
the boundary of the module it's in (tested this a while back, browser vendors
may have improved this since then). In my tests, it "sometimes does, sometimes
doesn't" end up being faster than JS, and it's hard to build intuition around
when that will happen consistently. Early days, so that may change, that's
just what I see atm.

It's also interesting to note projects like AssemblyScript which open WASM to
a Typescript subset. Very cool work they are doing.

When WASM first appeared, I had deep misgivings. I was picturing a dystopia of
unmaintainable bytecode springing up everywhere and the WAT format as a hand-
wavy dismissal of those concerns. Credit where credit is due, though, the W3C
groups working on this are doing a great job and WAT is actually not terrible
to read (or even write, if you have an afternoon to burn and want to take it
on just to learn a thing or two about WASM - look for the wabt compiler).

------
csense
Too bad Java was never properly integrated into Web browsers and ended up
dying. This is basically what the promise of Java was, way back in 1999 or so.

------
discardable_dan
I thought this was going to be one of those "learn X in Y minutes" articles.
It's not, unfortunately, but this is:
[https://learnxinyminutes.com/docs/wasm/](https://learnxinyminutes.com/docs/wasm/)

~~~
Sodman
I think this was useful as a "learn what WebAssembly _is_ " guide. It shows
you how to build a wasm module from c++ source code, and how to use your
module in a browser.

------
aquova
As a relative web novice, WebAssembly continues to be an incredibly promising
tool that has a lot of potential, but remains obtuse on how to actually get a
compiled .wasm binary to run properly in the browser. Most of the examples
I've seen either are trivial programs like the one here, where they I still
feel they pulled things like '_Z3addii' out of a hat. Alternatively, there are
some articles that require you to delve into a pile of Node dependencies just
to print out 'Hello World'.

I'm pleased to say I've finally uncovered the incantations to interface with a
.wasm binary easily, but I was surprised how much digging it required, even
with something as hyped as this. Perhaps I should write my own article on my
findings.

~~~
andrewf
_Z3addii looks like C++ name mangling - embedding parameter/return type
information in the symbol (function) name, required to support C++ features on
top of the linkers C++ grew up with.

Declaring the function as `extern "C"` would turn the symbol name into "add",
or maybe "_add". I suspect the author extracted the name from compiler-
generated assembly or from a tool to list the symbols a .wasm exports.

~~~
jesuisundev
Yes, you need to read the article to confirm it. Nothing is hidden.

------
jarjoura
WebAssembly is not for the faint of heart. Although you can easily output Rust
using cargo target, the memory model that interfaces with the browser is
completely manual.

Of course you should be able to create really complex algorithms and do really
advanced inlining to achieve near native performance. While also working
across all platforms that run Chrome/Edge/Safari/Firefox.

I think the question I have is, Figma is one product I know that really takes
full advantage of WebAssembly as a full experience. 1Password does another
that uses the Chrome extension for it. Would Figma's success have been the
same if they had just foregone the hassle of building in WASM and went pure
native desktop?

~~~
konaraddi
> Would Figma's success have been the same if they had just foregone the
> hassle of building in WASM and went pure native desktop?

I think Figma’s success can be at least partially attributed to being a web
app with good performance. Sharing designs with a URL is a lot quicker than
sharing files and importing them into a native desktop app which all users
would first need to install. Figma made collaborating on design easier and
more accessible than ever.

~~~
jarjoura
I have heard from a designer that they prefer windows even though all design
tools are usually Mac. So they like Figma for it working on Windows out of the
box.

------
ishcheklein
How does exactly it handles security? Will it be another hell like Adobe Flash
was?

