I'm trying to remember some details about the time when we tried out Zig as an alternative to Rust for the stdlib - as I recall (maybe @Jared Ramirez remembers?) we first tried out Rust, and then it wasn't going well, and then we talked about "wouldn't it be easier if we just did it in C?" and then "if we're going to do it in C, why not Zig?"
I definitely remember one of the challenges we ran into was a toolchain thing, something along the lines of the --emit=llvm-ir
flag not working the way we wanted to, or something like that
might also have been wasm-related?
does anyone remember the specifics of what originally motivated looking at non-Rust options?
(besides just "this uses unsafe
all over the place, so we aren't really getting much from Rust" and the opportunity cost of other languages having things like nicer opt-in runtime checking for memory management mistakes etc.)
I specifically remember that rust just added in lots of stuff we did not want/need
I'm guessing panics specifically?
also yeah LLVM might sort of work but getting the object files from rust is not easy
llvm would also get split into many separate files I think with rust
oh yeah
I would have thought no_std
would get rid of panic infrastructure, but maybe we didn't know about that at the time?
well it does panic = abort, which might not be what you want either?
generally rust generated code is pretty bloaty
yeah I just remember there was a moment where it was like "ugh, this is really painful...what if we did C?" and I remember it being a couple of specific development pain points rather than code gen
but I don't remember what exactly they were :laughing:
I don't recall the specific pain points either unfortunately, but I think the the rust generated llvm-ir needed quite a bit of transforming to get it to work with the output after the roc compiler gen was done (I seem to recall a lot of duplicate def issues, among other things). I also remember the dev process was pretty painful and it being annoying to link the generated bitcode back into the gen
crate
also found this old PR: https://github.com/roc-lang/roc/pull/568
the comment says
After talking, Richard and I decided to go with the completely different approach of using libc/c for builtins bitcode generation
so not very helpful as to what was the reasoning at the time
then we did use c for a bit which had it's own problems so we ultimately switched to zig
I definitely think the big thing was that everything was unsafe rust and it didn't feel very useful to use rust.
Like none of the benefits of rust
oh yeah! I forgot that we literally used C briefly - @Jared Ramirez do you remember what any of the C pain points were by any chance? :smiley:
a guess: cross-compilation?
but I think we always emit llvm bitcode, right? :thinking:
Not for dev backends
but that wasn't a real concern back then, I don't think.
Cause dev backends didn't exist
Maybe pain points was the wrong wording, I think it might've worked okay but Zig was easier to write safely and was new/exciting. Plus I think we just weren't psyched on writing C in general at the time
Last updated: Jul 06 2025 at 12:14 UTC