Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm one of the creators of lunatic and it's great to see it on HN again.

We have been working on a Rust web framework that builds on top of lunatic, called submillisecond[0]. It's still in alpha and there is a lot to be figured out. Currently, we are attempting to build something like Phoenix LiveView[1] for it. One of the drawbacks of LiveView is that it requires a permanent connection to the backend, but because lunatic uses WebAssembly on the backend we can actually move part of the backend into the browser to allow for low-latency and offline use cases. Hopefully, you will be able to "just write" rust backend apps, but automatically get rich user experiences with offline support.

A big struggle for us has been the translation of some of the dynamic patterns from Erlang/Elixir to the strict type system of Rust. Also, Rust can't fully understand lunatic's processes, because the language was not designed with a concurrency model in mind where each unit of work gets their own heap memory. So there is some de/serialization going on when pushing data between processes.

As someone else mentioned, lunatic extends WebAssembly with a concurrency model, networking support, permission system, distributed compute, preemptive scheduling. But it's also a whole system for executing Wasm. So you can from your running wasm app load external .wasm files and spawn processes from them with specific constraints (memory/cpu usage, filesystem access, etc.). Someone in our community is building a system that uses submillisecond in combination with a dynamic router that dispatches workloads to external .wasm files. As you can probably tell, I'm super excited about all the possibilities and the future of lunatic.

[0]: https://crates.io/crates/submillisecond

[1]: https://github.com/phoenixframework/phoenix_live_view



Re: "moving the backend into wasm", is there a repo somewhere we can look at?

I presume the bulk of the work there will be ensuring some kind of consistency between the backend database and whatever persistence layer one uses in the frontend (I presume something backed by `indexdb`)?

I ask, because I'm about to work on a full stack rust application (ie, even UI is handled by wasm) with gRPC, and I think I can learn things from your approach.


There are still many problems to be solved. One is the state syncing between backend and frontend. There is nothing public yet, until we decide on the direction that we want to actually take.


Thank you for your post. I am really excited about lunatic.

Do you have any web socket support? Web sockets that are serviced by actors make for a really nice programming model.


Web socket support was added a few days ago[0], but it's still not part of a release. I will probably push out alpha1 tomorrow including it and a few other changes.

[0]: https://github.com/lunatic-solutions/submillisecond/pull/78


Could lunatic one day run on a website? Wouldn't wasmtime itself need to be compiled to wasm for that to be possible?


Yes. We could use the in-browser wasm engine + a polyfill for the host functions. Of course, this would have some limitations. Functionality like UDP would not be supported.


> because lunatic uses WebAssembly on the backend

Isn't one of the main purposes of WebAssembly how it's like... portable/easy to run in different places? If you are in the backend, why not run a backend language like Rust in the first place + not introduce WebAssembly?


There are many other properties that WebAssembly gives us that would be hard (impossible?) to achieve with native Rust. Erlang-like fault tolerance based on a concurrency model where each unit gets their own heap. Fine-grained per request sandboxing. Green thread based async model. Hot reloading, ...


The sentence you extracted that quote from provides one answer to your question: it means they can take part of the backend code and actually execute it in the browser. Like edge functions, but even more so.

Here's the full context of the snippet you're questioning:

> One of the drawbacks of LiveView is that it requires a permanent connection to the backend, but because lunatic uses WebAssembly on the backend we can actually move part of the backend into the browser to allow for low-latency and offline use cases. Hopefully, you will be able to "just write" rust backend apps, but automatically get rich user experiences with offline support.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: