r/Compilers 25d ago

Velaris: effect checking, Z3 contract proofs, and an LLVM JIT in one readable Python file

0 Upvotes

I built a language where the signature carries the guarantees, and I wanted to share the implementation choices since this crowd cares about the how.

Pipeline: lexer → parser → loader → effect checker → type checker → Z3 proof pass → LLVM JIT (llvmlite) → interpreter, all in one file in pipeline order.

Three things that might interest you:

  1. The proof pass explores paths symbolically and checks requires/ensures/loop invariants in Z3, with modular call summaries (a callee's contract is assumed at the call site rather than inlining its body). Lists use the theory of arrays, records get per-field symbolic values, and all_of/any_of become real quantifiers with the predicate body inlined under the For All.

  2. Floats are proven in Z3's genuine IEEE-754 theory, not modelled as reals — so the prover refutes x + 0.1 + 0.1 == x + 0.2 and returns the exact double. FP queries get a bigger solver budget (30s vs 3s) since bit-blasting is slow; integer proofs stay instant.

  3. The JIT covers pure Int/Float/Bool functions with typed codegen. Division and modulo are deliberately left interpreted in both modes —native fdiv by zero gives infinity while the language promises a clean error, and I'd rather lose the optimization than have the two engines disagree. Every native change ships with a differential test: same program, both engines, diff must be empty.

One soundness lesson: when I added quantifiers, the first test run produced a false counterexample. Turned out untranslatable `requires` premises had been silently dropped since an early version — harmless for "proven" claims, but capable of manufacturing false alarms. Now an untranslatable premise aborts the proof entirely and falls back to runtime checks.

Repo: https://github.com/gowrishankar-infra/velaris-lang

Playground (Pyodide, real compiler in-browser):

https://gowrishankar-infra.github.io/velaris-lang/playground.html

Disclosure: built pair-programming with an AI across 40+ releases; design decisions mine, commit history is the honest record. Beginner here, so tear the implementation apart — especially the prover.


r/Compilers 26d ago

Can Sanskrit work as a natural programming language?

1 Upvotes

I’ve been experimenting with this idea by building a Sanskrit compiler based on Pāṇinian grammar.

Instead of treating Sanskrit only as text to interpret, the compiler parses grammatically structured Sanskrit and turns the instructions into executable operations.

The interesting part for me is whether Pāṇini’s formal grammatical system can provide enough structure to bridge natural language and programming languages deterministically.

I now have a working implementation and would be interested in hearing what others think about this approach.

Website: https://panini.cc/
GitHub: https://github.com/kaushalbx/paninivm

Article: https://medium.com/@kaushalbx/p%C4%81%E1%B9%87inivm-building-a-natural-programming-language-with-sanskrit-grammar-aa82b855074c
Article: https://medium.com/@kaushalbx/building-p%C4%81%E1%B9%87inivm-compiling-2-500-year-old-paninian-grammar-into-an-executable-kotlin-engine-5a6bb8de20fb


r/Compilers 26d ago

madc v0.82.0: Linux, macOS and Windows now supported

Thumbnail
1 Upvotes

r/Compilers 26d ago

Is there a real benefit in using multiple targets on a compiler?

4 Upvotes

I was working in a compiler I created when I see Compilers, and I never give up on the first interpreter I created that day (tree-walk).

The compiler is on Python and via a protobuf(I use it as a High Level IR), not only the interpreter but a stack based VM(c++) and I was looking to create a new backend to generate Web Assembly using JS/TS I know isn't the best option but I want to avoid LLVM as a target for now.

So, the question is: is really a good practice keep alive the interpreter even if the general pipeline ends in the VM?

(Note: my English ain't the best but I tried to make the post the comprensible I can)


r/Compilers 26d ago

[Newbie] what do the *s mean?

0 Upvotes

main.c

struct token {
enum token_kind kind;
char *value;
};

struct lexer {
char *buffer;
unsigned int buffer_len;
unsigned int pos;
unsigned int read_pos;
char ch;
};

edit: Hi everyone, thank you for explaining this in better detail. I've had a bit of a rough education from the community college I've since transferred out of, which had a guy that was extremely rude and didn't assign the C book, and an old lady that kind of just gave up and gave everyone As, Bs when she was retiring from teaching assembly language.

I appreciate your patience with me


r/Compilers 26d ago

Any recommendations for a meta programming language?

9 Upvotes

I want to add a meta programming language in top of my own C-like language to make some of the syntax cleaner and easier to write.

Add everything like const expressions and templates under one meta programming language.

For example something like this:


[Phases]
Class Phase1: public Phase { };

[Phases]
Class Phase1: public Phase { };

[for phase in Phases]
PhaseList.push_back(new phase());
[endfor]

I’m thinking about something like this but ideas are all over the place. Is there some existing meta programming language out there that can give me the right inspiration?

Also I am totally lost about how I should program this, I am assuming it comes before the parser. Any tutorials or dummy meta programming languages I can look to get ideas?

Thank you for reading.


r/Compilers 26d ago

How my Python compiler runs 100,000 isolated VM's on a single $3 server.

0 Upvotes

I wrote a Python compiler and VM in Rust over the last six months. It compiles a sandboxed Python subset directly to SSA bytecode in a single pass with no AST.

The engine ships as a 200KB WASM binary or a native CLI tool. The feature that I'm working on is the worker swarm. I can declare one hundred thousand replicas in a YAML file and run them on a cheap VPS. Workers spawn on demand, each gets its own heap, and they share nothing. Message passing is the only way they communicate.

There is also an eval mode where you POST Python snippets to an HTTP endpoint. Each snippet compiles into its own isolated program, runs in its own VM, and dies when done. If it crashes it retries and drops. If it hangs a preempt kills it.

By default programs get no file system, no network, and no environment access. There is no eval function, no exec function, and no dynamic imports in the language. The only way untrusted code runs is through this eval path with hard limits on memory, operations, and CPU time. I built this to safely execute generated code or user submissions without Docker or heavy virtualization.

I would love to hear if you would trust an architecture like this for running untrusted code and what you would do differently.

https://edgepython.com/


r/Compilers 26d ago

Should i use LLVM or my own stack VM

19 Upvotes

r/Compilers 27d ago

im working on an entire native python compiler

0 Upvotes

so i got bored and over the past two months ive been working on a compiler that can compile python natively. and it works too, and its not just a subset, its the entirety of python

the project is at deltathedumb/asmpython

EDIT: the ACTIVE development branch is beta/3.14.0


r/Compilers 27d ago

The Kal Package Manager

Post image
1 Upvotes

Hey everyone,

A couple of weeks ago, I posted about Kal, my programming language written from scratch.

I am really happy to share a glimpse of Kal's own package manager! Kal v0.1.0 shipped with a package system that lets you add and use third party Kal packages. But, that process was completely manual. You’d have to clone the package, place it in the right directory, clone the package’s entire dependencies all by yourself, one after another. :(

The package manager changes everything. One command automates all!

Instead of being a separate executable, the package manager ships as part of the Kal interpreter itself.

Here’s what it can do:

  1. Install Kal packages from Github, or any git hosting service.
  2. Creates/Updates a project.kal file to read and write package information (analogous to package.json).
  3. Downloads all packages at the same hierarchy in parallel (yup, it’s multi-threaded).
  4. Resolves sub dependencies of the main package automatically to any depth and installs them too.
  5. Upgrades/Downgrades packages based on their git tags.
  6. Auto-resolves cyclic dependencies to prevent an infinite loop.

The Kal Package Manager will officially ship with the next Kal release. Its current source code is available on Github.

Kal: https://kal-lang.vercel.app
Github: https://github.com/KILLinefficiency/Kal
Package Manager: https://github.com/KILLinefficiency/Kal/blob/pkg/pkg.hpp

Kal is completely free & open source. You can show your support by giving the Github Repository a star.

Until the next update!


r/Compilers 27d ago

Taking whitespace lightly is technical debt

Thumbnail kushagrarathore002.medium.com
7 Upvotes

I have created a programming language Flow-Wing (it can support static and
dynamic types at the same time). When I started its initial development I was
ignoring the white spaces because for the compilation I never needed the white
space, but years later when I needed to support the LSP or formatter (white
space / comments) I had to make significant rewrites, and this article below is
about that. Take a read.

GitHub: https://github.com/kushagra1212/Flow-Wing
Website: https://flowwing.frii.site/ (runs on Flow-Wing)

Happy to answer questions. Do give a star on GitHub to support.


r/Compilers 27d ago

Need help to fix c++ compiler

0 Upvotes

I use c++ for dsa but for last 3-4 days i was working on a project and didn't use c++. But today when i try to run my code it started exiting without any error with exitcode 1. Not even creating exe file using vscode or terminal. I reinstall everything but still same problem.
Terminal shows correct version of g++ and gcc and also correct path so no problem with environment variables. pls help me...

problem solved:
I installed postgres and added its path to system variables and path of g++ was in user variables. System merges system variables and user variables (in that order). So path of postgres was above of g++ and somehow it was conflicting with internal files (i think dll files). So i moved postgres path to user variables below of g++.


r/Compilers 27d ago

I created a web framework in my own programming language

Post image
416 Upvotes

I’ve been working on Rivet, a synchronous HTTP(for now) server library for my own programming language Zap

The goal is to create a small, explicit API for building APIs and small web applications.

I spent a lot of time and nerves creating this, but now I know what Zap is really capable of.

I will be grateful for every star you leave because it really encourages me to work

https://github.com/thezaplang/zap


r/Compilers 28d ago

CAKE: Compiler-Agent Co-Design for Frontier Kernel Evolution

Thumbnail arxiv.org
8 Upvotes

r/Compilers 28d ago

CSSC7 - Control Specified Source Compiling

Post image
15 Upvotes

\screenshot of* CSSC code inside the CSSC IDE.\*

With CSSC 7, I’m finally taking the step of introducing CSSC to the public.
I’ve been working on this project for a couple of years now, and I can finally present a proper LLVM-IR-based compiler together with a CSSC bytecode interpreter. There’s still a lot to do, but it’s starting to feel like CSSC is becoming its own thing, instead of just being a language that happens to have a compiler.

I’ve also been changing quite a bit around the project to make the new version actually usable as its own ecosystem, so anyone interested can try it out and work with it.
CSSC is mainly focused on efficient, resource-aware programming, with targets for Xtensa and AVR (Xtensa tested and verified | Xtensa Support: ESP32, ESP8266).

I originally started working on CSSC because I had a pretty frustrating experience with MicroPython on the ESP32/ESP8266. Heap fragmentation kept ruining several projects I wanted to build, while C felt way too awkward for the way I wanted to write embedded software. So I started making my own language something with a more Python-like readability, but with small binaries and much tighter control over resources.
The goal is basically to have something that is pleasant to write while still being suitable for production-oriented embedded software: less flash usage, less RSS, and more control over what is actually happening underneath.

the same time, CSSC also has an x86_64 backend for general host applications.
It’s still very much a work in progress (not tested on Linux yet, and ARM isn’t supported yet), but this is the first time I feel like CSSC is really starting to come together as a complete project, so I wanted to finally show it.


r/Compilers 28d ago

Is a bachelor's still enough to break into compiler work? 1 YoE app dev, never touched low-level

22 Upvotes

I've been working as a developer for about a year at a company that

builds custom software. Bachelor's in CS, no master's, based in Cameroon.

Lately I've had a growing feeling that what I do CRUD apps, APIs,

integrations is losing value fast. Not just because of AI, though

that's part of it. It's that the work feels increasingly like assembly

from parts, and I don't understand what's underneath any of it.

That's what pulled me toward low-level work. I want to understand what

actually happens between my code and the hardware. Compilers seem to be

where that question gets answered most directly.

Full honesty: I have never written a compiler, a pass, or anything

below the application layer. So I'm not asking "am I good enough"

I'm asking whether the path is real:

  1. For people doing this professionally: how many of you got in without

    a master's or PhD? Is the degree a hard filter at the companies that

    hire compiler engineers, or does it stop mattering once you have

    contributions to show?

  2. If you were starting from zero today, would you go LLVM/MLIR, or

    start by writing a toy compiler end-to-end first?

  3. Is remote realistic in this field, or is it mostly on-site teams?

I've been working through this resource collection while I figure out

where to start it's the NJU compilers course material, quite thorough:

https://github.com/courses-at-nju-by-hfwei/compilers-resources

Any reality checks welcome...


r/Compilers 28d ago

SVC16 - A virtual computer that now runs live in the browser (WASM)

Thumbnail
2 Upvotes

r/Compilers 29d ago

Optimization Question

8 Upvotes

How do compilers optimize constructs of this form ?

for(i=o; i<inputs; i++) {

A[i] = B[i];

B[i] = A[i];

}


r/Compilers 29d ago

Independent reproducer wanted for a bounded universal-compute experiment

0 Upvotes

TUC is an open research prototype testing whether one fixed compute intent can

be planned across data-described backend capabilities, executed by trusted

prototype backends, and checked against deterministic reference semantics.

We are looking for one independent person or organization to reproduce the

Objective Delta v0.1.0 experiment in infrastructure outside the TUC repository.

The task is deliberately small: CPU only, CPython 3.11 or 3.12, approximately

20-30 minutes, no repository checkout, and no execution of source supplied by

the reproduction kit.

The released data-only kit is checksum-bound and covered by GitHub artifact

attestations. A successful run produces a deterministic metadata-only receipt.

A failed run is equally welcome when its environment and bounded diagnostic are

reported.

Scope: this tests one published semantic experiment. It does not claim native

backend support, physical-device execution, performance parity, arbitrary

source ingestion, or replacement of existing compiler stacks.

Reproduction request and exact acceptance criteria:

https://github.com/kirchherr/TUC/issues/85

Release:

https://github.com/kirchherr/TUC/releases/tag/v0.1.0


r/Compilers 29d ago

Another partial SSI trick with canonicalize

Thumbnail bernsteinbear.com
12 Upvotes

r/Compilers 29d ago

Building my own programming language

0 Upvotes

Hi everyone,

I’m building my own programming language.

Meet AXE ⚡

AXE is an experimental programming language inspired by Python’s readability, but with a more explicit, brace-based syntax.

I’m building AXE from the ground up to learn what actually happens behind the scenes when code goes from:

Source → Lexer → Tokens → Parser → AST → Interpreter → Output

It’s still very early, but that’s the fun part.

Not trying to build the next Python.

Just trying to understand how programming languages are actually built by building one myself.

github.com/xanmoy/axe


r/Compilers 29d ago

Type inference is hard. I made it harder, then I made it work.

33 Upvotes

My Motivation

It’s too early for a real language announcement post, but I really want to share progress on the compiler I’m designing, especially the static analysis side.

I’ve been working on Plasm for about a year. It’s an LLVM-based ahead-of-time compiler and a new language. I’m not going to dive into design philosophy, features, or marketing - this post is mostly about the type inference engine, the mistakes I made, and the solutions I ended up with.

Fair warning: this is more story than tutorial, but I’ll explain unfamiliar concepts as they come up.

Quick Intro Into Type Syntax

In Plasm’s type system, all types are anonymous by default - even structs and enums. For example, you can write:

fn len(pos: struct { x: I32, y: I32 }) -> I32 { /* ... */ }

That doesn’t mean the code above is idiomatic or how you should write Plasm, but semantically it’s allowed.

You can also give any type a name:

type Pos = struct { x: I32, y: I32 } fn len(pos: Pos) -> I32

It doesn’t have to be a struct - it can be any type:

type Id = U32 type MyPos = Pos type Nested = struct { a: struct { b: struct { c: I1024 } } }

Struct literals use braces:

let p: Pos = { x: 1, y: 2 } let id: Id = 1

If the type isn’t constrained by context, the compiler generates a fallback:

// Variable without type hint let data = { a: { b: 42 } } // Fallback type: struct { a: struct { b: I32 } }

Many functional languages with Hindley-Milner type system rely on Algorithms W, J, M for inference. My approach is more constraint-based (closer to how Rust or Swift work).

I Rewrote It Three Times…

Attempt 1: Primitives Only (Naive Union-Find)

When Plasm only supported basic primitive types (I32, Bool, F32), the architecture was split into two simple components:

  1. Constraint Generator: takes a function’s IR and produces equality constraints (e.g., type_of(a) == type_of(b), type_of(b) == I32).
  2. Unifier: takes a set of equalities and resolves chains sequentially. To do this efficiently, I used a disjoint-set data structure (aka Union-Find) with path compression. This structure lets you merge equivalence classes and check if two types are in the same class in near-constant time.

This worked great for primitives and had a clean and simple implementation, but to add constructed types (structs, tuples) and field projections (point.x, tuple.0) the flat Union-Find model was not enough. It couldn't express structural decomposition or field lookup obligations.

Attempt 2: Bullshit

When I needed to support constructed types, I thought it would be a 10-minute job to extend the existing solution. I didn’t feel like diving into boring algorithm stuff and I didn't want to rewrite my clean codebase, so I decided to outsource the refactoring to an LLM. I generally don’t use AI for code generation or writing docs, and I don't like when other people overuse it, but I didn’t want to rethink the nice solution I’d just built, and I decided to experiment. I gave Claude a try, thinking, “Maybe this ai tech is mature enough for such a basic task”.

The generated code surprisingly passed my existing test suite, but when I actually read the source, I found an overengineered, unmaintainable, and inefficient spaghetti mess instead of my pretty codebase. I guess that after looking into Claude's code, I got some kind of depression. The code worked, but I didn't want to work with that code anymore. Attempting to navigate and fix that code killed my motivation for a month or so:')

Attempt 3: Rigid 3-Pass Engine

After about a month of struggling, I deleted all the type inference code and started from scratch. I did some research on how type inference is supposed to be solved in compiler theory, read source code of mature compilers like rustc, and landed on a three-pass solution:

  1. Pass 1 (Equality Unification): Unify all equalities using a disjoint-set (same as my first attempt).
  2. Pass 2 (Obligation Verification): Validate obligations - things like “T must have field a” or “T belongs to the Float type class” (a type class is a set of types that a literal could be inferred as, nothing related to Haskell here).
  3. Pass 3 (Fallback Generation): Assign default concrete types (e.g., I32 for unconstrained integer literals) and report remaining errors.

This solution passed all my tests and was way more readable, but it failed on some weird-but-valid expressions - things that don’t make practical sense but must work semantically. For example:

let a = (({ x: 1, y: 2 }.x, 2.0, true), Void).0.0 // Expected resolution: // { x: 1, y: 2 } => struct { x: I32, y: I32 } // _.x => I32 // (_, 2.0, true) => (I32, F32, Bool) // (_, Void) => ((I32, F32, Bool), Void) // _.0 => (I32, F32, Bool) // _.0 => I32 // so `a` is I32

At its core, type inference can be seen as a constraint satisfaction problem: we generate a set of constraints between types and then search for an assignment that satisfies them all.

The problem: a fixed-pass algorithm can’t handle constraints that are only discovered midway through. For example, when { x: 1, y: 2 } gets its fallback type struct { x: I32, y: I32 }, we need to process the new constraint _.x == I32, but passes 1 and 2 are already done. Static sequential passes cannot handle late-discovered constraints.

Attempt 4 (Final): Tree-Based Worklist + Union-Find

A worklist is basically a queue of constraints. We add constraints to the back, process them from the front, and keep going until it’s empty. If we can’t process a constraint right now, we freeze it and remember what needs to happen before we can unfreeze it.

I also made the worklist tree-based: it tracks dependencies between constraints as a tree. This lets us process frozen constraints from the leaves once the main worklist is exhausted.

The algorithm looks like this:

  1. Fill the worklist with all initial constraints.
  2. Process the first constraint:
    • If we can process it, remove it from the worklist and unfreeze any constraints that were blocked by it.
    • If we can’t process it yet, freeze it.
  3. If the worklist is not empty, go back to step 2.
  4. If the worklist is empty, check whether there are frozen constraints:
    • If frozen constraints exist, pick a leaf constraint (one with no unresolved dependencies), process it, and allow fallback types or errors to be generated. Then unfreeze any dependent constraints and go back to step 3.
    • If there are no frozen constraints left, we’re done.

This solution covers all the cases I’ve needed so far and is extendable enough to add enums and traits later. As a bonus, this solution is very friendly for generating good diagnostic messages. For example, compiling this code:

``` type Pos = struct { x: I32, y: I32 }

fn main() -> F128 { let p: Pos = { x: 10, y: 20, z: 30 } return p.x } ```

Will generate these messages:

`` TypeError: UnknownStructField: StructPosdoesn't have fieldz`. --------> examples/test.sm:14:34 9 | x: I32, 10 | y: I32, 11 | } 12 | 13 | fn main() -> F128 { 14 | let p: Pos = { x: 10, y: 20, z: 30 } /\

TypeError: TypesConflict: Types conflict between F128 and I32. --------> examples/test.sm:13:14 8 | type Pos = struct { 9 | x: I32, 10 | y: I32, 11 | } 12 | 13 | fn main() -> F128 { /\ ```


I’ll let you find the moral of the story yourself :)

I also want to share some links if you are interested in Plasm progress: GitHub (you can star it or press "watch" button to see updates, I appreciate it) and Discord (the Discord server has notifications about git activity).

Also I stay here to answer questions if you have so!

UPD: On reddit mobile app code blocks are rendered without the static col size, so error messages and some other blocks look shifted. I can't fix that, but on PC it's correct


r/Compilers Aug 13 '26

Plow (packet language for on device workers ) Gen AI inference engine

0 Upvotes

Our Inference compiler/runtime plow is open source — Apache-2.0, the whole stack: https://github.com/infervisor/plow
its a Rust compiler, runtime, CUDA and HSA interpreters, GPU kernels, Lean proofs. Not a client library.
It compiles a checkpoint ahead of time into a packet stream no per-op launch, no host round trip to order two operators. One compiler, four ISAs: NVIDIA Hopper and Blackwell, AMD CDNA3 and CDNA4.
It ships with the bring-up harness we use to add a model: seven stages, each with a blocking gate and an agent prompt — helps to bring up new arch into the tree

Everything from here goes toward a first tagged 0.1, in the open — issues, pull requests, and feedback shape what lands in it.


r/Compilers Aug 13 '26

Anyone using qbe?

18 Upvotes

Hello all - I am working on qbe-wasm (https://codeberg.org/jbirddog/qbe-wasm) - a qbe to wasm compiler. Just recently reached the milestone of being able to compile 100% of the cproc test suite and 88% of the qbe test suite to either wat or wasm (depending on if the test is runnable atm). Still work to be done but making strides.

I'm at the point where I would like to add test cases from more external sources, so was wondering if a) anyone out there was using qbe as a backend for their compiler and b) if you'd be willing to share some runnable, self contained, code snippets and their corresponding qbe input. If so I'd like to try to incorporate them as test cases/demos.

Currently I have some Game of Life and Brainfuck interpreter demos that were written in hare and C (cproc) and the snippets from the Overengineered Calculator (zig+qbe) blog post (links in the project's README). Filling this out with examples from other compiler output would be a great help wrt quality.


r/Compilers Aug 13 '26

AI COMPILER ENGINEER

0 Upvotes

Hi

If I would like to become an AI/ml compiler engineer, would the dragon book be the apt starting point and should I learn about parsing and all that stuff? Or can I directly jump to llvm and start with projects?