Hacker News with Generative AI: Compiler Design

Designing type inference for high quality type errors (polybdenum.com)
Type inference has a reputation for confusing and impossible-to-debug type errors. However, there is no reason why it has to be this way. If you design your language in the right way, you can still have high quality type errors even with powerful global type inference. This does mean avoiding certain features which are often convenient, but I think in the long run, having high quality error messages in your language is the superior tradeoff.
C++26: Constexpr Exceptions (sandordargo.com)
Starting with C++26, it will become possible to throw exceptions during constant evaluation. This capability is enabled through both language and library changes. Given the significance of this feature, it deserves its own dedicated post.
RakuAST Grant Report (niner.name)
The RakuAST project was a rewrite and redesign of the compiler frontend, i.e. the part that parses the original source code, figures out what the different parts are, does checks and optimizations and creates a low level representation which will then be turned into bytecode by the backend.
Usability Improvements in GCC 15 (redhat.com)
I work at Red Hat on GCC, the GNU Compiler Collection. I spent most of the past year working on how GCC emits diagnostics (errors and warnings) in the hope of making it easier to use. Let's take a look at 6 improvements to look forward to in the upcoming GCC 15.
Rust Any part 3: we have upcasts (pocoo.org)
As of Rust 1.86, this is finally fixed. The cast now works:
The way we're thinking about breaking changes (bearblog.dev)
A major problem plaguing modern compilers is that they have no concept of time.
Exo: Exocompilation for productive programming of hardware accelerators (github.com/exo-lang)
Exocompilation for productive programming of hardware accelerators
A Compiler IR for Scrapscript (bernsteinbear.com)
I wrote previously about different slices of life in the various implementations of the Scrapscript programming language. Until two weeks ago, the most interesting implementation was a so-called “baseline compiler” directly from the AST to C. Now we have an intermediate representation—an IR.
"dozer" Small Rust Compiler (codeberg.org)
Previously we were using the U_Array structure to handle flexible arrays, which had a number of issues. Namely, the fact that it encodes no type information and is very easy to misuse. This commit replaces it with a new flexible array type. It is represented by "T*", which aims to make it easier to index and iterate through.
The preview of -fbounds-safety is now accessible to the community (llvm.org)
Obvious things C should do (digitalmars.com)
Standard C undergoes regular improvements, now at C23. But there are baffling things that have not been fixed at all. The Dlang community embedded a C compiler in the D programming language compiler so it could compile C. This C compiler (aka ImportC) was built from scratch. It provided the opportunity to use modern compiler technology to fix those shortcomings. Why doesn’t Standard C fix them?
Peephole optimizations: adding `opt_respond_to` to the Ruby VM, part 4 (jpcamara.com)
In The Ruby Syntax Holy Grail: adding opt_respond_to to the Ruby VM, part 3, I found what I referred to as the “Holy Grail” of Ruby syntax. I’m way overstating it, but it’s a readable, sequential way of viewing how a large portion of the Ruby syntax is compiled.
A Novel Idea About `Functor` in Rust? (wolfgirl.dev)
So. In my last post about this compiler project, I wrote out the following trait definition, explaining that it’s what I was using to do type-safe AST transformations:
Stop making me memorize the borrow checker (erikmcclure.com)
I started learning Rust about 3 or 4 years ago. I am now knee-deep in several very complex Rust projects that keep slamming into the limitations of the Rust compiler. One of the most common and obnoxious problems is hitting a situation the borrow-checker can’t deal with and realizing that I need to completely re-architect how my program works, because lifetimes are “contagious” the same way async is. Naturally, Rust has both!
Implementing an Intermediate Representation for ArkScript (lexp.lt)
ArkScript is a scripting language, running on a VM. To accomplish this, we had (as of September 2024) a compiler generating bytecode for the virtual machine, receiving an AST from the parser (and a few other passes like name resolution, macro evaluation, name and scope resolution…).
C++ proposal: There are exactly 8 bits in a byte (open-std.org)
C has the CHAR_BIT macro which contains the implementation-defined number of bits in a byte, without restrictions on the value of this number. C++ imports this macro as-is. Many other macros and character traits have values derived from CHAR_BIT. While this was historically relevant in computing’s early days, modern hardware has overwhelmingly converged on the assumption that a byte is 8 bits. This document proposes that C++ formally mandates that a byte is 8 bits.
Speeding up the Rust compiler without changing its code (2022) (kobzol.github.io)
…Yes, I know that the title looks like a clickbait. But it’s actually not that far from the truth :)
Finding Simple Rewrite Rules for the JIT with Z3 (pypy.org)
Hydra: Generalizing peephole optimizations with program synthesis [pdf] (cs.utah.edu)
Writing memory safe JIT compilers (medium.com)