Skip to content
Adam

Adam

Pascal clarity. Native code. Its own toolchain.

A general-purpose systems language in the Pascal and Oberon line, with its own compiler, linkers and debug-info writer, written in Adam and built by itself, for Windows and Linux on x86_64.

Self-hosted Native x86_64 x86_64-windows-gnu and x86_64-linux-gnu Open source, MPL-2.0
Ideas

One tool, all the way down

Source goes to machine code, object files, an executable and its debug info through Adam's own parts. There is no other toolchain behind it.

Native from end to end

Adam's own instruction encoder writes the x86_64 code, its own writers the object files (COFF on Windows, ELF on Linux), its own linkers the executable and its own PDB writer the Windows debug info.

It builds itself

The compiler is written in Adam. A new compiler is installed only when the compiler it built, and the one that compiler built in turn, are the same byte for byte.

Two targets, one source

x86_64-windows-gnu and x86_64-linux-gnu, each named by its triple. A build defines TARGET_<triple>, so @ifdef picks the code for one of them; from Windows, a Linux program builds and runs under WSL.

C is a declaration away

A clink routine with an external clause is the whole binding; adam cimport writes a binding unit from a library's headers.

Errors speak Adam

A mistake is reported at the .adam file, line and column, with a code, before anything is built. A value never narrows silently.

Every example is checked

Every program on this site and in the docs is a file built and run on both targets; the output shown is the output it must print.

Real code

Checked on both targets

Each example is built and run on x86_64-windows-gnu and x86_64-linux-gnu by the docs' check, in a release build: what you see printed is what it prints.

objects_virtual.adam
module exe objects_virtual;

type
  Shape = object
    Title: string;

    virtual method Area(): int64;
    begin
      return 0;
    end;

    // The call through self reaches the object's own kind
    method Describe();
    begin
      println("{} has area {}", self.Title, self.Area());
    end;
  end;

  Square = object(Shape)
    Side: int64;

    override method Area(): int64;
    begin
      return self.Side * self.Side;
    end;
  end;

  Rectangle = object(Shape)
    Width: int64;
    Height: int64;

    override method Area(): int64;
    begin
      return self.Width * self.Height;
    end;
  end;

// Any shape, reached through a ref to the base
func Show(const AShape: ref Shape);
begin
  AShape.Describe();
end;

var
  GSquare: ref Square;
  GRect: ref Rectangle;

begin
  GSquare := ref Square;
  GSquare.Title := "square";
  GSquare.Side := 3;
  GRect := ref Rectangle;
  GRect.Title := "rectangle";
  GRect.Width := 4;
  GRect.Height := 5;
  Show(GSquare);
  Show(GRect);
end.
output on x86_64-windows-gnu and x86_64-linux-gnu
square has area 9
rectangle has area 20

Objects that say what they do

An object carries its fields and methods and reaches itself through self.

  • object(Base) extends Base.
  • A method is virtual only when it says virtual; a kind that replaces it says override.
  • A ref to a derived object goes wherever a ref to its base is asked for, and a virtual call through it reaches the object's own kind.
At a glance

The whole board

Every line below links to the page that shows it, and the docs' check proves each one against the compiler's own sources before this page is written.

Native, end to end

Pascal clarity

Modern control

C, one declaration away

Tools of its own

Media

Watch, read, listen

A short intro, the infographic, a one-minute short, the explainer and the deep-dive podcast.

Click a video to zoom it, click again or press Esc to put it back.Tap the infographic to open it full size.

Get started

From a file to a native program

A program is a module headed module exe <name>;, and its main block runs when it starts. Save this as hello.adam and build it:

build and run
adam build hello.adam -opt fast -r
adam build hello.adam -opt fast -t x86_64-linux-gnu -r

The second line builds the same source for Linux and, from Windows, runs it under WSL. Without -opt a build is debug, and a debug build also prints a heap report when the program ends.

hello.adam
module exe hello;

begin
  println("Hello from Adam!");
end.
output on x86_64-windows-gnu and x86_64-linux-gnu
Hello from Adam!

A compiler that compiles itself, and then your code.