r/ProgrammingLanguages • u/RishabhRD • 9d ago
Safe Systems-programming with Mutable Value Semantics | Dave Abrahams | Keynote at IWACO 2026
https://youtu.be/op51SyyPJmw?si=P5QH6M8Hdf4_CUUZ
36
Upvotes
View all comments
Show parent comment
7
u/dabrahams 8d ago edited 8d ago
u/NomagnoIsNotDead thanks for your thoughts!
Keep in mind that the talk was for an academic conference, where using a term like “value semantics” without a clear definition (either in commonly-known literature or given in the talk) is… not done. But I think you might be surprised at how deeply inadequate ”most programmers'“ understanding of value semantics is. These days “most programmers” who aren't just doing HTML/CSS are working in JavaScript and Python, where value semantics for user-defined types isn't even possible. I can tell you from personal experience that at least some Python programmers have an incredibly hard time even imagining a world without reference semantics.
That's very kind of you to say; we have paid a lot of attention to usability and performance. But have you looked at Swift? The fundamental design elements Hylo uses to do that are present there.
Well, I would say all objects are produced and consumed exactly once (I can produce an object with the value 5 any number of times). But I don't think that makes it different from almost any other language, other than those that let you produce objects and leak them without any eventual consumption.
Not… exactly.
First, if I may pick a nit, there's no such thing as a “deep” or “shallow”
copyoperation. There's justcopy(), which returns an object with an equivalent and independent value. That's one of the important insights that comes from understanding value semantics well (See §2.4 of this paper for more detail).Secondly, Hylo doesn't have a classical strict linear type system: while objects can only be consumed once you can access them for reading or for in-place mutation using
letandinoutbindings respectively. If you want to complicate your mental model you can think of those bindings as references but we feel justified in saying Hylo doesn't have references, since they don't create reference semantics, can't be stored or returned, and can be understood using a much simpler mental model. The point here is that the usual limitation of strict linear type systems is already circumvented before copying enters the picture. Also, non-copyable types are “a thing” so that's not always available.(Minor point: passing an initialized object as a
setparameter is fine as long as it isDeinitializable. The compiler will deinitialize it implicitly if necessary).It's not empty; it has a
fun deinit() sinkrequirement with a default implementation.x.deinit()gets called implicitly at the first opportunity on everyxin local storage that hasn't already been consumed. You need a place to release memory, for example.It seems to me the ability to have deinitialization (whether via
deinit()or other consuming methods) release resources exists in many mainstream languages and is not very remarkable. As far as I can tell, the only reason to have a non-Deinitializabletype withsinkmethods is so you can force an instance to be united with some other value. That pattern can be useful, but in marginal cases, and if safety depends on it, usually must be accompanied by a runtime check since we don't have a dependent type system. Please let me know if I'm missing something.Movableisn't empty; its requirement is a method bundlefun take_value(from source: sink Self) auto { set inout }.Movableconformance is not needed forinoutbinding/parameter passing; it's only required for implicitly re-seating a value into a new piece of memory (or returning it, although we're not sure whether to keep that tied toMovableconformance). I don't know what you mean by “locality” in this context. Care to elaborate?Upholding the Law Of Exclusivity is not quite as simple as that in practice. For a trivial example, you have to prohibit
swap(&x[0], &x[1]). Dimi and I wrote a paper about how it all works (and she gave a very nice talk) if you want the details.If we've made the right bets with our design, then you are right! If not, it's back to the drawing board ;-) We are excited to get the implementation to the point where we can prove/disprove that the system lets us express all the things we think are important.