Live data from Hacker News

The Java type system is broken

wouter.coekaerts.be

41–50 of 168 posts

Re: The Java type system is broken

#41
post #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 an…

[deleted]

Re: The Java type system is broken

#43
post #7

Earlier quoted context omitted.

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?

"Is X really worth it if it isn't perfect and doesn't cover every edge case?" I kinda feel like humanity has repeatedly decided the answer to this question is "yes". "Being valuable" isn't binary. There are relative amounts of value, I think.

Being valuable isn't binary, but you shouldn't stop in the middle if it's possible to do better easily.

Re: The Java type system is broken

#44
The mess that is the current Java type system makes me skeptical when proponents of languages like Go say not to worry, that generics can be added later.

If Java had generics in the beginning, it would look a lot different and the type system would be more powerful and safe.

Re: The Java type system is broken

#46
post #18

Earlier quoted context omitted.

Is it? The whole point of a type system is that it gives you guarantees over your code. Certain bugs should be inexpressible within the language.

Well, think of it this way. A seat belt cannot help you at all if an object flies through your windshield. Nevertheless, driving while wearing a seat belt is, overall, safer than driving without one.

Redefining the outlier. The outlier is a person catapulted out of its car during a accident. This is rarely a good thing, but sometimes a very lucky event. As only the lucky ones get to tell the tale in a bar, the world is full od outliers.

Re: The Java type system is broken

#47
post #18

Earlier quoted context omitted.

Is it? The whole point of a type system is that it gives you guarantees over your code. Certain bugs should be inexpressible within the language.

Well, think of it this way. A seat belt cannot help you at all if an object flies through your windshield. Nevertheless, driving while wearing a seat belt is, overall, safer than driving without one.

This is HN, we don't need seat belt analogies. Very strict type systems forbid this class of errors during compilation, others do a best effort and fail at runtime.

Re: The Java type system is broken

#48

The mess that is the current Java type system makes me skeptical when proponents of languages like Go say not to worry, that generics can be added later. If Java had generics in the beginning, it would look a lot different and the type system would be more powerful and safe.

Interesting. How do you think it would be different? I ask because the go-to is usually genetics erasure. Do you think more could or would have been different?

For what it's worth, Brian Goetz doesn't see type-erasure as a such a failure and defends the design choice[0].

[0]:https://m.youtube.com/watch?v=TkpcuL1t1lY

Re: The Java type system is broken

#49

The mess that is the current Java type system makes me skeptical when proponents of languages like Go say not to worry, that generics can be added later. If Java had generics in the beginning, it would look a lot different and the type system would be more powerful and safe.

I agree that generics should probably be a strong consideration right from the beginning. I disagree that this would mean that it would necessarily be done correctly or that it's impossible to add it later. That was the case with .Net and C#, it wasn't until the 2.0 release that generics were added. [0]

[0]: http://mattwarren.org/2018/03/02/How-generics-were-added-to-...

Re: The Java type system is broken

#50

The mess that is the current Java type system makes me skeptical when proponents of languages like Go say not to worry, that generics can be added later. If Java had generics in the beginning, it would look a lot different and the type system would be more powerful and safe.

Unlike Java, Go doesn't have to worry about bytecode backwards compatibility. That was the main issue that had them reaching for type erasure.

Take a look at C# which added it without many issues (because they were willing to break back compat of their bytecode). Go fits this model a whole lot better.

Post reply on HN