Lama 1.3 |
---|
is a programming language (initualy developed by JetBrains Research) for educational purposes as an exemplary language to introduce the domain of programming languages, compilers, and tools. Its general characteristics are:
The name is an acronym for Lambda-Algol since the language has borrowed the syntactic shape of operators from Algol-68; Haskell and OCaml can be mentioned as other languages of inspiration.
The main purpose of is to present a repertoire of constructs with certain runtime behavior and relevant implementation techniques. The lack of a type system (a vital feature for a real-world language for software engineering) is an intensional decision that allows showing the unchained diversity of runtime behaviors, including those that a typical type system is called to prevent. On the other hand the language can be used in the future as a raw substrate to apply various ways of software verification (including type systems).
The current implementation contains a native code compiler for x86-64, written in OCaml, a runtime library with garbage-collection support, written in C, and a small standard library, written in itself.
In addition, a source-level reference interpreter is implemented as well as a compiler to a small stack machine. The stack machine code can in turn be either interpreted on a stack machine interpreter, or used as an intermediate representation by the native code compiler.
The language specification can be found here.
Supported target: GNU/Linux x86_64, MacOS x86_64 (arm using Rosetta).
Windows users should get Windows Subsystem for Linux a.k.a WSL (recommended) or cygwin. Ubuntu-based variant of WSL is recommended.
System-wide prerequisites:
gcc
For example, (for Debian-based Linux):
sudo apt install gcc
clang
Should be automatically installed with developer tools.
Check that opam
is installed (using commands which opam
or opam --version
)
Installation guide
Install the right switch for the OCaml compiler
opam switch create lama --packages=ocaml-variants.4.14.2+options,ocaml-option-flambda
In the above command:
opam switch create
is a subcommand to create a new switchocaml-variants.4.14.2+options
is the name of a standard template for the switchlama
is an alias for the switch being created; on success a directory $(HOME)/.opam/lama
should be createdUpdate PATH variable for the fresh switch. (You can add these commands to your ~/.bashrc
for convenience but they should be added by opam
)
eval $(opam env --switch=lama --set-switch)
which ocamlc
; it should answer with /home/user/.opam/lama/bin/ocamlc
(or similar) and ocamlc -v
should answer with
The OCaml compiler, version 4.14.2
Standard library directory: /home/user/.opam/lama/lib/ocaml
Pin Lama package using opam
and right URL (remember of "#" being a comment character in various shells)
opam pin add Lama https://github.com/PLTools/Lama.git\#1.30 --no-action
The extra '#' sign is added because in various Shells it is the start of a comment
Install dependencies on system-wide external packages and lama
itself after that.
opam install Lama --yes
Check that lamac
executable was installed: which lamac
should answer with
/home/<USER>/.opam/lama/bin/lamac
Clone the repository and run make -C tutorial
.
It should build a local compiler src/lamac
and a few tutorial executables in tutorial/
.
let ... in ...
construct.-g
modeLISP2
(see GC Handbook for details: 1st edition, 2nd edition) mark-compact.