Re:The type system is a programmer's best friend
by masklinn on Saturday November 05, 2022 @09:27AM
(#33481251)
FWIW that's a pretty basic application called "units of measure". Some languages like F# have that natively.
[ Parent
| on HN ]
Re:The type system is a programmer's best friend
by mrkeen on Saturday November 05, 2022 @09:32AM
(#33481291)
I wish static typing were as uncontentious as units of measure.
Re:The type system is a programmer's best friend
by masklinn on Saturday November 05, 2022 @09:34AM
(#33481310)
I wouldn't say that UOM are uncontentious, things can get dicey around reference units and precision for instance, or the combinatorial explosion of composite units.
Re:The type system is a programmer's best friend
by mrkeen on Saturday November 05, 2022 @09:48AM
(#33481443)
Right, but if you told your professor you sometimes represent distance in Volts (to make your calculations simpler) you'd get some funny looks.
You could even double-down on it: "Have there been any studies that prove that using units of measure helps you get the right answer?"
Re:The type system is a programmer's best friend
by tsimionescu on Saturday November 05, 2022 @01:50PM
(#33483790)
Funnily enough, there are some applications for converting mechanics problems to analogous electricity problems to leverage circuit simulation software such as PSPICE to help solve things like transcendental equations.
Re:The type system is a programmer's best friend
by hither_shores on Saturday November 05, 2022 @03:47PM
(#33484909)
Yes, but the mapping doesn't change the relationship between the units of measure, which is the actual meaning as far as the type system is concerned. It's just a change of names.
Re:The type system is a programmer's best friend
by tsimionescu on Saturday November 05, 2022 @03:49PM
(#33484929)
Sure, I wasn't meaning to detract from the comment above, just to point out what I thought was an interesting related fact.