3 ms·
> null pointer dereference (C)none (Zig)runtime (Rust)runtime Not really rusts pointers are the `&`/`&mut` references which are compiler time proven to be not
by dathinab 6y ago
> null pointer dereference (C)none (Zig)runtime (Rust)runtime
Not really rusts pointers are the `&`/`&mut` references which are compiler time proven to be not just non null but actually differentiable and potentially writable in the given context. Which are MUCH stronger guarantees then just "not null".
> 2. only when using tagged unions
Which in rust are the default types, unions didn't exist for quite a while and require the use of unsafe making them heavily discouraged to be used.
Besides that it's not that rust enums are tagged unions where you at runtime check a tag and then access them, or where you "panic/throw an exception" when you try to access the wrong type, but incoperated into the type system and language given quite a different experience to classical tagged unions.
Lastly type confusions applies to more then just "tagged union style access" but also subtype stile access in which case rust can use trait objects instead of sum types.
Besides that many of the ways listed zig can archive more safety (weather applicable or not) are also applicable to C. And some of the checks Zig do can be "somewhat" archived in C too by combining non standard compiler options and code analysis tools.
Don't get me wrong. Zig is a very interesting language and I would argue the spiritual successor of C in how it's designed.
Still I guess the main ways to add more safety (and similar) to languages like Zig (or C) is to compile them to WebAsm. The module isolation while still being able to call other functions without to much overhead which can be archived with WebAsm might lead to quite interesting trends in the future.