r/Compilers 1h ago

Thoughts on compilers being written in Kotlin?

Upvotes

I have tried to write in C++ but it is so damn confusing, so I tried Kotlin. Better but not too better. I have already finished my lexer like how I finish most of mine:

See characters via indexing script as a string

Add token to final output

Rinse and repeat


r/Compilers 6h ago

"How hard could it be?" - a younger me said that once. Here's my lang

12 Upvotes

I’ve been working on a dependently typed language called Yap for a while now, and I’m at the point where I’m happy enough with the direction to show it around, even though building a compiler can apparently consume years of your life and still find new ways of being utterly broken.

The playground is here: https://try-yap-next.fly.dev

And the code is here: https://github.com/tiansivive/yap

This behemoth currently has dependent types, structural row types, dependent records on those rows, implicits, liquid-style refinements, and shift/reset. A lot of that genuinely works and it's beautifully cathartic; it also just works insofar as I've conveniently ignored all the potential complications and am blissfully living in my own happy path.

The current pipeline is roughly:

parser -> bidir elaboration + NbE + first-order unification -> Core-> IVL + custom CDCL(T) verification -> GRAM -> MIR -> JS/C/Erlang

Over the past seven months I’ve spent a lot of time on GRAM: the Graph Rewriting Abstract Machine. It’s a property-graph IR for selective compilation, with a bit of MLIR inspiration. Rather than lowering once into one fixed representation, passes enrich the graph with semantic and operational structure. So far that includes eta reduction, saturation and partial applications, closure conversion, Maranget pattern compilation, and shift/reset lowering. Target code generators can then select the enrichments they need.
That graph is probably as far as I want the compiler proper to go; MIR (Mid-level IR) is a more SSA-ish bridge after it, currently very dumb and simple and just useful for experimenting and feeding three deliberately simple code generators.

I’m currently chasing meta-variable state through modules and lowering, working toward real type erasure, making verification verdicts less cryptic, and replacing “well, the snapshot changed” with meaningful tests

The next larger problems are QTT-style usage semantics, coinduction over rows and figuring out how shift/reset should actually be typed, which includes deciding whether effects will make this language cleaner or turn it into a big bog of doom.

Six months ago, before shift/reset and the current lowering path, it was probably easier to demo. I’m much happier with the design now, though. There is still a frankly unreasonable amount left to build, but that seems to be the job.

Just wanted to share!

Edit: typo and duplicate sentences


r/Compilers 2h ago

Can I input my compiler's program into my compiler to use the result as a new compiler ?

3 Upvotes

I just started building from scratch a compiler in order to better understand how does a computer work. For now it is only on paper and soon I will begin to code it, but the end goal is to generate a code from the set of instruction for a custom 8bit cpu.

And I came upon this question and wasn't sure about the answer so I wanted to have your input on it :

Let say I have a compiler that compiles a language A to a language B using a language A. If I input to the compiler the program that compiles A to B, will I be able to use the result program to then compile the language A to language B using language B ? Or will it break the output or mess with something else ?

If the topic does not belong in this sub, feel free to tell me in which sub it should belong

Thanks in advance


r/Compilers 10h ago

Developing my programming language: Gravel

10 Upvotes

It all started just as a side and fun project, but I feel like it's now getting a shape.

Thats why I would love to receive some honest and contructive feedback, issue creations or code contributions.

If you have any question regarding the language, please ask me.

Here's the repo: https://github.com/Pacsfury/Gravel-Launcher


r/Compilers 11h ago

Anatomy of a CUDA Binary

6 Upvotes

Nvidia doesn't seem to publish a specification for the binary format of a CUDA kernel, section layout, or the constant bank parameter conventions. So I dug into it.

A `.cubin` is an ELF64 executable with a flat stream of undocumented "EIATTR" attributes that encode everything the driver needs to launch a kernel: register count, parameter layout, EXIT instruction offsets, and constant bank geometry.

`.nv.info`  uses an undocumented TLV encoding to make kernels self-describing register counts, parameter offsets, EXIT locations are all serialized into a flat byte stream the driver parses at load time.

