4 ms·
I remember strings being "not so easy" in C/C++ too.
by k__ 4y ago
I remember strings being "not so easy" in C/C++ too.
- oconnor663 4y agoI think the big differences are that copying and reference taking are automatic and invisible in C++. So a lot of APIs taking string or string& will "just work" for the beginners, and you can delay the part where you talk about how different those things are. This sounds like a minor difference, but I've met lots of developers who do meaningful work in C++ but who don't know what a copy constructor is. I get the impression that there's an enormous difference between being a C++ "user" vs a "library writer", because there's so much automatic stuff happing under the covers. Rust tends to have a bit less invisible complexity, I think, but some of that difference is just making the complexity visible (like reference taking), which effectively frontloads it onto beginners. It's a tough tradeoff.
- rocqua 4y agoI occasionally port my C code to C++ just for more ergonomic strings.