News for hackers. Stuff that matters.
Re:Atlas, a hopefully better engineering IDE by g_delgado14 on Monday May 10, 2021 @11:29PM (#27113920)
Isn't the "newtype" pattern something that addresses this issue elegantly?

Is there something that I'm missing here?

Re:Atlas, a hopefully better engineering IDE by heisenzombie on Monday May 10, 2021 @11:41PM (#27113975)
Not really, a units systems needs to be able to combine units in a useful way, like if I typed this:

  radius = 15 [mm]
  area = pi*radius^3
  force = 100 [N]

  def will_i_blow_up(pressure [Pa]):
    if(pressure > 1 [Gpa]):
      return "Oh no it blew up"

  will_i_blow_up( force/area )
should raise an error like "UnitsException, [N/mm^3] is not compatible with [Pa]". I could then look over my code and realize I should have written:

    area = pi*radius^2
Re:Atlas, a hopefully better engineering IDE by yladiz on Tuesday May 11, 2021 @03:02PM (#27122087)
If you have a language that supports tagged types and can overload operators, you can basically get there. I think a language like Idris and Julia (with the right packages) should be able to support this.
Re:Atlas, a hopefully better engineering IDE by cwhy on Monday May 10, 2021 @11:50PM (#27114029)
This is rather a math-specific operation (type conversion on math operators), not the scope of general purpose language. A lot of dependent typed language can achieve this naturally and most languages with ADT can simulate this.
Re:Atlas, a hopefully better engineering IDE by dragonwriter on Tuesday May 11, 2021 @01:16AM (#27114469)
> This is rather a math-specific operation

Math is a kind of a core use case for, really, almost any programming language, and is central to much of what computers are used for (as is hinted at in their name.)

Though dealing with this aspect of units is less “math-specific” than central to the relation between math and real-world meaning, which is arguably even more important than abstract math in computing applications.

Re:Atlas, a hopefully better engineering IDE by burke on Monday May 10, 2021 @11:32PM (#27113934)
Yep, it allows you to tag something a metres per second, but it doesn’t automatically make multiplying it by a duration yield a distance without writing any custom code. F# can do that, and it’s rather cool. There are dimensional analysis libraries for other languages, but none that I’m aware of baked in.