r/Compilers • • 29d ago

I made a game in 3 kB… and accidentally created a programming language

Thumbnail youtube.com
0 Upvotes

I wrote a technical blog post about my experimentation a few months ago. I've just adapted the content to youtube, so you can choose the format you enjoy the most:

https://laurent.le-brun.eu/blog/making-a-game-on-a-custom-bytecode-vm-in-7-days-and-3kb

Things mentioned:

\- how to make an executable smaller than 10kB

\- other size-coding tricks

\- building a small compiler + bytecode interpreter

(the project was done last year, but sometimes it takes time to prepare the making-of content)


r/Compilers • • Nov 02 '26

How compiler handles files and its life time

21 Upvotes

I've made good progress on my own compiler, but it currently supports only a single source file. My next step is to add import and export functionality so projects can be split across multiple files and modules. I'm particularly interested in how your compiler handles things such as:

  • Discovering and loading imported files
  • Managing dependencies between files
  • The lifetime of parsed files, ASTs, and symbol tables
  • When data can safely be released from memory
  • How the overall compilation process is organized once multiple files are involved I'm especially interested in concrete implementations. If you've built a compiler yourself, I'd love to hear how you solved these problems, what architecture you chose, what worked well, and what you would do differently if you started again. Examples, code snippets, blog posts, repository links, or references to real-world compilers are all welcome. Thanks!

r/Compilers • • 29d ago

C* (C-Star): A design concept for a minimal C++ static safety extension. Looking for feedback and critique!

1 Upvotes

(Cross-posted to r/cpp and r/Compilers for wider feedback)

Hi everyone,

I'd like to share a design concept I've been working on called C (C-Star)*, which is a minimal static safety extension for C++.

The core concept is "30% human responsibility." By allowing developers to write simple compiler attributes ( [[cstar::...]] ), the compiler handles deterministic validation to achieve 0% execution overhead without breaking native SIMD vectorization.

To be transparent, I act as the idea generator and prompt engineer for this project. The core concept and structural direction are my original ideas, while the comprehensive text, solutions, and 1,399-line specification were fully generated and co-authored with AI. Because of this, there might be technical paradoxes or unfeasible assumptions, and I highly welcome your professional engineering insights to review and critique the compiler logic!

I would highly appreciate your professional insights, critique, and guidance on what might be broken and how it could be improved.

Based on my understanding of the Clang/LLVM codebase, I am currently targeting these specific files to make this work:

  1. Sema ( clang/lib/Sema/SemaType.cpp ): Trying to lock attribute metadata into QualType so it won't peel off during template expansions.
  2. Bitcode ( llvm/lib/Bitcode/Writer/BitcodeWriter.cpp ): Attempting to serialize static alias graphs into the ThinLTO summary to avoid halting problems at the link phase.
  3. CodeGen ( clang/lib/CodeGen/CGCall.cpp ): Trying to automatically generate compatible Bridge Thunks. For innermost loops, I'm hoping to make the thunk completely evaporate via inlining.

The full draft is hosted on GitHub:

GitHub URL: https://github.com/yuma-alpha-beta/Cstar_specification.md

Note: The detailed specification in the repository is currently written in Japanese. Please use your browser's translation feature or a tool like DeepL to read it.

If you find this concept interesting or have any suggestions on how to improve this design, I would love to hear your thoughts.

Thank you so much for your time and expertise!


r/Compilers • • 29d ago

Major Updates to Cole Compile-Time Execution and Type Reflection

Thumbnail reddit.com
1 Upvotes

r/Compilers • • 29d ago

Générer des appels à des DLLs sur Windows avec un interpréteur

0 Upvotes

Salut, j'ai fait du DLL Engineering avec de l'asm x86_64 sur Windows que j'ai mis dans mon interpréteur fr-simplecode en C.

On peut donc appeler n'importe quelle DLL dynamiquement, créer des structures compatibles avec du code C compilé. Et également utilisé un CALLBACK pour les fenêtres Windows (je mettrai les autres CALLBACK dans les prochaines mises à jour de l'interpréteur).

La dll dll_service.dll peut être lié à n'importe quel code C avec dll_service_api.h

Ici le code ne génère qu'une fenêtre Input simple avec deux codes différents : avec ou sans le CALLBACK par défaut : DLL-Engineering-x86_64-Windows/create_windows.frc at main · argentrocher/DLL-Engineering-x86_64-Windows

