4 ms·
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.
by opnitro 8y ago
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.
- emodendroket 8y agoWell, 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.
- opnitro 8y agoSure, 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.
- picsao 8y agoRedefining 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.
- ilikehurdles 8y agoThis 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.
- emodendroket 8y agoWhoever 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.
- ilikehurdles 8y agoOf 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.
- emodendroket 8y agoI was replying to someone implying that the type system was useless because it was not ironclad.
- hnbroseph 8y agobeing that this is hn, the expression "class of errors" verges on being a thought terminating cliche.
- seanmcdirmid 8y agoI don’t think that is true anymore. There are languages like typescript that don’t provide anything near that guarantee but are still seen as very useful.