News for hackers. Stuff that matters.
Re:Zig self hosted compiler is now capable of building itself by sanxiyn on Saturday April 16, 2022 @11:56AM (#31053319)
Zig uses manual memory management too (even more manual than Rust), so that's a bit strange question.
Re:Zig self hosted compiler is now capable of building itself by zigger69 on Saturday April 16, 2022 @05:59PM (#31056471)
It's really easy in Zig to be honest. Just put `defer thing.deinit()` in the right scope and you're done. You gain explicitness and know exactly what's going on in your Code. Everything is obvious. That's the reason Zig is so incredible simple and easy to read. Zig also has a GPA that will tell you about memory leaks or anything.
Re:Zig self hosted compiler is now capable of building itself by puffoflogic on Saturday April 16, 2022 @07:04PM (#31056888)
And in rust you just put `` in the right scope and you're done. This is perfectly explicit and you know exactly what's going on in your code. Everything is obvious.
Re:Zig self hosted compiler is now capable of building itself by zigger69 on Sunday April 17, 2022 @08:21AM (#31060352)
You can execute arbitrary code on drop operations by implementing `std::ops::Drop` for a type.
Re:Zig self hosted compiler is now capable of building itself by pornel on Monday April 18, 2022 @10:00PM (#31079078)
A `.deinit()` function could also run some arbitrary code that does weird and unexpected things. The point is that reasonable people don't abuse functions like that — if they do abuse, don't use their code. Neither Rust nor Zig is a sandbox that could stop actively stupid/malicious code.
Re:Zig self hosted compiler is now capable of building itself by dralley on Saturday April 16, 2022 @11:15PM (#31058144)
Rust's ownership rules are no less explicit. The object dies when the owner of the data goes out of scope.
Re:Zig self hosted compiler is now capable of building itself by cercatrova on Saturday April 16, 2022 @12:01PM (#31053363)
Interesting, based on their code samples it looked to me like a GC language since (at least from what I saw) I didn't see anything regarding memory management.
Re:Zig self hosted compiler is now capable of building itself by elcritch on Saturday April 16, 2022 @02:33PM (#31054820)
It’s easy, IMHO, to mistake Zig as a GC’ed language or more broadly as a memory safe systems language. It’s neither but it is a nicer C.
Re:Zig self hosted compiler is now capable of building itself by sanxiyn on Saturday April 16, 2022 @12:05PM (#31053397)
I am not sure what code samples you looked at, but https://ziglearn.org/chapter-2/ should give you an idea.