Giter Site home page Giter Site logo

leostera / lam Goto Github PK

View Code? Open in Web Editor NEW
248.0 14.0 15.0 21.04 MB

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

Home Page: https://lam.run/manual

License: Apache License 2.0

Rust 82.35% Erlang 0.50% Assembly 1.34% C 0.09% Makefile 0.60% JavaScript 5.01% Shell 0.42% TLA 2.94% Handlebars 6.74%
beam erlang virtual-machine webassembly native actor-model runtime-system vm elixir actor-machine

lam's Introduction

LAM logo

ย 

Main workflow

LAM is a lightweight, universal virtual machine for writing scalable and reliable applications that run natively and on WebAssembly.

It is inspired by Erlang and Lua, and it is compatible with the Erlang VM.

LAM lets you reuse the same programming paradigm, known for being productive, across your entire application stack.

Come join us on Discord! (Ps: we share a server with Caramel)

Features

  • Runs Natively and on WebAssembly -- pick and choose your runtime!
  • Easy to Target -- a small and specified bytecode with a text and binary format
  • Erlang VM compatibility -- run your existing Erlang, Elixir, Caramel, and Gleam code
  • Seamless multi-core -- built to scale from one to thousands of cores for free
  • Extreme reliability -- use Erlang's OTP supervision patterns

Status

Still under heavy development!

There's plenty of work to be done for it to be fully usable, but we keep a few tracking issues here:

The Erlang and Elixir ecosystem compatibility is tracked here:

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.7/lam-v0.0.7-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 ahead 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 |----+    +-----------+
                   +-------------+

lam's People

Contributors

jimt avatar leostera avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lam's Issues

WebAssembly and Native Runtime Support

Will use this issue tro track the broad strokes of standard APIs for LAM across runtimes.

Ideally we'd have a feature parity across platform but that can't be guaranteed so at least we should have a consistent core and platform specific extensions.

WebAssembly (Web)

WebAssembly (Server-side)

  • File System
  • Network
  • Logging
  • Time

Native

  • File System
  • Network
  • Logging
  • Time

Experiments

Here's a list of things to try out and see where we are:

  • mix-format -- compile and run the Elixir formatter as a binary
  • cloc -- a tool that counts lines of code using a map-reduce pattern
  • crane -- a tiny distributed build system
  • ...?

Erlang VM Compatibility Status

The following instructions are currently supported in some form. For some of them, it means "we can read them, but they have no effect", for some others, approximated semantics are used.

Since I'm implementing these as they are needed, it is likely that some won't be implemented for a long time unless you need them. If you need a specific instruction, please file a separate issue.

