Complexity Shock Horror II: the Sequel (was Re: MD5 in erlang .)

Twan van der Schoot twanvds@REDACTED
Mon Mar 31 23:20:54 CEST 2003


Hi Chris,

On Monday, March 31, 2003 9:35 PM, Chris Pressey  wrote:
>
> Yet, I don't see *any* scalar values in the world around me.  They *all*
> have units of measurement.

I'm sorry, but quite a number of constants in physical are dimensionless. 
 And these have  a "scalar" nature.

But in a typical programming context, what about an ordinal number like an 
index in an array?  And just counting of elements in a list?  Do you want 
to count the number of elements, like 23_element, or 23_list, in case that 
list is comprised of lists?

Besides, one introduces the requirement for a kind of type-system (i.c. 
dimension/unit checking and derivation).  For the usual arithmatical 
expressions this may be not a problem.  But what unit has a list of, say, 
metres? And the second question then pops up immediately.  Does one want to 
base such a measurement system on the structure of the dimension or should 
it be a level more concrete and should one use a concrete unit standard 
(like SI or BSI or ANSI). Eventhough it would make doc-hunting less 
necessary, it is much too concrete to be "sufficently" generic for a 
universal programming langauge.

BTW: Are you acquainted with the HP48?  That nifty calculator allows you to 
enter number extended with units and all arthimatic behaves nice.

So, I guess that leaving scalars in favour of "unit objects" is not a 
concept for a universal programming language.  But I do think it would be 
great to have facilities in a programming language which make it attractive 
to have a standard library available which lowers the threshold to 
implement /applications/ utilising unit objects as the main representation 
of a measurement.  What these facilities precisely should be without unduly 
interference with the basic clarity of the programming language, I don't 
know.

br

Twan van der Schoot.

>
> But, you may well say, what's the big deal?  We *have* to make some
> concessions to translate a model from the real world onto a computer -
> why is dropping the units of measurement not justifiable?
>
> Two reasons: the Gimli Glider[1] and the Mars Climate Orbiter[2].
>
> The latter resulted in an immense loss of property; the former would
> have resulted in the loss of life, had the pilots not been as skilled as
> they were, and had the Gimli airstrip not have had the foresight to be
> located in Gimli.
>
> Looking at these mixups you may well conclude, we should simply abandon
> imperial measurement in favour of metric (good luck!)
>
> Unfortunately, that would only help mitigate the problem; it doesn't
> help solve it.  Think of how many times you've had to look up the timer
> manpage to see if a given parameter is in milliseconds or microseconds.
>
> If the basic numeric type of Erlang (or in fact any other programming
> language) was rich enough to include the units of measurement, there
> would be no need for such confusion and doc-hunting - and I submit that
> the language would become that much more expressive:
>
>   receive
>     {update_distance, D} when D is_in m ->
>       {ok, whatever(D)}
>     after 5 sec ->
>       {error, timeout}
>   end
>
> For a while I tried designing a new language around measurements.  It
> was only a partial success, and I was encouraged to modify an existing
> language instead, for correctness issues - but when trying that with
> Erlang, I was discouraged from modifying the existing language, for
> familiarity / predictability issues.  I'm not sure which path I'll take
> next time.
>
> -Chris
>
> [1] http://www.wadenelson.com/gimli.html
> [2] http://mars.jpl.nasa.gov/msp98/news/mco990930.html



More information about the erlang-questions mailing list