
WebAssembly brings extensibility to network proxies - pjmlp
https://opensource.googleblog.com/2020/03/webassembly-brings-extensibility-to.html
======
withinboredom
[https://www.destroyallsoftware.com/talks/the-birth-and-
death...](https://www.destroyallsoftware.com/talks/the-birth-and-death-of-
javascript) I guess Gary was right. In other news, we have five years of war
ahead of us.

------
bakery2k
So, Envoy will be embedding WebAssembly alongside (or instead of) Lua?

Are other projects moving from Lua (or other embedded scripting languages) to
WebAssembly? What are the benefits of compiling an extension to WASM rather
than writing it in Lua?

~~~
danielheath
The obvious benefits (to me) are performance and security.

Performance: Other than the need for trampolines between the host and the wasm
code, WebAssembly runs at essentially full speed. Lua is fast for an language
built on dynamic types and dynamic dispatch - which is to say, quite slow.

Security: The reference Lua implementation was not designed for untrusted
code; there have been various attacks where loading invalid bytecode could
grant arbitrary execution. Using a format designed for executing untrusted
code has real advantages there.

~~~
fulafel
WebAssembly is slower than native too, how does it currently compare to Lua
with a comparably safe & high level language?

~~~
miohtama
Here an emulator author benchmarks Wasm implementation against JavaScript and
Closure (2018).

Wasm is 1.5x - 11x faster depending on a browser and such.

Here is a very technical 2019 paper comparing Wasm against native compilation.
Wasm is 1.5x slower than bare metal
[https://www.usenix.org/system/files/atc19-jangda.pdf](https://www.usenix.org/system/files/atc19-jangda.pdf)

~~~
fulafel
I think the first link is missing? But emulators are pretty unrepresentative
for this use case and they're often written in low-level & unsafe languages.

The second is about benchmarking C, I suspect it doesn't give us a lot of
information in this question either.

------
westurner
FWIW, Ethereum WASM (ewasm) has a cost (in "particles" ("gas")) for each
WebAssembly opcode. [1]

Opcode costs help to incentivize efficient code.

ewasm/design /README.md [2] links to the _complete_ WebAssembly instruction
set. [3]

[1]
[https://ewasm.readthedocs.io/en/mkdocs/determining_wasm_gas_...](https://ewasm.readthedocs.io/en/mkdocs/determining_wasm_gas_costs/#gas-
costs-of-individual-instructions)

[2]
[https://github.com/ewasm/design/blob/master/README.md](https://github.com/ewasm/design/blob/master/README.md)

[3] [https://webassembly.github.io/spec/core/appendix/index-
instr...](https://webassembly.github.io/spec/core/appendix/index-
instructions.html#index-instr)

