Skip to content
tinyBigGAMESPublic

About

Adam is a self-hosted, Pascal/Oberon-inspired systems programming language. Its single-executable compiler includes an optimizer, native code generator, linker, and debug writer. Features include generics, atomic reference-counted memory, concurrency, and C interoperability. Builds native binaries without external toolchains.

Topics

Resources

Code of conduct

Contributing

Stars

10 stars

Watchers

1 watching

Forks

Latest commit

ย 

History

755 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Adam

Discord Follow on Bluesky

Write Pascal-style code, get native machine code from a compiler written in itself.

Homepage ยท Documentation ยท Releases

Adam

Adam is a Pascal and Oberon inspired, general purpose systems programming language. Its compiler is written in Adam and compiles itself, and it turns .adam source straight into native x86_64 machine code with its own code generator and linker: no C compiler, no assembler and no external linker in the way.

๐Ÿ”ฅ What it is

Adam's syntax follows Pascal and Oberon: blocks open and close with words, assignment is := and equality is =, every control-flow construct carries its own end, every statement ends with ;, and names are declared before they are used.

The compiler reads each module through its own lexer, parser and semantic checker into one syntax tree, lowers it to an SSA form, optimizes it, selects x86_64 instructions, allocates registers and encodes the machine code. It writes the object files itself, COFF for x86_64-windows-gnu and ELF for x86_64-linux-gnu, links them with its own linkers into an executable (module exe), a shared library (module dll) or a static library (module lib), and writes Windows debug info with its own PDB writer. Each host builds for both targets, and every part of the compiler is written with more targets in mind.

C is reached by declaration, never by include: a routine declared external (with C or C++ linkage) is called like any Adam routine, and vendored C static libraries link through Adam's own linker.

๐Ÿš€ A first look

Here is readme_first_look.adam (below):

readme_first_look.adam: the README's first look: a task computes a square on a thread of its own while a for parallel loop adds 1 to 100 across the processors with atomicadd, then await gives the task's result.

module exe readme_first_look;

// The square of AValue, run as a task
func Square(const AValue: int64): int64;
begin
  return AValue * AValue;
end;

var
  LTask: task int64;
  LSum: int64;

begin
  LTask := async Square(12);
  LSum := 0;
  for parallel I := 1 to 100 do
    atomicadd(LSum, I);
  end;
  println("square {}", await LTask);
  println("sum {}", LSum);
end.

Output on x86_64-windows-gnu and x86_64-linux-gnu:

square 144
sum 5050

Build it and run it:

adam build readme_first_look.adam -opt fast -r

The executable lands in output\bin\x86_64-windows-gnu\fast\; -t x86_64-linux-gnu builds the same source for Linux, and from Windows -r runs it under WSL. A build is debug by default, and a debug build also prints the runtime's heap report (the [Heap] line) when the program ends.

๐Ÿงช Tests are part of the language

Unit tests need no framework, no test library and no extra tool. A module's test blocks follow its end. and see everything in it, and the asserts (testAssertEqualInt, testAssertEqualStr, testAssertTrue and the rest) report the file, the line and both values. With @unitTestMode on; the exe runs the test blocks of every unit it imports, then its own, instead of its body, and its exit code is the number of tests that failed, so a script or a CI job reads the result straight away.

Here is testing_runner.adam (below):

testing_runner.adam: with @unitTestMode on the exe runs its test blocks, not its body, and its exit code is the number of tests that failed.

module exe testing_runner;

@unitTestMode on;

// AValue squared
func Square(const AValue: int64): int64;
begin
  return AValue * AValue;
end;

begin
  println("the body does not run in test mode");
end.

test "squares a positive number"
begin
  testAssertEqualInt(9, Square(3));
end;

test "squares a negative number"
begin
  testAssertEqualInt(16, Square(-4));
end;

Output on x86_64-windows-gnu and x86_64-linux-gnu:


โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                     Unit Test Runner                         โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Running 2 test(s)...

โœ… PASS: squares a positive number
โœ… PASS: squares a negative number

โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
Results: 2 passed, 0 failed, 2 total
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Build it and run it: its tests run, not its body.

adam build testing_runner.adam -r

โœจ Highlights

  • Self-hosted. The compiler, its runtime and its standard library are written in Adam. Every compiler build is proven by a fixpoint: the compiler built by itself, twice, must come out byte for byte the same.
  • Its own back end. SSA lowering, an optimizer, instruction selection, register allocation, an x86_64 encoder, COFF and ELF object writers, the linkers and a PDB writer, all in the box. The output is deterministic at every optimize level.
  • Readable by design. Pascal and Oberon blocks, := for assignment, ; after every statement, each construct closed by its own end; enums are choices, written Name.Value.
  • Memory you can reason about. Strings, dynamic arrays and objects are managed: own, ref and weak owners with reference counts that are safe across threads, and a debug build reports every leak with where it was allocated.
  • Objects and interfaces. Object types with inheritance, virtual methods, init / copy / done, properties, interfaces, is / as, and operator declarations.
  • Threads in the language. async / await tasks (of a call, or of a whole begin .. end block), cancel / cancelled, for parallel, lock / trylock, atomics and threadstatic variables.
  • Exceptions that unwind. raise, guard with except / finally, on the platform's native unwinding, so every cleanup the language promises runs.
  • Data layout like C. Records (packed or aligned), overlays (unions), bitfields, anonymous members and inline record / overlay fields, laid out as C lays them out, so a C header maps one to one.
  • Unit tests in the language. test "name" begin .. end; blocks and asserts are part of Adam itself: @unitTestMode on; makes an exe its own test runner, its exit code the count of failed tests.
  • Errors speak Adam. Every diagnostic is reported at the .adam file, line and column, in Adam's own words, even when the linker finds the problem.
  • Fast rebuilds. Units compile once into .acu compiled units; the runtime and the standard library ship precompiled, and only what changed is compiled again.
  • Libraries in the box. The standard library's units (System.Base64, System.Bench, System.Collections, System.Console, System.CustomIO, System.Diagnostics, System.DynamicLibrary, System.ELF, System.Hash, System.HookABI, System.HookIO, System.HookIO.Core, System.IO, System.JSON.C, System.JSON.Ext, System.LibC.C, System.Linux, System.Machine, System.Math, System.MemMap, System.Minizip.C, System.MojoAL.C, System.Pack, System.Process, System.Raven.C, System.Raven.Ext, System.Raven.Raylib, System.Raylib.C, System.Raylib.Ext, System.ResData, System.SDL3.C, System.SDL3_mixer.C, System.Sign, System.SysUtils, System.TOML.C, System.TOML.Ext, System.TextTemplate, System.Windows, System.Windows.Debug, System.Windows.SDK, System.XML.C, System.XML.Ext, System.Zlib.C, System.Zlib.Ext and System.pl_mpeg.C), each with its own x86_64-windows-gnu and x86_64-linux-gnu parts where it needs the OS, and the vendored C libraries c, minizip, mojoal, pl_mpeg, raven, raylib, sdl3, sdl3_mixer, tomlc17, xml2, yyjson and zlib, built for both targets as static archives and linked into the program itself. A C library comes as a .C unit under its header's own names, and most also as an .Ext unit with an Adam API over it.
  • Two targets, one source. -t or @target picks x86_64-windows-gnu or x86_64-linux-gnu, one adam builds for both, and from Windows -r runs a Linux build through WSL.
  • Projects when you want them. A single file needs no project file. For a program with assets, adam init MyGame exe makes a project folder, adam build MyGame -r builds and runs it, and adam pack MyGame zips its assets folder into a password-protected MyGame.rez that every build copies beside the exe; the program opens it with ProjectPassword().

