6 ms·
Not providing generics was already a mistake > 25 years ago. Coming from C++ with its templates, I was astonished when Java came out without generics in 1995. I
by layer8 4y ago
Not providing generics was already a mistake > 25 years ago. Coming from C++ with its templates, I was astonished when Java came out without generics in 1995. It was dumbfounding, because parametric polymorphism was so obviously an essential feature for static typing (otherwise one has to resort to runtime type-casts all the time, relinquishing compile-time type safety), and Java was positioned as an alternative to C++. It took ten years for generics to finally be added to Java. (And another four years later Go came out, again without generics…) I later read an article or interview that one of the original Java implementers actually pushed for generics, but it was too much work/complexity and they wanted to get the language out.
- golergka 4y agoIt might have been understandable in 1995, because by then C++ already was mind-boggingly complex for a lot of applications, and it might not have been entirely clear which of it's features were the worst in that regard. But I was only starting programming with QBasic in 1995, so this is just a thought, not a fact.
- jeremyjh 4y agoI think there were already much better models to follow than C++, in ML for example.
- Jtsummers 4y agoAda generics are easy to understand and were at least publicly known for ~12 years in 1995 (going by the publication date of the first Ada standard, older if we go to drafts and discussions prior to that standard's release). Generics aren't hard to use, and they aren't novel. That there's any debate nearly 40 years after at least one major procedural language introduced them is mind-boggling to me.
- johnisgood 4y agoPeople really ought to look into Ada more. The language has a pretty neat type system (ranges are neat!), and it even has proper language constructs to do concurrent programming in it (had it for quite a while!). FWIW, search for "generic" here: https://en.wikibooks.org/wiki/Ada_Style_Guide/Concurrency https://en.wikibooks.org/wiki/Ada_Style_Guide/Concurrency
- ntoskrnl 4y agoDon't forget C# 1.0 which also shipped without generics. The people designing these langs were not inexperienced, far from it. Yet the mistake keeps being repeated every decade. I feel like the industry would be a lot further along if we paid more attention to these lessons from the past.
- derefr 4y agoIt seems that these languages without genetics keep getting popular. Perhaps they get popular in part because they don’t support generics at first, and so seem to be simpler?
- Jtsummers 4y agoIt seems to be inevitable. Few languages can remain simple forever because they run into the realities of large scale systems development. If they remain simple, they either force the programs to become more complex or effectively constrain the complexity of the systems that are developed. Even Fortran has added OO and generics.
- tines 4y agoAnders Hejlsberg, who designed C#, had previously designed Delphi, which has some support for generics (and I believe it had them before he left for Microsoft). I think the case may be that they're not making the same mistakes, but that they're just trying to ship software. Maybe though you would reply that generics are part of the minimum viable product of a programming language and it shouldn't ship without them. I can't say I disagree.
- layer8 4y agoWhen C# first came out it was in competition with Java, which at that point didn’t have generics yet either. That was probably a relevant consideration for shipping the first version without generics.
- scoopertrooper 4y ago
- KerrAvon 4y agoYes, considering the impact to the standard library, but generics are very hard to do well. The C++ language committee is still 30 years later dealing with the fallout from the underspecified initial template implementation. Java's implementation seems to get mixed reviews.
- layer8 4y agoYes, it’s not easy, but not designing them in from the beginning only imposes further restrictions on the eventual design. And the lesson has been that generics will have to be designed in at some point for the language to stay relevant. Nowadays we at least have more existing languages — and advances in type theory — to learn from.
- gpderetta 4y agoI would say that C++ templates have been extremely successful. The reason that the committee keeps tinkering with them is that users keep asking for even more features (very very few languages have all comparable features, so it is certainly not a matter of catching up).
- deleted 4y ago[deleted]
- DANK_YACHT 4y agoAnd yet Java and Go are both wildly successful languages. While lack of generic support may be a mistake, it's clearly not a critical one.
- layer8 4y agoThe question is for how long, if they hadn’t added generics at some point. There’s certainly a lot of pressure e.g. for Go to have added generics, and Rust and Swift likely wouldn’t have been as successful as they are if they didn’t include generics. This is anecdotal, but Java 5 adding generics was crucial for me to staying with a Java job. Without generics, working with generic algorithms and facilities was just miserable, and there was great temptation to use code generators based on some sort of templated Java as a workaround.
- DANK_YACHT 4y agoPerhaps it's necessary to add generics to keep users, but my takeaway is this: if you have innovative language features, then you don't need generics to attract a passionate set of early adopters. If you don't have innovative language features, people won't use your language regardless of generics support.
- layer8 4y agoYeah, as I already said I don’t think Rust’s borrowing semantics would have been quite enough for it to be as successful without generics, and Swift as a modern replacement for Objectice-C also wouldn’t have been quite as convincing without generics support (which was a pain point in Objective-C). I can’t exclude the possibility of new innovative language features outweighing the penalty of not having generics (like Go’s concurrency support did for a while) even today, but I believe it’s becoming increasingly unlikely (for statically typed languages, obviously).
- marcosdumay 4y agoRust's value proposition is being a modern language capable of low-level programming. Surely, the low-level part is essential, and the borrowing semantics brings it, but it wouldn't have much value if it hadn't modern features.
- deleted 4y ago[deleted]