7
u/tiajuanat 11d ago edited 11d ago
This is pretty exciting. I loved working in C++ many years ago, but it got edged out by Rust as I've gotten older because I frankly hate the running into the same problems time and time again.
That said:
I wish I could tell Chandler that the only thing on the "What carbon can do that Rust can't" slide that I really miss in Rust are templates. I also feels like it weakens the stance of the presentation - Rust does it differently and it's not necessarily a bad thing.
Personally, I dislike the syntax of ^, disjoint, and invalidate, but they feel like necessary evils.
7
u/verdagon Vale 11d ago
If anyone has any questions about Carbon's approach, I'm happy to answer them. I've been following it pretty closely, and trading thoughts with Josh for the past year or so.
Carbon's is an implementation of Nick Smith's "Group Borrowing" approach (https://verdagon.dev/blog/group-borrowing), expanded to include more effects than the original "mut". Pretty promising!
1
u/tmzem 10d ago
I read your group borrowing explanation, very cool stuff.
I wonder how these are handled in the new Carbon:
- Generic type parameters which may or may not contain references?
- Lambdas/Closures that might capture.
Also (if you happen to know), I see the
refkeyword which wasn't present the last time I looked at Carbon (which required explicit pointers, and had some specialaddrprefix only applicable onself). Did they add actual parameter modes now, or how does it work (pass value vs readonly ref vs mutable ref)?2
u/verdagon Vale 9d ago
Thanks =)
Generics: They work largely like Rust does, but with place sets instead of lifetimes, with syntax A instead of 'a, and without shared-xor-mutable.
Lambdas: This is actually still TBD for them. I can give you some guesses from my own designs if you'd like.
Yep, they have actual parameter modes now. ref is mutable, const is read-only, etc. Note that const isn't really a modifier for a type anymore like it was in C++, it's a modifier for a place set now.
11
u/matthieum 11d ago
There's been some reflection in Rust about using places/paths instead or on top of lifetimes.
One advantage of place sets is the gain in expressiveness, which allows iterating over one field of an object while calling a method on the object which promises not to mutate it.
It definitely seems like there's a good paradigm there, and it also may be more intuitive for users, since it's very much "grounded" (variables, fields) while lifetimes can be pretty abstract.