๐Ÿ› ๏ธ Tools

  • adam, the compiler: adam build <file>, adam check <file> (the front end only), and adam init / adam pack for a project folder with assets; adam help lists every command and option.
  • The Adam editor (adam editor [files]): a desktop program built on Electron with the Monaco editor, with build, run, pack and debug, on x86_64-windows-gnu today.
  • A language server (adam lsp): the Language Server Protocol server the editor runs, and any LSP client can: errors as you type, hover with the /// docs, go to definition, completion and formatting.
  • A debugger for x86_64-windows-gnu programs: the console debugger (adam build <file> -d) and the debug adapter (adam dap) the editor runs, both on one engine, reading the PDB Adam writes.
  • adamtest, the test runner: Adam's own test suite runs with adamtest -all, from an unzipped release, with nothing else installed.
  • adam bench, the benchmark suite: Adam's kernels timed beside their C twins at every level, with a report you can share.

โฑ๏ธ Benchmarks

Adam measures itself against C in the open. res/bench holds fourteen kernels (calls, loops, floating point, strings, allocation and ref counts, collections, closures, generics, for parallel), each with a C twin that must compute the same checksum, so every optimization level is seen doing the same work as C. From an unzipped release:

adam bench                                         every kernel, all four levels, this host
adam bench -t x86_64-windows-gnu,x86_64-linux-gnu  both targets (Linux through WSL on Windows)

It prints each kernel's time as a ratio to C's and writes the results as JSON plus one self-contained HTML5 report. The current numbers are at adamlang.org/bench.html, and the benchmark docs explain the method, the report's templates and --check, which fails a kernel whose ratio to C grew more than 10% over a baseline.

๐Ÿ“ฆ Getting Adam

Download the zip for your host from the latest release: Adam-<version>-x86_64-windows.zip for Windows x64, Adam-<version>-x86_64-linux.zip for Linux x64. Unzip it anywhere: it holds everything Adam needs, with nothing else to install. Then, in its bin folder:

adam build hello.adam -r      build and run a program
adam init mygame exe          start a project
adamtest -all                 run Adam's own test suite

Each zip comes with a .sha256 and a minisign .minisig; the release notes show how to check them.

The documentation is online at adamlang.org/docs, and offline in every release (bin/res/docs/index.html): start with the tour, and look words and codes up in the reference. Every program in it is built and run on both targets by the docs' check, and the output shown is the output it must print.

๐Ÿ”ง Building from source

Adam is self-hosted: it takes an Adam compiler to build one, and every release has one, with the compiler's own source beside it.

Requirement
Host OS Windows x64 or Linux x64
A release The latest release for your host. Its zip holds the compiler, adamtest, the compiler's source (src/, projects/), the runtime, the standard library and the static libraries for both targets, the assets and the offline docs (the Windows zip also the editor)

From a release: in the unzipped folder, run bin\build-adam.cmd (on Linux, bin/build-adam.sh).

To contribute (git history and pull requests):

  1. Clone the repo:

    git clone https://github.com/tinyBigGAMES/AdamLang.git
    
  2. Download the latest release for your host and unzip it into the root of the clone, so the compiler, the libraries and the other files git does not hold are in place.

  3. Run bin\build-adam.cmd (on Linux, bin/build-adam.sh).

build-adam builds the compiler three times (the installed adam builds stage A, A builds B, B builds C), checks that B and C are identical, builds adamtest with B, and installs them in bin. It ends with BUILD OK or BUILD FAILED.

โ“ FAQ

What do I need besides adam?

No C compiler, assembler or linker: Adam builds a program into native x86_64 machine code with its own instruction encoder, object writers and linkers, and on Windows its own PDB writer for the debug information. The standard library, the runtime and the vendored C libraries ship beside adam, for both targets. Running a x86_64-linux-gnu program on Windows goes through WSL. See Building and Targets.

Which systems can Adam build for?

Two targets, each named by its triple: x86_64-windows-gnu (the default) and x86_64-linux-gnu. One adam builds for both: the Windows adam builds a x86_64-linux-gnu program and -r runs it through WSL; the Linux adam runs its own. See Targets.

Is Adam's compiler written in Adam?

Yes, and it builds itself: a new compiler is installed only when the compiler it built (stage B) and the compiler that one built (stage C) are the same byte for byte. See What Adam is.

