6 ms·
Typesafe generics via a better void* would make me super happy. There are definitely other quality of life improvements that could be added or reworked that wou
by doboyy 7y ago
Typesafe generics via a better void* would make me super happy. There are definitely other quality of life improvements that could be added or reworked that wouldn't affect the simplicity too much.
- sdegutis 7y agoI'd say Rust is the improvements to C that I've always been wanting: better type safety, real generics, first-class closures, and OOP without inheritance, only using structs to structure data, leaving code execution to just functions. It's what I hoped Go would become. (Take with grain of salt, I'm just starting to learn Rust.)
- doboyy 7y agoI really don't like the monomorphization approach to generics (I think that's the concept?), where the function/struct essentially gets duplicated for each type. It seems to mess with linkage, increase binary sizes, and increase compile times. Other than that, Rust does seem to be an improvement and less... stressful to program in.
- tick_tock_tick 7y agoYou can always role dynamics dispatch yourself
- twic 7y agoDynamic dispatch is in the language too. use core::fmt::Display; fn show_monomorphic<T: Display>(first: T, second: T) { println!("{} then {}", first, second); } fn show_polymorphic(first: &dyn Display, second: &dyn Display) { println!("{} then {}", first, second); } pub fn main() { show_monomorphic(17, 23); show_monomorphic("fnord", "slack"); show_polymorphic(&42, &"quirkafleeg"); // mixed types! } There are things you can do with each that you can't do with the other, but they are often both viable choices.
- doboyy 7y agoIf you're doing dynamic dispatch then there is still code that's living for each specialization. Sort of solves linking because symbols don't have to be generated and compile times because you hand write the code. To be fair, I'm only considering basic data structures and algorithms where you can get away with something like foo(void *ptr, size_t size). Maybe generics is too broad a term for that.