r/ProgrammingLanguages • u/FedericoBruzzone • Apr 30 '26
The Mutable Value Semantics (MVS): A Non-superficial Study
I’m researching a new semantics for a new language. During this process, I studied the Mutable Value Semantics (MVS) and I wrote a post about it. I simply want to share this study with you all and I'd love to hear your thoughts.
A new post will be coming soon where I'll discuss the limitations I’m finding in current models, and what I’d like to have for my own.
28
Upvotes
View all comments
Show parent comment
6
u/l33n44 May 01 '26
Hylo dev here, you caught my attention ;)
I'm very happy to see others experiment with MVS and very curious to see what conclusions you'll make from this little adventure!
I am quite convinced that the ability to return references is not necessary for the vast, vast majority of use cases, including algorithms over collections. Overall it is a very expensive feature for your type system that brings little benefits if you also want an ownership model capable of guaranteeing exclusive access.
The iterator model of C++ is deeply tied to reference semantics and a typical motivation for supporting some kind of references. But that's not the only way to abstract over collections, as Swift already demonstrates. One can represent positions with independent values (e.g., indices) and use inversion of control to access the contents of a collection. In my very biased opinion, removing references in favor of this model makes the APIs of generic algorithms dramatically simpler, as one no longer has to constantly wonder where the `&` goes in a for loop.
In general I believe that the ability to store references is overrated in languages upholding exclusive write access. There's very little one can do with references that cannot be reproduced using Hylo's projection mechanism (i.e., the subscripts) or via independent identities. The performance is not better either, sometimes even worse. I wrote a paper about it, titled "Who Owns the Contents of a Doubly-Linked List". Also note that Hylo's projections are not even strictly less expressive than first-class references.
Remote parts are only for the closures and they are not strictly necessary. They capture somewhat formally what the compiler can figure out abut the environment of a closure, mostly for the sake of optimization. In Hylo we insist on representing environments in the type system to avoid dynamic allocation across function boundaries. But not every language has to care about every last bit of optimization. One could just assume that all captures are copied in some box deallocated by the closure's destructor and only attempt to optimize that box away opportunistically. Conversely one could also prevent closures from escaping so that their compiler could use references under the hood without having to track lifetimes.