231 points · by sts153 · 3y ago · 99 comments
We have been busy pushing out a lot of new stuff. Recently we released a web framework [0] for Rust building on top of lunatic, and a live-view library [1] for crating full stack apps in Rust without JS. For now we are staying close to the Phoenix LiveView implementation, where everything is rendered on the backend and just a diff is sent over websockets to the frontend. But a big advantage of Wasm is that it runs in the browser too, so we hope to leverage this part to move some of the logic directly into the browser, like form checking, or offer a way to create offline-first experiences with the backend running as PWA in a service worker.
[0]: https://github.com/lunatic-solutions/submillisecond
[1]: https://github.com/lunatic-solutions/submillisecond-live-vie...
I do not have much of anything to say, but I did come up with an idea. One thing that Fuchsia (operating system) does is that parents are able to lock down the permissions when spawning childs. For example, if a child is spawned with no I/O permissions, that child will have all those permissions removed, and any child that spawns from that will have the same restraints.
Could Lunatic support something like this on the far future?
EDIT: I just read the FAQ and looks to be heading that way. Awesome.
You can already do this in lunatic. For example, in the Rust library you can create a configuration (https://docs.rs/lunatic/latest/lunatic/struct.ProcessConfig....) with specific permissions (e.g. no i/o) and then use the spawn_config function to spawn children with it. Children will automatically inherit the configuration from their parents.
Lunatic is also a bit of a meta-system. We expose a lot of the vm stuff directly to the running wasm instances. So you can in a running wasm modules embed other modules or dynamically load them, then spawn processes from them. At the same time you can use the configurations to limit capabilities of this, potentially untrusted, modules.
I want to teach something like Tailscale about my contacts, so they are allowed to communicate with my services (through their services).
Then I want to run an app inside a strong sanbox (maybe Lunatic?) that has capability-based APIs to do things kind of like ZeroMQ for sending messages TO THE CONTACTS. I don't want the API to look like a tcp/ip or udp connection. I want the app to think it's sending a message to a contact I've given it permission to talk to, via some interface that Lunatic itself provides.
If this was running in a strong sandbox, I think this would be an awesome way to develop and use simple federated apps. If something like Mastodon existed on top of this, I'd think it would be really secure and much easier to tell people to stand up their own node...
And I want the whole thing to feel like Sandstorm.io, in that self-updating way, with an app store... But Sandstorm.io is like an Oasis... I want a Federation. And I feel like a Rust-language-implemented WebAssembly sandbox that uses CONTACTS (not TCP) and Messaging, over something like Tailscale for connectivity and encryption, and then a Capability model for storing locally, or talking to a DB, or making external HTTP requests depending on the service, etc...
I want a WebAssembly thin client running on my phone... And a WebAssembly server running on my PC at home. And the server at home runs applets that THINK they're running on my phone (like XWindows, basically). Talking to other applets on my server, which talk to other applets on YOUR server, which talk to applets on your phone. I type a message on my phone, lots of Tailscale happens, and you see the message on your phone. And in my head, there's basically no boilerplate in the code I write. It just looks like Contacts and strongly-typed Messages.
That's the thing I keep wanting.
In the phx protocol, their diffs depend on having split the render into a tree of 'statics', 'dynamics', 'components', and on each change, that structure is patched, and needs to be recursively zipped to a string, parsed into a DOM, and patches computed against the previous DOM.
I've been playing with a new client as a way of understanding it, and it's definitely a certain amount of work! Fortunately computing 'what needs to change to reconcile 2 html-like DOMs' is a project that's been wrapped into libraries a few times in a few languages (phoenix relies on other people having done that too, via the 'morphdom' library in JS, and Dockyard recently open-sourced an ergonomic Rust library I'm using in my client).
So -- it's a lot of client work, but it optimizes for bandwidth. Cool.
But I've wondered if there could be any benefit to optimizing for granularity of patches, and simpler clients -- by sending 'just the patches', ie the list of DOM operations that cause the desired end state. My intuition is that the bandwidth 'cost' would be prohibitive, because the list of patches required to perform the morph could be quite large for a change that appears small in 'what string has changed' terms. (maybe harder to debug, too? lots of trade-offs)
I just don't have the energy to try it that way too, hehe, on the off chance that my intuition is off base and it'd actually help improve things (simpler clients, and maybe the bandwidth hit wouldn't be too bad?); it'd require deep server changes as well, when up until now I've only been writing a client. So I was curious what approach y'all are taking.
Prior/related art in the Rust space: I know there's a non-Phoenix liveview project, 'dioxus', with a generic DOM liveview implementation that several clients have been created for, by making a state machine that operates on that list of generated Patches; however I don't know what that one sends, whether DOM patches directly, or Phx-style diffs that need to go phxDiff -> zippedUpString -> dom -> morphPatches -> applyToDom.
I don't think that sending DOM patches directly would have a significant higher bandwidth cost, but it would have higher "implementation" cost for us. That's why we choose to just use an existing "battle tested" library.
Thanks for the answer -- the current SDUI renaissance is a beautiful thing. Cheers :)
Didn't mean to distract from the main discussion either -- pre-emption is something that more people should want, I think, so y'all making it the default for WASM stuff feels super valuable. And surely the sandboxing is really valuable to some people too. (But day-to-day I probably won't use Lunatic, whereas LiveView-based SDUI is my current shop-time project).
I'm currently playing around with signals as in SolidJS. That would result in more granular updates, but it's not as easy to implement.
> This allows it to decide on a per process basis what syscalls are going to be forwarded to the operating systems.
1. Which system calls are being referred to here?
2. Does Lunatic follow WASI's capability-based filesystem access?
2. Yes
1. Stuff inside the vm that lets you keep the process id and message queue, but replaces the code running.
2. Higher level libraries that allows you to preserve state when the code is reloaded and potentially do state modification so that the newly loaded code can continue operating on the existing state.
This is fairly similar to how Erlang does it and I think it's a good approach for most use cases.
Taking half of that equation, and supporting any language, feels like you’re missing a big part of the benefit.
Having written concurrent code in Erlang, C# and Python, I'd view above as a win. A big win. Concurrency decisions in Erlang are simple: if things need to run concurrently, spawn them in different processes. If they're sequential, put them in a function. That's it.
In C# and Python it's nowhere near as straightforward. Do you use OS processes? Threads? Async/Await? Each has different strengths; each also has significant weaknesses.
So: a new runtime that aims to bring Erlang's simple, powerful and scalable concurrency model to any language that targets WebAssembly is, at the very least, interesting. It doesn't need to have all the wider benefits of OTP, or the symbiosis of Erlang and the BEAM. (Though that's great too obviously).
https://github.com/llaisdy/beam_languages
LFE is Virding's himself, and has been around for longer than Erlang has been popular: Robert Virding - LFE - a lisp flavour on the Erlang VM (Lambda Days 2016)
https://www.youtube.com/watch?v=Br2KY12LB2w
Edit: Implementing Languages on the BEAM - Robert Virding - London Erlang User Group
let's look at garbage collection.
How does tradition stop the world, Mark-and-sweep garbage collection work on the BEAM? it doesn't really.
Each process on the beam has its own garbage collection algo, because processes can't share memory, garbage collection on one process can happen without disrupting any other process.
Uhm, several ways:
1. Bind the VM in as a C FFI artefact
2. Write your ruby or Java bytecode emulator to run on one Erlang process only. Since Java supports threads, each thread could live on a different process, any shared memory would live on an Ets table.
"never" is a strong word. The reason why people don't do it is that it's not worth it.
I believe riak embeds javascript in the erlang VM. You can imagine why that might be worth it.
Each process has its own stack, heap, and even syscalls. If one process fails, it will not affect the rest of the system. This allows you to create very powerful and fault-tolerant abstraction.
This is also true for some other runtimes, but Lunatic goes one step further and makes it possible to use C bindings directly in your app without any fear. If the C code contains any security vulnerabilities or crashes, those issues will only affect the process currently executing the code. The only requirement is that the C code can be compiled to WebAssembly.
So as I understand it, an Erlang process can "crash" from an Erlang perspective and it's fine (and even encouraged!), but if it crashes from a system perspective (segfault or some such), it takes down all neighbouring processes as well - usually an issue when using foreign libraries.
With this set up, one of your erlang processes can segfault and it's fine?
I have to admit I'm not across using WASM as a general purpose backend.
there are three different types of crashes in Erlang.
First there are processes `spawn`ed with the spawn primitive. If such a process crashes, there's no risk for any other process in the system, not even exceptions can bubble up (or be intercepted for that matter).
The second type is a linked process, a process whose faith has been linked to their children.
In that situation if a parent process dies, intuitively all the children processes die with it too.
If a child process dies, it brings down the parent too, and if the parent process is a child itself, recursively until the top Application process.
It sounds risky until you realize that this mechanism allows parent processes to intercept child processes dying and act accordingly (restart one, restart all, ignore it, etc.)
That's how supervision works in Erlang.
Finally, if a process crashes when running as NIF (Native Implemented Function) or, to put it simply, a native library written in C (or that can export the same C calling convention) injected into the VM, it can bring down the entire VM.
- Erlang-style concurrency (which I haven't tried so don't understand but hear good things about always)
- With "platform" level capability security...
- ... and language-level capability security
- But with a sound and expressive type system like F# or similar
- Oh, and garbage collection
Good to see Lunatic here, they have been doing great work on their runtime. Props to Bernard and team :)
Lunatic is more opinionated than most of these or node, though, in that it's trying to emulate a particular concurrent system design pattern borrowed from Erlang/BEAM.
WASM has well defined boundaries and with WASI it adds some none browser APIs (but still sandboxed).
It's used a lot for:
- edge computing
- plugin systems (or sandboxing)
- easier cross platform code by targeting wasm (for code which is logically well-enough isolated you can compile it to wasm once end then just use it pretty much anywhere (web, app, desktop, server, edge, smarttv) reliable without having to worry about security or cross platform constraints.
- easier auto updating/ever green apps (e.g. I remember vaguely to have heard Disney+ does put all their core business logic into a wasm blob to for both easy cross platform and auto updating of some parts)
Lunatic doubles down one the server focused easy cross paltform + sandboxed aspects potentially deployed at the edge. But I also have seen people use a library wasm-runtime to embed a program written as stdin->dostuff->stdout CLI app into a go program without having to bother with cgo or cross platform support of the CLI app.
The word dramatically declined in popularity through the 19th century but started climbing again after ~1995[0]. The recent increase in usage is driven entirely by a much milder, colloquial meaning of "wildly foolish"[1].
I think being offended because our great-grandparents used the word literally is a bit silly.
[0] https://books.google.com/ngrams/graph?content=lunatic&year_s...
[1] Meriam Webster identifies the older meaning as "dated": https://www.merriam-webster.com/dictionary/lunatic
As someone who has family members with mental health issues, I don't find the term offensive at all.
I, for one, by default think more of someone who's obsessed with the moon, I guess it's because I never read that article, so I've never been told to be offended by it.
All that said, I do hope that the authors understand that they might be fighting an uphill battle with regards to adoption.
The very word has lost all real meaning.
Spare us the BS. Society is very much able to form opinions on what is widely considered offensive and what is not.
Case in point: legal proceedings for libel, threats and so on. Turns out society still gives meaning to words.
> it's impossible to even be proven wrong
You've been proven wrong right now.
Except there isn't an agreed upon opinion, just a certain number of loud individuals trying to silence others, and everyone else who just quietly don't care.
> You've been proven wrong right now.
I was saying that it's impossible to prove that something isn't offensive. Please take your time to actually understand posts you read before posting angry comments.
Sure enough, sensitized to it, I heard an NPR host and a Chipotle ad use it in the colloquial sense within the next week. And those are just the ones I noticed, and that were very-public rather than in private conversations.
This stuff's not mainstream and normal people don't care a bit. It's not even caught on in groups worried about impressing the word-police crowd (major advertisers and NPR both qualifying, I should think).
I didn't say it was offensive. If it was called "autistic", the word is not offensive but... why? It's just a really strange choice.
I personally thought it was a witty name. Had a tiny mental chuckle when I read it.
Better question is, why not? If it's not offensive, then what is the reason you "wish they had called it something else"?
> It's just a really strange choice
Doesn't sound like a real criticism to me...
Have you, your relatives or your friends ever used the phrases "are you insane?" and "are you out of your mind"? Were they being insesitive. Should you/they be more thoughtful how it would be perceived by other people, that you/they so casually use a very modern (and not 19th century) refernces to mental illness?
What about, I don't know, Insane Clown Posse who formed in 1989 and won Outstanding Hip-Hop Artist/Group at Detroit Music Awards? They probably need to re-think their name, too?
Looney Tunes? (Looney is the same as Lunatic) Or looking at some of the adjacent terms, perhaps Animaniacs?
The list just goes on. And on. And on. AND ON.
So if you have a law on the books governing how to treat lunatics, or how lunatics should be treated, it's a dumb old law because there's no official test for lunatic. It would be just as stupid if you had laws about the "wacky" or the "nuts."
The overwrought nature of the concern about seeing the word as the name of a piece of software is just a symptom of the current zeitgeist.
It is the right question. If a term once considered offensive no longer is one, and there's no one who gets offended by it, is it still offensive?
> With the whole English language to pick from there are probably better choices that are less ambiguous.
Given infinite time and finite language, every term will become offensive. What then? Especially considering the euphemism treadmill https://en.wikipedia.org/wiki/Euphemism#Lifespan
[1] https://www.bbc.co.uk/iplayer/episode/p0dhrlhm/the-reith-lec...
A few years back a non-native English speaker presented an Erlang library called `coon` because he like this abbreviation of the word `raccoon`. [1]
The shitstorm from Americans (US and Canada) was unbelievable. Even though:
- most people on the mailing list where this was discussed never heard it used as a slur
- people in the states where this word was purportedly still used as a slur never heard it used
- several black people (both African Americans IIRC and a guy from South Africa) said they had no problems with the name (and promptly ignored)
The name of the library was changed.
Now. The question is: who decides it is a slur especially in our global world? Somehow, increasingly, it's the white Americans who end up being offended on everyone's behalf.
See also: the performative activism around master/main branches in git.
[1] Actual reasons: the name was available: https://github.com/comtihon/enot/issues/59#issuecomment-3651...
* An obviously racist and currently in-use racial slur is not ok.
* A Victorian-era word, which was not even used as a slur (although it did have some negative connotation back then and now too) is most likely ok.
Whether you agree or not with the use of the term, names are part of communication, and communication that people are going to take issue with (rightly or wrongly) is going to have an impact on a product/project/business, and should probably be reconsidered, unless the point is to cause controversy or dogwhistle certain values.
This name for example would probably rule out use at many companies, and I suspect many would choose not to publicise it with things like conference talks.
It's definitely a fine line to walk. There are names that originated in an offensive context, and it's easier for me to see the objection to those. But "lunatic" hasn't been commonly used in its offensive sense in nearly a century, so I don't think it's fair to stoke outrage towards a project that started in the 2020s and chose it for extremely innocent reasons.
Sure, but there's a big difference to the marketability of a product between whether 30% get a funny feeling that it's not a great name and won't promote via word of mouth, vs 0.0001% who are known for taking issue with a lot of stuff shouting about it in their echochamber.
> But "lunatic" hasn't been commonly used in its offensive sense in nearly a century
I think it was reasonable to refer to "lunatic asylums" or even "looney bins" until quite recently. The offensiveness may be less, and less targeted at individuals than it was 100 years ago, but it's still there.
> Choosing proprietary tools and services for your free software project ultimately sends a message to downstream developers and users of your project that freedom of all users—developers included—is not a priority.
— Matt Lee
This means if Discord or Microsoft (parent of GitHub) or Twitter (I guess) decide to delete or ban your account, you are by proxy banned from the project, Lunatic; this means Lunatic is not in control of the moderation of its community. This also requires all users must give up personal data to the corporations in order to participate. This also further drives a wedge between those that prefer the spirit of open source not just in the style of communication, but those that want it in the tools used to create it as well.
This project isn’t the only or first offender, but it’s frustrating seeing this pattern pop up over and over and it needs to be called out every time. People care about their privacy more than ever. Interest in OSS has never been higher.
We just witnessed yet another exodus off Twitter for federated plaforms like Mastodon and other platforms because folks don’t want to deal with the whims of megacorporations. Everytime Microsoft or Microsoft GitHub make another questionable move, projects seek refuge on Codeberg/SourceHut/GitLab, or self-hosting. There are a non-negligible amount of folks that don’t want this.