Forge

Forge Documentation

Welcome to the official documentation for Forge — a systems programming language with a self-contained compiler (forgec) that compiles .dev source files directly to native machine code, with no external toolchain.

What is Forge?

Forge is a systems programming language designed for direct compilation to native code. The compiler forgec is a single binary that:

There is no LLVM, clang, NASM, or ld involved — forgec is written in Rust and does everything itself.

Key Features

Feature Description
Self-contained compiler No external toolchain dependencies
Multiple targets x86_64 (ELF64), x86_32 (ELF32), x86_16 (flat 512-byte boot sector)
Python-like syntax Indentation-based, def/let/var, if/elif/else, match/case
Static typing Explicit type annotations with inference for literals
Memory control Raw pointers, unsafe, heap alloc/free, optional GC on x86_64
Bare metal 512-byte boot sector written entirely in Forge

Example: Hello World

package hello

from std.io import puts

pub def main() -> int32:
    puts("Hello, Forge!\n")
    return 0
# Compile and run
forgec hello.dev -o hello --target x86_64-unknown-linux-gnu
./hello
# Output: Hello, Forge!

Example: Bare-Metal Bootloader

@freestanding
pub def _start() -> void:
    puts("Hello, Forge bootloader!")
    _dev_halt()
forgec bootloader.dev -o boot.bin --target x86_16-boot
qemu-system-x86_64 -fda boot.bin -nographic

Next Steps