re: What the hell is type-safe language? VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Why should I care about making a compiler happy in the first place? Static typing requires a huge boilerplate. No, thanks.
 

Well, you could have the compiler verify the types for you or write unit tests instead..

How else do you make sure the function expecting a User doesn't get a Monkey instead?

 

you could have the compiler verify the types for you or write unit tests instead

This is the biggest deception raised in the last ten years and I have no idea where is comes from. Strong static typing does not obsolete unit tests.

Please note, I even added strong to your original static which gives you even more freedom to argue.

A dozillion time strong and static as hell type would not help to catch "foo" instead of "bar". 99% of bugs exist not because somebody sent a monkey to the represent the user. Developers are not that stupid.

While pattern matching would. And restriction to create own types would. And even despite that we in erlang/elixir do indeed write unit tests. Because the vast majority of things that require an explicit check are like “the currency rate cannot be less than one if the currency pair is normalized.” Welcome to protect this with your vaunted types.

I never said you would write 0 unit tests. You would write no tests for types.

Kotlin has nullability built into the language, so I don't have to write a test what happens when the variable I am passing is null.

I also don't have to do defensive programming and check if the variable is null.

I never check the variable I pass is null, mostly because I am sober enough to not pass nulls where they don’t belong. In CS variables do not become null all of a sudden.

code of conduct - report abuse