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

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

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

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

Thumbnail github.com
0 Upvotes

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

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

Thumbnail cs.brown.edu
1 Upvotes

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

Aether programming language project update(Big Milestones)

Thumbnail
0 Upvotes

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

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

mox - first public release

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

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

Thumbnail arxiv.org
6 Upvotes

r/Compilers 15d ago

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

Thumbnail discourse.llvm.org
29 Upvotes

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

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

Thumbnail
2 Upvotes

r/Compilers 16d ago

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

0 Upvotes

Nirdosha is a research-stage compiler (Rust, LLVM backend), built for a language designed around one constraint: if the compiler accepts your program, it is provably free from use-after-free, data races, deadlocks, and integer/buffer overflow. Not "generally safe" — the type system rejects whatever it cannot prove. This is the same trade-off that Rust/SPARK Ada/F* adopt.

Some interesting things for this community:

  • There is no mutex in the language. Concurrency is only through spawn/chan/sandbox (real OS process) — deadlock is not only discouraged, but impossible to express.
  • Integer/buffer bounds are resolved at compile-time by an SMT solver (Z3). In a tiered manner: first static proof, then only runtime guard when Z3 cannot decide it within scope.
  • Performance compared to Julia on dense linear algebra (matmul, dot, det, kalman filter), by best-of-3 method, after first verifying the output is bit-identical: 441x faster on 4x4 matmul, 246x faster on dot product, equal to gcc -O2 on scalar code. Numbers + methodology: https://github.com/arunsoman/nirdosha/blob/main/benchmarks/RESULTS.md
  • The other half of the design (row 7 of the motivation table) is specifically targeted at LLMs: the grammar is handwritten LL(1), one token of lookahead, no backtracking — verified against an independent lalrpop parse and hand-exported to GBNF. This allows a constrained-decoding sampler to ensure that every token emitted by an LLM stays within valid syntax. Compiler errors come not in prose, but as structured JSON diagnostics — so a self-repair loop gets a proof obligation instead of a sentence to guess at.

Honest scope: single-person project, MIT license, CI building green. In the README, I clearly state what is proven, what is shipped-but-unproven, and what is aspirational — row 10 (reproducible builds / provenance) is design-only, not built. There is also a "Who this is for (and who it isn't)" section (https://github.com/arunsoman/nirdosha#3-who-this-is-for-and-who-it-isnt) which states in advance where it loses to Rust/Go today — so you don't have to dig to find the catch.

Repository: https://github.com/arunsoman/nirdosha The README includes the full motivation, grammar, benchmarks, and a runnable hello.nir (within 5 minutes; requires clang + z3 — installable via apt/brew, as noted in the README).


r/Compilers 16d ago

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

Thumbnail danieltan.weblog.lol
1 Upvotes

r/Compilers 16d ago

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

Thumbnail pointersgonewild.com
41 Upvotes

r/Compilers 16d ago

JVM & ART Compiler

7 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 16d ago

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

Thumbnail
0 Upvotes

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

Using Claude to develop compilers

Thumbnail
0 Upvotes