Hacker News new | ask | show | jobs
by jmull 4 days ago
Not every line of zig is "unsafe".
1 comments

No, but when the compiler isn't enforcing anything, how do you know which ones are safe and which ones are not? If we ignore declarations etc. and only consider statement lines that read or write memory, then any such line of Zig (or C, or C++, or any other unsafe language) can be classified as a potentially unsafe — not just today, but in the future, since safety bugs can be generated upstream by giving out pointers that aren't valid or concurrency-safe.
> If we ignore declarations etc. and only consider statement lines that read or write memory, then any such line of Zig (or C, or C++, or any other unsafe language)

Surely it's obvious that's trivially untrue?

Also, literally no code is safe from potential future upstream changes.

Anyway, I'm not arguing zig has the same safety guarantees as rust. That would be silly. But the weird binary thinking around memory safety is equally silly. People want things to be simple, but you really can't come to good conclusions by trying to pretend things are simpler than they are and through a lack of analysis and thinking.