3 ms·
No, I don't want _tacked on_ generics. What languages in your opinion have good, non-tacked-on generics? Are they generally better than other languages? Here
by iainmerrick 5y ago
No, I don't want _tacked on_ generics.
What languages in your opinion have good, non-tacked-on generics? Are they generally better than other languages?
Here are some pretty successful languages that gained generics after maturity: C++, Java, C#, TypeScript (based on JavaScript), Objective-C, even Python.
- spion 5y agoThe libraries are better because they're designed with generics in mind. Most C# libraries in use today were built after generics were added, and there never was a large ecosystem already developed at the time Java has had lots of libraries thrown away due to initial lack of generics and a lot of painful migration e.g. https://docs.oracle.com/javase/tutorial/extra/generics/convert.html https://docs.oracle.com/javase/tutorial/extra/generics/conve... A good parallel would be async-await in JS and nodejs. The entire core library and a huge percentage of the ecosystem ended up being really awkward to use after the introduction of async await. The whole ecosystem is now one big giant mess.
- spion 5y agoThe ecocystem did start moving forward, but it will take a long time for the older pre async-await libraries to fade away and there will always be some strangeness resulting from the fact a lot of the libraries you find use a totally different API convention that you have to call via promisifying tools.
- SideburnsOfDoom 5y ago> What languages in your opinion have good, non-tacked-on generics? It's cliche, but it's clear that generics like Result ( https://doc.rust-lang.org/std/result/ https://doc.rust-lang.org/std/result/ ) and Option ( https://doc.rust-lang.org/std/option/ https://doc.rust-lang.org/std/option/ ) are fundamental to Rust's design from the start. > some pretty successful languages that gained generics after maturity I'm very familiar with C#, of course it is a "pretty successful language", no kidding. I did not say otherwise, I said that there are "compromises" associated with adding generics in V2. And there are: e.g. starting with collection types, interfaces and base types in pairs, such as List<T> and List, IList<T> and IList, IEnumerable<T> and IEnumerable, etc ad nauseam. Then Delegates that precede Func<T> and Action<T>. I suggest that you reread my comment above; the point is not just that adding generics later causes complication (historic record is clear that it does). The point is that generics were _not_ proven in mainstream OO programming when c# 1.0 was released in 2002, but this has changed; now they are. Designs done in the last few years can avoid this complication: Ether your language wants them from the start, or it intends other ways to deal with the same kinds of problems.
- xigoi 5y ago> What languages in your opinion have good, non-tacked-on generics? ML and its derivatives, Haskell, Rust, Nim.
- josefx 5y ago> C++ The parsing rules for templates alone probably make a decent door stopper. They can also trivially kill compile times. The bloat from page long symbol names also isn't something to ignore, just std::map<std::string,std::string>::find() results in a decent chunk once the compiler is done expanding it. > Java That is a can of worms, haven't professionally worked with Java in some time, but from memory: * Compile time only, reflection or serialization heavy code will get raw Object types, yay type safety. * They do not support primitive types, resulting in object boxing and null-ability issues by default as well as third party copy paste libraries that provide collections specialized for primitives. * You cannot create an object or array using a generic type as that is unknown at runtime, as result some methods require a concrete array as argument just so they can create their own array with the correct runtime type. * It is fully backwards compatible, so nothing will tell you if you have a compiled library that uses raw types somewhere in your application dumping Integers into a List that should only contain Strings. * Calling code has to verify object types using runtime casts, you may not want to pay the cost of that. I could probably go on ... > Python Aren't those just hints that the interpreter completely ignores? I have a python 3 toy project that could have benefited from better type checking - the contents of its sqlite database are a mess.
- pjmlp 5y agoAda, ML, Modula-3 and CLU got generics since day one. In fact, so much research and Go generics are mostly similar to CLU.
- pjmlp 5y agoI forgot to mention Eiffel, Sather and BETA as well.