Live data from Hacker News

The Java type system is broken

wouter.coekaerts.be

1–10 of 168 posts

Re: The Java type system is broken

#4
From the examples: "String s = gridWrapper.get(0).get(0).get(0);" - Java type system is broken!

Java is not perfect, but this looks to me like a broken code indeed ".get(0).get(0).get(0)".

Could we rephrase the message of the article as "If you write really broken code in Java, you might be not guarded by the type system". And this is, well, uhm, well... acceptable?

Re: The Java type system is broken

#7
post #4

From the examples: "String s = gridWrapper.get(0).get(0).get(0);" - Java type system is broken! Java is not perfect, but this looks to me like a broken code indeed ".get(0).get(0).get(0)". Could we rephrase the message of the article as "If you write really broken code in Java, you might be not guarded by the type system". And this is, well, uhm, well... acceptable?

Is a type system really worth that much if it can't help you in a situation where your code is ugly and hard to follow?

Re: The Java type system is broken

#9

My favourite feature of Java's type system is that, because any object type also accepts null, the type system is unsound and you can convert anything to anything else: https://raw.githubusercontent.com/namin/unsound/master/doc/u...

Wouldn't that be a problem in most languages? Even Haskell allows for it through Data.Dynamic

If I can serialize to String, and then deserialize a String to any type of class, I can effectively "cast" anything to anything.

Re: The Java type system is broken

#10
Welcome to the world of enterprise-ready complex applications. I agree that these cases should be covered by the compiler but man, there are mainstream languages that don't implement generics just because they're complex and pretend that they're not helpful.

It would be nice of you to compare Java generics with equivalents instead of just criticizing it. It doesn't help anyone writing "this is broken" not offering any alternatives or suggesting ways to fix the problem.

Post reply on HN