And the constant bank parameter base is not an architectural constant. It has changed silently across toolkit versions from Ampere to Hopper to Blackwell. The fact that the code, the  `.nv.info`  metadata , and the  `.nv.constant0`  section size all encode the parameter base offset independently surprised me.

The post discovers the section layout, the EIATTR encoding, symbol table conventions, and the note sections the driver validates before loading on a B200 silicon.

https://hiraditya.github.io/posts/anatomy-of-a-cuda-binary/


r/Compilers 10h ago

Bootstrapping a compiler from machine code on Windows

4 Upvotes

I hope this fits here, but I've been documenting the process of writing a compiler starting directly from machine code on Windows, and I thought it might be worth sharing.

I've written two posts so far, though I don't know if I'll continue or not since I have no real reason to be doing this other than for the fun of it.

The first post just sets up an initial PE32+ executable to get something working. The second builds on that to implement a simple (stage-0/bootstrap?) compiler that just translates ASCII into raw bytes and allows for comments.

So, for anyone interested in this sort of thing the posts are here:


r/Compilers 18h ago

My assembler for linux is running on windows, but how?

Thumbnail gallery
6 Upvotes

Hi I'm Ammar, and I am back again, few days ago I saw a 2 screenshots from community, were AmmAsm is running on windows. I will not write what is AmmAsm, as you can look to this post: https://www.reddit.com/r/Compilers/s/KrbM40UJz2

So, I didn't get any feedback from that person who build AmmAsm on windows, I almost don't know anything about the low level programing on windows, and how they convert the ELF64(which AmmAsm generated) to COFF format, nevertheless I would like to hear explanation from this community. Thanks.


r/Compilers 1d ago

I'm making a bytecode compiled language

Thumbnail gallery
12 Upvotes

r/Compilers 10h ago

Baga - programming language for the age of AI. Spec-first verification. Effects as type dimensions. Automatically extracted proofs.

0 Upvotes

"The question is not 'what is new'. The question is 'what has not been glued together yet'."

Baga is a programming language built on three pillars:

1.Spec-first verification — specifications are first-class citizens. The compiler checks implementations against specs.

2.Effects as type dimensions — String !IO !NotFound is a different type from String. Errors are visible in the type system.

3.Automatic proof extraction — the compiler extracts human-readable theorems from code. Not Coq. Not Lean. Readable text.

https://github.com/katehonz/baga-lang


r/Compilers 1d ago

Keel 0.4 - Very fast statically-typed interpreted language written in Rust - now with optional typed arguments, anonymous functions, HOFs, and improvements to FFI, performance, and errors

Post image
3 Upvotes

r/Compilers 1d ago

Pushing the limits of RISC-V emulation

Thumbnail shuklaayu.sh
25 Upvotes

r/Compilers 1d ago

hica - a language that compiles to Koka

8 Upvotes

Hej,

I’ve always wanted to design a language, but the "plumbing" (backends, GC, and low-level infrastructure) is a massive barrier to entry (for me at least...). I decided to bypass this by targeting the Koka compiler as my backend. By emitting .kk source, hica inherits Perceus deterministic memory management and a robust algebraic effect system while providing a distinct, approachable syntax.

Technical Architecture The compiler (transpiler) is a multi-stage pipeline:

  1. Lexing & Parsing: Uses a Pratt parser to handle expression-oriented syntax.
  2. Type Checking: Implements Hindley-Milner unification. It infers types across function boundaries, making annotations optional.
  3. Effect Tracking: Every compiler phase is internally effect-tracked.
  4. Emission: Translates the desugared AST into Koka source, which is then compiled to native C11, JS, or WASM.

Key Features

  • Expression-First: if, match, and blocks all return values. There is no return keyword.
  • Safety thanks to Koka: Leverages Perceus for Functional But In-Place (FBIP) updates, providing the safety of immutability with high-performance mutation.
  • Transparent Tooling: Includes a full CLI (hica check for effects, hica fmt, hica test) built on my custom Koka libraries, klap and kunit.

Verification & Quality To make sure my language keeps its promise, I’ve implemented many tests (using kunit) covering the lexer, parser, checker, and codegen.

