r/Compilers • u/adityazero • Sep 25 '26
What is the tradeoff between the semantics of div by zero?
In C/C++ integer division by zero is undefined but in Rust it traps. What would you do if you were designing a new systems programming language?
r/Compilers • u/adityazero • Sep 25 '26
In C/C++ integer division by zero is undefined but in Rust it traps. What would you do if you were designing a new systems programming language?
r/Compilers • u/laaasoomaa • Sep 25 '26
Hello r/Compilers community. Over the past few months, I have been developing LSM, a standalone compiler pipeline built entirely from scratch without any external dependencies (without using LLVM, external linkers, or the GNU toolchain). The goal was to build a vertically integrated system capable of compiling directly to native machine code in a fraction of a second, while
ELFBuilder and a RawBinaryBuilder that writes a bootable MBR and floppy image directly.(I will leave the links to the GitHub repo and the preprint paper in the first comment below to avoid spam filters.)
I would love to hear your thoughts, feedback on the pipeline design, or critiques on the custom SSA passes and memory model!
r/Compilers • u/Motor_Alternative944 • Sep 24 '26
As I mentioned before, I’m doing this purely as a hobby. However, a friend told me that junior-level positions in this field either don’t exist or are extremely rare, requiring significant experience, and that entering the compiler domain is difficult regardless of whether you have a degree or not.
Is it true that most compiler-related jobs are concentrated in big tech companies, and that outside of those, the field is quite niche and mature? If one day I wanted to turn this hobby into a career, and I dedicated a lot of time to it, would that be impossible?
Right now, I don’t have such a plan I’m just asking out of curiosity. Still, since I’m seriously interested, I intend to spend a lot of time on this area, mostly as a hobby. Of course, contributing to open-source projects, such as rustc, is one of my primary goals along the way.
Thanks <3 <3
r/Compilers • u/General_Purple3060 • Sep 24 '26
I'm working on a C-like language with heterogeneous compute support, and I've been thinking about how compiler intrinsics should be described.
The usual approach seems to be keeping intrinsic definitions in a separate compiler-specific format. GCC uses files like builtins.def and target builtin tables. LLVM uses TableGen extensively for backend descriptions.
These approaches work well, but they introduce another language for describing something that often starts with a familiar concept: a function signature plus some extra properties.
So I started wondering:
Could the intrinsic description itself be written as a C declaration, with compiler metadata attached as attributes?
For example:
extern int4 __ldcs(const int4 *ptr)
__attribute__((compiler_intrinsic(
kind = target,
target = nvptx,
operation = ld_global_cs
)));The file is not intended to be the public API header. It is for compiler developers, similar in purpose to builtins.def, but using C declarations as the description format.
The compiler would parse this file and build its intrinsic information from the declarations. The same source could also generate a user-facing header by removing the compiler-specific attributes.
I started thinking about this because the intrinsics I need seem to fall into two different categories.
The first category is semantic intrinsics.
For example:
extern void __syncthreads()
__attribute__((compiler_intrinsic(
kind = semantic,
operation = barrier,
scope = block
)));The meaning is "synchronize threads in the current block".
The frontend does not need to know the final hardware instruction. Different backends can lower the same operation differently:
barrier
|
+-- NVPTX: bar.sync
+-- AMDGCN: s_barrierThe second category is target intrinsics.
For example:
extern int4 __ldcs(const int4 *ptr)
__attribute__((compiler_intrinsic(
kind = target,
target = nvptx,
operation = ld_global_cs
)));This is much closer to exposing a specific hardware capability. Another target may not have an equivalent instruction at all.
After parsing, these two kinds would take different paths:
semantic intrinsic
|
v
target-independent IR
|
v
backend lowering
target intrinsic
|
v
target-specific lowering
|
v
instructionMy question is:
Is keeping intrinsic descriptions in separate non-C tables mainly a historical choice, or are there deeper reasons why a declaration-based model does not work well?
I can see some possible challenges already. Overloading is one example. Many CUDA intrinsics have multiple signatures, and a C declaration-based format would need some way to express that.
But the basic idea still feels attractive: the declaration already contains most of the information needed to describe an intrinsic.
Has anyone explored a declaration-based intrinsic description model before?
r/Compilers • u/gitpushjoe • Sep 24 '26
r/Compilers • u/2006Nico • Sep 23 '26
Hi again,
I'm working on my own programming language as a hobby project. So far I've implemented a small type system with primitive types and user-defined structs, but I found even that more challenging than I initially expectedBefore I move on to more advanced features like polymorphism, function overloading, subtyping, generics, and a module system, I'd like to study some real-world language implementations and learn from their design choices. I'm looking for programming language implementations that are "realistic" enough to learn from, but still small enough that one person can reasonably understand the codebase.
I'm especially interested in languages that have:
I'm not looking for huge production compilers like GCC, Clang, Rust, or TypeScript. I want see hobby languages, research languages, educational projects, and smaller self-hosted languages are all welcome. If you could only recommend a handful of codebases to study, which ones would you pick and why? Thanks!
r/Compilers • u/SandPrestigious2317 • Sep 24 '26
r/Compilers • u/PrathameshSavane • Sep 23 '26
I'm planning to build a compiler project as a long-term academic and portfolio project, and I'd like feedback from people with experience in compiler development.
The overall idea is to build a modular compiler platform that can support multiple programming languages through separate frontends while sharing a common compilation pipeline.
My initial target is:
The goal isn't to recreate GCC, Clang, or CPython. Instead, I want to explore how a compiler can be designed so that additional languages can be added later without rebuilding the entire system from scratch.
The planned project would include things such as:
I'm still at the architecture/design stage, so I'm particularly interested in feedback from people who have actually worked with compilers, LLVM, language implementation, or related systems.
A few things I'd especially like opinions on:
I'm deliberately keeping the initial scope broad and would expand the language support incrementally rather than trying to implement complete C++ or Python immediately.
I'd appreciate feedback particularly from people with compiler/language implementation experience rather than general programming advice.
r/Compilers • u/NXDLang • Sep 23 '26
Last night I finished wiring source locations through the NXD compiler pipeline so semantic diagnostics can point to the exact symbol instead of defaulting to line 1, column 1.
The flow is roughly:
AST -> IR -> JSON -> Rust semantic analyzer -> LSP -> VS Code
I'm curious how other language projects handle location tracking through lowering and semantic analysis. Do you carry spans everywhere, attach them only to selected nodes, or reconstruct locations later?
r/Compilers • u/Pale_Motor3692 • Sep 24 '26
r/Compilers • u/NomadAvian • Sep 21 '26
Hello,
I have been trying to understand the inner-workings of Chromium's V8 engine for a research project. So far, I have gone over the parser with the help of ECMAScript. Currently, I am working through the AST and scoping part. It is a slow process and the codebase is massive, but resources are also sparse. I have only found various blogs and articles online and though they are great, none of them can contain the extreme volume of information and intricacies of the source.
I still think the most effective method is reading the source code, but the scale is quite overwhelming.
I have considered tracing execution using gdb, but due to my limited experience with it, I haven't able to take that step yet. I am not sure how I would even make use of gdb here.
Has anyone studied this codebase, or even a similarly large one for compilers, in the past? Any tips on how to systematically deconstruct the implementation?
r/Compilers • u/Big-Pair-9160 • Sep 21 '26
Hi guys, two weeks ago I've released Oonta version 0.3.2 which now finally have a GC runtime! Before this, the runtime is only a simple bump allocator 😄
GitHub repo: https://github.com/fuad1502/oonta 🐫
I utilized LLVM Statepoints passes / intrinsics, created the StackMap parser (https://github.com/fuad1502/llvm-stackmap-parser), and wrote the generational garbage collector from scratch (see `runtime/src`).
I'm sharing here primarily to help others here who might also be working on a GC using LLVM Statepoint. IMHO, resources on this is very minimal and outdated 😅 You can use my repo as a reference implementation, since (IMHO) my implementation is quite straight forward and should be relatively easy to understand 🙏
My StackMap parser crate can also be used as a standalone tool / dependency so that you can focus more on the GC implementation itself.
One last thing, one reference that helped me a lot in understanding the nuances of Garbage Collector design is a paper by Paul R. Wilson, titled “Uniprocessor Garbage Collection Techniques” (1994).
I am definitely not an expert, I also didn't study CS formally, but if you have any questions, please feel free to ask! I am also open to any comments and critiques about my work 😊
r/Compilers • u/Temporary-Ad8991 • Sep 21 '26
I wanted to share a rather radical idea I implemented in the compiler for my new programming language (Maxon).
After struggling with the performance of the register allocator in v1 of the self hosted compiler (74% of compile wall time) and of course most of that time is handling spilling, which is NP complete. You either have a fast naive spiller which kills performance, or an exponential algorithm to try and find an optimal solution (which will probably never be actually optimal).
So I decided to punt instead. If the live values exceeds the available pool of registers you get a compile error. The user then must then rewrite the code to reduce the number of live values. This is effectively what the register allocator usually does (spilling live values) but the reasoning is that the user can do a better job deciding what should be spilled than the register allocator can. Plus the compiler doesn't have to do this expensive and slow job on every compile. And you get a simpler register allocator.
It seems to be working well so far. Source is on github if you are interested.
r/Compilers • u/Ephemara • Sep 22 '26
I built Markscript, a prose-native JIT-compiled bytecode VM where your README or .md files are the executable code. Headings define domains/routines, blockquotes dispatch intents, and tables compile into data matrices. In short, your documentation can now live in the same files as code.
The README.md for the language is executeable. Because its Markdown at the core, there are no syntax errors. It also embeds a full mini-language inside \``markscript` fenced blocks for logic, string manipulation, and math.
Example Below
| NodeID | Host | Port |
|---|---|---|
| 0 | 127.0.0.1 | 8080 |
| 1 | 127.0.0.2 | 8081 |
print "Initializing nodes from table matrix..."
let node_count = 2
let i = 0
while i < node_count:
print("Spawning worker on port " + str(8080 + i))
i = i + 1r/Compilers • u/General_Purple3060 • Sep 21 '26
In implementing the heterogeneous compilation backend of AET, I ran into a specific architectural problem:
The main IR transformations in a compiler proceed through the stages, but later stages may still need to access information produced or owned by earlier stages.
For example, the compilation path in AET roughly looks like:
AET AST → GIMPLE → MTCS RTL → PTXThe AST handles AET's semantic processing, while MTCS is an independent heterogeneous backend. The two parts should not directly depend on each other, but they still need to communicate.
So I used a Mediator pattern in AET to centralize the communication between them:
AST ↔ AetMediator ↔ MTCSThe core interface looks roughly like this:
struct _AetMediatorUser {
AetMediator *mediator;
void (*astEnd)(AetMediatorUser *self, nboolean haveMtcs);
...
};For example, the MTCS parser cannot directly call lookup_name(), but it needs access to some declarations generated by the AST. It requests them through the Mediator:
tree aet_mediator_get_parent_device_array_decl(
AetMediator *self, char *sysName, AetMediatorUser *send);The Mediator also handles other cross-stage information, such as device declarations, link functions, compute versions, assembly variable names, and object files.
For this kind of situation, where compilation proceeds forward but later stages still need information from earlier stages, AET uses a Mediator to handle the communication.
I'd be interested in hearing how others would normally organize this in a compiler. Is a Mediator approach reasonable here, or are there mechanisms that fit this kind of cross-stage dependency better?
r/Compilers • u/kindredseer • Sep 21 '26
v0.100.0 — the Nexus: a multi-client IDE, an agent-addressable IR, and measured C++11 conformance at 75.1%
With version 0.100.0 of the madc compiler, based on the gcc torture test suites we currently score:
These percentages are measured independently against the applicable tests in each GCC suite, so the later-standard numbers are not cumulative and aren't expected to be monotonic.
GCC, Clang and MSVC already rule the conventional AOT C/C++ world. MadC is aimed at a somewhat different problem.
MadC is primarily a JIT C/C++ compiler. You can run C and C++ programs directly as shebang scripts, with commonly used system headers precompiled into the compiler so a separate development-header installation isn't normally required. External headers remain available when needed.
MadC can also be embedded into another application, allowing C/C++ itself to be used as an embedded JIT scripting language.
MadC also includes an IDE built around the compiler. The same binary can operate headlessly or provide CLI, ed/ex-style line editing, TUI and GUI interfaces on Linux, macOS and Windows.
The new Nexus architecture allows multiple clients — including humans, editors and agents — to connect to the same live compiler/IDE state. It includes client/server operation, MCP and LSP servers, and a VS Code client.
The idea is that the compiler's representation of the program becomes a shared service rather than something that exists only for the duration of a compile command.
Much of this work grew out of developing MadC's multi-mode UI module and experimenting with what an IDE looks like when the compiler, parser, IR, debugger and external clients all share the same underlying state.
In addition to standard C and C++, MadC supports the MadC dialect, which adds conveniences intended to make C/C++ more practical for scripting and interactive use, including:
main() wrappingdefer, :=, go, yield, await, and untyped variablesfile://, pipe://, tcp://, udp://, uds://, exec://The goal isn't to replace standard C or C++. Standard code remains standard code. The dialect is an optional layer for cases where some of C/C++'s traditional ceremony isn't particularly useful.
r/Compilers • u/ApprehensivePipe1584 • Sep 21 '26
I've been making a programming language, C^4 for almost a year. It's got generics, concepts, OOP, inheritance and polymorphism, error handling, and is able to build projects. It has some docs and a README, and a book is in the works. Wondering if anybody could check it out?
r/Compilers • u/pwdhack01 • Sep 20 '26
r/Compilers • u/Strict-Diamond-2410 • Sep 20 '26
I’m an AI Engineer with a Python/GenAI background and recently started going deeper into ML compilation and systems. I’m currently working through the MLC course and finding TensorIR/TVM quite interesting.
I want to eventually become stronger in the lower-level side of ML C++, GPU programming/CUDA, kernel optimization, inference systems, and compilers.
For people working in this area: what resources, courses, books, or projects would you recommend for building the right foundations and eventually becoming job-ready?
Especially interested in resources that are practical rather than purely theoretical.
r/Compilers • u/ryusei3135 • Sep 19 '26
I made my own programming language and I would like to get some feedback.
One of the main features of this language is a contract system.
For example, it can be used to safely handle functions like "malloc" and "free".
If a value has a contract, you have to finish the contract before leaving the scope.
The compiler checks whether the required function is called.
For example:
a: int * must=free = malloc(10)
[a] = 123
free(a)
In this example, "a" has a contract with "free".
If I forget to call "free(a)", the compiler gives an error.
It is also possible to define contracts for functions and structs.
My goal is to make low-level programming safer while still keeping the language simple and close to the hardware.
I am still developing the language, so I would like to hear opinions from people who are interested in programming languages.
What do you think about this idea?
Are there any similar features in other languages that I should look at?
And what problems do you think this kind of contract system could have?
Any feedback is welcome.
r/Compilers • • Sep 20 '26
Hey everyone! We’re building Hyper, a modern programming language with high performance, specially created for artificial intelligence (AI) and machine learning fields.
Full compatibility with Python: Hyper's syntax is very similar to Python. Existing codes and libraries written in Python can be easily used in the Hyper environment.
Maximum speed and performance: It provides the ability to manage memory at the C and C++ level and make maximum use of hardware (GPU, CPU).
Specially built for Artificial Intelligence: It is aimed at solving computational difficulties encountered in training neural networks and processing large amounts of data.
Security and modern architecture: Inspired by Rust, it includes memory safety and parallel computing (multithreading) features.
Hyper is an important tool for programmers involved in artificial intelligence and data analysis, providing the speed of the C language without losing the convenience of Python.
If you want to jump right in and start contributing, there are plenty of "good first issues" available in the repository to help you get acclimated. Let’s take Hyper to the next level together!
Check out the repository and documentation here: https://github.com/hyperlangg/hyper