BEAM Instructions

  • Allocate
  • AllocateHeap
  • AllocateHeapZero
  • AllocateZero
  • Apply
  • ApplyLast
  • Badmatch
  • Bif0
  • Bif1
  • Bif2
  • BsAdd
  • BsAppend
  • BsBitsToBytes
  • BsBitsToBytes2
  • BsContextToBinary
  • BsFinal
  • BsFinal2
  • BsGetBinary
  • BsGetBinary2
  • BsGetFloat
  • BsGetFloat2
  • BsGetInteger
  • BsGetInteger2
  • BsGetPosition
  • BsGetTail
  • BsGetUtf16
  • BsGetUtf32
  • BsGetUtf8
  • BsInit
  • BsInit2
  • BsInitBits
  • BsInitWritable
  • BsMatchString
  • BsNeedBuf
  • BsPrivateAppend
  • BsPutBinary
  • BsPutFloat
  • BsPutInteger
  • BsPutString
  • BsPutUtf16
  • BsPutUtf32
  • BsPutUtf8
  • BsRestore
  • BsRestore2
  • BsSave
  • BsSave2
  • BsSetPosition
  • BsSkipBits
  • BsSkipBits2
  • BsSkipUtf16
  • BsSkipUtf32
  • BsSkipUtf8
  • BsStartMatch
  • BsStartMatch2
  • BsStartMatch3
  • BsStartMatch4
  • BsTestTail
  • BsTestTail2
  • BsTestUnit
  • BsUtf16Size
  • BsUtf8Size
  • BuildStacktrace
  • Call
  • CallExt
  • CallExtLast
  • CallExtOnly
  • CallFun
  • CallLast
  • CallOnly
  • CaseEnd
  • Catch
  • CatchEnd
  • Deallocate
  • Fadd
  • Fcheckerror
  • Fclearerror
  • Fconv
  • Fdiv
  • Fmove
  • Fmul
  • Fnegate
  • Fsub
  • FuncInfo
  • FuncInfo
  • GcBif1
  • GcBif2
  • GcBif3
  • GetHd
  • GetList
  • GetMapElements
  • GetTl
  • GetTupleElement
  • HasMapFields
  • IfEnd
  • Init
  • IntBand
  • IntBnot
  • IntBor
  • IntBsl
  • IntBsr
  • IntBxor
  • IntCodeEnd
  • IntCodeEnd
  • IntDiv
  • IntRem
  • IsAtom
  • IsBinary
  • IsBitstr
  • IsBoolean
  • IsConstant
  • IsEq
  • IsEqExact
  • IsEqExact
  • IsFloat
  • IsFunction
  • IsFunction2
  • IsGe
  • IsInteger
  • IsList
  • IsLt
  • IsMap
  • IsNe
  • IsNeExact
  • IsNil
  • IsNonemptyList
  • IsNumber
  • IsPid
  • IsPort
  • IsReference
  • IsTaggedTuple
  • IsTuple
  • Jump
  • Label
  • Line
  • LoopRec
  • LoopRecEnd
  • MDiv
  • MMinus
  • MPlus
  • MTimes
  • MakeFun
  • MakeFun2
  • Move
  • OnLoad
  • Put
  • PutList
  • PutLiteral
  • PutMapAssoc
  • PutMapExact
  • PutString
  • PutTuple
  • PutTuple2
  • Raise
  • RawRaise
  • RecvMark
  • RecvSet
  • RemoveMessage
  • Return
  • SelectTupleArity
  • SelectVal
  • Send
  • SetTupleElement
  • Swap
  • TestArity
  • TestHeap
  • Timeout
  • Trim
  • Try
  • TryCase
  • TryCaseEnd
  • TryEnd
  • Wait
  • WaitTimeout

LAM Specification Status

One of the goals of LAM is to be formally specified.

This will allow other implementations to appear that are interchangeable with it, and will allow us to reason mathematically about their expected behaviors.

Instruction Set

Control Flow

  • Badmatch
  • Call
  • ConditionalJump
  • Halt
  • Jump
  • Label
  • Return
  • TailCall
  • Test

Values

  • ConsList
  • GetMapElements
  • GetTupleElement
  • MakeLambda
  • MakeTuple
  • SplitList
  • SplitListHead
  • SplitListTail

Processes & Message Passing

  • Kill
  • Monitor
  • PeekMessage
  • PidSelf
  • RemoveMessage
  • Send
  • Sleep
  • Spawn

Register Machine

  • Allocate
  • Clear
  • Deallocate
  • Move
  • RestoreLocals
  • ShiftLocals
  • Swap

Scheduler

  • Boot
  • Step

Scheduler Coordinator

  • Setup
  • Step
  • Halt

Erlang / Elixir Support Across Runtimes

This issue tracks compatibility with standard Erlang and Elixir built-in functions across the different runtimes.

Note that not all functions will be available in all runtimes, and some will not be available on any runtime and thus require external polyfills.

Targetability Status

One of the goals of LAM is to be easy to target.

This means that we should provide tools to work with the bytecode, inspect it, and debug it. Ideally both in binary and text format, and converting between them quickly.

Bytecode

  • Define a text format -- leaning towards S-expressions, like WebAssembly's .wat
  • Define a binary format -- open to ideas

Tools

  • lam validate -- can validate bytecode in text and binary format
  • lam text-to-bin and lam bin-to-text -- translate bytecode between text and binary format
  • lam inspect -- meta information about the provided bytecode
  • lam compile -- should emit DWARF debug symbols by default, but drop 'em with a --release flag
  • lam debug -- should start a step-debugger for a LAM program

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.