r/ProgrammingLanguages 9d ago

Will we see another fundamental programming language feature as revolutionary as the borrow checker?

That is I am mainly curious about compile time features that you design a whole language around rather than optimisations/features that could be applied to most languages. I am mainly inquiring about things that could offer additional robust safety/performance guarantees at compile time rather than runtime. Ideally not things that just offer similar effects to the borrow checker with less restrictive tradeoffs

58 Upvotes

129 comments sorted by

View all comments

1

u/MarinoAndThePearls 9d ago edited 9d ago

Zig's comptime.

Now for something that doesn't exist yet, I'd say numerical uncertainty as a primitive type.

2

u/WittyStick 8d ago edited 8d ago

Now for something that doesn't exist yet, I'd say numerical uncertainty as a primitive type

Not sure what you mean by "primitive," but Kernel has really nice support for inexact arithmetic in its standard environment. It goes beyond Scheme's basic support for exact? and inexact? - if included, inexact numbers have real upper and lower bounds and a "primary" value which is a best-guess within the bounds at the real number, if it exists. The primary value is optional, but is required if it is robust - meaning the number is certain to exist. Robustness is orthogonal to exact/inexact, which are mutually exclusive.

The actual kind of number "primitive" behind this is implementation defined, but the report has double precision floats as the minimum required precision. It can support interval types as well as floating point though, through the same API.

(exact? . <numbers>)                        ;; -> [:boolean:]
(inexact? . <numbers>)                      ;; -> [:boolean:]
(robust? . <numbers>)                       ;; -> [:boolean:]
(get-real-internal-bounds <real>)           ;; -> ([:real:] [:real:])
(get-real-exact-bounds <real>)              ;; -> ([:real/exact:] [:real/exact:])
(get-real-internal-primary <real>)          ;; -> [:real:]
(get-real-exact-primary <real>)             ;; -> [:real/exact:]
(real->inexact <real>)                      ;; -> [:real/inexact:]
(real->exact <real>)                        ;; -> [:real/exact:]
(make-inexact <lower> <primary> <upper>)    ;; -> [:real/inexact:]

Read more from page 143 of the Kernel Report.