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

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

View all comments

Show parent comment

6

u/eteran 15d 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 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_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 15d 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 15d 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 15d 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 15d 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.

3

u/eteran 15d ago

Slop slop slop, LOL. When bots think for you, you know nothing.

is an address calculation instruction. It computes base + index * scale + displacement. It has nothing to do with type widths.

It actually has EVERYTHING to do with type widths. It's WHY IT EXISTS. Sure it works the same regardless of the types, but that's not the point. The point is that when the compiler KNOWS that you want to scale the calculation based on the type (and it know that because you used a pointer to a different type), it will emit an LEA with an appropriate SCALE. Like 2 for. 16-bit pointer and 4 for a 32-bit pointer. There's a reason why the options for scale are 1,2,4, and 8. Because they match the native type widths the CPU supports.

"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." ... The fact that you don't know why it's relevant to your own argument is telling.

Oh I know why it's relevant in C, but it's irrelevant for languages that aren't mimicking how C works. Since you're (or more specifically Claude) writing the compiler, you can make volatile or whatever you choose to call it have clear and consistent semantics.

eliminating signed/unsigned mismatch bugs, implicit truncation, and integer promotion surprises is a technical argument.

All of those are solvable without elimination of other integer types.. for example Go solves it by simply requiring the dev br explicit.

You've moved from "can't be done" to "can be done but ugly"

Adjusting ones argument based on new information is a good thing, you should try it sometime.

to arguing about LEA instructions that have nothing to do with the point.

Except it does have to do with the point. Your design underutilizes what the hardware can do, that makes for a poor "systems" language.

1

u/Far-Championship-883 15d ago

LEA scales — Yes, LEA has scale factors 1, 2, 4, 8 for array stride calculations. The compiler emits LEA rax, [rbx + rcx*2] when indexing into 16-bit packed data. But the scale comes from the data layout, not the variable type. AILang knows an array element is 2 bytes wide when you're working with packed data — that's a storage descriptor, not a type in the variable declaration. The compiler emits the right LEA without the programmer declaring uint16_t. You're confusing what the code generator needs to know with what the programmer needs to say.

Volatile — "You can make volatile have clear and consistent semantics." Yes. We did. They're called SetByte, GetByte, GPU_Rd32, GPU_Wr32. Each one is an explicit access with defined width and no optimization ambiguity. That IS the clear and consistent volatile semantics you're describing, without the keyword that means six different things depending on compiler vendor.

"Go solves it by requiring the dev be explicit" — Go has multiple integer types AND requires explicit casts between them. AILang went further: one type, nothing to cast. Go reduced the bug surface. AILang eliminated it. Fewer types is the logical endpoint of Go's own direction.

"Underutilizes hardware" — the benchmarks say otherwise. If "underutilizing" the hardware means beating GNU grep 14/16 and running a CAD kernel at 302 MB flat, what's the "fully utilized" version supposed to look like? Show me the numbers.

3

u/eteran 15d ago

If I wanted a bot to explain how the hardware works I'd ask it myself 😂. But I'll answer just this one part because after looking at the code in the repo, I'm more convinced than ever that this is awful syntax..

Volatile — "You can make volatile have clear and consistent semantics." Yes. We did. They're called SetByte, GetByte, GPU_Rd32, GPU_Wr32.

So instead of having the dev be able to write what they mean, you had to introduce a zoo of special case functions (which have poor naming consistency BTW, is the size a number or a word describing the number? You chose... Both?).

I took a look at the array access code in your standard library and it's SUPER verbose and is a result of what I'd consider poor design decisions that no serious dev will want to deal with.

don't think ANYONE will want to use a language that works like this. But you know what, maybe I'm wrong. Best of luck.

1

u/Far-Championship-883 15d ago

Since you went digging through the repo and decided to lecture us on syntax, let’s talk about what AiLang actually is and why your critique is completely backwards.

  1. Designed for LLM-Human Pair Programming & Fast Reading: AiLang isn't a language written by hand for typing ergonomics on a laptop keyboard; it is engineered specifically for transformer-optimized LLM-human pair programming, where explicit, verb-first syntax ensures high token clarity, unambiguous semantics, and instant comprehension for both human architects and AI collaborators.
  2. The VS Code Shorthand & Type-Ahead Engine: Whining about verbosity ignores the reality of the toolchain. The VS Code plugin features a complete shorthand mode with bijective pre-lex transforms and type-ahead lookup that expands abbreviations instantly on the fly while keeping the canonical source clean, explicit, and self-contained on disk.
  3. Explicit Hardware & MMIO Control: Calling primitives like GetByte, SetByte, GPU_Rd32, and GPU_Wr32 a 'zoo' just exposes your unfamiliarity with real systems work. In a performance-critical systems language, deterministic MMIO without hidden compiler-obscured volatile side-effects or heavy runtime bloat is mandatory. You want magic; we want to know exactly when a read or write hits the bus.
  4. Self-Hosting Throughput & Zero Dependencies: While you're worried about whether size is a number or a word in a function name, the single-core compiler processes 250,000 LOC in under 20 seconds via direct Linux syscalls, emitting zero-dependency static binaries that beat GCC -O3 on multiple workloads while maintaining a fraction of the binary footprint.

If you want a language that holds your hand with heavy runtime abstractions and hidden macros, stick to the mainstream stack. AiLang is built for bare-metal performance, self-hosting systems engineering, and modern AI-augmented workflows."

→ More replies