r/Compilers • • Oct 23 '26

How do you make a programming language memory safe without paying a lot in overhead?

26 Upvotes

I am designing a language. I want memory safety without using a tracing garbage collector or having heavy runtime costs. I have been looking at the options and I would like to know how others have dealt with these tradeoffs.

The options I have looked at:

- Ownership and borrow checking (Rust-style): Zero runtime cost but the compiler must prove things and the learning curve and syntax friction are real. I am not a fan of Rusts syntax so I wonder if the same guarantees can be provided with a surface.

- Reference counting (Swift/Nim-style): Predictable and simple but you pay for increments and decrements on every copy and cycles need either weak references or a cycle collector.

- Tracing GC: Easy for the user. Pause times and memory overhead are the usual complaints. It is a fit if the language is meant for games or system work.

- Regions/arenas with escape analysis: Allocate in scopes and let the compiler prove that nothing escapes. Very cheap,. I am not sure how far escape analysis can go before it becomes too restrictive.

- Bounds checks and tagged or hardware‑assisted checks (like ARM MTE): Catch many errors at low cost but they are mitigations, not guarantees.

My current thinking is a mix arenas by default an ownership model for long‑lived values and bounds checks that can be elided when the compiler can prove them safe. I would like to know whether that is a direction or whether I am missing a well‑known approach.

Specific questions:

has anyone implemented escape analysis that stays useful without forcing annotations?

Is there a middle ground between full borrow checking and reference counting that does not reintroduce cycle problems?

for those who have shipped a memory‑safe language with overhead what would you do differently?

Links, to papers, languages or post‑mortems are very welcome :)


r/Compilers • • Oct 23 '26

I stopped maintaining my language, Sydrogen. The code and book are still up if you want to look around

8 Upvotes

Hi r/compilers

I built Sydrogen as my serious attempt at a compiler. It is a typed C-style systems language written in Rust. It was called ForgeLang until I renamed it since a lot of hobby languages use that name.

I've stopped working on it. The last release is Alpha-7 and there won't be more from me. I'm posting in case someone finds it useful or wants to take it

What might be interesting technically:

The compiler has two backends. The native one writes x86-64 machine code directly. Produces ELF64 or PE32+ executables without calling an external linker. The Cranelift one writes an object file and links with cc.

Both backends share the parser, AST and semantic checks, which run in parallel with Rayon.

It includes a set of language features like Do/Catch/Finally/Throw and fixed-size arrays and tuples though not all of them work on both backends.

What's unfinished:

The native backend doesn't handle floats or collections yet so those programs fall back to Cranelift.

The Windows backend doesn't have a runtime for Print or Input yet.

Finally doesn't run when Stop or Skip leaves a protected block.

There are no tests I'd call thorough. The README lists more gaps.

If you want to fork it fix something or just read the code the repo and book are here:

Repo: https://github.com/AeroForger/Sydrogen

Book: https://aeroforger.github.io/Sydrogen/

I'm not asking for anything. If you have questions, about how the native backend works I'm happy to answer them in the comments as I can.


r/Compilers • • Oct 24 '26

I used AI to create a JS-to-C++ compiler, with no packaged GC or VM.

0 Upvotes

Repo: https://github.com/alexios-angel/compile-time-browser

This project is AI-generated. Every line of code and every one of its ~6,500 commits was written by AI coding agents, mostly Claude and GPT. I didn't write the code. I just decided what to build, and sometimes directed the agents on how it should work.

I'm posting it here to show how far AI coding has gotten.

What got built

  • A browser engine in C++23, from scratch. HTML parser, CSS, layout, a software rasterizer, and its own JavaScript VM. The VM passes 96% of industry-standard JavaScript conformance tests. It opens real pages in a window.
  • A compiler that takes plain JavaScript and writes plain C++: structs, classes, std::vector, RAII, no garbage collector, no VM. When it can't prove something about the code, it refuses with an error instead of guessing. (The C++ it writes is correct but hard to read. It's in SSA form, one variable per intermediate value.)

Hasn't this been done? Turning JavaScript into native code, yes, many times. Almost every attempt either bundles a JS engine with the program or turns every value into a generic "could be anything" type backed by a runtime. All other major implementations package a garbage collector with your compiled code. My compiler does the opposite: it only writes C++ it can type and own, and refuses everything else. It also comes with its own browser engine, so web page code calls straight into it.

