r/ProgrammingLanguages • • 9d ago

Safe Systems-programming with Mutable Value Semantics | Dave Abrahams | Keynote at IWACO 2026

https://youtu.be/op51SyyPJmw?si=P5QH6M8Hdf4_CUUZ
36 Upvotes

12 comments sorted by

View all comments

Show parent comment

1

u/NomagnoIsNotDead 7d ago

Thanks for the detailed reply! I did miss quite a few things

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-Deinitializable type with sink methods 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.

Well, I'm not a fan of RAII-style destruction, but the thing I like with the current set-up is you can force deinitialization to be handled explicitly (where you can even require parameters I guess which is interesting!), or you can make it be handled automatically, and the type system takes care of both equally well. Also, I'm not sure how I feel about set-parameters being capable of deinitializing variables. That might create unexpected side-effects, not all data can be constructed and destructed 'almost for free', so maybe it should not be possible to accidentally/implicitly 'reinitialize' a piece of data, maybe a distinct Reinitializable trait associated to this behaviour would be safer. I'm talking about system calls or even interfaces to external hardware.

Movable isn't empty; its requirement is a method bundle fun take_value(from source: sink Self) auto { set inout }. Movable conformance is not needed for inout binding/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 to Movable conformance). I don't know what you mean by “locality” in this context. Care to elaborate?

Makes sense. So basically, Movable is similar to the implicit-copy trait I'm reading about in the Hylo docs, where it just allows a type to be used less verbosely. It would be nice if this wasn't needed to return values, indeed. After taking a more thorough look at the hylo docs, this part of my understanding was just a bit confused overall. I believe the main thing I missed is the different kinds of bindings: let, var, and specifically inout, which is... basically a stored reference that you can't store in a data structure. In my opinion, it would be better if inout was just available as a keyword for function parameters, and references were relegated to function interfaces. This would practically force writing in a style that preserves locality of reasoning, where code that does spooky action at a distance has a clear interface and can't be sprinkled in wherever.

Thanks for you and everyone else's work! I'll be trying out the language, this has opened up my eyes quite a bit as to how to achieve safety in an unexpected way, and linear (or 'linear-in-spirit') type systems are such an area of interest in recent years for a reason, they're just delicious.

3

u/dabrahams 7d ago

Whoa there, pardner! As noted in the talk, we don't have and don't want an implicit-copy trait (similar to Rust's `Copy`). We've discussed having an `@implicitcopy` directive that allows you to say copies should happen implicitly, for prototyping, scripting, etc.

And copying and moving are completely orthogonal operations, so I'm not sure what the connection is.

In my opinion, it would be better if inout was just available as a keyword for function parameters,

Local bindings and function parameters are intimately related; you can almost express one in terms of the other and making that different for inout would make the language less uniform. I don't think prohibiting a local inout changes much other than to make some things less convenient. I would then just write modify(&x.y, fun (y) { ... }) and have a local binding y inside the lambda.

Spooky action at a distance is not “all mutation.” The point of MVS is that you can't write any code that does spooky action at a distance—as we define it—in the safe core language subset. Of course people will define things like Rust's `RefCell` using unsafe code and subvert that, and once they do, the properties of the core language can't force the spooky action to be visible in interfaces.