noncombatant.org

5 min read

fairly difficultArticle URL: https://noncombatant.org/2021/09/26/improving-software-numbers/
Comments URL: https://news.ycombinator.com/item?id=28660778
Points: 1
# Comments: 0

Improving Software 'Numbers'

26 September 2021

Programming languages should expose a flexible variety of explicit types and operators for handling arithmetic overflow and related problems. As language design problems go, this might be relatively less difficult to achieve. Rust is closest to where programming languages need to be, but not all the way there yet.

I believe that software should be able to reliably compute arithmetic expressions. You may say I'm a dreamer, but I'm not the only one.

To represent an infinite set in finite space is problematic. This is not news to most software engineers. We always need a coherent policy for how to deal with our inability to represent some elements of infinite sets, or expressions that would evaluate to representable elements if only we had space.

We can consistently apply some policy (whatever it may be) using the language's type system: by encoding policy in the set's type, and operators on and functions of it, we can get (if nothing else) consistent representation of and behavior in error states. (I'll call them representation errors generically.)

Surely, we can all agree that this is the minimum necessary for program correctness.

Surely, we can all agree that correctness is the minimum necessary for program safety.

Surely, we can all agree that providing people correct and safe software is our duty as engineers.

Even the most fundamental objects of computation, the reals and the integers and arithmetic on them, require some policy for unrepresentable values — even if it is simply to crash when no more memory is available to an arbitrary-precision arithemtic library (for example).

Machine words are more limited still, and have far less range to represent the reals and integers than do arbitrary-precision types. Even so, for practical efficiency, we typically use machine words to represent elements of these sets. For many circumstances, this is not a problem.

The machines we typically use implement reasonable…

26 September 2021

Programming languages should expose a flexible variety of explicit types and operators for handling arithmetic overflow and related problems. As language design problems go, this might be relatively less difficult to achieve. Rust is closest to where programming languages need to be, but not all the way there yet.

I believe that software should be able to reliably compute arithmetic expressions. You may say I'm a dreamer, but I'm not the only one.

To represent an infinite set in finite space is problematic. This is not news to most software engineers. We always need a coherent policy for how to deal with our inability to represent some elements of infinite sets, or expressions that would evaluate to representable elements if only we had space.

We can consistently apply some policy (whatever it may be) using the language's type system: by encoding policy in the set's type, and operators on and functions of it, we can get (if nothing else) consistent representation of and behavior in error states. (I'll call them representation errors generically.)

Surely, we can all agree that this is the minimum necessary for program correctness.

Surely, we can all agree that correctness is the minimum necessary for program safety.

Surely, we can all agree that providing people correct and safe software is our duty as engineers.

Even the most fundamental objects of computation, the reals and the integers and arithmetic on them, require some policy for unrepresentable values — even if it is simply to crash when no more memory is available to an arbitrary-precision arithemtic library (for example).

Machine words are more limited still, and have far less range to represent the reals and integers than do arbitrary-precision types. Even so, for practical efficiency, we typically use machine words to represent elements of these sets. For many circumstances, this is not a problem.

The machines we typically use implement reasonable…

Chris Palmer

Read full article

suggested articles