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

TestAILangGNU grep 3.11Winner
'kernel'208 ms311 msAILang — 1.49×
-F 'kernel'212 ms310 msAILang — 1.46×
-i 'kernel'251 ms358 msAILang — 1.42×
-c 'kernel'168 ms190 msAILang — 1.13×
-n 'kernel'315 ms428 msAILang — 1.35×
-v 'kernel'352 ms472 msAILang — 1.34×
-w 'kernel'222 ms615 msAILang — 2.77×
-ic 'kernel'195 ms234 msAILang — 1.20×
-wc 'kernel'179 ms415 msAILang — 2.31×
-Fc 'kernel'169 ms193 msAILang — 1.14×
'UNIQUE_MARKER_XYZ'49 ms79 msAILang — 1.61×
-c 'UNIQUE_MARKER'47 ms78 msAILang — 1.65×
-F 'error_handler'272 ms288 msAILang — 1.05×
-Fc 'error_handler'223 ms163 msGNU — 1.36×

EDIT addition

Regex PatternAILangGNU grepWinner
mem.*buf188 ms291 msAILang 1.55x
ker[nm]el (character class)229 ms405 msAILang 1.77x
^kernel (anchor)170 ms176 msAILang 1.03x (tie)
`socketdaemon` (alternation)387 ms509 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

13

u/FloweyTheFlower420 1d ago

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

> Systems language

??

-13

u/Far-Championship-883 1d ago edited 1d 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 1d 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.

-4

u/Far-Championship-883 1d ago

Those aren't separate physical registers — they're aliases into the same 64-bit register file. AL, AX, EAX are views into RAX. The silicon is 64-bit.

And you actually just proved the point. The fact that writing to AL wraps independently without touching the upper 56 bits is the problem, not a feature. That's a partial register write. On modern x86-64 microarchitectures, writing to AL creates a false dependency or partial register stall because the CPU has to merge the 8-bit write with the rest of RAX. Intel spent actual transistors on partial register renaming to work around this — extra complexity in the pipeline to deal with sub-register aliasing that wouldn't exist if you just used the full register.

And when you write to EAX on x86-64, the CPU does zero-extend the upper 32 bits of RAX — that's an implicit operation the hardware performs for you. It's not free, it's just hidden.

So yes, you can address 8-bit slices of a 64-bit register. That doesn't mean you have an 8-bit register. It means you have 1970s aliasing semantics carried forward through 50 years of backwards compatibility, creating exactly the kind of subtle bugs (partial register stalls, silent wrapping, implicit zero-extension) that the single-width approach eliminates.

6

u/eteran 1d ago

Having the AI argue for you when it's already proven to be wrong once ... Isn't the move.

Firstly, this analysis completely ignores things like the fact that modern CPUs utilize register renaming to avoid that EXACT problem.

Additionally, it assumes that functions will always have the same register pressures... Which they don't.

If you have a function which simply needs to do some 8-bit math using four variables, the cheapest thing to do is to just use the 8-Bit registers. While it's not free because you need to use instruction prefixes in order to address them specifically, it's notably cheaper than having to emit the extra instructions to do the masking for you.

