0
I finally got around to learn Rust. Well, starting to.
It’s amazing.
I’m comparing this to learning Basic, C, C++, Erlang, Fortran, Go,
Javascript, Pascal, Perl, PHP, Prolog and Python. I wouldn’t say I
know all these languages well, but I do know C, C++, Go, and Python
pretty well.
I can critique all these languages, but I’ve not found anything
frustrating or stupid in Rust yet.
Rust is like taking C++, but all the tricky parts are now the default,
and checked at compile time.
Copies
With C++11 we got move semantics, so we have to carefully disable the
(usually) default-created copy constructor and copy assignments, or if
you have to allow copies then every single use of the type has to be
very careful to not trigger copies unless absolutely necessary.
And you have to consider exactly when RVO kicks in. And even
the best of us will sometimes get it wrong, especially with
refactors. E.g. who would have thought that adding this optimization
would suddenly trigger a copy of the potentially very heavy Obj
object, a copy that was not there before?
--- before.cc 2022-12-28 10:32:50.969273274 +0000
+++ after.cc 2022-12-28 10:32:50.969273274 +0000
Continue reading