As direct and powerful as C, but modern: errors as values, explicit memory, compilation in fractions of a second, and a small syntax that AI agents get right on the first try.
// example.fj: errors are values, not surprises
enum Error { not_found }
proc find(id: i32) -> i32 ! Error {
if id == 0 {
return Error.not_found
}
return id * 10
}
proc twice(id: i32) -> i32 ! Error {
let v = try find(id)
return v * 2
}
proc main() {
switch r in twice(0) {
case i32:
print(r)
case Error:
print("not found")
}
}
$ forja run example.fj
not found
$
Forja is a compiled, general-purpose language for writing everything from command-line tools to native libraries, servers and games. You control memory and data as you would in C, without inheriting its traps.
Few ways to write each thing. No macros, no inheritance, no exceptions, no GC. What you read is what runs.
Every alloc says where the memory comes from; defer delete guarantees cleanup; leaks are flagged in development.
T ! E, try, and a switch that forces you to handle every case. No forgotten return codes.
Near-instant feedback, which matters as much to people as to agents that compile hundreds of times per task.
The foreign block calls mature C libraries (libcurl, zlib, HarfBuzz…) without reinventing the wheel, with handle ownership rules.
Since 0.24.0, the Forja compiler is written in Forja. The language proves itself every day.
The three snippets in each example were actually compiled and run, and they produce the same output. Compare what each language asks of you.
#include <stdio.h>
typedef enum { OK = 0, ERR_NOT_FOUND } Error;
Error find(int id, int *out) {
if (id == 0) return ERR_NOT_FOUND;
*out = id * 10;
return OK;
}
Error twice(int id, int *out) {
int v;
Error e = find(id, &v);
if (e != OK) return e;
*out = v * 2;
return OK;
}
int main(void) {
int r;
if (twice(0, &r) == OK) printf("%d\n", r);
else printf("not found\n");
return 0;
}enum Error { NotFound }
fn find(id: i32) -> Result<i32, Error> {
if id == 0 { return Err(Error::NotFound); }
Ok(id * 10)
}
fn twice(id: i32) -> Result<i32, Error> {
let v = find(id)?;
Ok(v * 2)
}
fn main() {
match twice(0) {
Ok(r) => println!("{}", r),
Err(_) => println!("not found"),
}
}enum Error { not_found }
proc find(id: i32) -> i32 ! Error {
if id == 0 {
return Error.not_found
}
return id * 10
}
proc twice(id: i32) -> i32 ! Error {
let v = try find(id)
return v * 2
}
proc main() {
switch r in twice(0) {
case i32:
print(r)
case Error:
print("not found")
}
}Result and ? work well, but they require familiarity with traits and the type system.T ! E is in the signature, try passes it along, and the switch only compiles if it handles both the value and the error.| C | RUST | FORJA | |
|---|---|---|---|
| Memory | malloc / realloc / free by hand | ownership + borrow checker (guarantee at compile time, learning curve) | explicit allocator + defer delete; single owner; leaks and use-after-free flagged in dev |
| Errors | return codes and output parameters | Result and ? | T ! E, try, or_else, exhaustive switch |
| Metaprogramming | preprocessor and macros | macros and traits | no macros: the code is what you see |
| Domain types | typedef (no protection) | newtypes | unit Meters: f32 and i32 in 0..=100 ranges, both native |
| Calling C libs | native | extern + unsafe | foreign block with ownership clauses (creates, destroys) |
| Build speed | fast | known for long builds | designed to compile in fractions of a second |
| Disk and CI | small objects and binaries | target/ folder that often passes 5 GB and reaches 10–20 GB; heavy CI, with tens of GB of cache | run and test in ≈ 90 ms, no artifact folder in the project; a complete .exe of tens of KB |
| For AI agents | undefined behavior, macros | very rich syntax and type system | 8 KB spec, forja explain, JSON diagnostics |
target/ folder. Cargo compiles the whole dependency graph and does not delete artifacts left by older compiler versions.target/ fills that up fast.target/ that filled the disk; the usual answer is sccache, cargo-sweep and merge queues.target/ as one of the biggest complaints. The reduction in nightly testing is about 27–30%: an improvement, not a solution.In practice, the team starts spending time on CI caching, disk cleanup and pipeline waits, instead of on the product.
Sources: DEV Community · Rust compiler performance survey 2025 · 2025 State of Rust Survey · matklad: Fast Rust Builds · Rust Users: “Is Rust compile time really that slow?” · Depot: sccache on GitHub Actions · Inside Rust: reducing target dir size · Rust Project Goals: Fast Builds. The 10–20 GB per-worktree sizes come from our own measurements, recorded in our projects.
forja run: compiles your change and runs the program right away.forja test: runs the file's test blocks right after the edit.forja check: points out the error before even generating the executable.run, test and check. No target/ folder.When you ask for the executable (forja build), it comes out directly: the dynamic list example produced a complete .exe of 64 KB. At large scale, a 200,000-line program passes check in ≈ 0.35 s and becomes an .exe in ≈ 1.8 s. It is a short cycle: no waiting for CI to know whether the change worked, and no filling up the disk.
Measured on this machine with forja 0.27.0: small programs (average of 3 runs) and the project's 200,000-line corpus. Times vary with the computer.
Transparency: Rust guarantees memory safety at compile time, something Forja does not promise. Forja's bet is different: simplicity, predictability and fast feedback, with index and memory checks at runtime and in development.
Languages were designed for humans typing slowly. Forja was designed for a new cycle: the agent writes, the compiler answers in a format machines can read, and the agent fixes it.
forja explain CODE teaches the fix.Own x64 backend: from .fj straight to an executable, with no gcc in the path. The compiler is designed to answer before you take your hands off the keyboard.
to parse and type-check a 200,000-line program (forja check, measured today)
to build the full .exe of that same 200,000-line program (measured today)
compact spec: it fits whole in an agent's context
automated compiler tests passing, plus thousands of CLI and Linux cases
At runtime, Forja generates native x64 code with its own optimizer. The project's stated goal is to match gcc -O2; we are still measuring and closing that gap, version by version.
If you would write it in C, Forja is a candidate. The standard library and ready-made packages already cover these scenarios:
Fast utilities, automation and compiled scripts, with std:os, std:process and std:flags.
export procs become a native library for PHP (FFI) and Python (ctypes).
Math, physics and animation in std, plus foreign for raylib and GLB model loading.
HTTP/HTTPS via libcurl, TCP, UDP, strict JSON, and email over SMTP, IMAP and POP3.
SQLite, MariaDB and PostgreSQL, CSV, binary and compression (deflate/zlib).
Foundation for PDF and Excel generation, with full Unicode text (HarfBuzz, utf8proc) and HTML.
Ideal for model-generated code: short contract, machine-readable errors, built-in tests with test.
Explicit memory, ^T pointers, threads, atomics and DLL hot reload: C's classic territory.
Today Forja generates native binaries for Windows and Linux, WebAssembly (WASI) modules and native code for Android ARM64 and iPhone (iOS). The same code becomes an Android app, with no Java or Kotlin in the app, and runs in the iPhone simulator.
The same .fj becomes a .wasm module (WASI) with forja build --target wasm32-wasip1 (alias: --target wasm). It runs on Node (node:wasi) and, with a minimal WASI JS loader, in the browser. A hello comes out at about 10 KB and a 351-line program at about 36 KB (release). Works with build, run and test (the last two run the .wasm in Node, which must be on the PATH). os.args and -- args work too (argument 0 is the .wasm itself). sort, sort_by, sort_by_key, binary_search and heap_push/heap_pop work too, in the same order as x64. In development, new/make with alloc = heap and no delete raise the R0009 warning at the end of run and in each test, just like x64 (nothing is checked in release). All of std:math (sine, cosine, pow, exp, log…) works, with the same bits as x64. A proc as a value (callback, struct field, return value) works too. Printing f32/f64 gives the same text as x64. os.exit works, and --mode dll builds a reactor: the pub export proc functions become exports that JS calls directly, with pointers as i32 offsets into memory. An export that returns text (cstr) makes the module also export forja_liberar(offset), so JS can give the block back to the heap after reading the text. In development, when the program allocates on the heap, the reactor also exports forja_relatar_vazamentos(), which reports R0009 on stderr and returns how many leak points there are (it does not exist in release). An append on a list with no allocator (zero value) raises R0007, just like x64. Plain structs passed by value in pub export proc work too: the parameter arrives as an i32 offset to a block that JS wrote into memory, and the return value goes to an extra leading i32 offset (sret), with the same layout as x64.
Target aarch64-linux-android: a native .so library (--mode dll) or a PIE executable (--mode exe), linked to Bionic, with Forja's own ARM64 backend. The APK is built by the separate forja_apk tool (Android SDK build-tools: aapt2, zipalign, apksigner), around a NativeActivity, with no Java or Kotlin in the app. A minimal Forja app was installed and run on an Android emulator; it has not been tested on a physical device yet. There is also the aarch64-linux target (static ARM64 ELF, Linux syscalls only). More than 1,500 test cases give the same result as x86_64-linux. On the roadmap: graphics (GLES/Vulkan), JNI, C libraries on Android and a real device.
Targets aarch64-apple-ios-sim (iPhone simulator) and aarch64-apple-ios (device; structural only, it has never run on a real iPhone). The compiler itself generates the console Mach-O executable with an ad-hoc signature: forja build --target aarch64-apple-ios-sim a.fj -o app. With --mode dll it produces a .dylib dynamic library loadable by dlopen. The .app with a UIKit screen (UIApplicationMain through the C API of the Objective-C runtime) is assembled by the external tool forja_ios_app; forja does not package the .app. Verified on the iPhone simulator of iOS in CI (GitHub Actions, macOS): 1,587 programs (dev and release mode) run with the same output as Linux x86_64 (only the planted canaries fail, as they should), the Abyssal kernel gives the same result, 7 dynamic libraries pass through dlopen and a full-screen app starts and stays alive. Building does not require a Mac (forja.exe generates the Mach-O on Windows); running and testing requires macOS (simulator) or a device. There is still no Swift or Objective-C written directly (only the C API of the runtime), no graphics (OpenGL ES/Metal) and no third-party C libraries (sqlite, zlib, curl…) on iOS, and the demo app only shows a solid-color screen. To run on Safari/iPhone without a Mac, the path remains PWA + WebAssembly.
Dive into a 3D reef with sharks, fish schools, an anchor, a wrecked boat and a treasure chest. Use WASD and the mouse; Esc takes you back to the site. The game is JavaScript with WebGPU, adapted from Abyssal Garden (by Noniv, MIT license). Forja did not generate the game. What it compiled to WebAssembly (wasm32-wasip1) was a calculation kernel from Abyssal's test workload, which you can run in the demo next to it, comparing the time against the same calculation in JavaScript.
Forja is open source under the Apache-2.0 license. The repository includes the compiler (written in Forja), the ready-to-use forja.exe for Windows, the standard library, the specification, the examples, and a CLAUDE.md that teaches AI agents to write Forja.
Clone the repository or download the ZIP from GitHub. The forja.exe is already in the bin/windows-x64 folder: there is no installer.
git clone https://github.com/cougarweb-lgtm/forjalanguage
Compiles and runs a .fj file right away. With forja build you generate the .exe.
forja run examples/01_hello.fj
The language/doc folder holds the specification, the syntax card and recipes; examples/ holds ready-made programs. AI agents start with the root CLAUDE.md.
People and AIs may download, study, modify and train with this code. Use by language models, including to learn the language, is expressly permitted.
Windows may warn about a new .exe. Check the SHA256 published on the release page.
A question, a partnership, or want to try Forja? Write through the form or message us directly on WhatsApp.
Small, fast, native, and built to be written by people and by agents. Forja is being forged right now.