Le code de la DLL dll_service.dll doit être lié à fr-simplecode0.5 avec la commande suivante si vous souhaitez l'exécuter :

fr-simplecode0.5 --dll[0]:"dll_service.dll" --dll_filters[0]

Trouvez-vous ce code fonctionnel et performant ?


r/Compilers • • Nov 02 '26

Update on the Monad language Oak framework for web apps and more

1 Upvotes

r/Compilers • • Nov 02 '26

Any opportunities for engineering undergrad?

12 Upvotes

I am a final year engineering student. I am extremely interested in learning and building compilers . Now I need some guidance and some project to work on with professors or industry experts or people who have worked a lot in this domain .

If you have or you know any internships , project assistant roles or anything , please let me know .

it will be of a great help .


r/Compilers • • Nov 02 '26

Zena : a language for WebAssembly

Thumbnail zena-lang.dev
0 Upvotes

r/Compilers • • Nov 02 '26

ASMBI description

Thumbnail reddit.com
0 Upvotes

r/Compilers • • Nov 02 '26

3.51x speedup against C++ and Rust: Why Goose‘s claims aren‘t fair (kinda)

0 Upvotes

Everyone is talking about the new Programming language called goose. It‘s biggest claims are a 3.51x speedup against Rust and C++ and dynamically sized containers with stable references.

This is true — but only under very specific circumstances. Looking at the benchmarks (16 in total), the 3.51x speedup is a win against "idiomatic C++". The gains against "hand optimized" C++ and safe Rust are 1.24x and 1.13x, while there is nowhere specified what "kind" of goose was used in those benchmarks, while the term "optimized" is also not objectively defined. And Goose isn‘t even faster in all cases. For example:

  • Goose loses to expert C++ and safe Rust in the LRU benchmark: 0.88× & 0.81x.
  • Goose loses to safe Rust in the scene benchmark: 0.82×.
  • Goose loses to safe Rust in the calculation benchmark: 0.91×.

3.51x Speedup is a very selective representation of the result.

The biggest Catch: "No heap" doesn‘t mean unlimited memory.

Goose uses statically assigned data stacks with large reserved address-space ranges and bump pointers. The official documentation says:

  • Every resizable container has it‘s own data stack. (While ownership of the stack can move to another value if the old one goes out-of-scope, so maybe, so it gets reused when they live sequencially)
  • Groth advances a bump pointer.

And exactly that is the catch. It is not real dynamically sized data. I mean, conceptually, it is. It can grow at runtime. Every Goose data stack reserves a few Gigabytes of virtual address space by default, and commits physical memory if needed without occupying it from the beginning, granting stable references. But, and that’s a big "but", if that virtual adress space exceeds, the program gets terminated, like an uncatchable exception.

That can destroy the purpose of dynamic data.

When the size of a container is clear at compile or construction time, an array absolutely fulfills this job in almost every case.

The reason You need dynamically sized data is this: Imagine having a game where enemies spawn and get killed. There is no limit for enemies that can exist at the same time. You don‘t know what the player does at compile time. There could be only three enemies, but also a hundred or thousands of enemies. You can‘t reserve the whole RAM for your game, of course, and you can‘t just use the memory right after your container because it may be already occupied. And scattering objects across memory is not an option either, because it destroys CPU locality and therefore also performance. So normally, you allocate new space that is bigger, copy/move all the old elements and free the old space.

But in that case, you cannot use one of goose‘s „dynamically sized“ containers. Because, if you have so much enemies it exceeds a certain memory limit, your game gets terminated (which you usually don‘t want in prod)

So, my statement: It is not apples to apples. Goose's performance advantages come from several things: No general-purpose allocator on the allocation path. No per-object destruction. Contiguous data layouts. Narrow relative references instead of full pointers. More compact variable-sized enum representations. No relocation when growing containers. These are genuine architectural advantages, but they aren't exclusive to Goose.


r/Compilers • • Nov 01 '26

I made a Concurrency lib in Nim using macro and it perform on par with the Goroutine has many features and is easy to use than you can think.

Thumbnail reddit.com
3 Upvotes

r/Compilers • • Nov 02 '26

