r/Compilers 5d ago

Program like it's 1992 again - Hello Pascal!

Post image
95 Upvotes

Back in the 90's, some of use slightly older folk used Pascal, a lot. I've been working on an interpreter for Pascal for a while and it has turned into a compiler sort of by accident. WasmPascal is a compiler written in Odin (for now) that compiles Pascal code to wasm. The resulting binaries are capable of running on their own. It's not entirely feature complete, but if you look at the examples, you'll see that you can already build interesting and potentially useful things with it.

The compiler runs in the browser, no downloads, no installs. It's at https://wasmpascal.com/. I enjoy Pascal, a lot, and it's fun to use it to do web assembly stuff. Right now I'm obviously leaning mostly towards casual game development, but I have a long todo list for this. To see an example of one of the games running standalone, visit https://nofuss.co.za/games/breakout/. I built that with wasmpascal, exported it as an archive and hosted it as static files.


r/Compilers 4d ago

Pub my memory safe & OOP language

Thumbnail github.com
2 Upvotes

The language I tried to create by combining safety, OOP, and flexibility—Feng.


r/Compilers 4d ago

I've created an extensible JS parser in Go

5 Upvotes

The parser can be extended naturally:
https://github.com/xjslang/xjs

Instead of creating a language from scratch, you simply add your custom features to JS. This can save you a lot of time.

Any help is welcome, as creating a JS parser requires a lot of dedication.


r/Compilers 4d ago

Admiran 3.0 released (a pure, lazy, functional language and compiler)

7 Upvotes

I made a post introducing Admiran about 18 months ago, and have been making steady progress on migrating it towards the language I want to use each day. Since that time I've made a lot of performance and coding-style enhancements, such as:

  • escape analysis in the compiler's analyze pass to help determine if a lazy thunk is only evaluated at most once, allowing it to be emitted without extra code to update it to its value (saves ~15% code space and execution time!)

  • optimization to coalesce consecutive continuation closures on the stack during lowering to the Spineless Tagless G-machine (STG) implementation, deferring the popping of the entire closure until a tail-call or return

  • added a uniform set of left-to-right operators for creating computation pipelines

  • tweaking the inlining pass parameters to get the best performance / code-size tradeoffs

The latest big change was to fully migrate from an ad-hoc prefix naming convention to using qualified names, and deferring name conflict resolution to the name-resolution pass, allowing modules with conflicting imports to still be imported, as long as the conflicting unqualified names aren't used, or are used only in a qualified form.

During these changes, I've migrated new features into the (self-hosting) compiler's code base itself, through a continuous bootstrapping process.

If you have an interest in lazy functional languages and how they are implemented, you might be interested in looking at it. I'm open to any questions or comments about the language and it's compiler implementation.

git repository: https://github.com/taolson/Admiran

Lovingly hand-crafted with no AI.


r/Compilers 3d ago

ZCC — an AI-authored C99+ compiler in Rust: 83% of gcc -O2 on kernels, 86–99% on real apps (AArch64 ELF)

Thumbnail github.com
0 Upvotes

I watched Anthropic burn $20K on 100k LOC compiler and still come out ~157,000× slower than GCC on sqlite bench in the worst case, and then Blitzy's BCC doubled both the line count and the budget without shipping any verification at all. So I pointed Claude at a different target: zcc, focused on correctness (csmith + yarpgen, 10k seeds), performance (~30 passes), and staying small — under 30K LOC in 2 weeks. It currently targets AArch64 ELF only, because I built it on a MacBook Pro M1. I'd really like someone to extend it to x86-64 — with AI, obviously :D


r/Compilers 4d ago

One emitted C header instead of N binding generators — how our compiler's FFI boundary is built and tested

4 Upvotes

We're building a language (Zorith) whose compiler emits one native library and one C header per project — and the interop bet is that this is the whole FFI story: no bindings generator per language, ever. The header is emitted by the compiler itself, from the same type identity the language's two implementations (a C compiler and an executable formal semantics) are held to agree on.

As of this week, six languages call the same library through that one header, each with its stock mechanism: C directly, C++ via the header's own extern "C", Python via ctypes, Go via cgo including the header verbatim, Java via its FFM API, and .NET via NativeLibrary + delegates. The .NET row was witnessed on real x86-64 hardware before it merged, and now runs in CI on every push.

