Java generics are sufficient for container classes, and not much more. Useful, but underwhelming.
Containers and std::algorithm stuff would already be a big win for the kind of software that gets written in C, but C doesn't have proper generics so it's void* all over the place.
Linux for instance makes wide use of generic containers (lists, hashtables, trees). Each time you iterate over the container you need to know what elements it holds and cast appropriately. Simple type erasure (aka parametric polymorphism, idea as old as C) could tidy up the code and make it robust against oopsies.
A further detail is that these are intrusive containers - you put "
struct list_head list;" in your object and the object can be linked into lists by means of pointers in this member object, using completely generic list code which only cares about list_heads. So they also have a "container_of" macro which takes you from a list_head or similar object back to the object which contains it, provided that you know all the types and member names.
Trivial stuff which could be a language feature but isn't, the closest analog being C++ static_cast<> but it only works with that multiple inheritance nonsense, not ordinary aggregates. And it's unsafe, because the language is stupid and has no concept of "struct list_head which is also the member 'list' of struct Foo".
Simple type system extensions like generics and "member element types" could make existing C code cleaner and safer with zero runtime overhead and only minor editing - remove casts, add more sophisticated type annotations. No one appears to be working on such things, save for obscure research languages, mostly functional, so pretty much guaranteed to never gain mainstream acceptance.
For C++ generics
C++ doesn't have generics besides void* it inherited from C and virtual methods, which are syntactic sugar over tables of function pointers that C also has.
C++ has templates, and they do exactly what you'd expect: generate a lot of repetitive code.
Yesterday's news: "With the upcoming Linux 6.8 kernel cycle, the first Rust network driver is set to be introduced." https://www.phoronix.com/news/Linux-6.8-Rust-PHY-Driver
Frustration with C is no reason to fall for Rust hype. Rust was created by C++ developers and as such it inevitably amounts to little more than somebody's favorite "safe subset of C++", because your (stereo)typical C++ developer has never known anything other than C++. This includes C.
Rust has no generics either and what they disingenuously call generics is templates. I am at all unconvinced that this language has any ability to produce efficient and lightweight containers of the sort that Linux uses, without resorting to void* trickery, maybe with "unsafe" prepended to it
![Tongue :P](https://www.eevblog.com/forum/Smileys/default/xtongue.gif.pagespeed.ic.J5mTe0A2NA.png)
There was already an attempt to rewrite Linux in C++.