3 ms·
Go (without generics) is not Java 1.4. Go's built-in collections are actually generic and Java's generic-less awkwardness was mostly about collections.
by praptak 6y ago
Go (without generics) is not Java 1.4.
Go's built-in collections are actually generic and Java's generic-less awkwardness was mostly about collections.
- anothernewdude 6y agoI know, right? In Java 1.4 you cast to Object, in Go you cast to interface{}. Totally different.
- praptak 6y agoMost of the casting in Java 1.4 was from collections of Object. In Go the collections are typed, so the casting is confined to some very specialized pieces of code.
- simiones 6y agoThe only difference between Go and Java 1.4 in terms of collections is that Go has a generic map type, which Java didn't. Java 1.4 still had generic arrays, just like Go. In fact, it was a little easier to program with generic arrays in Java vs Go (but also less safe) because in Java a subtype[] can be passed to a function which takes a supertype[] (arrays are covariant).
- pjmlp 6y agoYeah, right because we never been there before. class IntList { private List objList; public add(int elem) { objList.add(Integer.of(elem)); } } Rest is left as exercise for the readers that never used Java generics, or C++ templates.