Skip to content
/ lam Public

🚀 a lightweight, universal actor-model vm for writing scalable and reliable applications that run natively and on WebAssembly

License

Notifications You must be signed in to change notification settings

leostera/lam

Folders and files

NameName
Last commit message
Last commit date

Latest commit

6ad66b6 · Nov 22, 2020
Nov 22, 2020
Nov 22, 2020
Nov 22, 2020
Nov 22, 2020
Nov 10, 2020
Nov 15, 2020
Nov 22, 2020
Nov 8, 2020
Nov 22, 2020
Nov 14, 2020
Nov 15, 2020
Nov 22, 2020
Nov 22, 2020
Nov 22, 2020

Repository files navigation

░█▒░▒▄▀▄░█▄▒▄█ ...:rocket:
▒█▄▄░█▀█░█▒▀▒█

A Little Actor Machine that runs on Native and WebAssembly

What is LAM?

LAM is a research project exploring a lightweight alternative to the BEAM that runs as Native and WebAssembly binaries, both on WASI-enabled systems and browsers.

It will supports:

  • Immutable functional programming with proper tail calls
  • Concurrency via processes and message passing
  • Multi-core scheduling (except on the Web)
  • Erlang/OTP architectural patterns (such as supervision trees)

It will not support hot-code reloading or distribution, and so not all BEAM programs will be supported.

It will be useful for building:

  • short-lived, fast-startup services (e.g AWS Lambdas / Google Cloud Functions)
  • web apps
  • fast command line tools
  • native GUI applications

Getting Started

You can download the latest binary from the releases page. After unpacking it you should be able to add it to your PATH env and start playing around with the lam binary.

Like this:

# in this example I'm running linux with glibc
$ wget https://github.com/AbstractMachinesLab/lam/releases/download/v0.0.5/lam-v0.0.5-x86_64-unknown-linux-gnu.tar.gz
$ tar xzf lam-*
$ export PATH=$(pwd)/lam/bin:$PATH

Now we can do a quick test. Make a file test.erl with this contents:

-module(test).

-export([main/1]).

main([]) -> ok;
main([Name|T]) ->
  io:format(<<"Hello, ~p!\n">>, [Name]),
  main(T).

And we can compile it to BEAM byte code and use LAM to build a binary for it, like this:

$ erlc test.erl
$ lam build test.beam --output test.exe --target native --entrypoint test
$ ./test.exe Joe Robert Mike
Hello, Joe!
Hello, Robert!
Hello, Mike!

How does it work?

LAM compiles your .beam files ahed of time into a representation that's optimized for running them.

Then it bundles that with the appropriate target runtime into some binary output.

                       binary
                    instructions
                   +------------+              output
 .beam files +---->| 1001101110 |-----+    +-----------+
                   +------------+     |    | .exe      |
                                      |--->| .wasm     |
                   +-------------+    |    | .wasm/.js |
                   | LAM RunTime |----+    +-----------+
                   +-------------+