All of that of course, plus the sheer number of times you need to repeat a given type.
- every time you declare AND define a variable - every time you make a defensive copy of some collection - every time you create a new collection to accept the transformed output of another collection - every time you create a property on a POJO - etc. And having an IDE generate some of it really doesn't help, this stuff still has to be read. On 30 July 2012 13:55, Ricky Clarkson <[email protected]> wrote: > Java type-system issues: > > 1. Arrays.asList("foo", "bar") gets the type List<String> when it's the > only thing in the expression, but as soon as you pass it to something else > the type parameter gets inferred to be Object. > > 2. No way of saying that an Iterator<String> is an Iterator<Object> even > though logically it could be (no covariance or contravariance) > > 3. Arrays are covariant so the compiler lets you add an invalid item to an > array. > > 4. List<int> doesn't work. Nothing to do with erasure, as Scala manages > it. > > 5. null inhabits every reference type (like in lots of other mainstream > languages). > > 6. foreach is not open for extension, i.e., it only works with Iterables > and arrays. > > 7. try-with-resources is not open for extension, e.g., it can't be made to > work with locks without wrapper objects. > > 8. Varargs use arrays. Given the incompatibility between generics and > arrays (caused by arrays' covariance) this just seems a mistake. Again, > should be open for extension. > > 9. No higher kinds. I can't write Monad in Java because there's no way of > saying "this type parameter has a type parameter". This occasionally > results in either code with warnings or duplication. > > 10. Definite assignment could use a tweak: > > final int x; > try { > x = foo(); > } catch (FooException e) { > x = 5; > } > > That doesn't compile because x might have been assigned to twice. I > suppose that's not really the type system but I've typed out that code on > my phone now so it's staying! > > 11. A culture issue rather than strictly a type system issue but the whole > Java community seems to have a collective brainfart and start waffling > about complexity budgets when they see Enum<E extends Enum<E>>. Perhaps > the type system issue is that Java has no self types so we end up doing > that in generics. > On Jul 30, 2012 8:17 AM, "Jess Holle" <[email protected]> wrote: > >> There are issues. >> >> That said, most developers move on and get a lot done without being >> overly bothered. >> >> A few just seem to get stuck on every wart -- making mountains out of >> mole hills (or warts). >> >> On 7/30/2012 6:11 AM, [email protected] wrote: >> >> > I definitely see a lot of frustration from people over Java's type >> system. Can't say I blame 'em, to be honest. >> >> I'd like to see some numbers here :-) because I don't see any particular >> frustration at all. I'm not saying it's hassle-free, I'm saying is quite >> manageable and there's not frustration. >> >> -- You received this message because you are subscribed to the Google Groups "Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
