News for hackers. Stuff that matters.
Re:Code.nasa.gov by dthal on Monday March 09, 2015 @05:59PM (#9174491)
From the article:

>>libSPRITE defines engineering units as types (i.e., Meters or Radians instead of double or int).

I guess experience is a harsh teacher.[1]

[1]http://en.wikipedia.org/wiki/Mars_Climate_Orbiter#Cause_of_f...

Re:Code.nasa.gov by davidgrenier on Monday March 09, 2015 @08:05PM (#9175007)
Worth noting that F# has language-support for Units of Measures and countless new languages have come since 2008 without that in mind.
Re:Code.nasa.gov by pron on Tuesday March 10, 2015 @12:48AM (#9176080)
Added in Java 8 as one of its pluggable type systems: http://types.cs.washington.edu/checker-framework/current/che...
Re:Code.nasa.gov by bokchoi on Tuesday March 10, 2015 @02:42AM (#9176395)
Ok, that's awesome.
Re:Code.nasa.gov by Osmium on Monday March 09, 2015 @08:10PM (#9175025)
> Worth noting that F# has language-support for Units of Measures

I had no idea. That is crazy cool. Do you have any recommended resources for learning how this works behind the scenes?

(I tried implementing something similar in Swift, without knowledge of prior examples, so probably ended up doing it in a really dumb way. I tried using structs ('Quantities') containing the underlying value and also dimensional information, and then enabling mathematical operations using operator overloading and generics. I'd love to know of a better/"proper" way of implementing it though. The big unknown for me was the best underlying type/data structure to use to represent SI dimensions, including fractional dimensions, and that would allow them to be combined algebraically. Might just have to have another go this weekend following F#'s example!)

Edit: found this paper if anyone's interested http://research.microsoft.com/en-us/um/people/akenn/units/CE...

Re:Code.nasa.gov by louthy on Tuesday March 10, 2015 @07:52AM (#9177195)
> I had no idea. That is crazy cool. Do you have any recommended resources for learning how this works behind the scenes?

http://fsharpforfunandprofit.com/posts/units-of-measure/

The units are lost at runtime and are used for static type checking only. So if you were to consume an F# lib from C# (for example) then you wouldn't have a such strong system. Hopefully one day they'll end up as part of the CLR so it can be enforced at runtime too.

Re:Code.nasa.gov by doublec on Monday March 09, 2015 @11:51PM (#9175916)
"Scientific and Engineering C++" by Barton and Nackman had a good example of doing units in C++ using templates. This blog post describes the basic approach http://learningcppisfun.blogspot.com/2007/01/units-and-dimen...
Re:Code.nasa.gov by GimbalLock on Tuesday March 10, 2015 @01:32AM (#9176223)
I just interned with the guy responsible for libSPRITE last summer at the Marshall Spaceflight Center in Huntsville. Kind of awesome to see he open sourced it. He really was hoping to get approval to do so.

I used his library for my internship. Cool stuff. And he was a great teacher.

Re:Code.nasa.gov by akavel on Tuesday March 10, 2015 @06:55AM (#9177036)
Clicked on https://github.com/nasa/libSPRITE, but as of now the repo contains only a README with a "Coming Soon!" note... :/ dated 1 Dec 2014, so 3 months ago already...
Re:Code.nasa.gov by sliverstorm on Monday March 09, 2015 @07:54PM (#9174960)
Gah, how many different times has unit incompatibility hit our space program now?
Re:Code.nasa.gov by plutonium on Monday March 09, 2015 @07:11PM (#9174753)
> Meters or Radians instead of double or int

I was just thinking I've seen that at my job, but then I noticed [1] is my employer, heh.