r/Compilers • u/Far-Championship-883 • 15d ago
AiLang, Artificial Intelligence Programming Language with a Self hosting x86_64 compiler, performance comparable to gcc -03 llvm clang in many instances.
https://github.com/AiLang-Author/Ailang-Self-Hosting-Hi my name is Bob I am a contributor to the AiLang project.
Why this is in compilers, rather simple, this repo has a fully self contained self hosting x86_64 optimizing compiler. From the Read me below.
AiLang
A self-hosting systems language designed for consistency, readable code, and AI-assisted development.
AILang is built around a deliberate trade-off: a constrained syntax with a rich set of primitives. Rather than accumulating many special cases, language constructs follow consistent shapes—from primitive arguments to functions and subroutines. The result is code intended to be easy to scan, search with tools like grep, generate with AI, and understand in human–AI pair programming.
The language is not only a proposal: its compiler is written in AILang and compiles AILang programs to native code. The project is working toward version 1.0.0, targeted for December 31, 2026.
Why AILang
- Consistency over syntax variety. Primitives, arguments, functions, and subroutines follow coherent conventions, reducing the number of forms a reader or code-generation tool needs to learn.
- A constrained language with substantial primitives. Keep the surface syntax deliberate while providing reusable capabilities for practical systems code.
- Designed to be read and searched. Clear, regular code is easier to skim, inspect, and navigate with ordinary tools—including
grep. - Built for human and AI collaboration. Predictable structure supports code generation and review without giving up human readability.
- Systems programming with a self-hosting compiler. AILang is statically typed and compiles to native code; the compiler itself is implemented in AILang.
Performance
AILang's compiler and generated code are being optimized continuously. Project benchmarks show performance competitive with GCC -O3 on a number of measured workloads, with results varying by program and workload. See the benchmark results for the measurements and test details.
Performance claims should be read in the context of those specific benchmarks—not as a guarantee that every AILang program matches GCC. The goal is to keep improving generated code while retaining the language's emphasis on explicit, readable structure.
AILang grep beats GNU grep 3.11 in 13 out of 14 tests. Here's the scorecard:
| Test | AILang | GNU grep 3.11 | Winner |
|---|---|---|---|
'kernel' | 208 ms | 311 ms | AILang — 1.49× |
-F 'kernel' | 212 ms | 310 ms | AILang — 1.46× |
-i 'kernel' | 251 ms | 358 ms | AILang — 1.42× |
-c 'kernel' | 168 ms | 190 ms | AILang — 1.13× |
-n 'kernel' | 315 ms | 428 ms | AILang — 1.35× |
-v 'kernel' | 352 ms | 472 ms | AILang — 1.34× |
-w 'kernel' | 222 ms | 615 ms | AILang — 2.77× |
-ic 'kernel' | 195 ms | 234 ms | AILang — 1.20× |
-wc 'kernel' | 179 ms | 415 ms | AILang — 2.31× |
-Fc 'kernel' | 169 ms | 193 ms | AILang — 1.14× |
'UNIQUE_MARKER_XYZ' | 49 ms | 79 ms | AILang — 1.61× |
-c 'UNIQUE_MARKER' | 47 ms | 78 ms | AILang — 1.65× |
-F 'error_handler' | 272 ms | 288 ms | AILang — 1.05× |
-Fc 'error_handler' | 223 ms | 163 ms | GNU — 1.36× |
EDIT addition
| Regex Pattern | AILang | GNU grep | Winner |
|---|---|---|---|
mem.*buf | 188 ms | 291 ms | AILang 1.55x |
ker[nm]el (character class) | 229 ms | 405 ms | AILang 1.77x |
^kernel (anchor) | 170 ms | 176 ms | AILang 1.03x (tie) |
| `socket | daemon` (alternation) | 387 ms | 509 ms |
Highlights:
- Word match (
-w) is 2.77× faster than GNU grep. - Rare-pattern search is 1.65× faster — MemMem's scan-and-skip is very efficient.
- Case-insensitive search is 1.42× faster — MemMemFold pays off.
- The only loss is long fixed-pattern count (
-Fc error_handler), where GNU's Boyer–Moore–Horspool skip table gives it an edge on 13-character patterns. - The AILang binary is 118 KB vs. GNU's 1.7 MB — 14× smaller.
- 100% correctness — every test matches GNU grep output exactly.
What it can express
AILang is intended to span a broad range of programs: from a small “Hello, world!” to substantial systems software. The repository includes a self-hosted compiler, reusable libraries, command-line utilities, and larger projects such as a custom CAD kernel and an OS runtime layer running on the Linux kernel. These projects are at different stages of development; see their own documentation for current status.
Try AILang
Compile a source file with the compiler:
./ailang.x path/to/program.ailangFor installation, options, and compiler commands, see install_compiler.sh and the compiler documentation.
Start learning with the programming manuals and browse the demo programs. The workspace guide describes the repository layout.
Project status
AILang is under active development. The compiler, language, libraries, and example systems are evolving; expect incomplete features and occasional regressions. The project is progressing toward its December 31, 2026 version 1.0.0 target. Check the relevant project documentation and tests for the current state of individual components.
View all comments
Show parent comment
-1
u/Far-Championship-883 15d ago
You are still wrong,. go hit the fucking manual for the CPU and errata.
We're four replies deep and you still haven't answered the original question: what does variable width buy you?
You've explained that CPUs have register aliases. You've explained that register renaming mitigates the problems those aliases create. You've explained that compilers emit masks and shifts to handle narrowing. None of that is an argument for variable width types in a language — it's a description of the machinery required to support them.
So concretely: show me a program where using
uint8_tinstead ofint64_tproduces faster code, uses less memory at runtime, or prevents a bug. Not a theoretical register pressure scenario — actual code, actual measurements. Because I've posted benchmarks. The 236 KB static binary with one integer type beats GNU grep on 14 of 16 cases including regex. The reproducible script is in the repo. Run it.The burden of proof is on the person defending the complexity. You're arguing that 20 integer types are necessary.
In addition to that here is again my response, here are counters to every theological thing you;ve stated.
Register renaming solves partial register stalls — yes, by adding extra silicon complexity. That's the CPU spending transistors to work around sub-register aliasing. You're citing the band-aid as evidence there's no problem.
Hardware had to fix a software design flaw.
Register pressure and 8-bit variables — using AL doesn't free up RAX. They're the same physical register. On x86-64 you have 16 GPRs. Using narrower aliases doesn't give you more of them. And the high-byte registers (AH, BH, CH, DH) can't even be used with REX-prefixed instructions in 64-bit mode, so narrow types actually reduce your available register space.
Just shuffling deck chairs
"The cheapest thing is to just use the 8-bit registers" — the ALU functional units are 64-bit. An 8-bit ADD doesn't execute faster than a 64-bit ADD. It uses the same execution port, the same cycle count. You're not saving any execution resources.
got benchmarks for this ?
"The compiler would just emit the masks and shifts for you" — you just made my argument. If the compiler handles the narrowing regardless, then exposing 20 integer widths to the programmer is pure cognitive overhead with zero hardware benefit. One type in the language, compiler handles storage packing at the boundaries. Which is exactly what AILang does.
You started by saying I'm confused about language vs hardware abstractions, then concluded by explaining that the compiler abstracts away the hardware regardless. That's the point.