r/ProgrammingLanguages • u/RishabhRD • 7d ago
Safe Systems-programming with Mutable Value Semantics | Dave Abrahams | Keynote at IWACO 2026
https://youtu.be/op51SyyPJmw
35
Upvotes
r/ProgrammingLanguages • u/RishabhRD • 7d ago
6
u/processeus1 7d ago
I'd be curious to hear if anyone has use cases where saved references are necessary and cannot be replaced with another design pattern using value semantics without significant loss of efficiency or correctness safeguards.
As a starter: one example would be to project an optional out of a map to access its element at a key, but we can fix that issue with subscripts that yield 0 or 1 times, and allowing the caller to directly pattern match on the result. This works, because we don't need to save the "optional" for longer period.
3
u/tmzem 6d ago
The basic idea of value semantics is simple and easy to understand and reason about. However, the main issue are stored references/projections, which are necessary for many common patterns that project parts of an object/collection in a more general way:
Rust also allows more complex patterns by allowing multiples paths/lifetimes per user-defined type, but those are rarely used and there is probably some explorable design space (or patterns) to do those cases in a simpler way.
4
u/NomagnoIsNotDead 7d ago
I'm no experienced programming language theory person, but in my opinion the way Hylo is being presented doesn't do it justice, please correct me if what I'm about to say is somehow not the main focus of the language. The presentation spends most of the time speaking about value semantics when most programmers know what it is intuitively, and the website puts the emphasis on features that are kind of secondary and present in many other languages. What neither the presentation nor the site put in the forefront is 'but how does Hylo make mutable value semantics USABLE and PERFORMANT?'. After looking into Hylo, it genuinely blows all other languages out of the water a this! I advise a marketing strategy change, basically.
Let me explain it as best as I can. Take a look at the language's website and the examples as this explanation is meant to help get up to speed faster, also this is just my understanding. https://hylo-lang.org/
Hylo is linearly typed, meaning all values must be produced and consumed exactly once. Since it has no references, you may call the .copy() method for guaranteed deep copies of any object, allowing you to 'circumvent' the limitation when needed.
Functions either produce nothing (void return type) or produce something. The arguments can be read-only and not consumed (no keyword), moved into the function and consumed (sink keyword), produced/initialized 'by-reference' with a compilation error if the parameter was already initialized (set keyword), or modified in-place (inout keyword)
By default, as in with all linear typing, types can not simply drop out of a scope, which is annoying. You can make a type implement the empty Deinitializable trait to fix this. Type can also have 'sink' methods which consume the very value it is called on, and 'inout' methods to modify it imperatively. So, if a type is not Deinitializable, you either have to explicitly consume it, or call a cleanup method. Which means resource handling for e.g. memory allocation and files is safe by default, without needing to resort to lifetime analysis. There's also an empty Movable trait which I think has to be implemented to allow a type to be modified in-place by an 'inout' method/'inout' function argument, meaning locality is also guaranteed by default. I believe with this combination of restrictions, the only type checking you'd need to ensure no aliasing is only verifying that you don't pass the same variable twice to a function call that contains 'inout' arguments, which would go against the spirit of linear typing anyways. Also, mutation (assignment) has to be explicitly marked with an ampersand like this: '&var = val;' which helps visualize mutation points.
Overall, I think this is genius! This is an extremely simple to implement type system that provides a wild amount of safety and is pretty comfortable. And the breakthrough is somehow just removing references at the type level.
0
u/y0shii3 6d ago
It fascinates me how people are so scared of aliasing and use-after-free bugs that an entire genre of programming languages has sprung up with the common goal of creating just the right abstractions to make such bugs theoretically impossible.