Fulfilling a Pikedream: the ups of downs of porting 50k lines of C++ to Go

Just a few quick comments on Rust:

Rust definitely has less powerful templates than C++.

Yeah. Both generic value parameters and variadic templates are high on the list of "very want" features for post 1.0. This is why when traits are implemented for static arrays and tuples, they're implemented up to a fixed number of elements, since each size has to be done separately.

shadowing within a scope

Honestly, I've never had an issue with it. It's massively useful for writing functional-flavoured mutation code. Plus, the borrow checker makes it really hard to make any mistakes with this. But I can definitely appreciate why you'd be suspicious of it.

Then there is this thing with two string-types and no implicit conversion between them even though it would be completely safe in both directions.

I admit I'm a little surprised; I'd have expected C++ devs to be in favour of this. The distinction exists to ensure that both non-owning strings (string literals, slices into larger strings), and owned strings are efficient. Currently, I believe the language will implicitly coerce from a &String to a &str. There's no implicit &str → String conversion because that would involve implicit allocations, and Rust errs on the side of being explicit. It would be safe, but slow.

code should be written for humans, not computers

True, but there are trade-offs here. C++ being difficult to parse has caused so much grief over the years, I don't really see a huge problem with adding two extra characters to disambiguate. Besides, having to explicitly specify template parameters doesn't come up all that often.

To be honest, aside from the two major generic deficiencies, and in some cases traditional OO abstractions, I'm really not missing anything else from C++.

Still, each to their own. :)

/r/programming Thread Link - togototo.wordpress.com