Live data from Hacker News

Zig Is Self-Hosted Now, What's Next?

kristoff.it

1–10 of 159 posts

Re: Zig Is Self-Hosted Now, What's Next?

#2
Nice achievement.

Curious about this though:

> building the compiler itself used to require 9.6GB of RAM, while now it takes 2.8GB.

Why is the RAM usage so high? It was only a few years back and we were building C++ compilers on machines with barely 16MB.

Re: Zig Is Self-Hosted Now, What's Next?

#3
Correctness please. Zig is a way too simple language to justify all the really easy to hit bugs.

I'd give everything for a zig compiler that's 10 times as slow but actually compiles my code.

Also testing infrastructure. Zig really needs fuzzing and property testing tooling build-in. Hitting stage 2 with arbitrary autogenerated zig code and IR, would have really helped detect regressions for example.

Re: Zig Is Self-Hosted Now, What's Next?

#4
post #2

Nice achievement. Curious about this though: > building the compiler itself used to require 9.6GB of RAM, while now it takes 2.8GB. Why is the RAM usage so high? It was only a few years back and we were building C++ compilers on machines with barely 16MB.

Yeah that is interesting ... I guess it's because Zig compilation is single-process, parallel, and threaded, not like the C++ compilation model of separate processes?

I never tried, but I highly doubt either gcc or Clang could be built with 16 MB of RAM, even serially, at any point in the last 10 years. Probably not even 20 years, though I could be wrong

Re: Zig Is Self-Hosted Now, What's Next?

#5
post #2

Nice achievement. Curious about this though: > building the compiler itself used to require 9.6GB of RAM, while now it takes 2.8GB. Why is the RAM usage so high? It was only a few years back and we were building C++ compilers on machines with barely 16MB.

I don't know about Zig specifically, but things using LLVM tend to be absurd memory hogs. I remember having to disable parallel compilation for clang to prevent OOM issues.

Re: Zig Is Self-Hosted Now, What's Next?

#6
post #2

Nice achievement. Curious about this though: > building the compiler itself used to require 9.6GB of RAM, while now it takes 2.8GB. Why is the RAM usage so high? It was only a few years back and we were building C++ compilers on machines with barely 16MB.

Hey, back in the day, I used a Pascal compiler on CP/M that worked with 64K.

Re: Zig Is Self-Hosted Now, What's Next?

#7
post #2

Nice achievement. Curious about this though: > building the compiler itself used to require 9.6GB of RAM, while now it takes 2.8GB. Why is the RAM usage so high? It was only a few years back and we were building C++ compilers on machines with barely 16MB.

I wanted to say "probably because of LLVM", but that wouldn't explain why replacing the frontend would make such a difference (assuming that the 2.8GB number includes the LLVM backend).

Re: Zig Is Self-Hosted Now, What's Next?

#8
post #2

Nice achievement. Curious about this though: > building the compiler itself used to require 9.6GB of RAM, while now it takes 2.8GB. Why is the RAM usage so high? It was only a few years back and we were building C++ compilers on machines with barely 16MB.

> It was only a few years back and we were building C++ compilers on machines with barely 16MB.

"A few years" seems like a serious understatement, but beyond that... compilers in the time period you're talking about weren't really doing optimizations, they were just shoveling assembly out the door. Doing very little work takes very few resources, but the resulting binaries were way slower than they could have been. Any compiler that uses LLVM tends to be slow, in my experience, but it does offer excellent optimizations.

Re: Zig Is Self-Hosted Now, What's Next?

#9
post #2

Nice achievement. Curious about this though: > building the compiler itself used to require 9.6GB of RAM, while now it takes 2.8GB. Why is the RAM usage so high? It was only a few years back and we were building C++ compilers on machines with barely 16MB.

Zig puts the whole project into a single giant compilation unit. This has some benefits, but one of the drawbacks as you note is memory usage for larger projects.
Post reply on HN