lunatic-solutions / lunatic

Lunatic is an Erlang-inspired runtime for WebAssembly
https://lunatic.solutions
Apache License 2.0
4.61k stars 138 forks source link

Lunatic for client side? #50

Open codec-abc opened 3 years ago

codec-abc commented 3 years ago

Hi,

I don't know if it make much sense but I would like to know if, in theory, Lunatic could be used for client application (Web, Desktop, mobiles,...)

The advantage I see is that Lunatic would allow to reuse some code across platform (since it would be compiled to WASM) and also use an embeddable preemptive actor model (which is a thing that isn't easy to get) which be a nicer way to structure your app.

The potential issues I see :

Yet, those don't seem impossible given enough time and effort. I would even say that it might become a nice way to write client side applications but I might miss some parts of the picture.

Anyway, did you think about Lunatic usage on the client side? Do you think it make some sense? Is it something you would like to explore at some point?

bkolobara commented 3 years ago

Hi @codec-abc,

The main use case I can see lunatic supporting is sharing code between the client and server. If everything is compiled to Wasm you could easily share some logic between the frontend and backend (running on lunatic). Bringing the lunatic runtime to the browser would be a challenging task. Currently we depend on a lot of low-level native code to accomplish many tasks and I don't know if we could provide an equivalent environment in the browser.

Regarding desktop and mobile environments. Theoretically, we could expose all the APIs needed to create windows, paint, listen to user input and others. I just don't see many benefits over using the native APIs directly from let's say Rust. It would be a huge undertaking to provide bindings for all platforms, guest libraries that use these bindings & frameworks for different languages building on top of the libraries.

Another interesting use case could be embedding the lunatic-runtime in your desktop/mobile apps to run sandboxed plugins utilising the actor architecture and preemptive scheduling.

codec-abc commented 3 years ago

Another interesting use case could be embedding the lunatic-runtime in your desktop/mobile apps to run sandboxed plugins utilising the actor architecture and preemptive scheduling.

This is what I meant by desktop/mobile clients. I am wondering if the actor architecture and preemptive scheduling could make a nicer approach to application development. The only alternative I know are Erlang and Pony but them call with their own (rather heavy) ecosystem and lunatic could be a lighter approach here which might make it easier to embed somewhere.