Spectre v0.0.12 released, with benchmarks surpassing Zig in runtime performance

0 Upvotes

A few new things in this release, including the fmt command (formatter) and critic subcommand (Iinter/checker), plus std/netx for simplifying usage of the std/net API. The language compiles to QBE IR, which compiles to assembly.

https://github.com/spectrelang/benches

Here are the benches showcasing Spectre runtime performance vs other compiled systems programming languages, and here is the site.

Spectre v0.0.12 release

EDIT: TheOddYehudi919 is a real piece of shit and should fuck off and rot in a ditch tbh.


r/Compilers • • Oct 31 '26

Template Metaprogramming's Performance Limitations

Thumbnail reddit.com
5 Upvotes

r/Compilers • • Nov 01 '26

Sail AI Language

0 Upvotes

I've created new programming language for AI by AI named Sail. It supports neuro-symbolic binding `infer| ... fall|`, fuzzy operator ~ , and other stuff. Source code: https://github.com/zema26/sail-one-language/

Working web version:

https://sailcompiler.replit.app


r/Compilers • • Oct 30 '26

Updates on Cole, and Version 0.1.4 announcement

8 Upvotes

Hello everyone, since my last two posts here, I got into a small flow-state with the codebase and improved Cole quite a bit. I took the advices of the wonderful people in the comments as well, and it helped me a lot to be honest.

Since the last posts, I added:

- 212 tests in total, testing various aspects of the compiler through simple programs,
- Proper generic type generation with full generic definition support through comptime called functions,
- Proper generic function generation through comptime called functions,
- Type deduplication, and codegen improvements,
- And many more bugfixes on different aspects of the compiler.

In the current state, the backend is embedded TCC, so codegen emits almost-human-readable C code. But I will replace the backend in the future with LLVM, QBE or handwritten x86_86 generator. However for now, since the rest of the compiler is not solid enough, the C backend eases the development quite a bit.

Beside all of this, I made a small website (which doesn't work quite well because I self-host it on an old laptop, it is for giggles of it so don't take it seriously) that has versioned language reference, a small welcome page with a hello world snippet, and installation instructions.

Overall, Cole has become something far beyond what I imagined it would become in a good way. I am self taught, so I am pretty content with what I have accomplished. But criticism is always welcome.

The link to the Cole website is here. And the Codeberg and Github repos are here and here.

Also, occasionally, I write blogposts about what I'm currently working on, so I'll leave it here as well.

Many thanks to everyone that commented to any of my previous posts, have a good day/night!


r/Compilers • • Oct 31 '26

I'm making a programming language, searching for contributors

0 Upvotes

Hi! Me and another person are working on a programming language called KrabbaScript! It's garbage-collected (optional), statically typed and trying to be as simple and intuitive as golang but more human-friendly. This is KrabbaScript's syntax:

Variables are defined as:

var krabba = "Krabba!";

Variables may also have a type or be uninitialized, like:

var with_type: F32 = 5.0;
var uninitialized: Str;

KrabbaScript also has values, which are immutable, example:

val constant = 5;
val with_type: I32 = 5;

KrabbaScript also has control-flow (duh), example of a repeat statement:

repeat {
  Std.print("KrabbaScript is the best language OAT!");
} until popular;

KrabbaScript also has a when statement, which is more of a switch one:

when language {
  == "Elixir" do celebrate();
  == "Haskell" do complain();
  == "KrabbaScript" do {
    contribute!;
    applaude!;
  }
  else do Std.print("I don't know anything about " + language);
}

KrabbaScript also provides an ASI (Automatic Semicolon Inserter) if you're tired and sick of semicolons, you can use it with the format command.

If you want a little bit more examples, check out the repo! We are also working on tools for KrabbaScript like package manager, style checker, etc.

We are searching for contributors and maybe you, the person reading this post, can help us create KrabbaScript or improve it!


r/Compilers • • Oct 30 '26

What are the features you wished your everyday programming language had?

9 Upvotes

I'm designing my own programming language called Snore, and besides other things, I aim to make it general purpose and hence if i can fix any common struggles or annoying forms in popular languages, it would be really helpful. Which such struggles do you experience? (my language is at https://codeberg.org/grewstad/snore though it is at quite an early stage)


r/Compilers • • Oct 30 '26