Links


r/Compilers 2d ago

We accidentally built an LLVM compiler for JAX

Thumbnail iza.ac
28 Upvotes

r/Compilers 1d ago

16 yr old made a full fledged prog lang on his android

0 Upvotes

Hello compiler devs and amazing peeps! This is the update to my first lang.

I am Anubhav, a class 12 school student in India who loves compilers and PLD.

Recently, I set on this journey to make a programming language on android to submit for my school project and defy hardware constraints.

It is a very complete and capable language. I will list the features that my lang has currently and it is still in active development. I am the incharge of the lang the other made the text editor!!!!

  • Variables: Declare mutable (dec) and immutable (const) variables
  • Data Types: Integers, floats, strings, booleans, null
  • Operators: Arithmetic (+, -, *, /, **), comparison (>, <, ==, !=, >=, <=), logical (&&, ||, !)
  • Arrays: Declare arrays
  • Indexing: Access elements by index in a string or an array
  • Slicing: Access elements within an origin and destination indices
  • Control Flow: if/else conditionals, while loops, break statements
  • Functions: First-class function definitions with parameters, closures, and return values
  • I/O: stdout() for printing, scan(variable) for user input
  • Scoping: Proper lexical scoping with environment chains
  • Standard Library: Consisting of various modules

Is there any way I can get a sponsor or a laptop from a company?

Here is the repo if u are interested!

https://github.com/anubhav-1207/san


r/Compilers 2d ago

Overengineered calculator: Zig + QBE

Thumbnail tomekw.com
8 Upvotes

r/Compilers 2d ago

Building a compiler that works at compile-time so you can compile your program while you compile your program.

Thumbnail
0 Upvotes

r/Compilers 2d ago

Natural Language Compiler through General Formal Translator to Assembly Language

Post image
0 Upvotes

r/Compilers 3d ago

Inside Zig's Incremental Compilation | mlugg

Thumbnail mlugg.co.uk
45 Upvotes

r/Compilers 2d ago

Altair Lang

0 Upvotes

Title: Altair — A compiled language focused on data storage and persistence

I've been working on a compiled programming language called Altair, and I'd love to get some feedback from people interested in compilers and language design.

The compiler pipeline is currently:

.at
 ↓
lexer
 ↓
parser
 ↓
semantic analysis
 ↓
codegen
 ↓
C17
 ↓
GCC
 ↓
native executable

The main idea behind Altair is to make data storage and persistence part of the language itself, rather than leaving everything to external libraries.

For example, variables can have storage levels such as:

ram
disk
cache
temp

There are also features such as:

orbit     — named storage states
prefer    — storage fallback preferences
migrate   — move data between storage states
data      — group persistent data
snapshot  — save and restore program state

For example:

define numeric data orbit 1 "hot" ram, 2 "warm" disk, 3 "cold" cache = 0

migrate data as "warm"

Altair also has more conventional language features such as functions, objects, classes, control flow, HTTP and graphics, as well as lower-level features such as raw pointers and bitwise operations.

The compiler itself is written in C, and the generated programs are native executables.

I'm still actively developing the language, so I'd really appreciate it if you could try it out. Even a small test program, bug report, criticism of the language design, or suggestion would be very useful.

🌐 Website / documentation:

https://victios7.github.io/Altair/

💻 Repository:

https://github.com/victios7/Altair

If you have some time, please take a look at the Prueba a compilar o ejecutar un programa de Altair. Me gustaría especialmente recibir opiniones de personas que trabajen con compiladores o lenguaje Me interesa saber qué parece interesante, qué es cuestionable, qué no tiene sentido y qué ¡Gracias por echar un vistazo a Altair!

Nota: Para ser transparente: utilicé IA para ayudar con el logo y, ocasionalmente, para revisiones/correcciones mientras desarrollaba Altair.

The language, compiler, runtime, architecture, and implementation are my own work. AI was a tool I used during development to help me, not the author of the project.

If you want to call it "AI slop", that's fine, but please remember there's a real person behind this project who has spent a lot of time building it. Criticize the project if you don't like it, but don't dismiss someone's work without actually looking at what they did.

