4 ms·
> Wow. Listen: code written in languages heavy with sigils and shorthand are hard to understand, read and most importantly: maintain. As someone who maintains
by kouteiheika 5y ago
> Wow. Listen: code written in languages heavy with sigils and shorthand are hard to understand, read and most importantly: maintain.
As someone who maintains a 145k line Rust codebase all on his own, I have to hard disagree on this one.
Once you get used to the syntax it just blends into the background and becomes a non-issue.
> This adds a mental load which is -- as clearly visible from above -- is totally unnecessary.
Totally unnecessary? Okay, so how would you do the following with the sigilless syntax (and disambiguate between them):
- Specify a unique reference? (`&T` is shared, `&mut T` is unique)
- Specify a lifetime? (`&'a T` is a reference to T with lifetime `a`)
- Specify a raw pointer? (`*const T` and `*mut T` are const/non-const raw pointers)
- Specify that the argument is moved into the function? (just the raw type `T`)
People have been trying to come up with a better syntax for Rust, and AFAIK so far nobody has been able to do it. There's always a tradeoff somewhere that ends up making matters worse than what we have now.
- Aeolun 5y ago> Specify a unique reference? (`&T` is shared, `&mut T` is unique) shared T shared mut T > Specify a lifetime? (`&'a T` is a reference to T with lifetime `a`) shared T lifetime a > Specify a raw pointer? (`const T` and `mut T` are const/non-const raw pointers) const point T point mut T > Specify that the argument is moved into the function? (just the raw type `T`) T
- conradludgate 5y agoWhile this may be better in retrospect, it doesn't mean it's how Rust should have been. Rust was designed to replace C++, so using more C++ was probably the right call to get people to consider it more. I do disagree on the syntax for the references though. I prefer they be easier to type than the owned versions (eg &[u8] vs Vec<u8>) as this can promote the usual better choice (this is a weak argument, I acknowledge). I do wish that history had chosen a different symbol for references though. But there's only so much we can do now
- iamthemalto 5y agoInteresting idea, but honestly that seems too far in the other direction. A midpoint between the two ends that optimizes both brevity and readability is probably ideal.