It took about 3 months of my time and roughly $40,000 in total, between AI usage and cloud costs/machines.

Where it is now

It's an alpha, and as of this week, current AIs are not good enough to continue progress on the goal of compiling real-world programs. The browser works on a lot of pages. The compiler handles small programs completely, but big real-world scripts are still mostly refused. I've shut down the cloud services I was using and AI API's until the AI does get good enough to continue writing code for the project.

Maybe if I get enough extra cash flow, I will continue the project in the immediate future.

AMA about the workflow, the costs, or what the AI wrote (I barely understand most of the code myself).


r/Compilers • • Oct 23 '26

How close can pure FP get to C?

Thumbnail rtfeldman.com
4 Upvotes

I found the discussion really interesting and thought you all would too. Richard talks about a pure Roc implementation of libdeflate and how to do performance optimizations unique to Roc. From a compiler perspective this is really interesting as to achievd this level of performance there are many optimizations needed under the hood, e.g. to mutate in place or elide checks etc.


r/Compilers • • Oct 22 '26

Advices for young compiler engineers

51 Upvotes

Hi everyone, I am quite new to work as a compiler engineer, but I am quite confident with my day to day loop (find optimization opportunities or fixing any broken stuff). Most of my work is on the backend (and also most of my knowledge).

However, sometimes I am lacking of intresting ideas to implement, I also (almost) never touch LLVM middle end, yet.

Often times, I am in the "now what ?" situation. I would love to know how to keep improving and get better at compiler engineering.

Thanks.


r/Compilers • • Oct 23 '26

🎉 Blaise v0.15.0 is out — hello, Apple Silicon!

Thumbnail reddit.com
0 Upvotes

r/Compilers • • Oct 23 '26

building my own programming language

Thumbnail github.com
0 Upvotes

I'm building my own programming language! Currently working on the standard library and bug fixes. It's designed to aim for memory safety with easy C interoperability.


r/Compilers • • Oct 22 '26

How to Attract Contributors on a Compiler Project

4 Upvotes

I've been trying to create my own compiler for my custom language for some time now. But doing everything alone has started to take its toll on me. How do I even attract contributors and/or get help somehow?

Edit: Let me tell you more about the project. The language is called Cole, you can find the github and codeberg repos here and here. Cole is a recreational attempt to create a language that is similar to Zig in many aspects. It aims to be as simple and as powerful as C. My motivation behind the project was that it is really hard to get into compiler dev. Contributing to compilers is a tough process, and creating your own from scratch is also hard. So I thought, why not create something that doesn't have insanely high standards so people that are starting out can contribute easily? Essentially, Cole's purpose is not to be an active-in-industry language, but a learning one for everyone.


r/Compilers • • Oct 22 '26

Highly Optimizing Ahead-of-Time Compilers for Dynamic Languages [PhD Defense Slides]

Thumbnail olimel.net
25 Upvotes

r/Compilers • • Oct 21 '26

[Hiring] Compiler Interns (Graduate & Undergraduate), Intel Graphics Compiler (GPU backend), Santa Clara, US - onsite only

138 Upvotes

Hi r/Compilers,

