Live data from Hacker News

GNU Units

gnu.org

91–100 of 117 posts

Re: GNU Units

#91
post #73

Earlier quoted context omitted.

Someone on the team needs to know about it. That person needs to set up the API to expect properly typed inputs. Others can remain ignorant about units of measurement and the compiler will educate them. F# has this built in but it can be achieved with libraries in some other languages. For example, in Haskell with the dimensional package[1]: import Numeric.Units.Dimensional.Prelude import Numeric.Units.Dimensional.No…

You're not getting it. The Mars probe didn't crash because of bad unit conversion. It crashed because there were no units in the data !!! Go read about it yourself. NASA got some data from a contractor. The data had no units at all . The contractor assumed the data to be in some kind of US-standard units. NASA got these raw numbers and assumed they were in some kind of SI units. Having enforced units in your language…

In that case, you're right.

Re: GNU Units

#92
post #41

Only tangential to this but somebody might find it usefull. I’m doing lots of calculations in Python involving various units. I’m using a similar library called Pint. https://github.com/hgrecco/pint My business is thermodynamics of power plants. Professionals in the industry tend to use convenient units like C, bars, kJ/kg and so on. But the formulas usualy need basic SI units. Using this library not only streamlines…

I'll second that. I work in the renewable energy space where we get all manner of atmospheric and power data in a wide variety of units depending on the data source, so Pint is incredibly useful in normalizing them as well as making it clear in the code what and how unit conversion is happening. The fact that it integrates fairly nicely with Pandas and Numpy is great, too.

I will third that and add that I use pint regularly and currently work in non-renewable energy.

Re: GNU Units

#93
post #77

IIRC, GNU Units was once the center of a small controversy. Google (still, AFAIK) offers unit conversion as a part of their search box; you can type a unit conversion into Google and get a conversion done. Some people noted this, wondered about what the backend might be, and typed some stuff in which was known to trigger a then-present bug in GNU Units. And wouldn’t you know it, Google showed the same bug. This was a…

This is why I AGPL my projects even if i feel like it isn't likely to be used as a network backend.

Re: GNU Units

#94
post #77

IIRC, GNU Units was once the center of a small controversy. Google (still, AFAIK) offers unit conversion as a part of their search box; you can type a unit conversion into Google and get a conversion done. Some people noted this, wondered about what the backend might be, and typed some stuff in which was known to trigger a then-present bug in GNU Units. And wouldn’t you know it, Google showed the same bug. This was a…

Maybe the ripped out GNU Units.

Never know, since they never distributed it.

Re: GNU Units

#95
post #73

Earlier quoted context omitted.

Someone on the team needs to know about it. That person needs to set up the API to expect properly typed inputs. Others can remain ignorant about units of measurement and the compiler will educate them. F# has this built in but it can be achieved with libraries in some other languages. For example, in Haskell with the dimensional package[1]: import Numeric.Units.Dimensional.Prelude import Numeric.Units.Dimensional.No…

You're not getting it. The Mars probe didn't crash because of bad unit conversion. It crashed because there were no units in the data !!! Go read about it yourself. NASA got some data from a contractor. The data had no units at all . The contractor assumed the data to be in some kind of US-standard units. NASA got these raw numbers and assumed they were in some kind of SI units. Having enforced units in your language…

Notably, the NASA spec said the units were supposed to be in SI.

Re: GNU Units

#96
post #7

Units of measure are, of course, the aboriginal type system for pre-software hand calculation.. carrying units along to make sure you do not add apples to oranges { unless you know how to convert "apples" to "oranges" for some adapted metaphorical fruits.. e.g. orange section/segment/slices :-) }. Nim [1] has sufficient compile-time strength that units can be integrated with the static type system: https://github.com…

Just for curiosity, what Nim does that other languages with operator overloading wouldn't do? Aside from the "number.unit" syntax, you could do some trickery to get units comparison and conversions even on C++

I work in large C++ codebase for a suite of physics simulation software, and there are like 200 something strongly typed arithmetic units here.

Re: GNU Units

#99
post #93
post #77

IIRC, GNU Units was once the center of a small controversy. Google (still, AFAIK) offers unit conversion as a part of their search box; you can type a unit conversion into Google and get a conversion done. Some people noted this, wondered about what the backend might be, and typed some stuff in which was known to trigger a then-present bug in GNU Units. And wouldn’t you know it, Google showed the same bug. This was a…

This is why I AGPL my projects even if i feel like it isn't likely to be used as a network backend.

What's nice about AGPL is that, as per Google's policy, it serves as an automatic ban from your software being used at Google, including non-networked applications like Android. Some people have said this is a downside or that Google's policy represents a red flag about the license itself, I see it as a good thing that the license makes them nervous.

Re: GNU Units

#100
post #22
post #2

This tool is underrated. Failing to deal with units conversion already crashed a Mars probe: https://www.latimes.com/archives/la-xpm-1999-oct-01-mn-17288... I wonder if the recent problem with the voyager was due to something like this, for example, 2 arcminutes or 2*pi radians being mistaken for 2 degrees.

The idea of using units is underrated, yes. More programming languages should be offer support for units, and more program should be using them. That particular tool, "GNU Units"? Nope. It is pretty good command-line calculator (especially if you give inputs on command line so that history is preserved), but it is not really scriptable, and you'd _definitely_ want to avoid all manual calculations in any sort of impor…

> More programming languages should be offer support for units, and more program should be using them.

There is some solution for most programming languages:

https://gmpreussner.com/research/dimensional-analysis-in-pro...

How well it works mostly depends on features of a programming language or it's compiler.

That said it's rare for a programming language to have a type system with extra features and unit checking support in it's standard library like F# or GNAT does:

https://learn.microsoft.com/en-us/dotnet/fsharp/language-ref...

https://gcc.gnu.org/onlinedocs/gnat_ugn/Performing-Dimension...

Post reply on HN