www.inference.vc/the-future-o... #software #machinecode #compiler #future
Latest posts tagged with #Compiler on Bluesky
www.inference.vc/the-future-o... #software #machinecode #compiler #future
Two files in my language showing a barebones gameboy CPU and raylib draw loop with the gameboy window running, showing a blank screen
Getting to the point where I can write semi-serious programs in my language. It's a great way to find a bunch of subtle bugs and missing functionality. E.g. here's a ~totally functioning~ gameboy emulator
#programming #compiler #raylib
A program in my language showing function overloads: ``` struct Vec2 { x: u32, y: u32 } struct Vec3 { x: u32, y: u32, z: u32 } fn add(a: Vec2, b: Vec2): Vec2 { return Vec2 { a.x + b.x, a.y + b.y } } fn add(a: Vec3, b: Vec3): Vec3 { return Vec3 { a.x + b.x, a.y + b.y, a.z + b.z } } fn main(): u32 { let v2a = Vec2 { 3, 2 } let v2b = Vec2 { 4, 3 } let v2c = add(v2a, v2b) println(v2c) let v3a = Vec3 { 3, 2, 1 } let v3b = Vec3 { 2, 1, 1 } let v3c: Vec3 = add(v3a, v3b) println(v3c) return 0 } ```
The output of the program: ``` { 7, 5 } { 5, 3, 2 } ```
Had to implement some name mangling when emitting functions to lay the groundwork for interfaces, and I noticed this gave me function overloads for free. Take that, C!
#compiler #programming
#Development #Explainers
The CodePen Compiler · The CodePen 2.0 editor has a whole new brain ilo.im/16bcg0 by CodePen
_____
#CodePen #CodeEditor #Compiler #Builder #Website #WebDev #Frontend #HTML #CSS #JavaScript
Starting to get some credible looking (unoptimized) IR out of the stage3 compiler. Physical registers are dollar-prefixed, virtual registers percent-prefixed. The comments on the basic blocks are human-friendly tags to help see which part of the codegen they came from.
#Projects #Compiler
A snippet of my programming language showing optionals and early returns on optionals: ``` fn maybe(b: bool): ?u32 { if (b) return 10 return none } fn opt_return(b: bool): ?u32 { let x = maybe(b) println(x?) //if x is none, return here, else print the value of x (10) println("x was some!") return x } fn main(): u32 { let x = opt_return(true) if (x) |value| { println(value + 10) } else println("x was none") let y = opt_return(false) if (y) |value| { println(value + 10) } else println("y was none") return 0 } ```
The output of the program: ``` 10 x was some! 20 y was none ```
It's all coming together. Now I have unions I can implement the optional type ?T which is just a tagged union. In addition I could implement rust style try-unwrap of optionals basically for free with all the parts I have!
Here opt_return only prints x if it's some, else it returns early!
#compiler
my weekend warrior project #zigttp now has a web site (🚧):
zigttp.timok.deno.net
🎉🚀
#ziglang #typescript #runtime and #compiler
Now with the fancy struct syntax, implementing tagged unions was relatively easy. Also got rid of all those pesky semicolons messing up the place
#compiler
Using my MXVM Interpreter/Compiler to produce x86_64 Assembly language with AT&T syntax, then using att2intel to convert from AT&T to Intel. #asm #compiler
Xcode Swift: “expression too complex to resolve…”
So, you’re saying the language is non-deterministic and too convulsed even for a compiler… Gotcha!
My bane in using Swift. You have to jump through hoops and invent non-existent curses to resolve the error.
#apple #swift #xcode #compiler #failure
Blew apart my struct and function parsing to allow default values and named arguments. Pretty swanky imo
#compiler
Not sure it's the greatest use of it but the new `with` statement works nicely with raylib 😅
#raylib #compiler
A snippet of my programming language showing the defer statement: ``` fn main() { let f = os::open_file("test.txt"); defer os::close(f); for _ in 0..15 { os::write(f, "Hello once again from osmium!\n"); } } ```
A snippet from my programming language showing the same code but using a `with` statement: ``` fn main() { with let f = os::open_file("test.txt"); { println("closing file!"); os::close(f); } { for _ in 0..15 { os::write(f, "Hello once again from osmium!\n"); } println("done writing!"); } println("end of main!"); } ```
The output of the with statement variant showing the order in which things are run: ``` done writing! closing file! end of main! ```
Added a defer statement to my language, but I didn't like how the resource acquisition and disposal had to be separated. So I added a with statement that just desugars to defer, and I kinda like it!
#compiler
A program in my programming language showing pointer allocation and illegal freeing: ``` fn bad(ptr: &u32) { free ptr; } fn main() { let x = new u32; free x; let i = 10; let p = &i; free p; } ```
The error messages from compiling the program: ``` Error: Cannot free a pointer with lifetime `Param` at src\main\resources\examples\memory.os:2:5 2 | free ptr; | ^^^^^^^^^ Error: Cannot free a pointer with lifetime `Stack` at src\main\resources\examples\memory.os:11:5 11 | free p; | ^^^^^^^ ```
Starting on the memory management for my language. Nothing fancy but just a few more guard rails than C. Every pointer has an "origin": Stack, Param, Heap, or Global. Only Heap can be freed, and Stack can't be returned from functions.
Maybe this will cause problems but we'll see!
#compiler #llvm
This is patch #306
#OpenSource #Wave #Compiler #Patch
blog.wave-lang.dev/patch-306-po...
The amount of almost-identical duplicate Makefile goop to support running the tests against the various different stages of the compiler finally hit a point where I decided committing some hideous acts of GNUMakefile macroing was the lesser evil...
github.com/swetland/spl...
#Projects #Compiler
This is patch #303
#OpenSource #Wave #Compiler #Patch
blog.wave-lang.dev/patch-303-cr...
Put together a little diagram of how things get built, from which sources, using which tools, for the little compiler project. Note that the stage3 stuff is where active development is happening now that I've got stage2 able to rebuild itself with itself...
#Projects #Compiler
A program in my programming language showing FFI: ``` extern fn exit(status: u32); extern struct FILE(); extern fn fopen(filename: &const char, mode: &const char): &FILE; extern fn fputs(s: &const char, file: &FILE): u32; extern fn fclose(file: &FILE); fn main() { let file = fopen("test.txt".data, "w".data); if file == null { println("Could not open file!"); exit(1); } for _ in 0..10 { fputs("Hello from osmium!\n".data, file); } fclose(file); } ```
The output in a new file `test.txt` ``` Hello from osmium! Hello from osmium! Hello from osmium! Hello from osmium! Hello from osmium! Hello from osmium! Hello from osmium! Hello from osmium! Hello from osmium! Hello from osmium! ```
Decided the next logical step from modules was ffi, surprisingly straightforward to implement! Now I can tuck all that nasty ffi code in a libc.os or something
#compiler
This is patch #300
#OpenSource #Wave #Compiler #Patch
blog.wave-lang.dev/patch-300-ev...
A picture of 3 separate files in my programming language that form a dependency chain. main.os imports io.os and math.os, math.os imports io.os. main.os: ``` import "math.os"; import "io.os"; fn main() { io::print_msg("Hello from main.os!"); var v = math::Vec(1.0, 2.0); println(math::dot(v, v)); var x = math::pow(2.0, 3); println(x); math::greet(); } ``` math.os: ``` import "io.os"; struct Vec(x: f32, y: f32) { fn dot(v1: Vec, v2: Vec): f32 { return v1.x * v2.x + v1.y * v2.y; } } fn pow(x: f32, p: u32): f32 { for _ in 1..p x = x * x; return x; } fn greet() { io::print_msg("Hello from math.os!"); } ``` io.os: ``` fn print_msg(msg: string) { println(msg); } ```
The output of the program: ``` Hello from main.os! 5.000000 16.000000 Hello from math.os! ```
I managed to implement a somewhat halfway decent module system. I'm not thrilled that the import needs the relative path but it'll do for now. Plus it handles the same file being imported multiple times across the compilation graph 😌
#compiler #llvm
This is patch #298
#OpenSource #Wave #Compiler #Patch
blog.wave-lang.dev/patch-298-lo...
A program in my programming language showing string slicing: ``` fn main() { var s: string = "Hello from osmium!"; println(s); println(s[6..=10]); var sl = s[8..17]; println(sl); for c in s[0..5] { print(c); print(' '); } } ```
The output of the program: ``` Hello from osmium! from om osmium H e l l o ```
Added strings to my language, since they're just backed by a slice of u8's all the regular slice operations just worked out of the box
Again nothing real languages don't do but it's so satisfying seeing it work!
#compiler #llvm
[ #compiler ] I wrote a study notes blog post on Day 6 of Matt Godbolt's Advent of Compiler Optimisations 2025 series: "Integer Division".
Read more here: gapry.github.io/2026/02/28/A...
A program in my programming language showing array slicing: ``` fn print_slice(sl: []u32) { for i in sl print(i); } fn main() { var a = [*]u32 { 4, 5, 6, 7 }; print_slice(&a); var sl: []u32 = a[2..=3]; print_slice(sl); print(sl); //prints the raw underlying struct { ptr, len } sl[0] = 1; //mutate the original array through the slice, makes sense since []T == &[N]T for x in a print(x); } ```
The output of running the program: ``` 4 5 6 7 6 7 { &[0x61dff2e8], 2 } 4 5 1 7 ```
One huge rewrite later and a brand new backend (LLVM) and I'm extremely happy with my programming language's slices. Nothing fancy that any other real language doesn't do but it's fun seeing my scrappy little compiler go.
#compiler
[ #compiler ] I wrote a study notes blog post on Day 5 of Matt Godbolt's Advent of Compiler Optimisations 2025 series: "ARM’s barrel shifter tricks".
Read more here: gapry.github.io/2026/02/28/A...
[ #compiler ] I wrote a study notes blog post on Day 4 of Matt Godbolt's Advent of Compiler Optimisations 2025 series: "Multiplying with a constant".
Read more here: gapry.github.io/2026/02/27/A...