Hacker News new | ask | show | jobs
by fn-mote 261 days ago
> strong typing often obviates the need for unit tests

Do languages like Java have strong typing?

I thought so, but I can’t reconcile that with the belief that unit tests in Java would be unnecessary.

2 comments

It's reasonably strong, so that on practice you can trust it to verify the properties it verifies. (Though, it's not completely flawless in theory.)

It's also static, so your types declarations will replace tests.

But it's extremely inexpressive, so you can declare very few properties, and so it will replace very few tests.

And it's inflexible, so it will get on your way all the time while you program.

Anyway, I can almost guarantee you the GP wasn't talking about Java.

There's no single definition of strong with respect to typing, but I would probably put Java into the weaker of type systems, though it has gotten better over time. You can usually tell by how many casts you see in the code, and with most java codebases I see them everywhere. The pervasive nulls and untyped arrays are also huge red flags.