Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Comments on Any testimonials for any C++ units of measure library?

Post

Any testimonials for any C++ units of measure library?

+5
−0

The question is about libraries that extend the data type system to ensure physically realistic computations. Think std::chrono but for distance and mass and other things as well as for time. Instead of adding 2 and 3 to get five, you can add 2 kilometers and 3 meters to get 2003 meters. It's easy to find people who dislike using them, but are there success stories? My particular reservations are about learning curves. I'm in a shop with a smart but very small team that can't take a lot of time to figure out something like Boost Units. That leaves, by one estimate, about 3700 other libraries in the same space. If anyone's a satisfied user, which one did you integrate in your project, how did you pick it, and what problems should I look out for?

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

What problem does it solve? (3 comments)
What problem does it solve?
Lundin‭ wrote about 2 years ago · edited about 2 years ago

One of the most important things I was taught in physics classes back at school was to always convert each operand to the basic SI unit before using it in calculations. That is, always convert km to m. Always convert hours/minutes to seconds. And so on. This for manual calculations - programming is of course even more pedantic about using proper types. So I can't think of any sensible reason not to do this while writing computer programs. Now as it happens, once a veteran of writing computer programs, you also realize that you should pick a unit which is friendly to the computer, not to the programmer. Because each time you re-scale something going from raw data to some human-friendly unit, you risk losing accuracy caused by rounding errors. You should only need one single such conversion to human-friendly formats, and that's before displaying something.

celtschk‭ wrote about 2 years ago

It solves the same problem that any strong typing system solves: Catching errors.

Fred Wamsley‭ wrote about 2 years ago

Yes, it's a sound alternative to convert everything to a single system (I would choose SI too), but anything that involves trusting humans to do the same thing right every time is not as reliable as delegating enforcement to a compiler. The problems such libraries solve are problems like the units conversion error that destroyed the Mars Climate Orbiter at a cost of almost $200 million. The question is whether the solution comes at an acceptable cost in developer bandwidth and maintenance.