Conversation

Go has GC and Rust doesn't. If you were to design an explicitly C-like language with memory safety and without GC, it would look a lot more like Rust than Go. The idea that Rust was designed by a bunch of C++ fans is absurd. Most of us were ML fans more than anything. t.co/SWJhLJptY3
This Tweet is unavailable.
3
238
This Tweet was deleted by the Tweet author. Learn more
The issue is that generics are basically a requirement for memory safety without GC as Rust does it. Otherwise you can't create safe abstractions, which would mean that every time you want a linked list you have to write unsafe code. That would undermine memory safety.
2
15
Replying to and
You need a way for the language to understand that the lifetime of the returned reference is based on the lifetime of the received reference. For non-trivial cases, the language needs a way to express what lifetimes are based on. Lifetimes are part of types so you need generics.
1
1
Show replies
If you don't have a way to do this, there's not much you can do without entirely copying everything over and over to do anything. If the language doesn't have nullable references by default, which is a huge design mistake, my example would also likely return Option<&T> instead.
1
Generics and sum types are expected these days for productivity but with the focus on safety they become essential for usability for various reasons. It's very desirable for generics to specify the requirements for the types to specify the API properly and provide proper errors.
1
1
Show replies