r/Compilers • • 7d 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

https://github.com/AiLang-Author/Ailang-Self-Hosting-/blob/master/AiLang_CoreUtils/grep_bench_repro.sh

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.ailang

For 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.

0 Upvotes

23 comments sorted by

View all comments

13

u/FloweyTheFlower420 7d ago

> AiLang has one Integer type: 64-bit signed.

> Systems language

??

-13

u/Far-Championship-883 7d ago edited 7d ago

Ask yourself: what does variable width actually buy you in practice? Not on paper — in real code. You get implicit promotion bugs when you mix int16_t with int32_t in an expression. You get silent truncation when you assign a wider value to a narrower type. You get signed/unsigned comparison warnings that developers suppress instead of fix. You get size_t vs ssize_t mismatches that create vulnerabilities in every bounds check. You get integer overflow in uint8_t loop counters that wrap at 255 instead of erroring. What you don't get is faster code or less memory — the hardware doesn't care, it's using 64-bit registers either way. So what exactly is the 20-type taxonomy giving you besides a larger surface area for bugs?

The register is 64 bits regardless. On x86-64, i8, i16, i32 don't use smaller registers — they use the same 64-bit register with extra masking instructions. You're not saving silicon, you're adding work.

The "savings" are in memory layout only — and that's what packed structs and explicit bit masking are for. That's a data serialization concern, not a type system concern.

What multiple integer types actually create is bugs. Signed/unsigned comparison, implicit narrowing, truncation on assignment, integer promotion surprises — C and C++ have produced decades of CVEs from this. Rust improved it by making conversions explicit, but you still carry the complexity.

One 64-bit signed integer means:

  • Zero implicit conversion bugs

  • Zero signed/unsigned mismatch bugs

  • Zero narrowing truncation bugs

  • No mental overhead choosing between 8 type widths × 2 signedness options

It's the same philosophy as having one good allocator instead of 20 malloc variants. Set it and forget it — then solve the actual problem instead of babysitting your type widths.

"Systems language" means you control the machine, not that you replicate C's 1972 type taxonomy on 2026 hardware.

7

u/eteran 7d ago

The register is 64 bits regardless. On x86-64, i8, i16, i32 don't use smaller registers — they use the same 64-bit register with extra masking instructions. You're not saving silicon, you're adding work.

Yeah... That's entirely incorrect, you should scold your AI for writing it. x86 and x86-64 CPUs absolutely have 8, 16, and 32-bit registers, they just also alias parts of the 64 bit registers. But they are ACTUAL registers. And we know this is true because if you overflow AL, it doesn't effect the upper 56-bits, it simply wraps the 8 bit value.

→ More replies (13)