131 points · by juancampa · 5y ago · 40 comments
If they happen to load all dependencies into a giant blob of linear memory, C written extensions will take care of corrupting their runtime's memory, regardless of WebAssembly "security".
(Sure, you could screw it up if the caller accepts a negative-size bitmap and corrupts its heap. Lets assume that process is written in a memory-safe language.)
If Lunatic can do that, it would be a game changer for distributed computing.
For example, Kay https://github.com/aeplay/kay (used in https://aeplay.org/citybound)
I'm less sure about Axiom https://docs.rs/axiom/0.2.1/axiom/
And then there is Bastion https://crates.io/crates/bastion that I think allows moving an actor to another machine
I think I saw some Rust library do this but I can't find it.
We are working on a distributed lunatic implementation built on top of nats.io.
Like Flash, Silverlight and Java, it allows the embedding and running of binary applications in the browser (although currently this also requires a Javascript shim to allow access to the DOM.) Unlike those, however, Webassembly is not intended to be used only by a single language. You can compile C, C++, Rust, and many other languages to Webassembly and run them both in the browser and as native applications.
This stacks with DOM sandboxed APIs so you get same level of isolation in the browser as JS but better perf and a memory model more suitable to other languages.
Outside of browser you still get sandboxed low level VM suitable for running C and other low level languages. Eg. you could compile a C module for say node and ship it compiled as WASM
That's a high bar. It needs to be portable to everywhere web browsers run, and it needs to be sandboxed so that it's safe to run downloaded code.
WebAssembly is now widely used outside of web browsers as well. The article linked here is not about web browsers; Lunatic runs on a server.
I think the best way to think of it is that "WebAssembly" is a great marketing name, but what it does is be a modern-day JVM: a byte code language that can run anywhere.
You have also removed the shackles of JS and provided an environment to which you can compile and you get the ability to port a lot of libraries and code to the new platform. How does this help? One, you can use other languages to write apps for the web. Two, you can use existing libraries to help develop your app. Three, by having a permission system to access system resources in a secure way, you can incorporate native application features and performance into your web app. Think about stuff like direct printer access, USB access, etc.
As someone who doesn't mind the "shackles" of JS, from what I have seen so far, apps written in WebAssembly are up to two times slower than their JS counterparts. DOM access is abysmal, and from what I've seen in the wild, no one has written a serious business critical application using it yet.
What does webassembly do today, and what experience does it provide over javascript? I get the sandbox and distribution, but again, those advantages mostly apply to JS as well.
There are lots of such applications, including:
* Figma
* Unity games on the Web
* Google Earth
* AutoCAD
* Aside from entire applications, crucial features in things like Zoom and Google Meet (filters, backgrounds, etc.).
WebAssembly won't replace JavaScript - it's for different things. Wasm lets you port native code to the Web, and it lets that type of code run very fast. That's even without SIMD and multithreading - with those things, wasm is even faster.
I'm not even a JS dev but it is certainly literally mind-blowing once you see it.
How does messaging work between processes? What sort of overhead is involved?
Processes don't share any memory, so the message will need to be copied from one process to another. This should be the biggest overhead involved when sending them.
Erlang uses a trick for big binary data structures, they are allocated inside a common memory space and reference counted. That way big messages can be sent just by reference. I was thinking of doing something similar, the wasm spec allows you to import multiple memories and one of the memories could be a commonly shared one. The only issue is that most higher level languages, like Rust, don't have a concept of multiple memories. So it would be really hard to use this trick inside them.
Once we can run lunatic in a distributed way, some messages will need to be sent over the network and we can't cheat there. From this perspective it's even better if we can force architectures where the messages stay small.
> All processes running on Lunatic are preemptively scheduled and executed by a work stealing async executor.
Sounds like Erlang to me.
Erlang is special for other reasons.
Some things that would make it more like Erlang than Go (but that I won't bother to verify):
1. Go isn't really pre-emptive, it just has a lot of hidden yield points afaik
2. Go doesn't enforce message passing, Erlang obviously does
3. When you send a message to a goroutine that has panicked you hang and, potentially at some point, panic. In Erlang an actor dying can send out a final exit message that other actors (likely a supervisor) can subscribe to.
So yeah IDK. To me if it's got lightweight processes, pre-emption, and message passing, it's got everything that makes Erlang special. If it says it's inspired by Erlang I'm going to assume that, along with those things, it also shares goals like fault tolerance.