r/ProgrammingLanguages • u/jimbobmcgoo • Jul 23 '26
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
61
Upvotes
64
u/dkubb Jul 23 '26
Not new ideas, because they are in niche languages, but when the UX is nailed I think these are on par with the borrow checker in terms of impact:
Dependent Types are more powerful than Refinement Types, the UX for some common tasks is better for Refinement Types. If there was some way to desugar Refinement Types into Dependent Types without making the error messages too complex I think that would be amazing.
30
u/faiface Jul 23 '26
Yes, session types
81
u/AustinVelonaut Admiran Jul 23 '26
Algebraic effects like Koka?
20
u/matthieum Jul 23 '26
I'm tempted to say "obviously yes"?
First of all, the borrow-checker is not that revolutionary:
ReadWriteLockin a sense.The future is unbounded, so there's bound (!) to be more improvements in programming in general.
Even right now, Carbon's approach to memory safety is both similar yet different with regard to the borrow-checker -- lifetimes ~= place sets -- in allowing multiple concurrent mutators, which some see as a great change.
And Hylo's Mutable Value Semantics are also pretty interesting, and quite different.
If anything, one could argue the Borrow Check kicked the hornet's nest, and rekindled interest in automatic enforcement of memory safety without GCs. I'd be pretty disappointed in humanity if it ended up being the best way, surely we'll figure out better.
17
u/Inconstant_Moo 🧿 Pipefish Jul 23 '26
The basic idea of my lang is that if you enforce the functional-core/imperative-shell pattern in the semantics of the language, this is a very simple way of ensuring that most of your functions are pure. After five years or so I'm pretty sure no-one else is doing this.
11
u/mamcx Jul 23 '26
Other focus on types, I will go for big things (that are in part unlocked by types):
I bet this is the main test that proves if any idea is worth it. The borrow checker become revolutionary not because was a fancy type idea, but because allow , partially, "fearless concurrency".
This is my pet peeve when worked on a RDBMS, so is more niche, but the point is that the IO we have, well, sucks. Even system languages DO NOT tell you when and where sucks, and that means you need lore to know what to do.
BTW, this could be alleviated if we have annotations about "locks, blocks".
Is from above, but there is not way to make this from the primitives of any language I know, and all ways are tacky and error prone.
This is the other test that proves if any idea is revolutionary as the borrow checker, because, partially, Rust make possible to model safely concurrent mutations and reads (but not in full)
Is yet to be invented, all you can do is hack and hack.
The AMOUNT of resources used by compilers for C++/Rust is NUTS. There is a huge climb that once passed, turn your insignificant MB of input into HUGE time outputs. Why? I bet is because there is not a true kind of "compile engine" solely focused in eat the input, optimize and generate fast output. AFAIK is only informally done inside each compiler.
This is my main pet peeve, but will be cool for see an actual relational language implemented!
The theory of how types work is not well developed and so far only found one paper about it:
https://github.com/Tablam/TablaM/blob/master/RESEARCH.md
8
u/dacydergoth Jul 23 '26
A blast from the past : Unification Algorithm from Prolog
8
u/kaplotnikov Jul 23 '26
Firstly, while Rust's borrow checker has been pragmatically successful at preventing memory bugs, I believe its long-term role in future systems languages is limited. The borrow checker essentially acts as a workaround for overly low-level concurrency primitives, and its theorems are notoriously difficult to formally verify. This complexity is a symptom of a deeper issue: reasoning complexity is not concentrated in key hierarchical boundaries, but spread throughout the code via data-path analysis. This is a language design smell that points to overly low-level foundational abstractions.
I think its problems are directly related to the Rust concurrency model. The primary problem with Rust's concurrency is that message sending is the goto of asynchronous programming. It is not possible to create a good set of composable theorems over it. It suffers from all the problems of goto described in "Go To Considered Harmful". The
sendoperation is a direct implementation of this concept.Is there an alternative? There are promises and actions over them. For example, statements like the following could have been in the language (pseudo-code):
Here we could reason that
qis shared between branchescompute_aandcompute_b, and exclusive inmerge_results_a_and_b, because blocks provide visible reasoning boundaries. Thespawn/sendoperations provide no boundaries; they provide data leak paths.Such structured constructs could exist as a library, an intrinsic DSL, or direct language statements. The idea is to move from goto-style programming to structured programming, so reasoning will follow the code tree rather than the data path. The borrow checker is a tool for data path reasoning, but this problem only exists because we have gotos.
This issue isn't limited to concurrency; it defines single-threaded Rust as well. AFAIR early versions of Rust tried to reason using lexical scopes, but it was too restrictive for developers. To fix it, they introduced Non-Lexical Lifetimes, which officially shifted the borrow checker to data-path reasoning via control flow graphs.
Data-path reasoning effectively acts as a flat abstraction layer over a control flow graph. Just like goto flattened the control flow of early programs, non-lexical lifetimes flatten the data flow. This is precisely why people constantly "fight the compiler." Humans excel at hierarchical, tree-like reasoning (scopes and blocks), but Rust forces both the programmer and the compiler to trace a complex, fragmented web of data paths across the entire function. By abandoning structured, scoped boundaries for data management, Rust created the very complexity it now struggles to manage.
There are plenty of structured concurrency operators possible that create a better basis for reasoning in concurrent systems. For example, see asyncflows. It is a Java-based DSL, but it reflects the idea of what is possible with native language support. I just combined the ideas of Occam and E languages, so there are few completely novel ideas there.
As for what the future holds, I have my own vision, which I've outlined in this article: Measuring Abstraction Level of Languages. It also describes a framework for making such predictions. I think the future belongs to system composition languages, because humans naturally switch to these concepts to describe large programs as compositions of systems and subsystems. I am currently working on a language PoC that uses systems/holons and statically typed aspects as basic elements to enable this kind of composition.
For sample below,
in,local, andoutare not merely visibility keywords; they are the theorem pieces of the language's type system. They provide a formal, compositional way to reason about lifetimes based on lexical and semantic scope and dependencies (not unlike C++, but with transitive and verifiable guarantees):This creates an algebra of systems that allows reasoning along the code tree, rather than relying on 'storytelling-style' reasoning in an omnibus format, where the lifetime narrative is fragmented across shifting viewpoints. These abstractions could be essentially zero-cost and seamlessly extendable to both heap- and stack-based allocation. And it does not matter where a dependency originates, as long as the caller statically maintains the invariants required for the duration of the component's or function's lifetime.
7
u/Royal_Pin_1971 Jul 23 '26
Unison's content-addressed code checks at admission time — instead of compile time or runtime. A definition is type-checked when it enters the codebase and never again. The result is a permanent fact attached to the hash, not a per-build byproduct.
6
u/itsybitesyspider Jul 23 '26
My opinion software transactional memory is not itself a compile time thing but it is wildly underutilized because it requires so many compile time guardrails.
21
u/Dry-Light5851 Jul 23 '26
well if anyone here knows of a killer idea that can reinvent the wheel, i would like to know so i can take the creadit for it. /s
5
u/OSR_Workshops Jul 24 '26 edited Jul 24 '26
One idea I haven't seen mentioned: Capabilities, in the sense of "Capability-Oriented" programming, and languages such as E. Given the recent focus on "safe" programming, I'm surprised Capabilities haven't attracted as much attention lately given they have a similar safety focus (albeit addressing different kinds of vulnerabilities).
The basic idea of Capabilities (at least in one version) is that any procedures' authority for nonlocal effects should be an explicit part of its interface. As a canonical example, a procedure that can alter the local file system -- saving a new file or modifying one -- should be passed a file system object as an explicit input parameter, rather than relying on "ambient" capabilities such as std::ofstream. Another way of saying that is that constructing an std::ofstream object is an origination point for a capability which needs a specific form of authority, and such origination points should be clearly isolated.
Such principles could simply be enforced by how libraries are designed, but true language-level support for capabilities in this sense would include, at least, a mechanism to transfer authority from a caller to a callee via a distinct "channel" (partly to avoid confusion with ordinary function parameters). Sometimes such transfer may be implicit or automatic, not explicit. For instance, using std::cout as a simple form of debugging should bypass the capability system (maybe via some distinct object encapsulating access to the console) at least in debug mode. This can be achieved by ensuring that procedures can silently pass that specific capability amongst themselves. But the list of which capabilities are implicitly shared, and which ones require explicit declaration, can change from one context to the next (e.g., different build modes). When sharing is explicit, the relevant capabilities should be expressed as a distinct list apart from normal parameters, by analogy to how "this" objects have a separate syntax from other arguments.
There are other cases where distinct input "channels" can be used to enforce contracts or authority concerns. For instance, suppose a method on a list depends that the list be non-empty. If such a call occurs in the scope of a block like "if !foo.isEmpty() { ... }" then a "proof" of foo's non-zero size is present at the call-site and could be transferred to called methods via a similar sort of back-door channel. Certain Design-by-Contract requirements could then be expressed in terms of "proof" channels along these lines: a function can declare that it needs a particular proof to be supplied alongside input arguments, and the compiler can check whether such a proof value exists in the present scope (at the call site). If not, it could attempt to supply such a proof by runtime tests or else call an overloaded version of the function which has a different signature, one wherein the proof object is not a requisite parameter (presumably the overload would explicitly test the preconditions rather than just assuming them).
Imagine, however, that the programmer knows a list is nonempty in a context where the compiler cannot formally guarantee that fact. Here the programmer could instantiate an explicit proof value and insert it into the "channel" as a visible part of the call-code, rather than the contract being verified behind the scenes.
What the Capabilities and DbC cases have in common in that certain values related to safety and verification are envisioned as passed from caller to callee, but via some channel separate from normal function input (and output) and with the possibility of the value's presence being implicit in some contexts and explicit in others. My own opinion is that first-class support for these kind of features might be an attention-getter on par with borrow checking, or other examples speculated on here.
4
u/ChiveSalad Jul 23 '26
Currently, if you store stuff on the stack, the compiler can go absolutely hog wild in changing how / when / where / whether it is actually stored to ram. A true equivalent for heap storage would make efficient programming vastly easier in a way that goes beyond just an optimization improvement.
4
u/reini_urban Jul 23 '26
I don't find the borrow checker revolutional. Just ownership tracking to allow for concurrency safety. Which rust doesnt do btw, just Pony
3
u/AndreVallestero Jul 23 '26
Mojo's heterogenous compilation model (really just fully leveraging llvm mlir) is really cool.
3
u/alex-weej Jul 23 '26
Profile-guided data structure selection
3
u/EggplantExtra4946 Jul 23 '26 edited Jul 23 '26
There is no modern Prolog, or Prolog mixed with the imperative paradigm. (Prolog mixed with FP exists: Mercury).
Is there a language with usable delimited continuations? That is not a Lisp? Not sure.
There is no scripting language with a good and usable builtin PEG parser, we're stuck with lowly regexes.
There is no language like ATS.
There is barely any language with goto outside of C, C++, C#, D, let alone computed goto. Almost all "C-replacements" don't have it: Rust, Zig, Jai, Odin, Hare, C3, Nature. Only V still has it.
There is no language with good inline assembly.
There is no language with actually good metaprogramming features. Hygienic macros is far too rare in non Lisp languages and we could have more than that.
There is barely any language with parametrized modules.
Is there any language other than Scala with both sum types and classes? Let alone type classes and abstract classes.
There is no language allowing you to insert instrumentation code for debugging, profiling, testing, hardening, etc..
There is no language allowing you to bounds check the call stack and to grow it how you see fit (reallocation, segmented stack, ..). Could be used for implementing effectively a heap allocated call stack for unbounded recursion, coroutines, continuations, Prolog, a concurrent runtime, etc.. as a library.
There is no language that takes conditional compilation seriously, which is the bare minimum along with powerful metaprogramming features to have highly configurable programs that can be very well adapted to multiple specific hardware targets and OSes, which is what you want if you want fast programs.
3
u/qrzychu69 Jul 24 '26
https://www.roc-lang.org/
This would be my go to list
There is more, but these are my top :D
2
u/Morphon Jul 23 '26
Mathematics and logic are in the realm of the "unlimited" so there will be many such revolutions to come. Perhaps even in our lifetimes!
2
u/SwedishFindecanor Jul 23 '26
Imagine that you have code that manipulates data structures with pointers in them, and then have a type of proof that that code is memory-safe.
Then imagine that you do it the other way around: Give the compiler only the "proofs": in the form of declarations of which data structure topologies that can exist, which transitions between them that are legal, and let the compiler infer the code from them. Less code to write (than having to write imperative code and proofs), and the compiler is always correct if the declarations are consistent with one-another.
I have presented down a variation of this idea earlier, but not done much work on it after the initial idea. The example is for a memory-safe doubly-linked lists, which is something that can't be expressed in Rust.
I feel like this is important, but there is very much more work to do:
I would be very happy if someone would adopt this idea but produce something completely different than what I have been thinking of.
2
u/brucejbell sard Jul 23 '26
The core feature of my project is compile-time alias tracking. Unfortunately it might not be ideal for you because the idea is to offer comparable safety to Rust's borrow checker without its severe restrictions or its fiddly lifetime parameters.
Like Fortran, function arguments in my language are supposed to be non-aliased by default. Unlike Fortran, this requirement will be checked (conservatively) at compile time.
Briefly, it will be perfectly fine to create aliases to mutable variables and other resources. However, updates to aliased resources must have a well-defined sequence. As a consequence, aliased function arguments are only allowed if that aliasing is declared as part of the function type.
When writing C/C++, you need to keep this kind of aliasing logic in mind anyway, as part of the discipline necessary to write good code. But, rather than juggling it all in your head, it would be better to set up some static analysis. And rather than offloading that static analysis ad hoc to some kind of linter, it would be better to build it as part of your language.
2
u/catladywitch Jul 23 '26
I have this vague idea inspired by Rust, Koka, OCaml, and C++ I've got to flesh out better but could lead to something: control flow and memory lifetimes being one and the same. Imagine a compiler that does an intermediate pass transpiling into continuation passing style, that flows (barring tailcall loops and coroutines) strictly in a single direction. As long as a continuation is strictly one-shot and the place it's being passed to can be statically determined, the memory it takes can be managed deterministically at compile time, right? And, with some trickery borrowed from in-place immutable data structures, their allocated memory can be reused in place minimising reallocation. Clear move semantics and limitations on moving mutable references Rust-style would make static analysis possible in most cases. Tailcall recursion shouldn't be a problem, because as long as the end condition is deterministic, the continuation's lifetime is entirely bound, and they're allocated as lexical regions (which I guess would need to be defensively sized). However, coroutines are tricky and I'm kinda lost. So far the idea I've got is a two-tier system signalled by an effect signature as in Koka? I'm not sure this isn't bullshit but so far my idea is: when all suspension points are enumerable as a flat struct and execution order can be proven, then the coroutine is defunctionalised and the suspension points are matched against, just like your average async function, or the coroutine is split into functions and the suspension points are function pointers, so there's kind of like a CPS flow with delegate dispatch. If the stack depth of the caller can't be worked out statically, then the compiler inserts a stackful fiber allocation with its own memory region on first call, and the code needs to explicitly call an effect handler, like OCaml's effects, then the continuation's memory can be reused in place as long as the coroutine has a single owner (which, I think, should always be true? because async/await and generator type constructs are semi-coroutines with a single return point, and callers block on await right?). And if the effect signature and effect handler call isn't right, then the compiler gives an error and halts. For parallellism, it'd be the same kind of stackful fiber, but each one would own a fully encapsulated region, and each fiber would communicate through an actor model-style mailbox, and messages could only be passed to concrete fibers and ALWAYS be full ownership moves to ensure thread safety. So the move/lifetime semantics could be type-based kind of like Rust: either freely copy-able but strictly immutable and not reusable allocation wise (i.e. your plain old local stack values), or affine which can be moved but that there can only be one live reference at any given time and it might or might not be consumed (which would be the basis for continuations that can be dropped on branching, meaning they can't be reused in place), and linear so they're like affine so unique and moveable but it is known they will be consumed at it will be exactly once no matter the control flow, which would allow memory management of normal one-shot continuations and reusing their memory in-place. Since these are type-bound, the compiler should know everything it needs to manage lifetimes, just like Rust does, right? And then coroutines could be called with, besides an effect handler, an explicit scheduler, kind of like Kotlin's Dispatchers.
I'm not sure how the compiler would work because I don't know whether any of this really hold water, but I'd expect something like lexing -> parsing and type/effect/useage-type checking -> unrolling effect handlers and coroutines -> tco/contification of recursive loops -> sorting coroutines into defunctionalised structs/delegates vs stackful fibers -> region inference and inserting allocators/deallocators -> Koka-style reusability analysis (with literally Perceus I guess? but extended to continuations and control flow???) -> generating intermediate representation in C?? LLVM??? -> passing on to backend for final compilation
I don't know, maybe I'm full of shit, I'm just obsessed with the idea of a functional language that does the Rust thing. Basically the novel thing would be continuation-passing control flow being the same as borrow checking, so linear continuations based on reusable regions, and stackful fibers when the calling site is recursive or somehow opaque.
2
u/Mission-Landscape-17 Jul 24 '26
Unless you think programming is now a solved problem the answer has to be yes absolutely. That said I'm not sure that the borrow checker is in fact revolutionary. For it to be called revolutionary we would have to see languages with borrow checkers actually take over, and this hasn't happened. I'm not saying it can't happen, I don't know, just that it hasn't yet.
5
u/alphaglosined Jul 23 '26
The following list is off the top of my head of features that exist for program security:
However, you really need to understand what the borrow checker is, its escape analysis with a single observation attached to it: perhaps we shouldn't allow reference counting borrows to have a longer lifetime than the RC owner. It was inevitable given escape analysis and with that improved hardware.
But all the last 15 years of work has been towards adding abstract interpretation capabilities to compilers and languages now that the hardware has caught up to have enough resources to do it. Plus, with the growing body of CVE's its pretty clear that this stuff isn't optional.
2
u/arthurno1 Jul 23 '26
Well, if you are interested about compile time programming, Common Lisp has had it since invention. You have the entire language available to you at compile time. Quote operator gives you access to the unevaluated code in internal format you can manipulate and expect with ordinary tools as any other data, so no special api, syntax or tools. Super simple evaluation rule makes to source uniform and predictable thus easy to work with. All those features have been there sonce 1980's but people are ignoring them and going for lesser tools, because Lisp has parentheses 😀. And yes those features are much more revolutionary than borrow checker.
1
u/flatfinger Jul 23 '26
The "feature" I would like to see would be a recognition of most program/function executions as having three states:
Many programs may and functions over their lifetime sometimes be invoked in situations where they can perform useful work, and sometimes in situations where they cannot (typically, though hardly exclusively, because of invalid input or a lack of resources). Useful program execution often requires precisely specified behavior, but when that is not possible a variety of behaviors may be considered equally tolerably useless. A compiler that is allowed to freely choose from among such behaviors may be able to more efficiently satisfy requirements than one which treats all executions as either being totally defined or totally undefined.
Consider the following function:
It would be reasonable to assume that x will be less than 32768 on any useful invocation of that function. In many scenarios, however, getting stuck in the loop would be considered an "acceptably useless" response to an overly large
x, as would be cleanly skipping execution of the loop if nothing would make use of the function's return value. What would not be "acceptably useless" would be performing a store toarr[x]when x is greater than 32767. A good language should allow the compiler the option of either executing or skipping the loop in cases where x is greater than 32767 and the return value is ignored, but not allow a compiler the option of generating code that could perform an out-of-bounds access toarr.1
u/WalkerCodeRanger Azoth Language Jul 23 '26
You have narrowed down what you are looking for more than the title suggests, so I am not sure if you will count some of these.
I am working on a language Azoth, with what in the literature are called reference capabilities. This is something like a relaxed borrow checker for GC languages that gives the same fearless concurrency guarantees. I think that might be an example. As an example of the innovation this leads to, the combination of reference capabilities with reference and value types has led me to the creation of a new hybrid category of types. Where the initial instance of a type acts as an affine value type, but other instances are reference types. The distinction of when you have a value vs a reference is controlled by the reference capability.
Another example is structured concurrency. While various libraries and languages have been adopting elements of it, we haven't seen a language built around it. I think it is the kind of paradigm that will give most of its benefits in a language built for it, where all code follows the paradigm.
Of course, the real answer is probably yes something we aren't even thinking of now. We still live in the dark ages of computer programming.
1
u/paul_h Jul 23 '26
Not new, but I really love the DSL idea that's like https://paulhammant.com/2024/02/14/that-ruby-and-groovy-language-feature. Not just UI markup, also as a general purpose way of composing apps
1
u/kwan_e tonal-lang Jul 24 '26
I personally wouldn't call the borrow checker revolutionary. It's just a linter enforcing certain rules that is part of the compile chain.
So if that passes for "revolutionary", then the next feature would be some sort of extra linter that becomes part of the compiler.
In that vein, the next fundamental and revolutionary feature would be something in the language that spans the whole build process past the compilation phase. But without the "save to program image" that the LISP and Smalltalk family uses. It would integrate into CI/CD/packaging
1
u/JeffD000 Squint Jul 24 '26 edited Jul 24 '26
Yes. You can eliminate all kinds of errors by turning allocation/deallocation decisions over to the compiler, rather than using library functions such as malloc()/free() for creating and destroying memory. A relational database "data type", properly constructed, can allow you to competely eliminate indexing errors in programs (e.g. a[i] = b[i] + c[i] would flag an error if a, b, and c were not all fields defined over "compatible" topological spaces. Furthermore, explicit array indexing on any field is not needed in such a language, since all operations could occur through indexsets with deep relational semantics.)
1
u/RedMe5432 Jul 30 '26
An interesting topic can be the CALM paradigm for writing distributed systems with some consistency properties proven by construction. The most recent project is https://hydro.run/
"Hydro helps you avoid distributed systems bugs at each stage of development. Just like Rust ensures memory safety through the borrow checker, Hydro ensures distributed safety through stream types. These types have zero runtime overhead; you retain full control over the network protocol, compute placement, and serialization format."
An older paper about the CALM paradigm is https://dsf.berkeley.edu/papers/cidr11-bloom.pdf
A "fun fact" is that these approaches can be superior also to relational DBMS, because often (nearly always), relational DBMS do not run with full ACID transactions enabled. The CALM approach is probably a more pragmatic and honest one, because it combines performances and guarantee consistency of some properties.
1
u/MarinoAndThePearls Jul 23 '26 edited Jul 23 '26
Zig's comptime.
Now for something that doesn't exist yet, I'd say numerical uncertainty as a primitive type.
6
u/[deleted] Jul 23 '26
[removed] — view removed comment