Live data from Hacker News

Zig: Build System Reworked

ziglang.org

211–220 of 263 posts

Re: Zig: Build System Reworked

#213

Earlier quoted context omitted.

And if you really need more performance (or, more often, fast startup times), Go gives you 90% of the speed with 30% of the effort. Rust if you really want to squeeze everything that can possibly be squeezed of that CPU.

Zig gives you more control than Rust, which should theoretically lead to a higher performance ceiling. There's not much magic in Zig. Keep hitting goto-definition and you can eventually see the OS switch statements and syscalls.

Neither Rust nor Zig give you any more control than the other. If you want raw pointers or inline assembly, Rust supports that.

Re: Zig: Build System Reworked

#214

Earlier quoted context omitted.

Wow that’s gnarly it’s using dynamic dispatch. I mean I get it, but I thought zig was some sort of performance demon.

I believe their plan is using "restricted function pointers", where you can specify that a pointer will only ever be to a function defined in the codebase. I'm pretty sure they also have plans for devirtualization, but I haven't followed super closely.

"you can specify that a pointer"

i dont think you need to specify that. the compiler can figure it out and do an optimization pass at the end.

Re: Zig: Build System Reworked

#216
post #7

Earlier quoted context omitted.

> Zig's compilation times are already terrific In my experience, this (for now) is mostly aspirational. It's obviously a major goal, and there are clear milestones outlined on how to achieve it, but in practice the initial compile of an empty project or the excruciating pause when you `direnv allow` and ZLS needs to be (re)built are not what I'd describe as "terrific".

Maybe you're right, but how many other system programming languages toolchains give you sub 50ms re compilations across millions of LoC?

I'm not pjmlp, but the cached answer is Turbo Pascal.

Re: Zig: Build System Reworked

#217

Earlier quoted context omitted.

Is it really that good? My go-to "tinker in my garage" language is Python - lightweight syntax that stays out of your face, batteries included, packages for everything that's not included. What's Zig's edge?

That's so funny. At university we didn't use Python, but mostly Java, C++, C a bit of Haskell and some even more esoteric ones. Sure thing I got exposed to Python, but to this day, I don't like it. All that whitespace typing just kills me xD I am not normally someone who cares the slightest about Syntax. I've written Rust, C++, C, C#, JavaScript, TypeScript, Haskell, Kotlin, Scala, PHP, and many, many more in my spar…

Well, I feel you very much about Python! Also was coding in plenty of languages for past 30 years (assembly, pascal, C, D, java, visual basic, typescript, C++, and so on and so for) and every now and then I wonder if that aversion of mine towards indentation based languages (python, nim) comes from lack of enough flexibility of my mind/aversion towards training my brain to use and recognize different coding way or it is simply because it not ergonomic enough once you reach certain skill level.

Re: Zig: Build System Reworked

#218

Would someone tell a rust user why they should and should not try zig?

> and should not try zig? Because it isn't memory safe. I honestly think it's beyond the point of "irresponsible" and well into "negligence" that we're still developing unsafe technologies - people are being harmed by this choice. It's one thing when you have to target specific platforms and maybe Rust wasn't an option or whatever, but the reasons to choose unsafe languages at this point are vanishingly small. Zig is…

> I'd probably advocate that software written in languages like Zig be flagged for FEDRAMP

this is an insane take

Re: Zig: Build System Reworked

#219
post #205

Earlier quoted context omitted.

> and should not try zig? Because it isn't memory safe. I honestly think it's beyond the point of "irresponsible" and well into "negligence" that we're still developing unsafe technologies - people are being harmed by this choice. It's one thing when you have to target specific platforms and maybe Rust wasn't an option or whatever, but the reasons to choose unsafe languages at this point are vanishingly small. Zig is…

I completely agree. Zig has a nicer DX no doubt - no fighting the borrow checker etc. But if you are are writing software for other people they don't care about how nice your developer experience is, they only want the software to work correctly - and how can you guarantee that the software you wrote does what you expect it to do if it's not memory safe?

how does memory safety guarantee that software does what you expect?

Re: Zig: Build System Reworked

#220

Earlier quoted context omitted.

I believe their plan is using "restricted function pointers", where you can specify that a pointer will only ever be to a function defined in the codebase. I'm pretty sure they also have plans for devirtualization, but I haven't followed super closely.

"you can specify that a pointer" i dont think you need to specify that. the compiler can figure it out and do an optimization pass at the end.

Oh, is it not a specific keyword? I thought they were thinking of it being a keyword so you could be sure that it was restricted, in case a variable or function was exported that took in a foreign pointer.
Post reply on HN