Live data from Hacker News

Zig is now self–hosted by default

github.com

91–100 of 115 posts

Re: Zig is now self–hosted by default

#91
post #71
post #66

Earlier quoted context omitted.

Once upon a time C was bootstrapped as well. A great outcome of bootstrapped compilers is that most contributors can use the language they known instead of two, and better it kills the myth that C is the only game in town for writing compilers.

C is a wretchedly bad language for writing compilers.

Indeed, however since that is what many see, plenty of which place the genesis of high level languages on the birth of UNIX, the myth persists.

Re: Zig is now self–hosted by default

#92
post #66

Earlier quoted context omitted.

Once upon a time C was bootstrapped as well. A great outcome of bootstrapped compilers is that most contributors can use the language they known instead of two, and better it kills the myth that C is the only game in town for writing compilers.

> it kills the myth that C is the only game in town for writing compilers A compiler is a pretty pure, high-level operation. Makes no sense to use a low-level language for it.

Agreed, but that is how things go, bad teachers that propagate the myth of UNIX being the genesis, language runtimes that happen to use C mostly of convenience than anything else, and around goes the myth.

Hence why stuff like MaximeVM, Jikes and now Graal are so relevant.

Re: Zig is now self–hosted by default

#93
post #39

Earlier quoted context omitted.

I'd call tools like ASAN and friends debug tooling. I'm not sure if zig has tooling that doesn't have an analogue in the c++ world, but having them built in to the compiler by default is a notable feature.

Right, defaults matter. The fact sanitizers exist is much less of a game changer than the default behaviour being sanitized. Because C++ defaults are notoriously all wrong, in programming language design you could usually do worse than consider, "Is there an alternative to what C++ does here by default?" and if there is one, choose that alternative as your default because it's more likely to be correct. Sometimes C++…

C++ frameworks pre-standard used to have better defaults, unfortunately there a majority of people voting that would rather have the wrong defaults, and so here we are, and given how ISO works it won't change.

Those that care know where the knobs are to re-enable those proper defaults, given that for some domains, C++ is going to stay around for a while, regardless of the alternatives.

Re: Zig is now self–hosted by default

#94
post #44

I never understood why "self-hosting" is considered a good thing. Sure, the compiler developers can write in their favorite language and I guess it means the language is stable enough to be used in a complex project; however requiring an (older) compiler to build the compiler seems a significant complication for software distributions. You either have to set up an ever increasing chain of compilers, as the complexity…

I believe Andy noted that it's way easier to find contributors for the self hosted compiler. If someone is passionate about the language, they want to write the language, not C++. And specifically for languages like Rust and Zig, the explicit orthodoxy is that the language is a better successor to C++/C. If you're spending your time telling people that they shouldn't write C++/C and should instead write your language…

Better educate yourself on Swift, not only does Apple clearly assert on their documentation that Swift is their replacement for C, C++ and Objective-C, they have started the planning efforts to bootsptrap it.

Ruby and Python are scripting language, as such seldom bootstraped.

Re: Zig is now self–hosted by default

#95

Earlier quoted context omitted.

There's a third option that you missed which is what Zig does. It has a "bootstrap" compiler, written in C, which is kept in sync with the self-hosted compiler. Features are implemented twice, once in the bootstrap compiler, once in the self-hosted compiler. So the build process involves a fixed set of steps - stage1, stage2, stage3 - and the chain never grows more than this. No pre-existing binaries are required.

> No pre-existing binaries are required. Except for of course a c compiler.

Currently, alternatively they could cross-compile.

Re: Zig is now self–hosted by default

#96
post #54
post #44

I never understood why "self-hosting" is considered a good thing. Sure, the compiler developers can write in their favorite language and I guess it means the language is stable enough to be used in a complex project; however requiring an (older) compiler to build the compiler seems a significant complication for software distributions. You either have to set up an ever increasing chain of compilers, as the complexity…

If Zig is built on a C compiler, and (I assume) the C compiler self-hosts, then if Zig starts to self-host, it doesn't _introduce_ the dependency on a chain of previously built binaries, it just makes it a step more severe while removing a dependency. Would you prefer if Zig not only didn't self-host, but didn't have any self-hosting dependencies? For your ideal compiler, would a full build from scratch require makin…

That would be a possibility, another one is to cross-compile.

Re: Zig is now self–hosted by default

#98

To clarify what this means, since things can get confusing with subtle differences in wordings: * stage1 is when zig is built from C++ code[1] (the "bootstrap" compiler) using system C/C++ compiler toolchain. * stage2 is when zig is built from Zig code[2] using stage1. * stage3 is when zig is rebuilt from the same Zig code[2] using stage2. Before today, zig would give you stage1 by default, and you could opt in to st…

> Zig produces smaller, faster binaries than C++

This seems fairly significant to me and makes me wonder how this is possible with all the effort that has gone into optimizing C++

Re: Zig is now self–hosted by default

#99

Earlier quoted context omitted.

There's a third option that you missed which is what Zig does. It has a "bootstrap" compiler, written in C, which is kept in sync with the self-hosted compiler. Features are implemented twice, once in the bootstrap compiler, once in the self-hosted compiler. So the build process involves a fixed set of steps - stage1, stage2, stage3 - and the chain never grows more than this. No pre-existing binaries are required.

> No pre-existing binaries are required. Except for of course a c compiler.

Which is something mescc and friends solve. Zig doesn't need to solve the full bootstrap from nothing chain, just the entry.
Post reply on HN