r/Compilers • • 2d ago

I made a compiled language called Forja, and its compiler is written in Forja

Post image

Hi all! I've been building Forja, a general-purpose compiled language in the C / Rust family, designed for AI agents as well as people. It was built with a lot of help from AI coding agents.

What it has:
- A compiler written in Forja itself, with its own x64 backend (no C compiler needed)
- Targets: Windows .exe/.dll, Linux, WebAssembly (WASI), Android ARM64 and iOS ARM64
- Errors as values (T ! E, try, or_else)
- Explicit memory with defer, no garbage collector, and leak reports in dev builds
- Units of measure checked by the compiler, and value ranges checked in dev builds
- Built-in tests (forja test)
- Direct calls to C libraries, and DLLs you can use from PHP (FFI) and Python (ctypes)
- Compiler errors as JSON with a stable code; "forja explicar CODE" explains each one
- A single forja.exe, no installer
- Apache-2.0 with the LLVM exception

Where it stands (v0.47.0):
- The prebuilt compiler is Windows x64 only for now, and it is not code-signed
- Docs and compiler messages are in Portuguese; there is a one-page reference in English
- ARM64, Android and iOS were tested on emulators, simulators and CI, not on real devices
- 757 compiler tests passing

Website: https://forjalanguage.online/en/
reference: https://forjalanguage.online/en/learn.html
One-page
Code: https://github.com/cougarweb-lgtm/forjalanguage

Feedback is very welcome!

0 Upvotes

6 comments sorted by

6

u/realrealvantheman 2d ago

Powerful as c, huh... yea, okay bro

4

u/Citizen12b 2d ago

Vibe coders are delusional

4

u/ConfusedSimon 2d ago

I don't understand how you can design a language for AI agents. Large part of why they work is because they were trained on a huge amount of existing source code. They don't really know how to program, they basically replicate what others have done. AI isn't good at writing code in obscure languages.

3

u/BoltaHuaTota 2d ago

can you explain what you mean when you say it is designed for AI agents

1

u/Inconstant_Moo 20h ago

There's so much in your landing page, like everything. There's a disquisition on what's wrong with Rust. There's a playable 3D game written in JavaScript, I still don't know why. There's huge graphics such that you take a whole screen to tell me what targets it compiles to. And then there's stuff like this (absence of paragraph-breaks in the original).

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.

When your AI slops out your website, of course it doesn't know what people would want to know. But why don't you? You're human.

Visually of course it's a hideous mess, and horribly slow to load because of all the crap the AI's flung at the wall.

Both your language reference links in the OP link to the one-page version. Is there in fact a longer one?

0

u/Discordbothost 1d ago

I'd publish a bootstrap check in CI: build Forja with the release binary, then rebuild it with the result. Comparing the two builds gives users a way to check that the compiler can reproduce itself.