How do I call a C function?

Declare it: a clink routine with an external clause, with no header and no wrapper. For a whole header, adam cimport turns the headers an import spec names into an Adam .C binding unit. See External declarations and adam cimport.

Which C libraries come with Adam, and how are they linked?

Each vendored C library ships as a static archive per target, lib<name>.a in res/libs/vendor/, with the headers it was built from. A .C unit's routines name their library in their external clause: external "zlib" is found as libzlib.a. See Vendored libraries.

How do I start a project?

adam init <name> <exe|dll|lib> makes the folder with project.toml, src/<name>.adam (a starter for the kind) and an empty assets folder; the new project.toml carries a 64-character pack password. adam build <folder> builds the project whose project.toml is in . See Projects and The adam command.

How does my program read its assets?

adam pack zips the project's assets folder into <name>.rez, and every build copies it beside the exe. The program opens an entry with CreateZipFileIO("$P:<name>.rez", "<entry>", ProjectPassword()): $P: is the folder of the program's exe, and ProjectPassword() is the project file's pack password, handed to the program scrambled. See Projects.

Why does my program print a heap report when it ends?

A debug build counts every heap block it hands out and takes back and prints the heap report as the process ends; a release build counts nothing and prints no report. See The runtime.

How do I run tests?

Tests are part of the language: test "name" begin .. end; blocks follow a module's end., with asserts such as testAssertEqualInt and testAssertTrue. Put @unitTestMode on; in the exe and adam build <file> -r runs the test blocks of every unit it imports, then its own, instead of its body; the exit code is the number of tests that failed. See Testing. Whole folders of test programs, Adam's own suite among them, run with adamtest: see The test suite.

How do I debug a program?

adam build <file> -d builds the program for debugging and runs it at a (dbg) prompt in the same console; adam dap serves an editor the same engine. Adam has a debugger for its host's programs where it has one: x86_64-windows-gnu today. See The debugger.

Is there an editor?

adam editor starts the Adam editor, which checks, builds, runs and debugs your code. Any other editor that speaks the Language Server Protocol gets Adam's checks from adam lsp. See The Adam editor and The language server.

Something does not work. Is it known?

The Known issues page lists what does not work yet, where it shows and what to do meanwhile.

๐Ÿค Contributing

  • Report bugs with a minimal .adam reproduction, the exact command used, and the compiler's diagnostics.
  • Suggest features: describe the use case first, then the behavior you have in mind.
  • Submit pull requests for bug fixes, documentation, new test cases and well-scoped features; open an issue first for substantial language or compiler changes.
  • Review and discuss open pull requests and issues.

Read CONTRIBUTING and the Code of Conduct before you start. Join the Discord to talk development, ask questions, or show what you are building.

๐Ÿ’– Support the project

If Adam interests you or sparks something useful:

  • โญ Star the repo: it costs nothing and helps others find the project
  • ๐Ÿ“ฃ Spread the word: write a post, mention it in a community, or share a screenshot
  • ๐Ÿ’ฌ Join the community: help shape what comes next on Discord
  • ๐Ÿงช Build something real: real usage finds issues that synthetic tests miss
  • ๐Ÿ’– Become a sponsor: sponsorship directly funds development, examples, and documentation

๐Ÿ“œ License

Adam is free and open source under the Mozilla Public License 2.0: see LICENSE and NOTICE. The runtime and standard library files that Adam builds into your programs carry an additional permission: see RUNTIME-EXCEPTION. The Adam name and marks: TRADEMARK.

๐Ÿ”— Links

Adamโ„ข Programming Language

Copyright ยฉ 2026-present tinyBigGAMESโ„ข LLC
All Rights Reserved.

About

Adam is a self-hosted, Pascal/Oberon-inspired systems programming language. Its single-executable compiler includes an optimizer, native code generator, linker, and debug writer. Features include generics, atomic reference-counted memory, concurrency, and C interoperability. Builds native binaries without external toolchains.

Topics

Resources

Code of conduct

Contributing

Stars

10 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Contributors

Languages