5 ms·
SafeC and CheckedC do nothing for temporal safety. Zig is in the same boat. There's not really a simpler alternative to Rust with the same featureset, even its
by zozbot234 4y ago
SafeC and CheckedC do nothing for temporal safety. Zig is in the same boat. There's not really a simpler alternative to Rust with the same featureset, even its direct predecessor Cyclone was in fact quite a bit harder to use. Rust itself is also improving very quickly and becoming easier to use over time.
- elcritch 4y agoUnfortunately, Rust's core design philosophy is fundamentally opposed to much of the design philosophy that made C and C++ so popular and flexible. It's almost the exact opposite extreme on the pendulum, where C allowed anything while Rust limits to only what the language designers conceive as proper and not just safe. Zig can gain memory management systems like Nim's ARC which works well for system design and adds temporal safety. On the other hand Rust's trait system likely will never become an "open ended" type system like say Julia's. Heck, even overloaded function types don't seem likely in Rust.
- estebank 4y agoWhat task can you do in C that you can't in Rust (or Zig, for that matter)?
- elcritch 4y agoNo, I'd count Zig as having more of an "open ended" type system / philosophy. Though, it looks like Zig doesn't do function overloading either [1]. That's a disappointment. So you end up with `array_count`, `map_count`, etc instead of just `count`. In my way of thinking that's more work reduces readability. It's one of the paint points of C vs C++ to need `array_list_count` and `hash_map_add` instead of just saying `vec.insert(...)`. The biggest ones for me in Rust is that it disallows extending traits for types you don't own, and the lack of function overloading. Neither of those are required for the borrow checker or safety, but it's a philosophical design decision. 1: https://github.com/ziglang/zig/issues/1251 https://github.com/ziglang/zig/issues/1251
- kristoff_it 4y ago> Though, it looks like Zig doesn't do function overloading either [1]. That's a disappointment. So you end up with `array_count`, `map_count`, etc instead of just `count`. In my way of thinking that's more work reduces readability. It's one of the paint points of C vs C++ to need `array_list_count` and `hash_map_add` instead of just saying `vec.insert(...)`. Zig doesn't have function overloading but it does have namespaced functions, so you can define your types and your "methods" on them. https://ziglang.org/documentation/master/#struct https://ziglang.org/documentation/master/#struct
- AndyKelley 4y agoOne of the main drawbacks of function overloading is that it can make code harder to read and understand. When the same function name is used for multiple different purposes, it is confusing for developers who are reading the code. This makes it more difficult to maintain and modify the code in the future, as developers spend extra time trying to understand the various function definitions and how they are being used. Even finding what file the function is in can be a non-trivial task. Another issue with function overloading is that it can make code more difficult to debug. If a bug is found in one of the overloaded functions, it can be difficult to determine which function is causing the issue. This can make it more time-consuming to fix the bug and can lead to frustration for the developer. I remember debugging an issue at OkCupid and we lost many hours due to debug information being collapsed for overloads, making it look like the wrong function was being called in the debugger. Finally, function overloading can lead to code that is more prone to errors. When the same function name is used for multiple different purposes, it can be easy to accidentally call the wrong function with the wrong arguments, which can lead to unintended consequences or runtime errors. In conclusion, good riddance. This is what makes Zig a great language, that it doesn't have garbage like function overloading.
- elcritch 4y ago> it is confusing for developers who are reading the code. … as developers spend extra time trying to understand the various function definitions and how they are being used. This is a similar argument to Hungarian encoding, IMHO. A decent LSP makes it trivial to see which function is being called. The other issue you mention is a problem with the debugger/compiler, not function overloading. > Even finding what file the function is in can be a non-trivial task. Not really, control-click and you’re at the function def. > it can be difficult to determine which function is causing the issue. This can make it more time-consuming to fix the bug and can lead to frustration for the developer. Not any harder than “method” overloads, which it sounds like Zig does have. Personally I find the opposite. Having 20 names for functions that all equate to `len` requires more mental overhead.
- KerrAvon 4y agoTrue dat. But I want to note: - Swift has plans to incorporate temporal safety in upcoming releases. - Zig isn’t fully baked yet. Rust will be king of that space for a while, though.
- asveikau 4y agoRust seems to have a lot of C++ influence to me, specifically later C++ where RAII and smart pointers became the norm. This makes sense that it came out of Mozilla, who have always had large C++ code bases.
- anfilt 4y agoThis is honestly my biggest problem with Rust. C is a small language where the std libraries and language are defined in hundreds of pages. C++ last I checked in the latest standard was getting to almost 2000 pages. Rust does not have a defined standard yet, but I suspect it also would be quite large.