Title: Hi HN! We’re Bernard &amp; Hrvoje and we are Lunatic (<a href="https:&#x2F;&#x2F;lunatic.solutions&#x2F;" rel="nofollow">https:&#x2F;&#x2F;lunatic.solutions&#x2F;</a>). Our goal is to improve how you run server-side code by building an open-source runtime that gives you lightweight processes, fault tolerance, and capability-based security for different parts of the application. Basically, we want to combine the power of Erlang with WebAssembly and bring that to new and existing applications.<p>The two of us met in high school, studied computer science together, but then went separate ways working as backend engineers. Bernard worked at CERN and Hrvoje co-founded Amodo, an insurance tech startup. Bernard, being a huge fan of Erlang&#x2F;Elixir, started working on a similar open-source runtime for WebAssembly which he called Lunatic (<a href="https:&#x2F;&#x2F;github.com&#x2F;lunatic-solutions&#x2F;lunatic" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;lunatic-solutions&#x2F;lunatic</a>).<p>Lunatic runs Wasm modules as lightweight processes with its own heap&#x2F;stack and preemptively schedules them on a multi-threaded executor. You can spawn those processes using a library we provide (currently for Rust and AssemblyScript) to enable actor-based architectures with message passing. Scheduling is implemented by modifying a Wasm module and adding “reduction counts” (similar to Erlang). You can write seemingly blocking code but it won’t actually block the underlying OS thread as our implementation of WebAssembly System Interface (WASI, think of it as POSIX syscalls) will be implemented with async Rust and a bit of magic [0] :) The code is JIT’ed and we build on top of existing Wasm runtimes Wasmtime&#x2F;Wasmer for this part (codegen is done by LLVM or Cranelift).<p>To step back from technical details, working on Lunatic for the past few months, we have started to form a bigger picture about server-side applications. Over the years we have witnessed many trends: Docker &amp; containers became popular, asynchronous programming and green threads are ubiquitous for IO intense work, polyglot codebases are always present, microservice architecture became popular, and distributed is being used both for scale and to bring computation closer to clients to lower latency. Two important driving forces are hardware capabilities and how we develop software. Those have changed dramatically from the time operating systems were created.<p>For example, to maximize resource usage of a single machine, we started running virtual machines and then moved to more lightweight containers, both to give isolation and sandboxing to different applications. Serverless is pushing this even further. Lunatic builds on top of WebAssembly security principles [1] to give sandboxing and isolation to enable even more lightweight environments.<p>Servers also needed to handle more and more network connections and spawning an OS thread per connection became problematic so developers used different programming patterns, async implementations, or user-space threads&#x2F;processes to tackle this problem. Lunatic solves this by using Erlang’s proven approach [2].<p>How we develop software has also changed. Today most of our application consists of third-party libraries and it’s common to have hundreds or even thousands of dependencies and obviously it’s impossible to audit them all. When you compile and run your application, the whole code has the same privileges, so a malicious dependency could easily steal your private keys.[3,4,5] WebAssembly is trying to standardise ideas like Interface Types and dynamic linking between Wasm modules. We could isolate libraries into different modules based on capabilities they require (which “system calls” they use) and let developers decide which parts of their app have what capabilities.<p>Other use-cases that Lunatic and Wasm enable are plugin architecture to run third-party code, sharing code between frontend and backend, polyglot codebases that use Wasm interface types to call each other functions, etc.<p>Currently Lunatic is just a runtime but ultimately we want it to be more like an operating system for server-side applications. The value we want to give to developers is simpler deployment and management of running apps, better capability-based security model, and seamless integration with third-party tools (logging, monitoring, profiling). Ideally all you need to do is compile your app to WebAssembly and you are ready to go.<p>We have built two demo apps to showcase Lunatic. Lunatic.run (<a href="https:&#x2F;&#x2F;lunatic.solutions&#x2F;run&#x2F;" rel="nofollow">https:&#x2F;&#x2F;lunatic.solutions&#x2F;run&#x2F;</a>) turns any command line application into a web server endpoint. Read HTTP requests from stdin and respond to stdout. The other is Lunatic.chat, a telnet chat server written in Rust using actor-based architecture (<a href="https:&#x2F;&#x2F;github.com&#x2F;lunatic-solutions&#x2F;chat" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;lunatic-solutions&#x2F;chat</a>).<p>We are super excited to work on these problems and we hope we have managed to convey some of that excitement to you. Please share with us your thoughts and questions. Does our big picture resonate with you? Would you like to use a runtime like Lunatic? Do you have some other use-cases in mind?<p>[0] <a href="https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;async-wormhole" rel="nofollow">https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;async-wormhole</a>
[1] <a href="https:&#x2F;&#x2F;webassembly.org&#x2F;docs&#x2F;security&#x2F;" rel="nofollow">https:&#x2F;&#x2F;webassembly.org&#x2F;docs&#x2F;security&#x2F;</a>
[2] <a href="https:&#x2F;&#x2F;www.phoenixframework.org&#x2F;blog&#x2F;the-road-to-2-million-websocket-connections" rel="nofollow">https:&#x2F;&#x2F;www.phoenixframework.org&#x2F;blog&#x2F;the-road-to-2-million-...</a>
[3] <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=26087064" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=26087064</a>
[4] <a href="https:&#x2F;&#x2F;jordan-wright.com&#x2F;blog&#x2F;post&#x2F;2020-11-12-hunting-for-malicious-packages-on-pypi&#x2F;" rel="nofollow">https:&#x2F;&#x2F;jordan-wright.com&#x2F;blog&#x2F;post&#x2F;2020-11-12-hunting-for-m...</a>
[5] <a href="https:&#x2F;&#x2F;snyk.io&#x2F;blog&#x2F;yet-another-malicious-package-found-in-npm-targeting-cryptocurrency-wallets&#x2F;" rel="nofollow">https:&#x2F;&#x2F;snyk.io&#x2F;blog&#x2F;yet-another-malicious-package-found-in-...</a>
Upvote: