News for hackers. Stuff that matters.
Re:Zig's New Relationship with LLVM by ikskuh on Monday September 28, 2020 @09:45AM (#24616521)
Zig is also designed around safety and security. It's not as obvious as with Rust, but it's still there.

Zig is way easier to verify than rust code (no hidden control flow, no hidden allocations that might fail, ...) which means a security expert can read a single function (without knowing more about the code) and can reason about that function.

This does not work in languages like C++ and Rust where RAII is a common pattern and code will be implicitly be executed when some objects go out of scope.

Yes, sure. Rust does a lot of verification work already, but so do tools like cppcheck and other verification tools and i'm sure those will emerge for Zig as well.

Zig (in contrast to C or Rust) has no warnings. Behaviours that might not be OK are compile errors and cannot be ignored. There are also plans (as in "not implemented yet") to forbid declaring unused variables and such so even this gets a compile error. This makes Zig also easy to reason about (seeing a variable declaration means that it's guaranteed to be used later)

Re:Zig's New Relationship with LLVM by the_duke on Monday September 28, 2020 @01:23PM (#24619032)
> No hidden control flow

It's true that a macro in Rust could introduce an early, invisible return. But this can only happen inside a macro. A reasonable option would be to disallow those in a project where such concerns are critical.

Otherwise Zigs "try" is similar to `?` in Rust, and "defer" comes pretty close to non-obvious control flow for me.

I'm particularly not a big fan of "defer" (and "errdefer"), which I already don't like in Go. Sprinkle multiple of those in a larger function, and following the logic can become quite tedious.

Re:Zig's New Relationship with LLVM by alexnask on Monday September 28, 2020 @01:44PM (#24619290)
fwiw, the defers apply to scopes in Zig (similar to D's scope(exit) and scope(failure)) and thus are always static, not dynamic like Go's.
Re:Zig's New Relationship with LLVM by danhor on Monday September 28, 2020 @10:04AM (#24616698)
> Zig has no warnings.

That sounds very fraught with issues to me. Does that mean existing code will have to be updated in case other behavior turns out to be kinda iffy in practice? Isn't there a strong perverse incentive to just not add anything if that's the case?

What about the deprecation of existing code?

Re:Zig's New Relationship with LLVM by dilap on Monday September 28, 2020 @10:39AM (#24617084)
Go also has no warnings, and it seems to be working fine.

(Though, some people do use linters to get back the warnings. But the language itself doesn't have any.)

The main thing about having warnings isn't being silent in the face of possibly-shady constructs, it's about just making them errors, so you can be sure they don't occur. So e.g. in Go an unused import is an error.

Re:Zig's New Relationship with LLVM by wtetzner on Monday September 28, 2020 @01:14PM (#24618943)
> So e.g. in Go an unused import is an error.

Which is an incredibly annoying thing, because you can't easily just comment out some code and do a quick build to test something. You are forced to cleanup imports/unused variables every time you want to build something.

Re:Zig's New Relationship with LLVM by dilap on Monday September 28, 2020 @01:25PM (#24619067)
Tradeoffs :-)

(Also, if you use something like goimports, it's pretty much automatic.)