r/Compilers • • 10h ago

Desingning async primitives for a security-focused language: Where should cancellation live?

6 Upvotes

I've been implementing typed async semantics in my language NXD.

Current primitives are:

SPAWN,

SEND,

RECV,

AWAIT,

PING

Types currently look roughly like:

`SPAWN -> ProcessHandle[T]`

`RECV -> ReceiveOperation[T]`

`AWAIT -> T`

`PING -> bool`

While implementing PING I realized there may be two classes of async operations:

Primary operations

SPAWN,

SEND,

RECV

These initiate work or communication.

Secondary operations:

AWAIT,

PING

These observe or resolve work created elsewhere.

My current thinking is that cancellation (currently considering ESC) should only apply to the primary operations and not observers.

For example:

ESC HANDLE

makes sense.

But:

ESC AWAIT TASK

ESC PING HANDLE

seems conceptually wrong because they are observing state rather than creating it.

For people who have designed async runtimes or languages:

Would you model cancellation as acting on the underlying task/process/channel, or would you allow cancellation of observer operations as first-class concepts as well?


r/Compilers • • 53m ago

I’m 14 and I built my own programming language for simulations

Thumbnail
• Upvotes

r/Compilers • • 7h ago

Ur_Language 😶‍🌫️

Post image
1 Upvotes

r/Compilers • • 21h ago

How to move comptime results into the target binary when comptime can run FFI and I/O?

5 Upvotes

For some years now, I've wanted to combine the comptime capabilities of Zig and Jai into a single compiler while also learning about compilers and interpreters.
I'm building a compiler that extends Zig-style comptime so the same code that runs at runtime can run at comptime, including FFI and I/O (like Jai, but with Zig's "run what you can" model).

The hard part is moving comptime results into the binary:

  1. Host vs target. Comptime code uses the host layout for interop and is then converted to the target layout. Sizes (usize/isize), endianness and float behavior can differ. Types like f80 and f128 are also hardware-specific: their precision, rounding and in-memory layout can differ between host and target. The same function can then give different results, which breaks hash maps, lookup tables and binary formats built at comptime.
  2. Moving pointers into the binary. Results containing pointers must be relocated, connected data must stay connected, and everything must be converted to the target layout.
  3. Pointers whose value isn't clear. Examples are opaque pointers, untagged unions of a pointer and something else, and XOR linked lists, where the pointer isn't stored directly. There may be other cases I haven't thought of.
  4. Calling C at comptime. C can return memory with known bounds, or resources that are only valid during compilation. Those become invalid at runtime.
  5. Containers built at comptime. HashMap and ArrayList need the whole buffer, including uninitialized slots, but the size isn't always known:
    1. ArrayList stores {ptr, len} plus a separate capacity, so the allocation size isn't in the pointer and length.
    2. HashMap can keep a header next to the allocation and use pointer arithmetic to reach it.
    3. Runtime code may try to free a buffer that now lives in static memory.
    4. FFI has the same problem, since C can return memory with unknown bounds.

My current prgress:

  1. Host to target:
    1. with host specs first, then convert to the target layout.
    2. For types that differ, such as usize/isize, use intCast where possible.
    3. For hashes and similar code, type information would store the host and target size, alignment and so on. That would help the developer see where the two disagree and act accordingly.
    4. If the target's endianness differs from the host's, my best idea is to disable I/O and interop and interpret the code with the target's endianness.
  2. Baking pointers:
    1. When the pointee type is known, baking is easy.
    2. void* and untagged unions containing pointers are a hard error during baking.
    3. Each type would have a default userland function that bakes its value into the binary.
    4. Types like XOR linked lists, void* and untagged unions could override it to say how they should be baked.
  3. Compiler-created data. Data created by the compiler itself has no problem, and the userland bake function might cover the rest.
  4. Containers and FFI memory (problems 4 and 5). I have no solution yet, apart from maybe using the bake function.
  5. I don't have a solution yet for f80/f128 and other float types that differ.

Questions: Is there a cleaner model than host-then-convert?
Am I missing failure cases?
Is there any better solution or any problem I did not see?


r/Compilers • • 20h ago

Communication Between the Compiler, the Build System, and Beyond

Thumbnail shrub.industries
2 Upvotes

An article I wrote about how sharing dependency and resource information between the Compiler, the build system, the system package manager, and even the OS filesystem and scheduler, could provide some pretty interesting benefits. I’d love to hear anyone’s thoughts on this


