News for hackers. Stuff that matters.
Re:The Java type system is broken by emodendroket on Thursday July 19, 2018 @10:10AM (#17566402)
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 by ilikehurdles on Thursday July 19, 2018 @10:59AM (#17566888)
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 by emodendroket on Thursday July 19, 2018 @11:11AM (#17567034)
Whoever you are, analogies can help clarify your thinking. A type system that prevents some errors is not without value just because it cannot catch others. If the uncaught types of errors are rare and the type system that would solve them somehow burdensome it may even be a reasonable compromise to accept these faults.
Re:The Java type system is broken by ilikehurdles on Thursday July 19, 2018 @12:57PM (#17568222)
Of course. At this point I'm not sure what this has to do with the code snippet mentioned upthread or the response to it. Your analogy didn't really convey why you'd think java allowing "String s = gridWrapper.get(0).get(0).get(0);" is a good vs bad thing, it just tells me that types don't protect you from everything, I think. I didn't find that the analogy added anything valuable and instead kind of simplified a problem that didn't need simplifying. The topic isn't whether type systems are valuable, but whether the positive value of java's outweighs the harmful logic it allows the developer to write.

A language like rust can prevent writing code like that, and thus prevent that sort of error, while a language like javascript is even more lax. Both have their tradeoffs wrt productivity and performance.

Re:The Java type system is broken by emodendroket on Thursday July 19, 2018 @01:12PM (#17568409)
I was replying to someone implying that the type system was useless because it was not ironclad.
Re:The Java type system is broken by hnbroseph on Thursday July 19, 2018 @11:24AM (#17567178)
being that this is hn, the expression "class of errors" verges on being a thought terminating cliche.
Re:The Java type system is broken by opnitro on Thursday July 19, 2018 @11:14AM (#17567070)
Sure, and there's a point to all kinds of semi-strong typing. I'm glad Python does time checking at runtime, even it can't protect me from everything. When the type system becomes part of the grammar, it should be stronger than that though.