News for hackers. Stuff that matters.
Re:Strong typing, a hill I'm willing to die on by Someone on Wednesday October 04, 2023 @12:02PM (#37767154)
> For things like kilometers versus hours I'm still undecided.

Those help you more if you do a lot of math involving both them, but that’s also when it becomes a nightmare in most programming languages because of an explosion in the number of types.

Let’s say your code computes

  3km × 4hours
If so, you need a “km hour” type.

In many languages, you also have to write code to make that happen, and to make it have the same type as

  4hours × 3km
Even if you don’t ever store values with those types in variables, you also may need types for per km, per hour, km² and hour² for expressing the types of intermediate values (for example, in a physics computation, you may encounter √(3km²/4hour² to compute a velocity in km/hour)

And that’s ignoring that you may

- encounter minutes, meters, yards, etc.

- want to use algorithms that compute exp(3km) or log(4hours). What types do these have? Here, you probably want to forget about string typing values.

Re:Strong typing, a hill I'm willing to die on by flohofwoe on Wednesday October 04, 2023 @12:19PM (#37767397)
Apologies, I edited my post while you wrote your reply and removed the kilometers vs hours thing. But your reply makes perfect sense, and I think this "type explosion" is my main gripe with too extremist strong typing.