Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Awesome achievement but I have to say the units stressed me out. I hope that in the real world there's some kind of dimensional analysis code linter that verifies no one is comparing slugs to feet or something, and that altitude doesn't go below zero.


In practice, unit checking is almost never done on actual code, though it should be done. From what I recall, some Fortran folks have been trying to get unit checking into the Fortran standard itself since the 1970s without success.

I was able to coerce Fortran's type system into checking units, but it comes with quite a few downsides: https://fortran-lang.discourse.group/t/compile-time-unit-che...

An approach based on static analysis would not have the downsides I listed, but I personally would prefer being unable to compile the code at all if it had an error that could be detected.


Elaborate typing is what Ada was for.


You actually need the altimeter to be capable of reading below 0 in the real world.

Aircraft altimeters are based on air pressure. The reference pressure is variable based on atmospheric conditions and is decided by controllers, or in the case of uncontrolled airspace, the matching the altimeter of the known altitude that you took off from.

All that is to say, on my home (uncontrolled) airport which is ~10 feet above sea level, I occasionally land at a negative altimeter value since the weather conditions have changed while I am in the air.

Assuming that an altimeter reading must be positive is a bad assumption.


I've seen a few libraries that attempt to put strong unit types into languages, to use the type system to ensure correctness.

In rust I'm familiar with https://docs.rs/uom/latest/uom/ and typescript I've seen safe-units https://jscheiny.github.io/safe-units/ used.


Hi, author here.

In my experience in both the aerospace industry and the video game industry, there are no tools like this in use. In aerospace specifically, errors like that are caught by manual human review, including third-party validation companies. Unit tests are used to sanity check every calculation. And finally, everything is run in a flight simulator before ever going onto a real aircraft.

In video games however, it's the wild west. Math errors there are funny, not deadly.





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: