1. 52
  1. 13

    Dimensional analysis is one of the simplest and most useful tools I ever encountered during my engineering schooling. If you work a problem and the units don’t end up in the form you need, it’s a strong indicator that you screwed up in your math somewhere–it’s also a good hint about what sorts of governing equations or information you need to hunt down to solve the problem.

    It’s so neat to have a language that does that as a first-class thing.

    1. 11

      I admire the effort put into Frink, which makes me even sadder that, though Frink is a free-to-use indie programming language, Frink is not open source. Reading the creator’s accounts of their research struggles in the units data file is quite entertaining until you realize that anyone building an open-source unit-aware calculator is going to have to do all that work again.

      Once, for a school assignment on the topic of GUIs, I used Frink’s embeddability to start building an open-source GUI for Frink, CalcuDoc. CalcuDoc’s difference from Frink’s official GUI was its use of the document paradigm pioneered by Soulver and InstaCalc. I abandoned CalcuDoc once I realized I was wrong in my initial assumption that Frink was open source.

      1. 3

        while i appreciate the author’s reasons for not being open source, i do wish they had at least open sourced the units data file. they could then have fun experimenting with the code, and other people could use the data file to build another open source units-aware language.

        1. 2

          To give you a little bit of hope, Frink’s website does invite readers to “e-mail Alan Eliasen with questions, comments, or vituperation”. So there is the option of contacting the author and asking if they would be willing to open-source the units data file. Perhaps they could be convinced that open-sourcing the file wouldn’t harm their goals.

          If Alan thinks that open-sourcing the units data would harm future monetization of Frink, they might agree to an arrangement where they get paid a lump sum and then open source the units data forever. Depending on the price, a new open-source project might find such a deal cheaper than replicating Alan’s work.

          I’m not sure if Alan Eliasen actually reads that email address, though. They never replied when I linked them to my project CalcuDoc five years ago.

      2. 3

        As you enter a gravity well, the rate at which gravitational force changes has at which the gravitation force changes with distance has dimensions N/m.

        Uh… Wat?

        Also, just to show that your broad-mindedness is at least roughly commensurate with your sense of humor, it might be worth acknowledging that Reagan isn’t really responsible for the British Empire… or the Romans. (My dad was a carpenter, so I can stick up for duodecimal systems just on the basis of divisibility… also, hexadecimal has its own reasons, which SI knoweth not… but not gonna waste any further keystrokes on the matter.)

        All that aside, hooray for Frink! Good on you for spreading the word. Now if only there were some kind of library or type system extension or something, so all this good stuff wasn’t stuck inside a DSL…

        1. 4

          Whoops, pushing fixes! The reason I’m blaming Reagan isn’t because he caused us to use customary units, but because he cancelled the metricization project already underway. Also pushed a fixed to clarify that.

          I think base 12 systems are waaay cooler than base ten and the Babylonians were right in getting us on a base 60 time system.

          1. 1

            base 12 systems are waaay cooler than base ten

            How about six?

        2. 4

          I mean, this was interesting, but I seriously thought it was going to be about Frinkiac, the meme finder for Simpsons GIFs, or Professor Frink himself.

          Also, +1000 for the Zardoz reference.

          1. 6

            That’s actually the source of the name! From the site:

            Frink was named after one of my personal heroes, and great scientists of our time, the brilliant Professor John Frink. Professor Frink noted, decades ago:

            “I predict that within 100 years, computers will be twice as powerful, ten thousand times larger, and so expensive that only the five richest kings of Europe will own them.”

          2. 2

            Julia is pretty good at this stuff too with Unitful.jl:

            ]add Unitful
            julia> using Unitful: m, ft
            julia> using Statistics: cov
            julia> cov(rand(100).*m)
            0.07996239074313088 m^2
            julia> 1ft + 1m
            1631//1250 m

            It’s probably not quite as ergonomic out of the box as Frink, but you get the added benefit of being able to use Julia’s speed and packages.

            1. 2

              Is there a fork which deliberately ignores SI’s decision to pretend that “cycle” is unitless, makes 1 radian = 1/2pi cycles, and makes Hz = 1/cycle? :)

              Edit: a very small thing, but I like the title. Whimsical and amusing without being clickbaity.

              1. 2

                There’s the SI system, which all sane, right-thinking nations use, and then there’s the American system.

                I really don’t think that is a fair characterisation. Traditional units are imperfect, but they have advantages when manipulating concrete quantities. Moreover, all is not sweetness and light on the other side of the fence.

                Note that the Mars orbiter would have been just as broken had it mixed kilometres/hour and centimetres/minute!

                1. 2

                  I don’t have problem with US Customary units in a vacuum, I just have a problem when only everybody else uses something different! It’d be like if everyone used UTF-8 except windows, which used UTF-16.

                2. 1

                  Does Frink really disallow adding two timestamps?

                  1. 6

                    If it does, then it is right to do so!

                    A timestamp cannot be added to a different timestamp, as there is no natural zero value for it (Big Bang could theoretically be one, but it is not practical for obvious reasons). Think about it similarly like a position in space. Two points (places) cannot be added, but their difference can be calculated, and it can be added to any of them. In a coordinate system you have an origin, and places are differences from that point, and those differences can be added! You probably think about a similar operation.

                    You cannot add London to Budapest, but you can add the vector pointing from point on the equator and on the Greenwich meridian to London to the vector pointig from the same origin to Budapest.

                    I guess what you mean by adding two timestamps is something similar to the above: like: 1999-12-31 23:59:59 + 2000-01-01 00:00:01 = 4000-01-01 00:00:00 (this is obviously incorrect numerically, just some demonstrataion of the concept). In this case you are not thinking about timestamps, you are actually adding two time intervals, getting a third time interval. These timestamps have an ‘origin’ in their coordinate systems, which are eras in timekeeping, and the above timestamps are in the Christian calendar era.

                    I hope it clarifies the reason why timestamps cannot be added, but why the usecase You have in mind might make sense, only your intuition of the problem was a bit rough (if I guessed correctly).

                      1. 1

                        I don’t get what interface you mean by it. It does not make sense for me in any other way than stated above.

                        Maybe you could share some user story you have in your mind?

                        1. 2

                          Sorry my previous comments were on the phone so I was terse. Let me back up.

                          The first part of OP points out several complexities about units. Some (like timestamps) permit selective operations. Some with the same dimensions (like surface tension and rate of change of force) are not commensurable. I agree with the observations, but as someone who’s built languages in the past I have no idea how to support these patterns in a general way that permits new units to be defined.

                          I went looking in Frink’s default unit definitions, but saw no mention of timestamps or surface tension or gravity wells. Hence my original question: was the initial list of complexities just a general list, or was it actually alluding to features Frink supports? If it does support them, I’m curious to know if there are limitations that are just hard-coded to specific units, or if they’re provided in a general way that allows me to say “two values of unit foo cannot be added together.”

                          1. 1

                            Ah, thank you for the clarification!

                    1. 1

                      What value would it be? Subtracting two is well defined as the time interval between them.

                      1. 2

                        No, it makes sense as an interface. I just don’t immediately understand how the implementation would work. Do arbitrary new units support arbitrary restrictions on operations and compatible units? How does it deal with the incompatible N/m units?

                        I guess I’m wishing your article was longer :)

                        1. 1

                          I just don’t immediately understand how the implementation would work.

                          Not sure either but really glad you highlighted this!

                          So I guess maybe a generalization is that timestamps, like some other…things, are a difference from whatever we chose as the conventional zero point, vs. durations, lengths, etc. being differences that don’t need a conventional zero defined.

                          Like, when you say it’s 2020, you mean it’s 2,020 years from the human-chosen year 0. Subtraction cancels out the constant, getting you a difference independent of when year 0 was. Finding a midpoint between two times gets you another timestamp relative to the same year zero. Adding or doubling gets you some number with the conventional-zero-point constant factor doubled (you move year 0 one year, result moves two years) and that doesn’t make sense anymore.

                          We could apply “positions vs. a conventional zero aren’t the same thing as deltas” in some places we don’t, e.g. you wouldn’t want to add two temperatures Fahrenheit, as opposed to a temperature and a temp. difference, or two temp. differences. (But since we write both degrees-F, it’s not intuitive/trivial to apply.) I now recall my physics teacher scolding me for talking about a voltage at a point in a circuit, rather than between two points – guess we wanted a difference, not a position relative to ground.

                          Then there are tricky things like lat/lon pairs (angles relative to the poles), where you sure can’t add, can maybe sorta subtract for a pair of angles?, and you have some mostly-well-defined operations like midpoint and distance.

                          I’m getting in over my head and my language is all wrong, but the whole issue of arbitrary zero points (and the other examples in the post like angular force and energy) suggest there is depth to this beyond the dimensional analysis I was taught in school, which is pretty fun.

                          1. 8

                            In terms of established language, timestamps form a one-dimensional affine space, with time deltas as the associated one-dimensional vector space.

                            1. 1

                              Oh most interesting, thank you.

                              1. 1

                                Thank you!