r/ProgrammingLanguages • u/verdagon Vale • Jun 28 '26
Ante: A New Way to Blend Borrow Checking and Reference Counting
https://verdagon.dev/blog/ante-blending-borrowing-rc
83
Upvotes
r/ProgrammingLanguages • u/verdagon Vale • Jun 28 '26
24
u/shadowndacorner Jun 28 '26
Always love your blogs. What happened to Vale, though?
3
u/Guvante Jun 28 '26
I don't understand why shared mutability is a super power here, Rust doesn't have mutable XOR shared due to memory safety concerns, it has that because shared mutation is almost impossible to get correct.
Note the comment about try_borrow "moving the problem somewhere else" the problem is breaking mutable XOR shared which again is vital for predictable code.
You can of course write code that has mutable sharing but it requires a lot more care and the issues aren't as simple as dangling pointers.
2
u/gplgang Jun 30 '26
I got worried after your last posts being so long ago after approaching the edge of the abyss of interop!
I really enjoyed those posts and had been wanting to try similar things with Rust FFI for a while.
Cool to see Ante has caught your attention as well! It seems promising
11
u/Effective-Spring-271 Jun 28 '26 edited Jun 28 '26
Sounds really interesting, however I feel like maybe I'm missing something because I don't see how this deals with memory aliasing?
Edit: I saw the other comment about the shared mutable references are not send / sync which means they can't be shared between threads. Suddenly all the answers make sense, thanks everyone!
16
u/farsightfallen Jun 28 '26
If i can be honest, I bailed half way through because it got bogged down by details specific to the language's syntax.
I also think that extraordinary claims about memory management should be made simple. Ultimately non-gc memory management isn't that magical or difficult - it just comes down to tradeoffs in implementation details. I would like those tradeoffs upfront. Like rust has shortcomings around partial borrows, and run time only checks for interior mutability. That stuff can be done statically, but it isn't because the language decided against it. It's always possible to have a special block with special rules that constrain the usage in a way that allows for guarntees. I just want to know those restrictions up front.
I guess that's essentially what the
uniqfeature is. But that's what 90% of the article should've been about, with a clarifications around it's usage, ergonomics, pros/cons, etc.side note, but I've never really thought about unions being good for performance; their main advantage has always been (for me anyways) to type-safely downcast, and do things like exhuastive checking.
4
u/ahh1618 Jun 28 '26
Fun read. Does the uniq cast work with concurrency? It looks like you're getting local assurances that nothing in your scope is going to delete something that you're modifying. And you know at compile time that you don't have two references to the same object if you don't have two references to the same type. I'm wondering if that assurance is enough if different functions are operating on the data at the same time.
3
u/Tasty_Replacement_29 Bau Jun 28 '26
Right, that's what my language is doing as well: combining reference counting and ownership / borrowing. And supporting multiple mutable borrows. (We messages about this at the end of 2025 here on Reddit).
I think it's a good option. I assume there are some differences in how Ante works and how my language works; I'm very interested in these details and will see if there's anything worth stealing :-) assuming there are no plans to patent this. (And feel free to steal from my language, if you find anything you could use.)
I think it's a really promising idea, and I think there is a relatively big design space to be investigated. Interesting times!
3
u/david-1-1 Jun 29 '26
This article says that unions (in the C sense) are unsafe. But giving each structure a unique type name makes them safe. A union value would contain at runtime the memory block plus type name, and it's totally safe. It's also safe when resolved into optimal code at compile time.
1
u/IAMPowaaaaa Jun 29 '26
Sounds minorly like TCell?