r/rust • u/dabrahams • 8d ago
đĄ ideas & proposals Safe Systems-programming with Mutable Value Semantics | Dave Abrahams | Keynote at IWACO 2026
https://youtu.be/op51SyyPJmw?si=P5QH6M8Hdf4_CUUZI gave this talk about the Hylo programming language at IWACO last month. I had a lot to say about Rust, so thought it might be of interest here.
8
u/Shnatsel 7d ago
Graydon Hoare, the original creator of Rust, didn't want explicit lifetimes in Rust either: https://archive.is/VM05I
From his article:
the dominant use-cases have to do with things like exterior iterators and library-provided containers
So these are the places I would start looking into for limitations of the Hylo model.
But really, that entire article is worth a read.
6
u/dabrahams 7d ago
Thanks; weâre familiar with that article and believe we have answers for those particular cases. Proof is in the pudding of course!
4
u/tialaramex 7d ago
Hylo's web site has a "blog" link with three blog posts in 2025 but in fact two of those posts basically just say "TODO". Such as this one: https://hylo-lang.org/blog/what-we-mean-by-safety/
A year later it's too late to tell us (and perhaps to remember) what you meant by safety in October 2025 but I think Hylo should remove these TODO items and if appropriate the whole blog.
5
u/dabrahams 7d ago
Thanks for the pointer. If you still care what we meant, see https://github.com/hylo-lang/hylo-new/blob/main/Docs/Safety.md
2
4
u/JoJoModding 7d ago
This talk is about Hylo and its mutable value semantics. For people here (in r/rust), Hylo can best be summarized as "what if references but only in function arguments?"
This is quite powerful, especially when coming from functional programming. But it does not allow e.g. Cell or Mutex or other shared mutable state (idk if they do concurrency at all?). It does not prevent iterator invalidation. Many things (like index_mut on arrays/vectors) are under the hood desugared to chaining functions alike to modify_at(&mut self, idx: usize, f: impl FnOnce(T) -> T) instead of having real references in return position. (And they use coroutines to make it nice but that of course requires a whole runtime.)
But I did not watch this video, I only read the paper (some time ago)/docs (cursorily). Maybe they added some new things I am not aware of.
2
u/dabrahams 7d ago
You can think "what if references but only in function arguments?" but one of the points of the talk is that you don't have to think about references (and accept the associated mental tax) at all.
I encourage you to watch the talk; I make points about Rust and references thatâto my knowledgeâhaven't been expressed anywhere before.
it does not allow e.g.
CellorMutexor other shared mutable stateNor do Rust references! In either language, if you want those things you have to build them using using unsafe parts.
Many things (like
index_muton arrays/vectors) are under the hood desugared to chaining functions alike tomodify_at(&mut self, idx: usize, f: impl FnOnce(T) -> T)instead of having real references in return position.Almost; they are desugared into higher-order functions but in such a way that doesn't imply lexical lifetimes.
(And they use coroutines to make it nice but that of course requires a whole runtime.)
No, as mentioned in the talk, in fact we do not use coroutines and this mechanism requires no runtime. Everything is decomposed in terms of plain functions.
1
u/JoJoModding 7d ago
I apologize for not watching the talk, but I do not have the time to watch an hour of video where reading would be much quicker. If you have the slides somewhere, I will click through them đ
Since I do not know Hylo, I wonder how it does things like Cell or Mutex? In Rust they might be implemented using unsafe code but that does not matter at all and the fact you bring it up makes me think you missed the key point: these are safe abstractions whose safety is ensured by the type system and these ones in particular are often hard to support safely in other type systems. Rust is not about the references, it is about the lifetimes, which make having safe APIs for these types sound.
And I do not think references are mentally taxing. At least not more than figuring out where and how values are mutated in Hylo. The same mental model works for both.
And your final point confuses me as well: I take it that coroutines are compiled by inlining (and compiler magic that figures out where to call them and how)--but that retains the "rigidity" of a call stack and makes it impossible to call functions that would, in Rust, return references, especially when these functions are opaque to the compiler (because they are e.g. written in C). The compiler relies on being able to insert the "slide" at the "lifetime end" position, which means it must know what the slide is. Right?
2
u/dabrahams 7d ago edited 7d ago
Fair warning: if you want to try to understand what I'm saying without watching the talk it'll likely take you more time than it would to watch the relevant parts of the talk, because the talk is carefully designed to present the material efficiently and completely, and because there are timestamps that let you easily skip the introductory material. But if you really think it'll save you time, the slides are here. You won't get the talk contents by looking at the slides alone, but if you read the presenter notes while clicking through the animations, and you click at the right points in the presenter notes (mostly marked by
>>) you'll get everything except audience interaction. There are options to show the presenter notes while playing the deck.Hylo âdoesâ
CellandMutexprecisely the same way Rust âdoesâ, i.e. the language doesn't do it, or even allow it in the safe subset. Someone builds safe abstractions using unsafe parts, and these particular abstractions are no harder to build in Hylo than they are in Rust.Rust is not about the references, it is about the lifetimes
I don't know what that means, but the two things are deeply coupled. Without first class references, there's little motivation for the lifetimes feature. What the lifetimes feature adds on top of something much simpler is a slightly more fine-grained ability to track lifetime dependency relationships and the ability to store references⌠temporarily. The value of both things is in the margins of utility and comes with a huge complexity cost, and neither is needed to make a sound API for
CellorMutex.And I do not think references are mentally taxing.
â𤡠just get good at referencesâ ;-). Less glibly, the argument about a mental tax are nuanced and the talk presents them well; there's no way I can do it justice here.
âŚAt least not more than figuring out where and how values are mutated in Hylo. The same mental model works for both.
Well⌠yes, if you mean you can use the same complex mental model to think about both Rust and Hylo. There's a simpler mental model that works for Hylo but does not cover everything Rust references do. Again, I feel like you can't appreciate this without watching the talk.
The compiler relies on being able to insert the "slide" at the "lifetime end" position, which means it must know what the slide is.
The slide gets passed as a parameter to the plateau function, which calls it in the right place, so knowledge of the slide's contents exists only on the callee side of the opaque boundary between caller and callee.
1
u/JoJoModding 6d ago edited 6d ago
I tried finding the Hylo Stdlib Mutex, and could not really. Can you? What does the API look like for locking and unlocking?
In Rust you have "RAII" mutex guards whose lifetime ensures they are dropped before the mutex is deallocated. (Or rather, it ensures they and the mutex content are last accessed before the mutex is deallocated because of the type system being affine, but whatever.) In other words, they have a reference internally but this is really just an implementation detail.
And Rust has ghostcell, which has lifetimes but no references. Which is what I mean by "Rust is about the lifetimes" -- it can do more with them than just references. Similarly about Hylo you might say it is about MVS and the ramp-slide continuation thingy.
2
u/dabrahams 6d ago
Hylo's implementation is still immature and there's a lot you won't find in the standard library at this point. There wouldn't be a point in building things like Rust's
Mutexuntil we stand up some more parts of the core language mechanics, but I imagine it would be something like this:public struct SharedMutable<T> is Regular { init(start: sink T) subscript self() -> T { let inout } }You'd use it by creating
var x = SharedMutable(someInitialValue)and then you'd access the shared value (with synchronization), asx[]. I mention how subscripts enable this around 56:00.The talk is about Hylo's core language. Everything you're talking about here is outside the core Rust language and thus implemented in libraries. They would be the same in Hylo, and in the cases I've seen we'd be able to provide an equivalent API, or sometimes, as in this case, a nicer one.
FWIW I am not compelled by ghostcell. It seems to be solving a problem that in practical cases can be handled much more simply without any significant loss of efficiency. But I also would not be at all surprised if a similar API could be implemented in Hylo.
1
u/JoJoModding 5d ago
I am not convinced by the "core language vs library" distinction. A good type system enables interesting libraries/APIs. Rust has demonstrated this. Hylo has not. Writing a (bad but sound) Mutex/Cell/RwLock/... is really not that hard, you could just do it and you would learn a lot about what works and does not work.
1
u/dabrahams 5d ago
That distinction wasnât meant to convince you of anything. Rust has demonstrated many things that Hylo has not! It is a mature language with a proven track record.
I know writing these things isnât that hard. Iâve done those things and many more in Swift where we have all the same primary features, but also a robust environment for testing, etc. itâs just not a very good use of time to explore certain library designs in Hylo when the generics system is only partway working, printing to the console as a challenge, strings are only partially implemented, the diagnostics are poor, etc.
2
u/JoJoModding 5d ago
I see. I am sorry if I came off as antagonistic. I can totally see that there are many things to work on right now and I look forward to Hylo being more ready--it sounds like it will be a fun language to use, and maybe even the best language for some niches. Best of luck with the development.
8
u/BoringAccount-_- 8d ago
Wow. I usually donât just watch hour long vids like this but, I did and it was awesome!!
6
2
u/dabrahams 6d ago
Hylo is a very young language and there will be a lot missing from the standard library until weâve finished building out the core language implementation. Hijacking destructors to do things other than destruction is a hack. Hylo has a much better approach to mutex unlocking, which is discussed in the talk. Watch if youâre curious⌠or donât!
1
u/Professional-You4950 6d ago
Do you have a rough Idea what Sync and Send would like in Hylo? I struggle to see how this would work without another set of abstractions in keywords like subscript, inout, `@unprojected` etc.
I also don't necessarily like yield. Why couldn't the return type/value in the function signature be the return value at the end of the function body?
2
u/dabrahams 6d ago
They will look like ââ đ . There's no need to classify types that way if all safe types can be copied/moved to other threads. The tiny win you'd get by having these traits is the ability to express a type with shared mutable state whose safe operations would be unsafe if it were copied/moved to another thread. Hylo's philosophy is: shared mutable state does not have value semantics. You can do it if you really want to, but if you want to call accesses to it âsafeâ in Hylo, you will pay for some mechanism that prevents data races when it is accessed from multiple threads. Simply put, those traits don't pay for their complexity with a commensurate benefit, and we're willing to âexpress just a bit lessâ to avoid them.
Why couldn't the return type/value in the function signature be the return value at the end of the function body?
If all you have is a return is at the end of a function body, there's no place for a slide, and you can't do the things described in this part of the talk: project a mutable bool out of a bit vector, project a mutable slice out of an arbitrary collection, project synchronized access to shared mutable state, etcâŚ
4
u/SkiFire13 7d ago
It's a bit weird to me that the "Abstraction leak" example is criticized in Rust, but the same example is brought back in the Hylo's "Finer grained lifetime dependencies" slide, arguing that it might not be an issue in practice.
In my experience the situation of throwing the same lifetime everywhere is a pretty common source of issues for beginners. It generally works in simple cases, but as soon as you have a slightly more complex situation where you should really give different lifetimes to different references it breaks down.
I believe this is a fundamental issue with any kind of default for aliasing: you can choose a model where everything alias by default, or nothing alias by default, but ultimately both of them will be wrong for some cases and only the user will be able to reasonably know what is the correct aliasing contract for the function.
4
u/dabrahams 7d ago
I think youâre probably referring to why I said a compiler couldnât be allowed to look inside function bodies to deduce lifetime information. Thatâs just a constraint on any language with separate compilation, not a critique of any particular design decision.
2
u/processeus1 7d ago
Do you have some examples where we would need finer grained lifetime dependencies, e.g. @unprojected?
2
u/dabrahams 7d ago
Need? No. Slides starting at 147 (where
@unprojectedis introduced) give an example of where you might want them. But as noted in the talk, it's a toy example, and we want to see how the minimal design plays out in the real world before adding such a feature.1
u/processeus1 6d ago
Yeah, I asked for examples so that we are aware of them. Not suggesting that it should drive the language design, but I'm still curious.
1
u/dabrahams 6d ago
Sorry, didn't realize who you were, so didn't know you were asking on behalf of Hylo!
1
u/Own_Designer_3819 6d ago
Thanks for this. I watched the whole video. I consider myself adept in C, C++, and Rust. My personal experience watching the video (YMMV) was that the beginning to 51:14 was too slow, and from 51:14 to the end was too fast (I understand that there is no "one size fits all" presentation, just providing feedback). One thing which I think would help me would be an explanation for how "subscript" is "lowered" to normal function calls in any of C, C++, Rust. Do you have any documentation on that, preferably with a few examples? My intuition is telling me that there's something interesting here and I'd like to dig in more. Thanks again.
1
u/dabrahams 6d ago
Sorry it's not in terms of C, C++, or Rust, but I think it should be easy enough to understand this posting. If not, please feel free to ask questions and I'll do my best to help.
1
17
u/teerre 8d ago
The other I googled your name and saw you're retired. Combined with all that is going on in the world of software engineering, it made me a little sad. I'm glad you're actually still around! Love your talks!