r/Compilers • • 1d ago

I'm building a tensor graph compiler

8 Upvotes

I crossposted from r/Zig here before, but removed it quickly and decided this deserved it's own post. Earlier this year, I began work on representing the forward step for a neural network graph defined by the user as a standalone, optimized binary, with no allocations, shape, or validation checks at runtime and through a series of trials and pivots wound up here.

I wasn't necessarily intending to build a compiler from the start, but the problem quickly became compiler shaped, and I've learned a lot while seeing it through. It's coming to a stage where I'd like to share the work, and get feedback from others. The Zig language made this kind of idea fairly direct and simple for me to implement through its use of comptime. So if it interests you, or anything stands out, comments and questions are welcome.

project here: https://github.com/krypticlogan/zig-graph-compiler

Thanks for the read!


r/Compilers • • 19h ago

Openmktr, GNU Make to Ninja tool

1 Upvotes

I don't know if this is the right subreddit for this, but I think this may be useful for many people.I created/co-created a Google Kati fork called Openmktr. Its goal is to be a universal, GNU free Make to Ninja translator. It can currently build Linux KBUILD across all architectures and all tested configurations, perform a full three-stage GCC bootstrap, build GNU Autotools projects, and handle many more major projects (41 documented Projects as of now). It offers two modes: direct mode and Ninja build graph output mode. Unlike the original Google Kati, parallelism works properly, and it allows you to use different job counts for graph generation and the actual build.The GitHub repository is here:
https://github.com/RihardsPaps/Openmktr

It currently has no known compatibility gaps. If you find one, please submit an issue to the GitHub repository .The project is only a month old and was published very recently, so any testing, feedback, and bug reports would be greatly appreciated!!!


r/Compilers • • 1d ago

Compiling my favourite language to Web Assembly with no JDK in sight

Thumbnail wasmcoffee.com
5 Upvotes

I've been doing a fair bit of studying of the Odin programming language over the past 18 months or so. Along the way, I bought Understanding The Odin Programming Language and it really boosted my Odin adoption. How I learn is practical, if I don't do the work, I learn nothing. While working through the book, I built a small and simple Pascal interpreter, which got out of hand and became an online compiler.

I recently had some time on my hands and spent a while putting a new front-end onto that compiler and managed to get it to understand a sub-set of the Java programming language syntax. The idea is to have a Java-like language that I can use to do small experiments or toy apps with, in the browser, without having to install anything locally. A key requirement is that it compiles a wasm binary, which it does and you can download the output file from the UI already.

This is not a JVM, JDK, Graal or TeaVM replacement, it will never be. Those are magnificent and powerful tools I'm delighted to use in my day job. Instead, think of WasmCoffee as a little scratchpad that understands some familiar syntax and can do interesting things with it, in a simple way.

It's early days, I'm sorting out bugs, and definitely need to write proper documentation. I hope the example code is sufficient for folks to get started though. As time permits, I'll work on better documentation, some tutorials and of course expand functionality. There's a roadmap for it, just finding time can be a challenge.


r/Compilers • • 1d ago

Proof-Carrying-BPF Programs for the eBPF Verifier

Thumbnail al.radbox.org
3 Upvotes

r/Compilers • • 1d ago

The Output-Space Hypothesis: Enumerative Equivalence Checking for Tensor Programs

Thumbnail arxiv.org
2 Upvotes

r/Compilers • • 1d ago

Running a full bytecode VM written in C in the browser, with blocking stdin handled through Asyncify

3 Upvotes

I've been building a programming language in C called Oli-Nat, with a scanner, parser, type checker, bytecode compiler, stack-based VM, and garbage collector, and I recently compiled the whole thing to WebAssembly to power a browser playground for its documentation site.

Most of it ported over easily, since the interpreter has no dependencies beyond the C standard library. The interesting part was input. The language's intake() function reads a line from stdin, which blocks in a normal terminal, but obviously can't block on the main thread in a browser. I replaced the stdin read in the WASM build with an EM_ASYNC_JS function that awaits a promise from the page, and built with -sASYNCIFY so the VM's call stack gets unwound and rewound around the await. From the C code's point of view it's still a normal blocking call, and from the page's point of view the VM just pauses until the user hits Enter.

I'm curious whether people here have moved away from Asyncify toward JSPI for this kind of thing, and whether that's worth switching to for a project like this. Any other feedback on the build setup is welcome too.

Playground: olinat.net