Where to start? Any books, resources youd recommend?

16 Upvotes

Hello,

For my final year project at university, I need to essentially design and implement a programming language (omitting lots of details). The issue is that I have not yet studied compilers at uni, and will be doing that in january, but i need to start work on my project now

I dont know much about compiler design. I dont really know how to make a lexer or a parser

Where should i start? Are there any books or resources youd recommend?


r/Compilers • • Oct 30 '26

Heavenly delights of hashing numbers under EQUALP

Thumbnail turtleware.eu
2 Upvotes

r/Compilers • • Oct 30 '26

TornadoVM v8.0.0: Meet TC, TornadoVM's Own Compiler (replacing old Graal/JVMCI-based solution)

Thumbnail tornadovm.org
2 Upvotes

r/Compilers • • Oct 30 '26

The Convergence on Deterministic AST Invariants: Why Frontier AI Had to Abandon Probabilistic Code Editing

Thumbnail reddit.com
0 Upvotes

r/Compilers • • Oct 29 '26

Could source-level formal verification enable better IR optimizations?

5 Upvotes

Recent advances in LLM-assisted proof construction seem to make formal verification increasingly practical.

This got me wondering whether the results of formal verification could also benefit compiler optimizations.

For example, a compiler frontend or a separate tool could formally verify annotated source code, then propagate verified properties, such as constraints, invariants, and preconditions, into the IR for subsequent optimization passes.

Could this enable optimization opportunities that conventional static analysis might otherwise miss?


r/Compilers • • Oct 29 '26

InferType, and toolkits for building compilers

Thumbnail drops.dagstuhl.de
7 Upvotes

(not the author, just sharing because I found it)

Recently I came across the paper by Senxi Li et al, InferType: A Compiler Toolkit for Implementing Efficient Constraint-Based Type Inference. Check it out!

I've always found interesting the concept of making modular, extensible compilers. And by "modular", I don't just mean separate compilation à la OCaml, Haskell (they're cool btw), or parser generators à la lex, yacc (also cool btw).. I mean embedded domain specific languages and libraries à la parser combinators, MetaOCaml for concrete code generation.. components that can generalize a part in the compilation pipeline and can be imported as a reusable library. We have seen libraries to handle the lexing and parsing part. But for further semantics-related analysis parts.. not so many? So far I've found InferType, are there others like this?

Also related are language workbenches, like JetBrains MPS, and the Truffle framework and their dialects of Python and JavaScript. But so far they have only been used for making interpreters for DSLs, what about full-fledge compilers for general-purpose programming languages?


r/Compilers • • Oct 29 '26

Try/Catch: Yes or No

7 Upvotes

My language, QuarticC, has many ways to error handle.
Unions:

type Err = DivByZeroErr | int;  
Err divide(int lhs, int rhs) {  
    if (rhs == 0) return DivByZeroErr();  
    return lhs / rhs;  
}  
// Or generic:
type Err<T, E> = T | E;
Err<DivByZeroErr, int> divide...

Tagged Enums:

enum Result<T, E> {  
    Err(E);  
    Ok(T);  
}  
Result<int, DivByZeroErr> divide(int lhs, int rhs) {
    if (rhs == 0) return Result<int, DivByZeroErr>.Err(DivByZeroError());
    return Result<int, DivByZeroErr>.Ok(lhs / rhs);
// Or you could make it non generic.

Multi-Return (assuming your error types have a "ok" state):

DivByZeroErr, int divide(int lhs, int rhs) {
    if (rhs == 0) return DivByZeroErr(), -1;
    return DivByZeroErr(true) /* assuming true = ok */, lhs / rhs;
}

Tuples (same as above, but returning tuples):

(DivByZeroErr, int) divide...

And the problem, try/catch.

int divide(int lhs, int rhs) {
    if (rhs == 0) throw DivByZeroErr();
    return lhs/rhs;
}

I actually don't have a problem with the idea that handling a error isn't required too much, however the big problem is defer. Because I want defer to be a zero-cost, it does not run during stack unwinding, and I don't want to put in the effort to make it do so. This is annoying because if your primary error handling is throw, defer is basically useless for error cleanup, which is it's most useful purpose, and it's not like I'm loosing my main error handling, other forms work fine. So the question is: do I remove try catch, or do I make defer stack-unwinding.