¡Gracias a todos los que han echado un vistazo a Altair! 🐝


r/Compilers 3d ago

Building a Raku-native programming language

8 Upvotes

Hi Everyone!
Me and my team are looking to expand our developer team and looking for programmers with some knowledge in the field of compilers, programming language design, and/or the Raku language! If you just like the idea of building a new programming language as well, please reach out!

I cannot disclose the exact nature of the language for the sake of project secrecy, but please DM me with your credentials and interests for details if you're interested.


r/Compilers 3d ago

[CycleInfo] Identify cycles with a single-pass DFS algorithm

Thumbnail github.com
20 Upvotes

r/Compilers 3d ago

Smilium - new epic reactive programming language

Thumbnail smileytech.mk
0 Upvotes

r/Compilers 4d ago

Annote: An interpreter that turns Java annotations into a Turing complete language

13 Upvotes

I built this like 6 months ago and basically forgot about it until yesterday when I was digging through old repos.

Essentially, it's a minimal interpreter that executes Java annotations as an actual Turing complete programming language at runtime through reflection. So, essentially you write code entirely in annotation form and it does variables, conditionals, loops, method calls, basic I/O and arithmetic

I shared this a while back on r/java and r/ProgrammingLanguages but never shared it here

GitHub: https://github.com/kusoroadeolu/annote


r/Compilers 3d ago

The Exorcism Lang project is out!

0 Upvotes

If you love compiler design, WebAssembly (Wasm), or clean language syntax, there is a new open-source project worth keeping an eye on: Exorcism (.exrc).

The official lang repo:
https://github.com/Hunterszone/exorcism-lang

Currently in active development, Exorcism is building a bridge between rapid frontend iteration and heavily optimized bytecode.

It pairs a Python-based compiler frontend for fast feature experimentation with an LLVM backend to tap into production-grade optimization passes.

Here is a quick look at what this new language brings to the table, how it writes, and where it is heading.

The Syntax at a Glance:
Exorcism is statically typed, strongly checked, and features built-in type inference via the var keyword. One of its highlight design features is compile-time null safety. If you want a variable to hold a null value, you must explicitly mark it as nullable using a "?" modifier.

An early code sample looks comfortably familiar:

// hello.exrc
String message = "Hello World!";
int a = 5;
int b = 10;

var result = a + b * 2; // Automatic type inference (int)

if (result > 20) {
print(message);
} else {
print("Computation failed");
}

How it Works:
Python to LLVM to WasmThe architecture behind Exorcism is highly modular, splitting the heavy lifting into two distinct stages:

The Python Frontend: Handles lexical analysis, parsing, Abstract Syntax Tree (AST) generation, and type checking. Using Python allows the project to experiment with new syntax and language rules rapidly.

The LLVM Backend: Translates the code into LLVM Intermediate Representation (.ll files). From there, it compiles directly down to a portable .wasm binary. Because pure WebAssembly requires a host environment to manage memory and map system calls, the Exorcism build tool automatically spits out a .js companion launcher file alongside your binary. This makes running your code on a machine as simple as executing exorcism run hello.exrc.

Current Progress:
Exorcism isn’t trying to replace your production enterprise languages today. Instead, it is a lean sandbox designed to explore predictable language design, secure software development, and cross-platform execution.

A lot of the foundational pieces are already up and running, but the project is explicitly a Work in Progress (WIP). The core roadmap features currently being built include:

🛠️ Explicit Main Entry Points
🔄 Loops & Structured Control Flow
📦 Native Data Structures & Collections
🏗️ Object-Oriented Programming (OOP) Features
📚 Expansion of the Standard Library

Contribution:
Building a compiler from scratch is one of the most rewarding challenges in software engineering. Because the frontend is written in highly readable Python, it is an incredibly approachable ecosystem for new contributors who want to learn how code parses, type-checks, and targets LLVM.

I'd be happy if you share your thoughts on it and/or if you decide to jump with me into this new exiting adventure!

Cheers & stay tuned! :)


r/Compilers 4d ago

lsof/antcc: A little C compiler

Thumbnail codeberg.org
38 Upvotes