I'm on the Intel Graphics Compiler (IGC) backend team. We're hiring compiler interns at both the graduate (Master's/PhD) and undergraduate level. We build the compiler that turns shaders and compute kernels into machine code for Intel GPUs, and the work covers code generation, optimization, and getting the most performance out of the hardware.

If you've ever wanted to work on a production compiler that ships on millions of GPUs, this could be a good fit.

What you'd work on

- Compiler optimization and code generation for Intel GPU architectures

- LLVM-based compiler infrastructure

- Performance analysis and hardware/software co-design

- Real problems with real workloads: your work ships

---

Graduate Intern (Master's or PhD)

Minimum qualifications:

- Currently pursuing a Master's or PhD in CS, CE, EE, or a related field

- Graduate-level coursework in computer architecture and compilers

- Strong C++ programming and software development experience

- Experience with compiler design, optimization, or code generation through research, coursework, or prior internships

Nice to have:

- Experience with LLVM or another compiler infrastructure

- Knowledge of GPU architecture, parallel programming, or performance analysis

- Research or project experience in compiler optimizations, computer architecture, or HW/SW co-design

---

Undergraduate Intern

Minimum qualifications:

- Currently pursuing a Bachelor's in CS, CE, EE, or a related field

- Coursework in computer architecture and compilers

- C++ experience and a solid foundation in data structures and algorithms

- Experience developing and debugging software through coursework or projects

Nice to have:

- Compiler project experience or familiarity with LLVM

- GPU architecture knowledge or parallel programming with SYCL, OpenCL, or CUDA

- Familiarity with Python, Git, and software testing

---

How to apply

Email your resume to hou-jen.ko@intel.com. Use the subject line "[Compiler Intern] Graduate" or "[Compiler Intern] Undergraduate".

It helps to include links to anything compiler-related you've built: a toy compiler, an LLVM pass, upstream patches, a paper, a GitHub repo. We read those closely.

Happy to answer questions in the comments!


r/Compilers • • Oct 22 '26

TypeScript to bootable floppy - compiler, editor, emulator, all in-browser

Thumbnail branchpredict.com
3 Upvotes

Write TypeScript in a browser tab. Hit compile. A 16-bit x86 machine boots underneath - same bytes a floppy would run.

TypeScript to real-mode x86, no runtime, no OS, no JS engine. Bootable binary under 64KB.

Full toolchain in the browser: file tree, editor, compiler, emulator. Pick a demo - voxel engine, raycaster with sound, snake. Or write your own and boot it on real hardware.

Most of the work was what to leave out. 16-bit real mode didn't negotiate :-)

Deeper dive into the compiler is on the page, alongside the demos.

Due to the number of requests, try compiling it again if the queue is full.


r/Compilers • • Oct 22 '26

How would you guys define an Anonymous Function or a function pointer?

Thumbnail reddit.com
1 Upvotes

r/Compilers • • Oct 22 '26

Kcc, a C compiler built solo with an LLM on $100/mo boot Linux kernel

Thumbnail reddit.com
0 Upvotes

r/Compilers • • Oct 23 '26

Kcc, a C compiler built solo with an LLM on $100/mo boot Linux kernel

Thumbnail reddit.com
0 Upvotes

r/Compilers • • Oct 21 '26

Hackathon: Implement PTX Compiler

Thumbnail reddit.com
3 Upvotes

r/Compilers • • Oct 21 '26

Hike: A zero-overhead, Go-like systems language with dual LLVM/Wasm backends, deterministic memory, and full DWARF support

6 Upvotes

Hello r/Compilers,

I would like to share Hike, an open-source, zero-overhead systems programming language implemented in Go with a Go-inspired syntax, targeting both native machines (via LLVM) and WebAssembly.

It is backed by a test suite of over 1,000 compiler tests, proven stable, and is already running in production for commercial software in Japan.

Key Highlights & Motivation

While Go provides great developer productivity, its heavy runtime, garbage collector, and runtime calling conventions make it difficult to embed into ultra-constrained environments, bare-metal microcontrollers, or tiny WebAssembly modules.

Hike bridges this gap: it retains familiar Go-like ergonomics while stripping away the runtime completely.

  • Zero-Runtime & Deterministic Footprint: Hike does not rely on a monolithic runtime or a tracing GC. It can emit WebAssembly binaries as small as 2KB. In our stress tests, executing API entry points over 10,000 times resulted in zero memory growth.
  • Dual Backend Architecture:

    • LLVM Backend: Produces optimized native code and native objects.
    • Native Wasm/WABT Backend: Directly synthesizes structured WebAssembly (blocks, loops, branches) alongside full DWARF debug information. This enables source-level step debugging directly inside Google Chrome DevTools.
  • Extreme Portability (MCU to GPGPU):

    • Targets bare-metal microcontrollers like the Raspberry Pi Pico (RP2040).
    • Architecture designed to support GPGPU compute environments including OpenCL and CUDA.
  • High-Throughput / Large-Data Primitives: To support memory-intensive, massive-traffic applications, Hike introduces first-class language constructs:

    • Region/Area memory management for bulk allocations.
    • Threadable & Concurrent variables for explicit, thread-safe data access.
    • mmap-backed variables to operate directly on out-of-core data structures without manual syscall boilerplate.

Compiler Pipeline

The Hike compiler is structured around a High-Level Intermediate Representation (HIR) designed to preserve semantic intent before code generation:

  1. Frontend: Lexing, parsing, and type-checking Go-compatible syntax into HIR.
  2. Analysis: Escape analysis, ownership tracking, and lifetime inference for deterministic retain/release and region-based allocation.
  3. Emitter:

    • Generates clean LLVM IR for heavy machine optimization.
    • Generates clean, structured WebAssembly Text (WAT) preserving natural control flow (block, loop, br) rather than flattening the control flow graph into state-machine dispatchers.

Status & Ecosystem

Hike is actively maintained, stable, and used in production environments. We are also experimenting with cgo-free interoperability (such as embedding Rust-based UI engines like Slint statically into Go using generated .syso objects and Plan 9 ABI bridges).

I would love to hear feedback, critique, and architectural insights from fellow compiler developers—especially regarding our structured Wasm emission, region memory abstractions, and non-GC systems language design.


r/Compilers • • Oct 20 '26

From logic gates to a self-hosting compiler: my undergraduate HPC course is almost fully available in English

36 Upvotes

A few months ago, I shared not-abc, a tiny self-hosting compiler I developed for teaching.

Since then, I've been translating the worksheets and lecturer notes from my undergraduate course Introduction to High Performance Computing into English. The project is now almost complete, with nearly all the teaching material available on GitHub.

The course takes a somewhat unusual approach: students work their way toward building a compiler while simultaneously learning how computers work from the bottom up.

On one side, they explore programming languages, pointers, memory management, parsing, symbol tables, and code generation. On the other, they build logic circuits, an ALU, and a small CPU architecture.

Eventually, these two paths meet.

The compiler they develop targets LLVM IR. The reference compiler is self-hosting and deliberately minimal: it uses only 64-bit values, has no static type system, and supports a small set of built-in functions.

The teaching material includes worksheets, lecturer notes, and hands-on programming exercises. I've taught this course at the University of Ulm, Germany, and I'm making the material freely available for anyone interested in learning or teaching compiler construction.

Repository: https://github.com/michael-lehn/not-abc

One thing I'd particularly like to mention: the feedback I received from this community on my earlier posts has been incredibly valuable. Several suggestions led to concrete improvements in both the compiler and the teaching materials.

Now that the project is approaching completion, I'd love to get another round of feedback before wrapping things up. If you spot anything that could be improved, please let me know!

It's been a pleasure sharing this project here. What a great community!

And of course, if you find the project useful, a GitHub star would be very much appreciated. :)


r/Compilers • • Oct 21 '26

I wrote a compiler entirely in NASM x86-64 assembly — no LLVM, no C runtime, no external deps

2 Upvotes

Hi there, I've been working on a small systems programming language called CAP. The most interesting part (to me at least) is the compiler itself: it's written in ~pure NASM x86-64 assembly and emits x86-64 machine code directly. No LLVM, no C backend, no libc — the entire toolchain is self-contained.

The language has Python-like syntax (whitespace-sensitive, no fn main()) but no GC — you manage memory explicitly. It supports inline assembly, lists, dicts, and as of a few minutes ago, a native UI toolkit with charting built in (no external libs).

It's very early (v0.1.2), so don't expect a production-ready experience. But the codebase is small enough to read end-to-end if you're curious about how a compiler works at the lowest level.

Repo: https://github.com/Hideyukiakaza/CAP

Happy to answer questions about the architecture or share design decisions.


r/Compilers • • Oct 21 '26

Koppa load of this

0 Upvotes

"I asked Claude to invent a programming language. It invented one called Koppa where changing a single instruction can corrupt every instruction after it."
And the truly satanic part?
It works. It has an interpreter, a compiler, and working example programs.
The language isn't broken. The suffering is by design.
Somewhere, a compiler engineer is about to wake up screaming in hexadecimal.
Koppa (q): Because debugging wasn't painful enough.


r/Compilers • • Oct 20 '26

Mixed of FUNCTIONAL BASIC and CLIPPER 5.3 into a C99 Compiler

3 Upvotes

I always loved BASIC and CLIPPER 5.3, so I started from an old and never finished BASIC compiler and I asked the AI to improve it adding advanced functions and CLIPPER 5.3 commands, including code-blocks, macro, runtime eval, SAY/GET/READ subsystem. Currently the compiler works on MacOS and Linux. Window version by Visual C++ will come as soon as I will have a laptop with windows installed. I am trying Mingw for windows.

This is an example using macros, eval and code-blocks. It shows also functions passed as parameters of other functions and Sub Main as entry-point.

'FILE: Clipper/ClipperMacroEvalBlocksExtreme.bas

IMPORT ARRAYS

GLOBAL TaxRate AS DOUBLE
GLOBAL cName AS STRING

FUNCTION MkInc() AS FUNCTION(x) AS DOUBLE
    RETURN { |x| RETURN x + 1 }
END FUNCTION

FUNCTION ApplyFn(b AS FUNCTION(x) AS DOUBLE, v AS DOUBLE) AS DOUBLE
    RETURN EVAL(b, v)
END FUNCTION

SUB Main()

    TaxRate = 0.22
    PRINT "=== Clipper macro/EVAL/blocks (extreme) ==="

    'Macro ESPRESSIONE compilata (aritmetica + globale)
    DIM cPrice AS STRING = "100"
    DIM cNet AS STRING = "VAL(cPrice) * (1 + TaxRate)"
    PRINT "net="; &(cNet)                       ' 122

    'Macro VARIABILE: il nome della variabile e' nei dati
    DIM which AS STRING = "TaxRate"
    PRINT "tax="; &which                        ' 0.22

    'Macro COSTANTE che produce un CODE BLOCK (compilato una volta)
    DIM bGross = &("{ |p| RETURN p * (1 + TaxRate) }")
    PRINT "gross(100)="; EVAL(bGross, 100)      ' 122
    PRINT "gross(200)="; EVAL(bGross, 200)      ' 244

    'Macro su VARIABILE con block LETTERALE (espansione compile-time)
    DIM cBlockDef AS STRING = "{ |p| RETURN p * (1 + TaxRate) }"
    DIM bVar = &(cBlockDef)
    PRINT "vargross(150)="; EVAL(bVar, 150)     ' 183

    'Code block letterale + EVAL multi-argomento
    DIM bArea = { |w, h| RETURN w * h }
    PRINT "area="; EVAL(bArea, 6, 7)            ' 42

    'Block con concat: risultato stringa + param usato solo in concat
    DIM bBang = { |s| RETURN UPPER(s) + "!" }
    PRINT "bang="; EVAL(bBang, "x")             ' X!
    DIM bRaw = { |s| RETURN s + "!" }
    PRINT "raw="; EVAL(bRaw, "x")               ' x!

    'Block applicato a tutti gli elementi di un array (AEVAL: elemento, indice)
    DIM prices = {100, 200, 300}
    AEVAL prices, { |v, i| PRINT "  gross["; i; "]="; v * (1 + TaxRate) }   ' 122 244 366

    'Nested Macros
    DIM cThree AS STRING = "deep!"
    DIM cTwo AS STRING = "cThree"
    DIM cOne AS STRING = "&cTwo"
    PRINT "nested="; &cOne                       ' deep!
    'EVAL stringa (GMBasic) come COMANDO + text substitution (globale)
    EVAL("TaxRate = 0.10")
    PRINT "tax2="; &("TaxRate")                  ' 0.1
    cName = "world"
    PRINT "subst=Hello &cName!"     ' Hello world!  (globale espanso)

    'EVAL con block INLINE + block restituito da funzione
    PRINT "inline="; EVAL({ |s| RETURN UPPER(s) + "!" }, "x")   ' X!
    PRINT "fromfn="; EVAL(MkInc(), 5)                           ' 6
    DIM bm = MkInc()
    PRINT "infvar="; EVAL(bm, 5)                                ' 6
    EVAL({ |s| PRINT "stmt="; s }, "y")                         ' stmt=y

    'Closure: EVAL annidato + function-value catturato + param FUNCTION
    PRINT "nested="; EVAL({ |x| RETURN EVAL({ |y| RETURN y + 1 }, x) }, 5)  ' 6
    DIM inner = { |y| RETURN y + 1 }
    DIM outer = { |x| RETURN EVAL(inner, x) }
    PRINT "capt="; EVAL(outer, 5)                               ' 6
    PRINT "param="; ApplyFn({ |z| RETURN z * 2 }, 21)           ' 42
    PRINT "Clipper macro/EVAL/blocks: fatto."

END SUB

The compiler supports graphics by SDL, Vulkan, Game Loop (thousands of fluid sprites), TUI, Windows Manager, DBF files with memo field (DBIII/DBIV/Clipper/FoxPro), TBROWSE, ISAM, RDD system, SQL (SQLite/DuckDB integrated), REPL, Package Manager (like cargo/pip/modules), and more.

The compiler supports also numbered lines, GOTO, GOSUB, ON ERROR, ON KEY, etc.

This an attempt to bring old clipper/basic programmers into a modern world, saving their old code.

Will you try it if will be made open source and what do you think about it?


r/Compilers • • Oct 20 '26

Compound Memory Models

Thumbnail sigarch.org
6 Upvotes

r/Compilers • • Oct 20 '26

Durable workflows without replay: freezing the VM instead of re-running the code

Thumbnail qoqi.dev
2 Upvotes

r/Compilers • • Oct 20 '26

A C/C++ compiler to readable JavaScript, held to gcc: exact i386 and 16-bit DOS ABIs, C++98 lowered to C, deterministic builds

1 Upvotes

PRISM is a C and C++ compiler written in JavaScript, targeting JavaScript (not Wasm): one JS function per C function, run by the engine's JIT. Its purpose is to compile unmodified real-world code (MAME, Quake I–III, ScummVM, Lua, SQLite, PuTTY) and run it in a browser.

Disclosure up front: the code was written with Claude Code (Anthropic's coding agent) under my direction. Because of that, the whole project is built around not trusting it: every claim is checked by a gate against an independent implementation, and each gate carries a deliberate mutation it must catch.

Some design points that might interest this sub:

- Two exact ABIs: i386 System V and 16-bit real-mode DOS (small/medium/large, far/huge pointers). Struct layout is held to gcc 12 i386 on ~105,000 generated checks, bitfields included.

- Preprocessor token-identical to gcc -E, including 289 whole translation units.

- C++98 subset lowered to C (classes, virtual and multiple inheritance, templates, exceptions on setjmp/longjmp), enough for ScummVM and Enemy Territory.

- Assembly translated, not emulated: Borland inline asm, TASM modules, Watcom #pragma aux, NASM.

- Testing: c-testsuite and gcc.c-torture/execute with 0 wrong answers (a construct it can't compile is a named refusal, never a silent miscompile), csmith against gcc -O0/-O2, and whole programs bit-identical to native builds (MAME 0.34: 15/15 games over 1,500 frames).

- Deterministic: fixed __DATE__, a virtual clock when headless, so every comparison is exact and re-checkable.

A small example of what exact comparison turns up: on one float-only Rosetta Code program, x87 gcc, SSE gcc, clang (which fuses a*b+c into an FMA by default) and PRISM gave three different characters for one pixel; PRISM matched SSE gcc and -ffloat-store, i.e. IEEE single precision rounded per operation.

No optimiser yet: about 9.5× slower than clang -O2 on a Z80-core benchmark.

You can type C or C++ in the page and see the emitted JS: https://prism-compiler.pages.dev/web/live/

Source (MIT): https://github.com/jfrelat-lab/prism


r/Compilers • • Oct 19 '26

Bootstrap time has arrived!

Post image
11 Upvotes

The Flux compiler is now written in Flux.

This means the Python version of the compiler is now officially retired.

There’s still a long way to go till all components are translated and implemented, but progress is being made daily.

The package manager will also be capable of publishing soon as well.

Features such as the FVM and comptime will be held off until a significant portion of our own x86-64 backend is completed.

The borrow checker is next on the line for translation, and will also come with additional improvements.

We would love to hear some feedback about what you’d like to see added to the ecosystem next! Do you think the stdlib should be expanded, or shocked existing tooling be the focus?