Hacker News new | past | comments | ask | show | jobs | submit login

Can you give examples of C++ code which would not require you to keep the ownership or borrowing straight in your head, and which a port to Rust would cause you unnecessary verbosity?

I usually find that if my C++ code required little to no mental tracking of ownership or borrowing or lifetimes, the rust was straight forward. And if the rust was complex, the C++ required me to keep too much in my head (or even had bugs).




Technically, all code requires you to keep track of ownership and borrowing. In cases where these are intellectually trivial concerns (which, I would argue, are by far the most common cases), Rust's forcibly explicit approach is, if you accept the assumption of the previous sentence, unnecessarily verbose by definition.

I cannot address the latter part of your argument (the more important part, I think), however, because as I stated, I have not invested serious effort in Rust. Intuitively, from the code and documentation I've seen, I'd be wary of trying to implement, say, highly performant (emphasis on the performance) cyclic graphs in Rust rather than C++, but that's merely an impression, hence my interest in learning more. And certainly, whatever the difficulty, the likelihood of bugs in C++ would be higher.


I don't find rust verbose unless I am dealing with complex situations though; that was my point.

Move-by-default, elided lifetimes on many parameters, etc, are all verbosity-free.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: