Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think even in the year of our lord 2016 there's room for a language with safe defaults but seamless interoperability with existing unsafe code. It's certainly an improvement on the status quo and provides an alternative to rewriting the world in Rust or a GC language.


Except Zig defaults could be found on the year of our Lord in 1976, 1978, 1983 and 1986.

Exercise from other posts of mine which languages those might be.


I've been programming in rust for three years, until I picked up zig recently. I was also worried about memory safety when I started using it, but I've been pleasantly surprised how many safety features it has (it's certainly been easier to debug than the C code I've had to work with). Slices are often mentioned for safety, which they are great, but even better has been all of the casting functions. In Debug and ReleaseSafe mode, @intCast will panic if you try to narrow on integer that's too big. @alignCast checks that the alignment is correct. @bitCast ensures that both types have the same bit width. Non-packed unions will panic if you access the wrong field. Integer under and overflow has revealed some of my bad code like four times now. defer/errdefer is much easier to reason about that "goto cleanup" (it also lets me write custom cleanup code, instead of being beholden to the author's drop implementation).

So no, it's not as safe as rust in terms of memory, but it's quite close, and in the process lets you do some really cool stuff.


You could have achieved the same with Modula-2, which is the mapping to 1978 from those dates.


That's fair. I was born twenty years after Modula-2 was released, so I definitely have gaps in my language knowledge :D



Thanks!


Sure, but Zig is bringing those to users and making headlines on HN. I think that’s generally a good thing. Bringing the best of prior languages together in a new package


Except in 2025 we know better regarding safer systems programming languages, use after free is no longer something that we should tolerate.


It's way to early to declare Rust and borrow checking as a panacea for systems level languages. Zig has a solid story for memory safety but makes a different set of trade offs than Rust. IMHO there is room for a few different approaches to systems programming.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: