8 ms·
“Modern C++” is very powerful, but also incredibly frustrating. Take std::variant/std::visit (sum types) for example.[0] Getting the value out is way more compl
by colejohnson66 6y ago
“Modern C++” is very powerful, but also incredibly frustrating. Take std::variant/std::visit (sum types) for example.[0] Getting the value out is way more complicated than Rust. And if you mess up, expect an indecipherable multi-dozen line error message!
[0]: https://bitbashing.io/std-visit.html https://bitbashing.io/std-visit.html
- ncmncm 6y agoI.e., don't design in such a way that you need visit. Most often, it's wankage. Design to eliminate wankage, and hire to eliminate wankers.
- colejohnson66 6y agoBut that’s not the C++ way! /s In reality, C++ is insanely complicated, and you’d be right about needing to avoid “wankage”, but sum types make sense sometimes. But the C++ committee refuses to do what I would consider sane and implement pattern matching. Instead, they gave us `std::visit` and all the confusion that goes along with it.
- ncmncm 6y agoPattern matching is under development. It's not an easy thing to get right. C++26 will probably have pattern matching, and then sum types will have better support. In the meantime, they might not always be the best solution. Everyone complains about C++ complexity, and also about all the features they think should be added. But each new feature makes the language more complex. The language is the wrong place to measure complexity. Complexity people experience directly is in programs, instead. A well designed language or library feature makes programs simpler and more understandable. Obsolete language features fall out of use, and rarely occupy our thoughts. Mainly, when we find obsolete features in programs, that dates the code, and helps us know what to expect.