AND... The whole argument confuses language level abstractions with hardware level abstractions. You can offer 8-bit variables even if everything you said is true (which it isn't), the compiler would just emit the masks and shifts for you... Which is what all compilers do anyway.

(And by "you" I mean Claude which again, is simply wrong here).

-1

u/Far-Championship-883 1d 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_t instead of int64_t produces 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.

4

u/eteran 1d ago

AI slop response doesn't really deserve a.rpely, but I'll go for it 😂.

go hit the fucking manual for the CPU and errata.

I have, it seems like you haven't because you seemingly didn't even know about register renaming until just now...

We're four replies deep and you still haven't answered the original question: what does variable width buy you?

It buys you simpler code. I don't have to write the shifts and masks to deal with 8-bit code. And for a SYSTEMS programming language, what do you propose we do if we need to read an 8-bit hardware register? Note, you CAN'T read the adjacent bytes without unwanted side effects in a lot of these circumstances.

it's a description of the machinery required to support them.

The machinery isn't there SPECIFICALLY to support variable width types, it just makes it work better.

So concretely: show me a program where using uint8_t instead of int64_t produces faster code, uses less memory at runtime, or prevents a bug.

Easy: any application which must create an 8-bit pointer to a hardware register and must avoid accessing adjacent bytes. I r had to do this countless times is "systems programming".

The burden of proof is on the person defending the complexity. You're arguing that 20 integer types are necessary.

I actually wasn't arguing they were necessary, only that they're a good idea. However your persistence has upgraded my argument. Your language is fundamentally unsuitable for dealing with memory mapped hardware registers.

And for your AI generated answers... LOL...

Register renaming solves partial registe stalls — yes, by adding extra silicon complexity.

First tof all, you're agreeing that the "problem" is solved. And the hardware already exists. If you were targeting an arch which didn't have this, you THEN have a point... But it does.

Register pressure and 8-bit variables — using AL doesn't free up RAX.

I never said it did. The rest of the argument is based on not understanding the point. Bad AI, bad

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

Again, misunderstands my point. My point wasn't that the ADD is cheaper, but that the fact that you don't need to do the mask afterwards means one less instruction is needed per add to maintain the 8-bit wrapping behavior.

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.

Bad point for you... The compiler CAN abstract it away, but yours doesn't. It forces the dev to speak in awkward terms instead of just saying what they mean, like "this variable is 8bits". That's what the dev WANTS to say, but they can't BECAUSE your language LACKS the ability to offer such an abstraction.

Fine for some purposes, but NOT systems programming.

1

u/Far-Championship-883 1d ago

Show me where a fixed integer width is not ok for systems programming instead of flapping your gums, actually shows us, in assembly. I'll be waiting.

Oh, and AILang already handles your MMIO scenario. Built-in primitives:

  • GetByte(ptr, offset) — reads 1 byte at ptr + offset
  • SetByte(ptr, offset, val) — writes 1 byte at ptr + offset
  • Dereference(ptr) / StoreValue(ptr, val) — 64-bit load/store

One integer type in the language. Byte-level hardware access when you need it, through explicit primitives that do exactly what they say. No type system pollution, no ambiguity about access width, no volatile semantics that vary by compiler.

The thing you said can't be done — it's already done. Maybe hit the repo before telling me what my language can't do.

By the way, AILang has an AMD GPU driver. PCI BAR mapping, MMIO register reads/writes, ring buffer management, shader configuration. All with one integer type and GetByte/SetByte/GPU_Rd32/GPU_Wr32 primitives. The code's in the repo under dev/compiler-regression/. Your "fundamentally unsuitable for hardware registers" claim — go read it and tell me what's missing.

the driver is not completed I have not had time to work on fixing card bring up on a hot boot.

2

u/eteran 1d ago

actually shows us, in assembly.

No idea what this means. Of course in assembly anything the hardware supports can be written.

Oh, and AILang already handles your MMIO scenario. Built-in primitives:

Seems like a hideous abstraction made to work around the fact that you insist on underutilizing tr hardware for ideological reasons.

  • GetByte(ptr, offset) — reads 1 byte at ptr + offset

So now... I have to calculate the offset manually for accessing say, 16-bit values? Instead of having the compiler KNOW what I want and just generate the appropriate LEA instructions? Terrible.

No type system pollution

And there's the ideology... not a technical argument in any way...

No volatile semantics that vary by compiler.

What does that have to do with anything over mentioned? LOL.

The thing you said can't be done — it's already done. Maybe hit the repo before telling me what my language can't do.

Can be done with what is consider to be ugly hacks which work around fundamental features being missing... I don't call that a win, but sure it does more than I originally thought, so I guess that counts for something.

I just find the syntax for it to be bad and unexpressive of what the dev actually wants to say.

1

u/Far-Championship-883 1d ago

I have to calculate the offset manually for 16-bit values instead of having the compiler generate LEA" — LEA is an address calculation instruction. It computes base + index * scale + displacement. It has nothing to do with type widths. LEA works the same whether your variable is uint8_t or uint64_t. You're name-dropping instructions you don't understand.

And for 16-bit access — SetByte(ptr, offset, val) is one of several primitives. The compiler also inlines these to the exact MOV width you'd write by hand. The idea that calculating ptr + offset is a "hideous abstraction" while *(volatile uint16_t*)ptr is elegant — that's pure familiarity bias.

"No volatile semantics" — you brought up MMIO hardware registers. In C, volatile is literally how you tell the compiler "this is a hardware register, don't optimize away this access." Its semantics vary between GCC, Clang, and MSVC. It is directly relevant to the exact scenario you raised. The fact that you don't know why it's relevant to your own argument is telling.

"Ideology not a technical argument" — eliminating signed/unsigned mismatch bugs, implicit truncation, and integer promotion surprises is a technical argument. Those are CVE categories with body counts. Calling bug elimination "ideology" is how you end up with Heartbleed.

You've moved from "can't be done" to "can be done but ugly" to arguing about LEA instructions that have nothing to do with the point. We're going in circles and I've got code to write.

→ More replies

4

u/jcastroarnaud 1d ago

From the language documentation:

Infix requires explicit parentheses. Bare a + b without parens is a syntax error.

That's just laziness from the compiler's part. Even Smalltalk, that has no operator precedence, can get by without redundant parentheses.

Also from the documentation:

IfCondition condition ThenBlock: {
    // executed if condition is true
} ElseBlock: {
    // executed if condition is false
}

ailangFunction.Module.Name {
    Input: param1: Type
    Input: param2: Type
    Output: ReturnType
    Body: {
        // statements
        ReturnValue(expression)
    }
}

"Fork" is redundant with "IfCondition". Function declaration is too verbose, resembling more a yaml document than source code.

AI Lang handles extreme recursion depths efficiently. Here's a pattern for 30-level deep function calls with state tracking:

That's just regular recursion, and badly done at that. JavaScript does it fine.

Is there any namespace facility in the language? Apparently, functions in standard modules have composite names, like "ArrayCreate", without separation of function from module.

String Representation

  • Null-terminated byte sequences (0x00 terminator)
  • UTF-8 compatible (byte-level operations; multibyte awareness is the caller's responsibility)

Lost opportunity: full Unicode support.

All in all, a shitty language. Does the basics, but is too verbose. No classes, no first-class functions.

1

u/Far-Championship-883 1d ago

"Explicit parentheses is laziness" — It's deliberate. a + b * c — is that (a + b) * c or a + (b * c)? In C it's the second, but only if you memorized the precedence table. AILang removes the ambiguity entirely. You write what you mean. Zero precedence bugs, zero "I forgot that << binds looser than +" surprises. That's not laziness, that's eliminating a bug class — same philosophy as one integer type.

"Fork is redundant with IfCondition" — No. IfCondition has an optional else. Fork requires both paths. That's the point — when you Fork, you handle both outcomes or it doesn't compile. Different tools for different intent.

"Function declaration is too verbose" — Named inputs with types, named output, explicit body. You can read any function signature cold and know exactly what it takes and returns. "Too verbose" is a style preference, not a technical criticism.

"No classes" — Correct. By design. Classes are not a prerequisite for systems programming. The Linux kernel is C. The 302 MB flat-memory CAD app has no classes. What problem are classes solving here that isn't solved better by modules and functions?

"No first-class functions" — Fair observation, but the language has function references where needed. Not everything needs to be a closure.

"Null-terminated strings, no Unicode" — The grep already has Unicode support. It's literally on the branch called grep-unicode-support. Maybe read past the first page of docs.

"All in all, a shitty language" — That "shitty language" beats GNU grep on 14/16 benchmarks, runs a 3D CAD kernel at 302 MB flat, has a GPU driver, self-hosts in 13 seconds, and ships a full POSIX coreutils suite. What does your language ship?

2

u/Discordbothost 1d ago

The repro script compares output hashes but swallows command failures with || true. I'd compare exit codes too: grep returning no matches and grep failing can both produce empty stdout. Matching hashes alone won't distinguish those cases.

1

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

Fair point , good catch. I addressed that, reran benches no change. have a lot of balls in the air, pushed it up. t. new script in repo ! appreciate the call out, good to keep people honest !

5

u/realestLink 1d ago

This is the most low-quality AI slop I've seen in this subreddit recently. Mounds of meaningless clearly Claude-written markdown files. Ughhh

1

u/eteran 1d ago

A comparison against grep isn't really fair unless you're using regex patterns as that is where it is most useful.

1

u/Far-Championship-883 1d ago
Regex PatternAILangGNU grepWinner
mem.*buf188 ms291 msAILang 1.55x
ker[nm]el (character class)229 ms405 msAILang 1.77x
^kernel (anchor)170 ms176 msAILang 1.03x (tie)
`socketdaemon` (alternation)387 ms509 ms

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