Live data from Hacker News

The Java type system is broken

wouter.coekaerts.be

51–60 of 168 posts

Re: The Java type system is broken

#51

Earlier quoted context omitted.

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.

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

#52
post #40
post #34

Earlier quoted context omitted.

So a type-system that does the right thing in 99.999999% of the cases is completely useless according to you?

I think the question is rhetorical.

Not really, a language in which some type errors are impossible (rather than merely very unlikely) makes it drastically easier to prove something useful about programs (e.g. to optimize away runtime checks that would otherwise be needed as a safety net and impossible cases).

Re: The Java type system is broken

#53
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.

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.

Re: The Java type system is broken

#55

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.

Did C# really break backwards compatibility of their bytecode? What I understand is that C# generic and non generic APIs are completely different, and are not inter operable.

Re: The Java type system is broken

#56

> Everything is broken. Everything is fine. This is the correct conclusion. The people getting outraged over this are the same that will hold long and boring monologues about how everybody does REST wrong.

Had a client just last month that were doing SOAP wrong somehow...

Required a SOAP message, that contained no XML after the message tag, but instead the entire message body was to be a JSON, and responded with a JSON if something was wrong, and a fully formed SOAP message if things were Ok.

That and the guys that handle your money use the Http status code as their personal error messages. Except when the error is on their end, in which case they return 200 and a JSON with an error message.

There are plenty of ways to do REST wrong, so let's not lump that into the people that make blog posts complaining about X because X is broken, and working just fine...

Re: The Java type system is broken

#57
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?

Unequivocally, yes. Several new languages (eg Typescript, Dart) have optional type systems that still bring significant value to the table. Sure - all other things being equal, I'd much rather have a type system that is completely sound. Ceylon's type system is beautiful and I'm happy to see its union + intersection types being adopted by Typescript. But honestly, I'm not going to lose much sleep over these particula…

> … Dart… have optional type systems…

fyi "Dart’s type system is now sound" and "…types are mandatory".

https://www.dartlang.org/guides/language/sound-dart

Re: The Java type system is broken

#58

It’s pretty tragic how people respond to such criticism emotionally, instead of acknowledging the issues and working towards fixing them or educating others in the traps and compromises involved. HN is less prone to toxicity, but this is reminiscent of Reddit and it drives away the people that want to help. As a piece of advice, some type theory never harmed anyone ;-)

I think it's just a knee jerk reaction to some academic/PL theory types that chime in with a "Huzza! Long live (Haskell/Scala/Ocaml/etc.)!" As if a lack of soundness is dawning on anyone and was anyone's issue to begin with.

It's pretty dramatic so it gets met with preemptive defensiveness.

From the end of article: Everything is broken. Everything is fine.

Re: The Java type system is broken

#59
post #34

Earlier quoted context omitted.

What's the point of strong typing if it only saves you most of the time?

So a type-system that does the right thing in 99.999999% of the cases is completely useless according to you?

Don't throw out a number like that. We're talking about a Turing complete language, which means we're talking about protections that have to range over all possible programs and abstractions. It may be that your problem domain is extremely biased toward some small region of that space, in which case a type system that doesn't work there is actually useless.

Either way, it is hard to reason about factors like that numerically when we've not qualified which kinds of programs we're expecting the type system to actually work for.

Re: The Java type system is broken

#60

It’s pretty tragic how people respond to such criticism emotionally, instead of acknowledging the issues and working towards fixing them or educating others in the traps and compromises involved. HN is less prone to toxicity, but this is reminiscent of Reddit and it drives away the people that want to help. As a piece of advice, some type theory never harmed anyone ;-)

Seems like the project acknowledged issues and is working towards fixing them. There is no flame in it and discussion in bugs that were opened is factual.
Post reply on HN