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

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

3

u/eteran 15d ago

You can't even write a simple reply without having AI write it kinda tells me everything i need to know. Can't think for yourself long enough to even defend your design choices in your own words. 😂

Also worth noting that all mainstream systems languages have basically no "heavy runtime" to speak of. You're trying to fix a problem that doesn't exist... Badly.