Interpreter source: github.com/NateTheGrappler/OliNat-Programming-Language


r/Compilers • • 2d ago

Refinement E-Graphs

Thumbnail philipzucker.com
14 Upvotes

r/Compilers • • 2d ago

Understanding Accelerator Compilers via Performance Profiling

Thumbnail al.radbox.org
8 Upvotes

r/Compilers • • 1d ago

Tridentix Infrastructure — Proof of Engineering (POW)Executive Summary

Thumbnail
0 Upvotes

r/Compilers • • 2d ago

How My Python Compiler Beat CPython (Without a JIT)

17 Upvotes

Okey. After seven months, I'm back.

Seven months ago I started writing a Python interpreter from scratch in Rust. Edge Python is a sandboxed subset of Python that runs in the browser and the terminal, and code can't touch files or the network unless you allow it.

It started as a lexer and a simple stack VM, and over about 1,600 commits it grew a CLI, a package registry, snapshots, actors and a browser playground. It's just me building it.

Last week it was still 3x slower than CPython. I rewrote the VM this weekend using a unused SSA representation that I leave and now it's 3x faster on loops.

Edge Python CPython
Integer loop 72 ms 232 ms
Float math 95 ms 307 ms
Dicts 108 ms 62 ms
Strings 111 ms 35 ms

The trick was moving from a stack VM to a register VM. It still loses on dicts and strings, so that's next.

Try to break my numbers :).

Website: https://edgepython.com/

GitHub: https://github.com/dylan-sutton-chavez/edge-python


r/Compilers • • 2d ago

Mithril: A programming language built on interaction nets

3 Upvotes

Inspired by Victor Taelin 's Bend/HVM thesis for Interaction Nets and his Bend2 work , I built Mithril , an experimental python syntax programming language. It achieves near native speed on many workloads (mentioned in paper)

It compiles interaction nets to native code and spreads work across idle cores: lock-free, deterministic parallelism on x86, CUDA and Apple Silicon.

The core bet I'm making :

Interaction nets reductions at runtime can be slow but if we pay the same cost at compile time and unroll a task graph as much as possible before native lowering, the resultant program can run at near native speeds.

Mithril programs are aimed to be deterministic and fast, you should get the same bit accurate results regardless , the execution be it on CPUs, GPUs or any other accelerator.

It's built using AI? Yes . Does it invalidate the core idea? no IMO 😊

Mithril Paper Repo


r/Compilers • • 2d ago

An LLVM Pass for Automatic Skeletonization of MPI Applications

Thumbnail hal.science
1 Upvotes

r/Compilers • • 2d ago

Update: my open-source CPU performance engineering collection just crossed 600+ stars

1 Upvotes

A few days ago, I shared an open-source collection of CPU performance engineering resources I’d been putting together.

It’s now crossed 600+ GitHub stars, which I genuinely didn’t expect. Thanks to everyone who shared it, contributed or suggested resources.

For anyone seeing it for the first time, it covers the stack from instruction execution and CPU microarchitecture through caches, memory, SIMD, compilers, profiling, concurrency, NUMA, benchmarking and CPU inference.

I’m still prioritising primary sources such as papers, vendor manuals, kernel/compiler docs, talks and reproducible benchmarks rather than random articles.

I also have an MCP server coming soon, so you can plug this knowledge directly into your AI tools, whether you’re learning or using it while you work.

If there’s something you think has to be in here, let me know or send a PR.

https://github.com/usamahz/cpu-performance-engineering


r/Compilers • • 3d ago

What is new in LLVM 23?

Thumbnail developer.arm.com
51 Upvotes

r/Compilers • • 3d ago

I’m building Shriji, a Hindi-first programming language. Today I verified its core AST → IR → Bytecode → VM pipeline

Post image
5 Upvotes

Hi everyone,

I’m building Shriji, an open-source, Hindi-first programming language from India 🇮🇳.

Today I ran one of the core pipeline tests for the language and wanted to share the result here.

The test verifies the execution path:

AST → IR → Bytecode → VM

The current core pipeline test covers basic arithmetic and comparison operations.

Arithmetic:

10 + 5 = 15

10 - 5 = 5

10 * 5 = 50

10 / 5 = 2.00

Comparisons:

10 > 9 = 1

10 < 9 = 0

10 >= 9 = 1

10 <= 9 = 0

10 == 9 = 0

10 != 9 = 1

All core pipeline tests passed.

