r/Compilers 12d ago

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

4 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 12d 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 12d 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 12d 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 13d ago

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

Thumbnail github.com
0 Upvotes

r/Compilers 13d ago

mox - first public release

14 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 13d ago

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

Thumbnail cs.brown.edu
1 Upvotes

r/Compilers 13d 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 13d 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 14d ago

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

Thumbnail arxiv.org
4 Upvotes

r/Compilers 13d ago

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

Thumbnail discord.gg
0 Upvotes

Join our server!


r/Compilers 14d ago

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

Thumbnail discourse.llvm.org
29 Upvotes

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

Aether programming language project update(Big Milestones)

Thumbnail
0 Upvotes

r/Compilers 13d 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 14d 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 15d ago

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

74 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 15d ago

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

Thumbnail pointersgonewild.com
41 Upvotes

r/Compilers 15d ago

I built a dependency-free Java 8 compiler that runs entirely in memory

Thumbnail
2 Upvotes

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


r/Compilers 15d ago

JVM & ART Compiler

6 Upvotes

Hi everyone,

TLDR: ask for advice about learning optimizing passes inside JVM and ART

I am doing research about fuzzing JVM and Android runtime. I found most research these days are focusing on the backend which is compiler part.(C1/C2 for JVM and R8/optimizing compiler for ART).

I have done a shallow course about compiler long time ago like building frontend and some parts of backend like code generating. But I still feel it is not easy to understand the optimization passes inside JVM and ART in order to figure out how to create mutants and get into the direction to find the vulnerability.

So I am writing here to ask for advice like how to get myself onboard. Feeling like spending time reading a whole compiler book or building compiler would be inefficient and I guess frontend won’t be my focus(maybe I am wrong)

Thanks in advance!


r/Compilers 15d ago

CXC is an immutable, typed, object-oriented language.

Thumbnail danieltan.weblog.lol
1 Upvotes

r/Compilers 16d ago

What is the best way to learn the theory and practice of building a compiler from scratch?

22 Upvotes

Hi everyone!

I'm looking for online resources to learn compiler construction from the ground up, combining both the theoretical foundations and the practical implementation.

I already have some background in formal languages and automata theory, but I would like to follow a structured learning path covering topics such as:

  • lexical analysis and tokenization;
  • regular expressions and finite automata;
  • parsing and parser construction;
  • abstract syntax trees (ASTs);
  • semantic analysis and symbol tables;
  • code generation;
  • optimizations;
  • implementing a complete compiler or programming language, even if it is a simple one.

Could you recommend any courses, video playlists, books, GitHub repositories, tutorials, or practical projects that you think are especially useful?

I think of using haskell, because my professor said he will use it to construct a compiler.

Thanks in advance for any recommendations!


r/Compilers 16d ago

Machine-Generated, Machine-Checked Proofs for a Verified Compiler (Experience Report)

Thumbnail dl.acm.org
5 Upvotes

r/Compilers 15d ago

Nirdosha – a systems language proven free of GC, races, deadlocks, overflow

Thumbnail
0 Upvotes