Skip to content

Adam v0.2.0

Latest

Choose a tag to compare

@jarroddavis68 jarroddavis68 released this 06 Dec 05:27

Adam 0.2.0 -- embedding, libAdam, benchmarks and a faster compiler

Adam is a Pascal and Oberon inspired systems programming language that compiles straight to native x86_64 machine code with its own compiler, optimizer, linker and debug-info writer: no C toolchain, no transpiling, nothing else to install. The compiler is written in Adam and builds itself, and every self-build proves it: the compiler built by itself builds itself again, byte for byte the same, or nothing is installed.

0.2.0 targets Windows and Linux on x86_64, each building for the other, as 0.1.0 did. It adds Adam compiled at run time inside your own program, a library form of that for C and Pascal hosts, a benchmark suite against C, and a long list of speed and correctness work.

What's new since 0.1.0

  • Adam inside your program -- an exe that imports Adam.Embed is an embedding host: it compiles module mem modules from text at run time, links them straight into memory against itself and calls them, on both targets. Build in the background and swap in at a point you choose, keep state across a hot reload (keep), override scripts from a mods folder, and share declarations both sides import (external mem). adam check <mod> --host <exe> checks a module against its host, and the debugger follows mem modules.
  • libAdam for C and Pascal -- the same, from a C or Delphi / Free Pascal program: libadam.a and adam.dll / libadam.so with adam.h and adam.pas, in the new bindings/ folder with C and Pascal examples. Every dll and lib Adam builds now writes a Pascal unit beside its C header, and @exportunit exports an imported unit's C API as the library's own.
  • A benchmark suite -- adam bench times 14 kernels beside C twins at every optimize level on both targets, checks every checksum against C, writes JSON and a themed HTML5 report, and --check fails a kernel that grew more than 10% against a baseline. See the Benchmarks page on the site.
  • Faster code -- inline routines; closure calls and borrowed references without count traffic; a chain of string + built in one allocation; returned references moved, not copied; functions aligned to cache lines; a register allocator that keeps loop values out of the loop's back edge.
  • Faster builds -- debug and release builds read compiled units without their code where they can, warm builds merge units about twice as fast, the compiler lowers its own source faster, and the std, runtime and compiler units ship prebuilt in res/acu.
  • New standard library units -- System.Machine (processor, OS, memory), System.MemMap (virtual memory, mapped and shared memory), System.DynamicLibrary (load a shared library at run time), System.TextTemplate (HTML, Markdown or text from JSON), System.Bench; 61 units in all.
  • Documented bindings -- adam cimport writes each C declaration's header comment as its /// doc, and the raylib, Raven, SDL3, SDL3_mixer, mojoAL, JSON, XML, TOML, zlib, minizip, pl_mpeg and libc units are regenerated with them: hovering an imported routine shows its documentation.
  • -g -- a release build writes its PDB too (Windows), so profilers name the code.
  • Fixes -- among them: a Windows process start no longer hands every inheritable handle to the child; reading a whole file that reports no size (Linux /proc, pipes) reads to its end; size(T) and yield inside generics; arrays written through a var parameter on a background task; compiled units are the same bytes whichever program compiles them; building Adam from an unzipped release works.

Highlights

  • Native code, its own toolchain -- source to exe, dll or static lib in one adam build: SSA optimizer, x86_64 code generator, COFF and ELF object writers, a linker and a PDB writer, all part of Adam.
  • Self-hosted -- the compiler is about 204,000 lines of Adam in 147 units, and every build of it checks the fixpoint (stage B = stage C, byte-identical), for the cross compiler too.
  • Two targets, cross both ways -- x86_64-windows-gnu and x86_64-linux-gnu; -t picks one, and adam build hello.adam -t x86_64-linux-gnu -r on Windows runs the Linux program through WSL2.
  • Four optimize levels -- debug, safe, fast and small (-opt).
  • The language -- modules compiled once into .acu units, objects and extend, generics, closures, exceptions (hardware faults included), defer, generators, tasks (async / await), for parallel, locks and atomics, inline, and built-in unit tests (test blocks and asserts).
  • C by declaration -- external, clink and cpplink bind any C library with no headers in the build, and adam cimport turns C headers into a documented Adam binding unit.
  • Tests that ship -- adamtest and 1,171 tests run from the unzipped release with nothing else: adamtest -all builds and runs every test.
  • Examples -- 96 programs: bin/res/examples/language/ one folder per language topic, GUI demos, and embed_arena, a raylib game whose logic is an Adam script compiled while it runs.

Quick start

Build and run a program:

adam build hello.adam -r

Start a project:

adam init mygame exe
adam build mygame -r

Run the test suite and the benchmarks (from bin):

adamtest -all
adam bench

Release files

  • Adam-0.2.0-x86_64-windows.zip -- for Windows x64: adam.exe, adamtest.exe and the editor.
  • Adam-0.2.0-x86_64-linux.zip -- for Linux x86_64: the adam and adamtest executables (the Linux editor and debugger come in a later release).

Each zip unzips at the repository root and holds bin/res/ with both targets' runtime, standard library and libraries, the prebuilt units, the tests, the examples, the benchmark suite, the offline docs (bin/res/docs/index.html), bindings/ and the compiler's source (src/).

Known issue

  • On Windows with WSLg, with monitors set to "Extend these displays" and one scaled above 100%, a Linux program's borderless toggle (the examples' F11 / Alt+Enter) also covers part of the next monitor, and back to windowed its size and frame are wrong; the Windows build is not affected. Meanwhile use "Duplicate these displays" or one monitor.

Documentation: open bin/res/docs/index.html offline, or read it at adamlang.org/docs; start with the tour.

License: free and open source under the Mozilla Public License 2.0. The runtime and standard library code Adam builds into your programs carries an additional permission: see RUNTIME-EXCEPTION.md.

Requirements: Windows x64 or Linux x86_64. Running a Linux program from Windows (-t x86_64-linux-gnu -r) needs WSL2.

File Integrity

Release files are signed with minisign to verify their authenticity and integrity.

SHA-256:

c14ae69961c433930c7a7ee2c89a6e74c152f5ab80261e2af81cd310e4cef25b  Adam-0.2.0-x86_64-windows.zip
d706bb023ce548b398ee0f4f84d738c165e35fe6269c0e549b8b689cb8cd5566  Adam-0.2.0-x86_64-linux.zip

Public key:
RWSLGfwSOWByrazkUwTzwlJ3rozKvaSnr3KT2aS/hSPDSLzUTPgj/m2X

To verify a downloaded file:

minisign -Vm <filename> -P RWSLGfwSOWByrazkUwTzwlJ3rozKvaSnr3KT2aS/hSPDSLzUTPgj/m2X

A successful verification confirms that the file was signed by the project and has not been modified since it was signed.