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…
The Java type system is broken
41–50 of 168 posts
Re: The Java type system is broken
#42Re: The Java type system is broken
#43Earlier 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.
Re: The Java type system is broken
#44If 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
#45Re: The Java type system is broken
#46Earlier 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.
Re: The Java type system is broken
#47Earlier 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.
Re: The Java type system is broken
#48The 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.
For what it's worth, Brian Goetz doesn't see type-erasure as a such a failure and defends the design choice[0].
Re: The Java type system is broken
#49The 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.
[0]: http://mattwarren.org/2018/03/02/How-generics-were-added-to-...
Re: The Java type system is broken
#50The 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.
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.