3 ms·
Exception handling and garbage collection are two features that feel superfluous, if not outright noxious, to a number of programmers; in particular those doing
by Bayart 5y ago
Exception handling and garbage collection are two features that feel superfluous, if not outright noxious, to a number of programmers; in particular those doing systems, embedded, real time programming. That is the crowd that still uses C. There's a cost associated with the execution environment taking control over from the program itself, and by proxy the programmer. It's not something you want when you design your code with the assumption that is it a more or less accurate representation of its execution flow.
Long story short : those who want that sort of programming language know why.
- oconnor663 5y agoAgreed about GC and exceptions, but I wanted to focus on other approaches. Rust and Go are good examples of doing error handling through regular return values. Similarly Rust and C++ do cleanup with destructors, and Go does at least some of it with deferred function calls. There are ways to do these things that are suitable for low-level programming. But doing nothing no longer seems viable to me. To the extent that Zig's features in these areas (and also generics) make it "not a real C replacement", that's when I question whether a real C replacement is actually what anybody wants.
- loeg 5y ago> Go does at least some of it with deferred function calls. For what it's worth, Zig has a very similar deferred function call mechanism for deferred cleanup, and something like Rust's Result type. See https://ziglang.org/documentation/master/#defer https://ziglang.org/documentation/master/#defer and https://ziglang.org/documentation/master/#Error-Union-Type https://ziglang.org/documentation/master/#Error-Union-Type .