What crosses is the part we sweat: struct returns at all three ABI size classes (single register, register pair, caller memory), struct parameters by value at every size, nested structs, arrays of structs, arrays of arrays, and a three-dimensional array field filled on one side and indexed from the other — executed and oracle-checked, with both compiler implementations required to emit every header spelling byte-identically.

The part I'd actually defend as method: what can't cross yet is refused by name, once, with the reason written — the header omits it and the object keeps it unexported, so neither half of the boundary promises what the other can't keep. That refusal has narrowed six times as forms earned their crossing and has never been silently deleted. Current standing refusal: a struct at the leaf of a nested array.

Write-up with the evidence (the language design itself is deliberately unpublished): https://zuroxia.com/research/zorith-one-doorway

Happy to answer anything about the header-emission discipline, the ABI size-class testing, or what refuse-by-name is like to maintain.


r/Compilers 4d ago

Built a C-transpiling language from scratch in C. Would love some feedback.

5 Upvotes

Hey folks,

I'm a student, and over the last ~40 days I've been building a little language called Quasar. It's statically typed and transpiles to C. The compiler is hand-written in C: lexer, recursive descent parser, AST, codegen, symbol table—no bison, no yacc, no LLVM. Just me and a lot of late nights.

What's working so far:

- Variables, functions, recursion, strings, loops, match, type conversions

- String concatenation / repetition / equality

- Custom error reporting with line/col info

- A small test suite and example programs in the repo

Planned (not built yet):

- @annotations for control (@fast, @c, @asm, etc.)

- Unified subcommands like `quasar build`, `quasar test`, `quasar profile` so you don't need a separate profiler, test runner, docs generator, etc.

I'm not trying to replace C or Python—just exploring what a less fragmented systems workflow could feel like.

If you're into compilers/systems, I'd love honest feedback on:

- Parser structure and precedence handling

- Codegen decisions (runtime helpers, function prototypes, etc.)

- Whether the @annotation idea makes sense or is overengineering

Repo: https://github.com/setsuna231/Quasar

Quick peek at the syntax and example output:

Example Fibonacci Program
Output of the example

Thanks <3

A small note : If you all want the generated c code, I'm happy to share!


r/Compilers 4d ago

Should I chose racket or common lisp please rate 1 - 10 I wanna make a dsl what are perfect tools for these (like lark etc.)

Thumbnail
1 Upvotes

r/Compilers 4d ago

Wrote a self-hosting compiler as a self-taught dev from a languages background — reflections on the bootstrap

0 Upvotes

Coming from languages, linguistics, and literature (no CS), I got pulled into compilers by curiosity and ended up building a small language whose compiler is written in itself.

The progression was the whole education: v1 a tree-walking interpreter, v2 a bytecode compiler and VM, v3 the compiler rewritten in the language itself.

The bootstrap is the honest test — when you rewrite the compiler in its own language, there's nowhere to hide.

If the scoping rules are wrong, the compiler breaks.

If the calling convention has edge cases, you hit them.

Reaching a byte-for-byte fixed point across generations means the language is finally complete enough to carry its own weight.

The C VM is a single dependency-free file with byte-identical output to the Rust reference.

Everything's public on my GitHub: https://github.com/whispem

Would love to hear from others who've done a self-hosting bootstrap.


r/Compilers 4d ago

altair

0 Upvotes

Altair – un lenguaje compilado pequeño que emite C (y lo rápido que pasó de “ni siquiera compila el hola mundo” a bucles numéricos competitivos en ~5 semanas)

He estado trabajando en Altair, un lenguaje compilado pequeño enfocado en almacenamiento explícito, un runtime ligero y en generar C limpio.

Diseño Fuente → frontend propio (AST + análisis semántico) → C → compilador de C del sistema (actualmente GCC). El compilador integra un runtime y aplica bajadas de nivel específicas del lenguaje. Los bucles con carga numérica intensiva se bajan a variables locales planas long long (alt_fastnum_t) para no pagar el coste del sistema general de variables.

El objetivo no es superar a C escrito a mano, sino mantenerse cerca mientras se ofrece un lenguaje de más alto nivel con su propio modelo de almacenamiento, órbita/migración, tokens, etc.

Chequeo rápido de la realidad en las primeras versiones Primera versión pública 1.6.5vB (18 Jul 2026). El primer paquete de Linux (1.6.5vC) era básicamente inutilizable: el C generado no incluía los tipos/funciones del runtime, así que incluso esto fallaba:

altairlog "hello"

Seis semanas después (1.8.5, 24 Ago 2026) los mismos programas compilan y se ejecutan limpiamente.

Más allá de los bucles: control explícito de bajo nivel

1. Tiers de almacenamiento por variable

numeric contador = 0 ram
text log_path = "app.log" disk
list cola = [] cache
text secreto = "token" temp

2. Buffers crudos p# y registros de hardware reg&

p#node buf = alloc(1024)
p#write(buf, 0, 42)
numeric x = p#read(buf, 0)
log p#bytes(buf)
p#free(buf)

reg&64 rax = 1
reg&read(rax)
reg&free(rax)

3. Punteros crudos a disco lba% (equivalente en disco a p#)

lba%node tmp = dalloc(1024)
lba%write(tmp, 0, 42)
numeric v = lba%read(tmp, 0)
lba%free(tmp)

lba%node persist = dopen("datos.bin", 4096)
lba%write(persist, 10, 3.14)
lba%free(persist)

# Solo Linux: acceso raw a dispositivo de bloques
lba%node dev = draw("/dev/sdb", 1048576)

4. Punteros a variables

numeric valor = 10 ram
numeric dir = system@point(valor)
numeric copia = system@unpoint(dir)

Micro-benchmark (280 mil millones de iteraciones)

numeric n = 280000000000 ram
numeric i = 0 ram
numeric sum = 0 ram
numeric x = 1 ram
while i < n;
    sum = sum + i
    x = x + sum
    i = i + 1
break
log sum
log x

Misma máquina (2× Xeon Platinum 8481C @ 2.70 GHz vCPU, single-thread):

Backend Tiempo de pared Aprox. iters/s
Solo TCC (sin opts) 457.7 s ~624 M
gcc -O2 sobre el C generado por Altair 105.6 s ~2.65 B
Binario nativo de Altairc 105.1 s ~2.67 B
gcc -O3 -march=native -flto … 99.0 s ~2.83 B

El binario nativo que produce altairc es esencialmente tan rápido como pasar el C generado a GCC -O2. La bajada de nivel específica del lenguaje (especialmente la vía rápida numérica) está haciendo el trabajo real.

Sobre lo que busco feedback

  1. ¿Es razonable el enfoque de “emitir C limpio + bajada de nivel específica del lenguaje” para esta etapa?
  2. ¿Cuál sería el siguiente paso de mayor impacto (IR propio + un par de optimizaciones clásicas, mejor conciencia de la presión sobre registros antes de emitir C, backend LLVM, …)?
  3. ¿Alguna señal de alerta obvia en el diseño o en los números?

Repo + releases: https://github.com/victios7/Altair/releases (Versión actual 1.8.5vB)

Encantado de responder preguntas o de ejecutar otros micro-benchmarks.

Note: This post was originally written in Spanish. If you are not a Spanish speaker, please enable auto-translation in your browser/client.


r/Compilers 5d ago

xtsc: TypeScript compiler, also lowering to native / WebAssembly / JVM bytecode (experimental)

Thumbnail github.com
0 Upvotes

r/Compilers 5d ago

mox - first public release

15 Upvotes

Hi everyone! Finally I'm ready to make first release of my programming language and compiler.

I was working on it for more than 5 years rewriting it from scratch a few times, it is not production ready but before whole internet is filled with slop languages (I hope it will not happen) I want to show it to public.

It is low level language aimed for software and games. Whole compiler is made from scratch including machine code generation. One of the main goals is to make compilation time very fast (0.5-1mln LOC/sec).

Compile time execution of any code. Types and ast are first class values, so you can access them at compile time and work with them same way you can work with any other value. No OOP, no RAII.

Here is release repository: https://github.com/morglod/mox

Good language overview is inside by_example.mox

Currently I want to hold compiler's source closed, because I dont want to see forks and support documentation and tools to work with it (for now).

SDL3, Raylib and Vulkan bindings included (in modules/vendor).

I will appreciate any feedback about the language and compiler bugs.

Example code:

fn go_like_import($path: []u8) {
    cached_path := path_to_cache($path);
    if (!cache_exists(cached_path)) {
        download_dep($path, cached_path);
    }
    ast := __compiler_parse(#format_temp("import \"{}\";", .{ cached_path; }));
    return ast;
}

// becomes import "cache/path/module.mox";
#run #land_ast go_like_import("github.com/module/path");

r/Compilers 5d ago

SoK: Multi-Layer Indirect Call Analysis in the Real World

Thumbnail cs.brown.edu
1 Upvotes

r/Compilers 5d ago

AET: Adding an Explicit Semantic Layer to C for OO

2 Upvotes

I've been working on AET, a GCC-based extension of C.
It adds three things: object-oriented programming, generics, and heterogeneous computing.

I've already written about Delayed Specialization (generics) and Execution Domain (heterogeneous). This post is about how I actually implemented OO.

The core idea is simple:

Don't try to force new language semantics through ordinary AST nodes and symbol tables.
Give them explicit semantic entities inside the compiler.

In AET the mapping looks like this:

class$ → ClassInfo
impl$ → ClassImpl
method → ClassFunc
call site → Funcall

These are not just AST nodes. They own data, support operations, and keep relationships with each other.

Example:

ClassInfo(Dog)

inherits


ClassInfo(Animal)

└── ClassFunc(speak)

When the compiler sees `dog->speak()`, it resolves the class, inheritance, method and call through these entities first, then lowers the result into GCC's representation.

This makes complicated features much easier to keep under control. The compiler works with the language semantics directly instead of trying to encode everything into the AST.

The same pattern is used for the other two directions:

- Generics → `GenericBlock`, `GenericGraph`, `GenericCodes`
- Heterogeneous → execution-domain information attached to the entities

So the overall pipeline is roughly:

AET source

semantic entities

semantic analysis

AST / GIMPLE / …

The important point is that the semantic entities exist **before** the program is lowered into the normal compiler IR.

I call this approach **semantic entity mapping**: mapping language concepts onto explicit compiler entities that can carry data, perform operations, and maintain relationships.

For me this has been a practical way to tame OO (and the other complex extensions) inside a C compiler.

I'm posting this because I think this kind of explicit semantic layer deserves more discussion. Curious how others structure the semantic side of their compilers.


r/Compilers 5d ago

Programming with nirdosha without knowing the syntax

Thumbnail github.com
1 Upvotes

Copy https://github.com/arunsoman/nirdosha/blob/main/agent-skills/nirdosha/paste-anywhere-prompt.md and paste this to your fav llm and , then describe your intent in plain English and ask it to emit a complete .nir file


r/Compilers 6d ago

IncSFS: Incremental Full-Sparse Flow-Sensitive Pointer Analysis for C/C++

Thumbnail arxiv.org
7 Upvotes

r/Compilers 5d ago

Are you a young programmer looking for other young founders and their experiences?

Thumbnail discord.gg
0 Upvotes

Join our server!


r/Compilers 6d ago

Change MIR to use block arguments instead of phis - LLVM Code Generation RFC

Thumbnail discourse.llvm.org
29 Upvotes

r/Compilers 5d ago

Been working on my own programming language, Colloquial. Tell me what you think!

Thumbnail colloquial.dev
0 Upvotes

It is still a work in progress but I'd love to hear your thoughts on what you think of it!

There is currently a playground where you can try it out. The docs are a little out of date so they may not match the language specification exactly but that shouldn't be an issue for most things. I'll include the Git repo sometime soonish once I've ironed out a few kinks and done some housekeeping.

Also if you have any suggestions for features to add next please let me know :)


r/Compilers 5d ago

Aether programming language project update(Big Milestones)

Thumbnail
0 Upvotes

r/Compilers 5d ago

I was fed up with manual parser writing, so i created(ish) a Parser libary and stopped working on my language(feedback is welcome but i just want to share this almost 4 year old project)

0 Upvotes

I started creating a language to create a interpreter for space engineers. made whole lot of errors along the way to the point where nothing was working. so i abandon it. Then i restarted the idea and tried to create a transpiled language which targets c#. parser got extremely complicated (i used exceptions to back track... which was bad as far as i know because slow and not very flexible) then i did some lexer and parser generation from ebnf in vlang and then the idea started with a regex based lexer and a parser library which works off that.

and so was Parseus Born. And Parseus works primarily off callbacks and a context if the parsed path is still valid. since all primitive-parse-functions are static functions working of a context it should be fairly simple to inline every function to reduce function call overhead because you can nest allot of shit together.

Here is a function parser using parseus as an example how it looks right now. ```csharp public class FunctionDefinitionStatement() : IStatement, IPrintable { public string? FuncName; public List<string> Parameters = new(); public List<CStatement> Body = new();

    public string Print() {
        var sb = new StringBuilder();
        sb.Append($"(func {FuncName}");
        foreach (var item in Parameters) {
            sb.Append($"(param {item})");
        }

        sb.AppendLine("");
        foreach (var item in Body) {
            sb.AppendLine($"{item.Statement.Print()}");
        }

        return sb.ToString();
    }
}

private static readonly Parser<FunctionDefinitionStatement> FunctionDefinitionParser = new((c, self) => {
    Token(c, Tokens.FNC);
    Token(c, Tokens.IDENTIFIER, t => { self.FuncName = t; });
    RepeatOpt(c, c => {
        Token(c, Tokens.IDENTIFIER, p => {
            self.Parameters.Add(p);
        });
    });
    Token(c, Tokens.COLON);
    //body
    ((c.Context as TinyScriptContext)!).BodyDepth++;
    RepeatOpt(c, c => {
        Node(c, StatementParser, s => {
            self.Body.Add(s);
        });
    });
    Token(c, Tokens.EXT);
    ((c.Context as TinyScriptContext)!).BodyDepth--;
});

``` Parseus maps basically to ebnf with optionals, reapetables, alternatives and literals/tokens. I am currently working on a parser-resync feature and error reporting because its stupid to read the parse to remember the langue i envisioned.

Repo: https://github.com/thumpnail/Parseus Disclaimer: I mostly programmed all by hand. some bugfixes and hard functions/weird features i handed off to an LLM because i just didn't want to deal with that shit for days. + a neat thing i found it, my vision for this, i explained to an LLM and it wasn't able to produce what i build. well i tried but (gpt i think) was not able to produce anything remotely close to how it turned out. But allmost all my commit messages are done through nemotron on ollama with my gitllm tool, allmost none is written by me because i dont know what i did.

TLDR.: Lots of yapping, created a parser libary because i am too stupid to create a recursive decent parser(i tried tho) which resulted in a regex based lexer(weird approach tbf) and callback based parser. thank you for reading

Edit.: idk how this was read differently, but this(Parseus) is not a Parser Generator. the parser generator was in a whole different language and was a thing/prototype where ideas emerged that ended up inside Parseus


r/Compilers 6d ago

I'm making a programming language, need criticism

0 Upvotes

I've been trying to make a programming language for a while. I'm trying to make it in Rust. I made the basic language. The intended problem it is solving is making a simple language like Python but can run code really fast. The program itself will have native tensors. Will have CUDA/GPU backend. I made a clone of numpy embedded in the language. Now I'm developing a pytorch clone for the language. So, I would like to know what other problems you want me to solve in the language. The semantics are not finalised yet. So, I am definitely open to take some opinions.


r/Compilers 7d ago

Replacing a Rust Enum with a 64-bit Word Made My Interpreter 17% Faster

Thumbnail pointersgonewild.com
42 Upvotes

r/Compilers 7d ago

My students struggled with compilers. I struggled with compilers. So I built PyLGEN.

75 Upvotes

I've been a university professor (not exactly a compilation professor) for just a year, so my memories of being a student are very fresh. And yes, the compilation course was tough.

A while back, I overheard my students complaining about the same thing in the hallways, and it brought back a lot of memories and mixed feelings. Then, while browsing Instagram, I stumbled upon a reel of "MessiScriptInterpreter": a language where each command is a Messi play, with phrases like "la agarra messi"("Messi gets it") or "¡gol!"("Goal!") I thought it was brilliant. Seeing someone build something so creative and, above all, fun, got me thinking.

Building a language should be a process of experimentation, not a source of frustration in an already packed course. MessiScript showed me that it can be done with humor and passion.

So, I set aside some of my free time, since I don't have as much homework as when I was a student, and I started building PyLGEN, a Python-native compiler framework.

Initially, the intention was very simple: I wanted it to be easy to understand what's happening at each stage of a compiler. Total transparency, zero magic, so my students could see and touch every cog in the machine.

Then, out of curiosity, I decided to compare it with other tools in the Python ecosystem. The results surprised me enough to think they were worth sharing, but I prefer that everyone verify them for themselves. I've published the benchmarks in the documentation, with the code and data needed to replicate them, so if anyone does and wants to share their results, they're free to do so, and I'd love to see those results, as it would be very good feedback on the project. I'm not going to tell you the numbers: we invite you to run them and draw your own conclusions.

That was the unexpected part of the journey: a project that started with an educational purpose ended up behaving in ways I didn't anticipate in certain scenarios.

Today, PyLGEN is a newborn. This is its first week of life. And I want to share it not as a finished product, but as an invitation to explore, to experiment, and, if you'd like, to contribute.

We invite you to try it, to play with it, and to build your own languages. Comments, criticisms, and contributions are welcome.

Source code


r/Compilers 8d ago

Behold my Abomination: Written in Pascal, Single Pass(ish), No AST, No IR

Post image
75 Upvotes

Rockskunk.

Float is the only type. Everything else is QWORD. Shove an "integer" and a string into the same array if you wish.

Compiler written in Pascal. Emits NASM with regex peephole optimization before compilation. Incredibly permissive, you can do whatever you want and are only stopped if there is a syntax error. There are some sassy warnings for unwise choices but it is not the compiler's decision what you do with your code. I have had tons of fun figuring out how things work and learning assembly through a firehose. The IR is nasm source haha. Never going to implement an AST. I didn't read any book but i will need to STUDY the Dragon Book for register allocation. I did a cursory overview and understand nothing.

Backstory. I have been making half-baked transpilers for quite sometime now. Pascal or lisp compiler to C or (a very short) attempt at LLVM but I couldn't get them to behave how i wanted and kept losing interest. I ripped the lexer from one of them and have been using the parsing architecture from the others as inspiration and decided to just buckle down and make what I wanted even though I have been scared of assembly. I am learning as I go and keep making unfortunate choices like trying to track state with a record refactor (arrays only from now on), or routing token evaluation through like 8 redundant functions.

I have always wanted a language like this is because I love systems programming and like to rewrite things like coreutils or make shells and stuff. I love Pascal and dislike C but I have always wanted something that just gets out of my way and lets me do what i want, kinda like a dangerous Lisp. Not in your way, save your thinking for the real puzzle, not which type do you need. I have written cat, non-recursive cp and a (just writes no blocksize or flags) dd. I am going to get those to production quality and also write ls and such. I am about halfway done porting an init system I wrote in Pascal to rockskunk and its gonna be a glorious moment when i start my computer with my own language for the first time.

I finalized the syntax well before I wrote it and there will be no extra concepts, NO OOP, no new types, no restrictions, no guardrails nothing. This is a language that does what you tell it and nothing more. There's tons that i have specced out and not accomplished, but it will always remain like an "Assembly++" incredibly low level language.

Eventual features that will take me 3 years and most of my sanity. Register allocation and first-class vector support. I do not know near enough to even plan how to do these yet but the idea is the compiler uses tests and an IFDEF system that determines by machine (or a flag) what vector unit you want to compile for and sets width and then doing SIMD ops is as simple as a ** b or (a, b) *+ c. Do not count on this ever getting fleshed out but boy am I gonna try.

https://github.com/liam-0398/rockskunk/tree/main

**EDIT when reviewing post just realized my cp doesn't preserve permissions. whoops.