The Maze, My Compiler Trap

The Maze, My Compiler Trap

posted 3 min read

Why Compiler is a very Breath Taking project for devs and single dev

I just got into the parser stage 2 days ago and the design were flowing like a breeze. Since my compiler is focused as a system programming compiler for my custom language I was at the type checking (local type checking) phase.

These is where I created a util.hpp file which I wrote a namespace containing polymorphic code as it a global type system my compiler will use to verify type at compile time.

My compiler makes sure it does everything at compile time as it really benefits as creating a custom language means you definitely tired of the scope of the current language compiler so that why we here!

Type System

The compiler tries to be ambitious like zig and more than it as it support variable width types from 1 to 65535 for both unsigned and signed. I won't lie I learnt the formula for signed and unsigned, but like I said the compiler scope got in my way how do I store 2^65535 - 1 for unsigned value range as we famous graphics dev and codec knows u8 is from 0 to 255. Wait it unrelated.

My Ambitions

I'm a rising video codec engineer but no traditional dct, motion vector in my vision, I did try to invent a proprietary upscaler called GVEST (Geometry Vector Expansion Spatial Transform) it better than bilinear in a few tens of db in edge construction without blurring and same db at noisey image if you want to see the images I will try to upload the graph and sim results which ai did run python code to generate, in another Non Compiler Series of ours. So to cut the story short I knew entropy coding and video codec need not just runtime precision but memory precision and don't get me Gemini ai helped me fix the formula as fitting the above range results from the above formula is not my path and didn't see it coming and I don't want another hours of burnout. I want to add theoretical bit size memory allocation to the value of that variable bits to memory meaning if a u8 which is 1 byte and the value was 5 which doesn't take the whole 8 bit or byte why waste memory. But it non trivial as unpacking them will be a big fit but still going that route.

What still breath taking

Won't lie your ambitious. As you got so much type system, dsa to optimize at compile time. I asked AI that why can't language optimized tree based DSA as I knew little about them, all my life from js to c++ isn't more than struct and arrays ( with vector in c++ case) I did learn to DSA in my days as a JS dev but c++ is different in everything, containers abstraction, stl, iterator, the .data() + index, end or the .begin(),.end() it everywhere in c++ and beginners and experience def still goes to the doc once in every why. And honestly the doc isn't great too.

I went through serious burnout today as I want my language even if c++ like to have ownership and lifetime and memory validation if you've seen my ambition above. It will also be friendly and clear with error message and fixed I already proud of my lexer stage error message on my string and char warning and recovering on unterminated literal. It really a breath taking journey.

Closing it all up

If you like the architecture and insight have seen or haven't, I welcome you in the comments section, and if you wanna subscribe to my Newsletter though still in early stage become my subscriber on substack Substack

I'm happy building the project as I'm not looking where I'm but where it gonna be I'm breaking the llvm oath in solo and you can too if you follow up everything counts for me

Part 3 of 3 in Building a Compiler

More Posts

Local-First: The Browser as the Vault

Pocket Portfolio - Apr 20

Tuesday Coding Tip 06 - Explicit template instantiation

Jakub Neruda - Apr 7

Tuesday Coding Tip 02 - Template with type-specific API

Jakub Neruda - Mar 10

The End of Data Export: Why the Cloud is a Compliance Trap

Pocket Portfolio - Apr 6

Split-Brain: Analyst-Grade Reasoning Without Raw Transactions on the Server

Pocket Portfolio - Apr 8
chevron_left

Related Jobs

View all jobs →

Commenters (This Week)

2 comments
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!