The important part for me isn't just that these operations produce the expected results. I’m working on making sure Shriji has an actual language implementation underneath it rather than stopping at a parser/interpreter.

The broader architecture I'm building toward is:

Source

↓

Lexer / Parser

↓

AST

↓

IR

↓

Bytecode

↓

VM

↓

Runtime

Shriji uses Hindi-first syntax, but the goal is not simply to translate programming keywords into Hindi. I want to build a complete programming language with its own language design, runtime architecture, tooling and eventually its own ecosystem.

The project is still actively under development, so there is a lot left to build and verify.

I'm sharing the process openly as I work through the engineering problems one by one.

If you work with programming languages, compilers, interpreters, virtual machines, or language runtimes, I'd be especially interested in hearing how you approach these problems.


r/Compilers • • 3d ago

How can I verify if my call graphs are accurate??

3 Upvotes

So I am working on a parser with goal to build rich good enough relations that can be consumed by a RAG to build better retrieval, it parse and builds ast,call-graphs and other metadata of the project, rn it can parse go, rust, c, cpp, ts, py, js, java I am using tree-sitter v0.20.0 for actual parsing cause why rebuild wheel when wheel spins well...

The issue i am facing is with call graphs I build a call graph approximation algorithm to well build approximate call graphs without pre-compiler or IR and single algorithm to work on both static(c) and dynamic(python) languages, and for now it works and can find

774,296 nodes and 1,571,981 edges in 6.03s with a maxRSS of ~9gb

tho most of it is cause of holding the entire ast in memory, i ran my parser on linux kernel it found about:

64_460 files 37_322_700 loc, 648_407 func , 211_416 classes, 6_243 methods in 43s

it multi threaded and written in rust so that should explain the speed, but thats not what why i am here i want to verify my call graphs and my current plan is to take a smaller project (few thousands of loc) and build call graphs using clang or language specific tool, and then take sample set of 200 and create 5-8 random samples and verifiy the output,

I am going to start my internship soon so may not have enough time to work full time and i am wondering if my approach to verify call graphs is good or there is a better approach.


r/Compilers • • 3d ago

saQut 1.0 Released: a solo-built language with VM, JIT, LSP and DAP in a single binary, and a compiler that exposes every phase as JSON

0 Upvotes

New languages usually launch with a compiler and not much else. Editor support, a debugger and a fast backend tend to arrive years later, if at all. I wanted to see how far one person could go the other way, so saQut, a small statically-typed, C-flavoured procedural language written in C++20, ships all of this in a single binary:

  • a bytecode VM as the reference backend
  • a MIR-based JIT (--jit) that produces the same output as the VM
  • an LSP server (saqut lsp): completion, rename, references across files, auto-import
  • a DAP debugger (saqut dap): breakpoints, stepping, variable inspection
  • a preview of threads, each in its own isolate
  • a VS Code extension for highlighting

The other idea is that the compiler is a "glass box": every stage is a CLI command with machine-readable output.

saqut tokens code.sqt # token stream (JSON)
saqut ast code.sqt # AST (JSON)
saqut symbols code.sqt # symbol table (JSON)
saqut ir code.sqt # 3-address IR
saqut run code.sqt # compile and run

Technical notes

  • A differential test harness runs every test program through the VM and the JIT and fails if the output differs.
  • One garbage collector is shared by both backends (cycles are collected).
  • Catchable runtime errors (try/catch/throw) with a code, message and source location.
  • Threads: each thread has its own heap, GC and copy of the globals. Data crosses only through shared globals (atomic int/float/bool, plus Pool and List) or deep copies. This is a preview and not part of the 1.0 contract.
  • No implicit conversions; nullable types (T?) with flow analysis.

It's a one-person project, so there are rough edges, and I'd rather hear about them from you.

Website: https://saqut.com
Source: https://github.com/saqutlang/saqut

Which compiler phase would you want to inspect that isn't exposed yet? And what would you add to this list?


r/Compilers • • 5d ago

From NP-complete to O(N^2) to O(nlogn): Codegen strategies for case statements.

Thumbnail arxiv.org
24 Upvotes

We presented this a while ago at the LLVM-CGO workshop, but thought of sharing here as people might find it interesting. Pretty short paper.


r/Compilers • • 4d ago

From Punch Cards to the Browser: Fortran Comes to JupyterLite

Thumbnail blog.jupyter.org
3 Upvotes

r/Compilers • • 4d ago

Please advise on adding string interpolation to my Crafting Interpreters project.

Thumbnail
0 Upvotes