Quick question, which maybe someone here can answer: I noticed that GitHub supports syntax highlighting in the Zig repo. How does that work for a new language such as Zig? Can you somehow upload a file which tells GitHub how you'd like programs written in your language to be displayed?
I believe this is the syntax highlighter’s repo: https://github.com/github/linguist/blob/master/CONTRIBUTING....
Zig self hosted compiler is now capable of building itself
151–160 of 285 posts
Re: Zig self hosted compiler is now capable of building itself
#152Earlier quoted context omitted.
I disagree. It is substantially and unequivocally better to hold onto memory until the end of scope than to leak memory by default. How can anyone argue that leaking memory is a better default? That’s a ticking time bomb. Maybe someone is so optimistic as to believe they’ll catch every leak before shipping new code? You can easily add a manual “drop” call in Rust at any point if you want to force an allocation to be…
Of course you can call drop() manually, but almost nobody does or even think about it because that's not the way you program in a language with RAII. Don't get me wrong. I do think that rust and c++ RAII is much more convenient and safe than the C or Zig way. (I'd even prefer if you could annotate given struct in rust so the compiler could drop them as soon as it's no longer used, but that s not that simple)
It would probably be a breaking change to automatically call an explicit Drop implementation anywhere other than the end of the current scope, so I think that would have to be left as-is. String doesn't implement Drop, so it could easily be dropped eagerly within the scope as soon as it won't be referenced again. Such a change would be roughly equivalent to any of the compiler optimizations that reorder statements in ways that should be unobservable.
Re: Zig self hosted compiler is now capable of building itself
#153Hello HN! Here is some context to decorate this announcement: The Zig self-hosted compiler codebase consists of 197,549 lines of code. There are several different backends, each at varying levels of completion. Here is how many behavior tests are passing: LLVM: 1101/1138 (97%) WASM: 919/1138 (81%) C: 740/1138 (65%) x86_64: 725/1138 (64%) arm: 490/1138 (43%) aarch64: 411/1138 (36%) As you might guess, the one that thi…
> written in Zig instead of C++, uses significantly less memory, and represents a modest performance improvement That's particularly interesting considering the rust compiler in rust has never been as fast as the original OCaml one
I was there and had to suffer through this more than virtually anyone else :)
Re: Zig self hosted compiler is now capable of building itself
#154Earlier quoted context omitted.
> It used to be the case that a compiler compiled itself to bare metal machine instructions, but now with so many cpu instruction set targets that's no longer the case. Tons of compilers emit machine code.
Sure, I didn't say they didn't. Are you refuting what I said and implying that a compiler is not self-hosted if it doesn't compile to machine code?
You said 'that's no longer the case'. Isn't that the same as saying they don't?
Re: Zig self hosted compiler is now capable of building itself
#155Earlier quoted context omitted.
I wonder how much this statement still holds. I've never used the OCaml bootstrap compiler but performance wise, the rust compiler has improved incredibly since the 1.0 release.
An apple to apple comparison is impossible because rustboot compiled a very different language. But I suspect suitably updated rustboot would be still faster because compilation time is dominated by LLVM.
Re: Zig self hosted compiler is now capable of building itself
#156Earlier quoted context omitted.
The point of C and Zig is that you can solve any kind of problems with them. In particular there is much more to memory reclamation than garbage collectors or Rust's borrow checker. Some of the reclamation schemes offer wait-freedom, or efficiently support linearizable operations.
Any kind of problem? So how do you solve SIMD with C, without language extensions? C is not a special snowflake.
Writing generic SIMD code is more portable. C has libraries, and Zig also has vector primitives available through built-in functions.
Re: Zig self hosted compiler is now capable of building itself
#157Re: Zig self hosted compiler is now capable of building itself
#158Earlier quoted context omitted.
And as we know from C, every developer is quite capable of taking care of use after free possible bugs.
The general purpose allocator in the zig standard library has protections against use after free bugs.
There is a scalable solution for UAF that doesn't involve introducing a lifetime/region system: garbage collection. Of course, that comes with its own set of tradeoffs.
Re: Zig self hosted compiler is now capable of building itself
#159Earlier quoted context omitted.
Because hand written assembly is readable!
I believe GP used assembler to refer to the program which reads your hand-written assembly and produces a binary. That program was presumably given to you so you need to trust it. No, the only way to solve this problem is to start with a computer entirely devoid of code and bit-bang your assembler into the machine with switches, the way the first users of the MITS Altair did it.
But, yeah if you don't have a bunch of grad students at the ready, an assembler hand-written in machine code is the only option if you want to trust the entire stack. Though I'm not sure what that would get you. I don't know of any higher language compilers that are written directly in assembly these days, so you'd never be able to compile your C/C++ compiler.
Re: Zig self hosted compiler is now capable of building itself
#160Earlier quoted context omitted.
Any kind of problem? So how do you solve SIMD with C, without language extensions? C is not a special snowflake.
Are there languages that "solve" SIMD?