r/cpp • u/Its_Blazertron • Aug 25 '21
Experience C++ developers: do you enjoy using C++ (even for personal/hobby projects?)
Do you actually enjoy using C++, or do you only use it for work, or purely for performance? This question is aimed at people with years of experience, who've worked on large projects in C++. I see people who dislike the language, but use it purely for performance reasons. This sort of discourages me from learning it. I don't want programming to feel like work.
204
Upvotes
3
u/braxtons12 Aug 25 '21
The short version of the reason is we like things to not break our, or our users', code.
Doing a
using namespace std;is asking for ADL issues to happen eventually.If you don't want to deal with verbose type names, it's fine to do a using for a type, eg
using std::vector;or similar, in a source file, but don't pollute your headers with it and force users to deal with that.I would also argue that explicitness is not clutter, it makes readability and maintainability better because you immediately see where things come from.
For reference on why it's bad, along with a lot of other things you should not do, see Titus's talk from a few years ago: https://youtu.be/BWvSSsKCiAw
Or the associated paper (SD-8): https://isocpp.org/std/standing-documents/sd-8-standard-library-compatibility