<story><title>Launch HN: Lunatic (YC W21) – An Erlang Inspired WebAssembly Platform</title><text>Hi HN! We’re Bernard &amp;amp; Hrvoje and we are Lunatic (&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;lunatic.solutions&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;lunatic.solutions&amp;#x2F;&lt;/a&gt;). 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.&lt;p&gt;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&amp;#x2F;Elixir, started working on a similar open-source runtime for WebAssembly which he called Lunatic (&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;lunatic-solutions&amp;#x2F;lunatic&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;lunatic-solutions&amp;#x2F;lunatic&lt;/a&gt;).&lt;p&gt;Lunatic runs Wasm modules as lightweight processes with its own heap&amp;#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&amp;#x2F;Wasmer for this part (codegen is done by LLVM or Cranelift).&lt;p&gt;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;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.&lt;p&gt;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.&lt;p&gt;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&amp;#x2F;processes to tackle this problem. Lunatic solves this by using Erlang’s proven approach [2].&lt;p&gt;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.&lt;p&gt;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.&lt;p&gt;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.&lt;p&gt;We have built two demo apps to showcase Lunatic. Lunatic.run (&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;lunatic.solutions&amp;#x2F;run&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;lunatic.solutions&amp;#x2F;run&amp;#x2F;&lt;/a&gt;) 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 (&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;lunatic-solutions&amp;#x2F;chat&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;lunatic-solutions&amp;#x2F;chat&lt;/a&gt;).&lt;p&gt;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?&lt;p&gt;[0] &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;crates.io&amp;#x2F;crates&amp;#x2F;async-wormhole&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;crates.io&amp;#x2F;crates&amp;#x2F;async-wormhole&lt;/a&gt;
[1] &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;webassembly.org&amp;#x2F;docs&amp;#x2F;security&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;webassembly.org&amp;#x2F;docs&amp;#x2F;security&amp;#x2F;&lt;/a&gt;
[2] &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;www.phoenixframework.org&amp;#x2F;blog&amp;#x2F;the-road-to-2-million-websocket-connections&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;www.phoenixframework.org&amp;#x2F;blog&amp;#x2F;the-road-to-2-million-...&lt;/a&gt;
[3] &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;news.ycombinator.com&amp;#x2F;item?id=26087064&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;news.ycombinator.com&amp;#x2F;item?id=26087064&lt;/a&gt;
[4] &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;jordan-wright.com&amp;#x2F;blog&amp;#x2F;post&amp;#x2F;2020-11-12-hunting-for-malicious-packages-on-pypi&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;jordan-wright.com&amp;#x2F;blog&amp;#x2F;post&amp;#x2F;2020-11-12-hunting-for-m...&lt;/a&gt;
[5] &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;snyk.io&amp;#x2F;blog&amp;#x2F;yet-another-malicious-package-found-in-npm-targeting-cryptocurrency-wallets&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;snyk.io&amp;#x2F;blog&amp;#x2F;yet-another-malicious-package-found-in-...&lt;/a&gt;</text></story><parent_chain></parent_chain><comment><author>nojvek</author><text>I 100% agree with some of the trends you mentioned&lt;p&gt;1) lightweight isolated computation - VMs, containers and the lot.&lt;p&gt;2) asynchronous io - user space green threads, epoll, event loops and the likes to have single OS process handle 1000s of connections&lt;p&gt;3) distributed - scale up compute + have it run close to user. Cloudflare workers, edge@lambda, fly.io.  They’re all moving to this direction.&lt;p&gt;4) polyglot micro services - rather than one big thing written in a single language, many small things that talk to each other via HTTP &amp;amp; grpc. They can be independently changed and scaled up without having to restart the whole system.&lt;p&gt;Erlang + webassembly are a great fit for this paradigm.&lt;p&gt;Seeing the success of fly.io, Cloudflare workers and other cloud providers, this definitely has legs and I would love to try it out.</text></comment>
<story><title>Launch HN: Lunatic (YC W21) – An Erlang Inspired WebAssembly Platform</title><text>Hi HN! We’re Bernard &amp;amp; Hrvoje and we are Lunatic (&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;lunatic.solutions&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;lunatic.solutions&amp;#x2F;&lt;/a&gt;). 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.&lt;p&gt;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&amp;#x2F;Elixir, started working on a similar open-source runtime for WebAssembly which he called Lunatic (&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;lunatic-solutions&amp;#x2F;lunatic&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;lunatic-solutions&amp;#x2F;lunatic&lt;/a&gt;).&lt;p&gt;Lunatic runs Wasm modules as lightweight processes with its own heap&amp;#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&amp;#x2F;Wasmer for this part (codegen is done by LLVM or Cranelift).&lt;p&gt;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;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.&lt;p&gt;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.&lt;p&gt;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&amp;#x2F;processes to tackle this problem. Lunatic solves this by using Erlang’s proven approach [2].&lt;p&gt;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.&lt;p&gt;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.&lt;p&gt;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.&lt;p&gt;We have built two demo apps to showcase Lunatic. Lunatic.run (&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;lunatic.solutions&amp;#x2F;run&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;lunatic.solutions&amp;#x2F;run&amp;#x2F;&lt;/a&gt;) 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 (&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;lunatic-solutions&amp;#x2F;chat&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;lunatic-solutions&amp;#x2F;chat&lt;/a&gt;).&lt;p&gt;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?&lt;p&gt;[0] &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;crates.io&amp;#x2F;crates&amp;#x2F;async-wormhole&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;crates.io&amp;#x2F;crates&amp;#x2F;async-wormhole&lt;/a&gt;
[1] &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;webassembly.org&amp;#x2F;docs&amp;#x2F;security&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;webassembly.org&amp;#x2F;docs&amp;#x2F;security&amp;#x2F;&lt;/a&gt;
[2] &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;www.phoenixframework.org&amp;#x2F;blog&amp;#x2F;the-road-to-2-million-websocket-connections&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;www.phoenixframework.org&amp;#x2F;blog&amp;#x2F;the-road-to-2-million-...&lt;/a&gt;
[3] &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;news.ycombinator.com&amp;#x2F;item?id=26087064&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;news.ycombinator.com&amp;#x2F;item?id=26087064&lt;/a&gt;
[4] &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;jordan-wright.com&amp;#x2F;blog&amp;#x2F;post&amp;#x2F;2020-11-12-hunting-for-malicious-packages-on-pypi&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;jordan-wright.com&amp;#x2F;blog&amp;#x2F;post&amp;#x2F;2020-11-12-hunting-for-m...&lt;/a&gt;
[5] &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;snyk.io&amp;#x2F;blog&amp;#x2F;yet-another-malicious-package-found-in-npm-targeting-cryptocurrency-wallets&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;snyk.io&amp;#x2F;blog&amp;#x2F;yet-another-malicious-package-found-in-...&lt;/a&gt;</text></story><parent_chain></parent_chain><comment><author>maxmcd</author><text>Hey, I tried to build something like this too: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;embly&amp;#x2F;embly&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;embly&amp;#x2F;embly&lt;/a&gt;&lt;p&gt;My takeaway after building that is that the build tooling is the major pain point. If you&amp;#x27;re trying to onboard someone onto this platform from their favorite language the hard part is getting from code to the .wasm file. wasm-bindgen (as an example) has put so much effort into build tooling, I wonder if that&amp;#x27;s a necessary path for success here. (edit: this also might be out of date, maybe wasi solves a lot of this)&lt;p&gt;It&amp;#x27;s also great that WASI exists now, if I had to do embly again I&amp;#x27;d just use wasi and then implement all of my &amp;quot;platform&amp;quot; features as filesystem features, not syscalls. If your API interface is the filesystem then you could provide interoperability between environments. Let&amp;#x27;s say you want to include a key-value store in the wasi runtime, you just make the keys files and the values file contents. Then you could so something like ship a FUSE filesystem to interact with the filesystem in the same way from a traditional VM or on a personal computer. I got really bogged down in custom syscalls and this path seems potentially more elegant.&lt;p&gt;Have you also thought about live process migration? I got really excited about this from a technical standpoint. Since you completely control the runtime you could set up a clustered wasm solution that moves long running processes from VM to VM by sending their live memory state to another machine. Not sure if that&amp;#x27;s actually useful, but cool that it&amp;#x27;s not bogged down by the usual complexities of doing the same in a full OS environment.&lt;p&gt;Anyway, so glad to see this. Please make a cloud platform and let me pay for it. Also happy to chat more if any of this is useful, I&amp;#x27;ve joined your discord as &amp;quot;max&amp;quot;.</text></comment>