Stream: beginners

Topic: Is there a good resource for learning how the compiler works


view this post on Zulip Christian Queyrouze (Feb 17 2024 at 19:26):

I'm new to building compilers, but I've learned that I love working on the concept and code from an interpreted math engine I'm building in Zig. I'd like to learn how this codebase works so that I can actively use it to learn and actively contribute to it.
I've found the document on Project ideas, but It'd also be cool if someone could point me to a list of the use cases so I have an more end to end idea of the direction of the language. I've listen to a lot of content from @Richard Feldman, so I have a pretty good idea of what its used for and the benefits which is why I'm interested, but they're not super concrete.

view this post on Zulip Richard Feldman (Feb 17 2024 at 19:39):

welcome!

view this post on Zulip Richard Feldman (Feb 17 2024 at 19:40):

I'm not sure exactly what you're looking for in terms of "list of use cases" but maybe this interview might help? https://www.youtube.com/watch?v=ssw0_udPla0&pp=ygUTcmljaGFyZCBmZWxkbWFuIHJvYw%3D%3D

view this post on Zulip Richard Feldman (Feb 17 2024 at 19:41):

in general, the idea is for Roc to be useful in the "long tail of use cases" by giving platform authors a way to write tailored platforms for those use cases

view this post on Zulip Richard Feldman (Feb 17 2024 at 19:43):

some non-goals include:

view this post on Zulip Richard Feldman (Feb 17 2024 at 19:47):

a non-exhaustive list of use cases we're aiming for:

view this post on Zulip Richard Feldman (Feb 17 2024 at 19:48):

browser GUIs might work too, although it wasn't an original motivating use case (because Elm is so good at that already) and we don't have a working proof of concept at this point

view this post on Zulip Christian Queyrouze (Feb 17 2024 at 20:05):

Thank you! and I'll check out the video when I'm not in public.
I think that list gives me a pretty good idea of what the language is for. I want some toy projects I can build a run to understand how the code works and should be working.
I'm a pretty big fan of the idea of hot swapping functions and not deallocating data until the end of a program including other language concepts that you've talked about on you're podcast. I'm a big believer that this language can run at or close to the speed of Zig, C, and other low level languages for the right use cases, and I think it can beat Rust for what it's good at because of the cost of abstracting memory management. I've also been looking for a functional language to replace Elixir in the web world.
Quick question, what's the benefit of self hosting the compiler? I've used a lot of high level languages that do that, and it always seems to be more of detriment than a benefit (obviously take what I say with a grain of salt. I'm not super knowledgeable on the topic).

view this post on Zulip Christian Queyrouze (Feb 17 2024 at 20:07):

I'm also happy you said it's good for games, because I was thinking about how useful it'd be for a game idea I had today.

view this post on Zulip Brendan Hansknecht (Feb 17 2024 at 20:19):

Quick question, what's the benefit of self hosting the compiler?

For a lot project it means the dev team actually gets to program in the language they built and love. So it is a huge boon in that sense. Otherwise, it is mostly done to test the compiler more. In many cases the compiler itself is one of the first large projects in a language.

view this post on Zulip Brendan Hansknecht (Feb 17 2024 at 20:20):

Also, in some cases, it is done cause the compiler is more mature and could really use a rewrite in general.

view this post on Zulip Norbert Hajagos (Feb 18 2024 at 19:26):

Quick question, what's the benefit of self hosting the compiler?

Bonus tip when you have decided you want to self host: You could create the first version of the compiler in a language which is really fast to iterate in for that purpuse, like OCaml (I've heard), and switch to the new version asap.
If you want to write a fast compiler, you do it in a systems language like C. But you would not want to write C for too long if your new language is also a systems language.


Last updated: Jul 06 2025 at 12:14 UTC