3 ms·
I've been wondering lately why many people write c in c++ rather than just c. I think this might be the reason.
by bobajeff 4y ago
I've been wondering lately why many people write c in c++ rather than just c. I think this might be the reason.
- qsort 4y agoPeople write C in C++ because they don't actually know C++ and think it's "basically C with classes and strings". There are legitimate reasons why someone would rather write C, but "I don't understand RAII" is not one of them.
- owlbite 4y agoC with basic templates is normally what I want. Occasionally other C++-isms drift in, but normally to the harm of the code quality.
- wruza 4y agoC++ doesn’t require you to commit to all of its features and/or paradigms. Using it as you see fit is valid. Just don’t advertise yourself as a C++ programmer to the job market, as it’s not what most people expect. There’s nothing wrong with “C with classes and strings” idea by itself, if that is your choice or a consciously sufficient level of competence.
- qsort 4y agoIt doesn't require you to commit to all of its features, that's certainly correct. But it does require you to commit to its principles; if you're needlessly passing naked pointers around, you're really writing C code with a C++ compiler.
- wruza 4y agoI don’t see how it requires you to commit to any principles, if you can avoid those you don’t need and still successfully compile. That’s called “suggests” or “allows”, not “requires”. Yes, some people are writing C code with classes and strings in C++. That’s why we call this mode “C with classes and strings”. I believe that you are attached to these principles (see their benefits), and that is fine. But not everybody likes full-on C++.
- tjoff 4y agoFor a long time on windows the official MS recommendations was to use the c++ compiler for c projects. Which was exerbated by an obsolete c compiler that only supported c89.
- zabzonk 4y agothe usual accusation is that many people write c++ code as if it were c. also, the the code in 2nd ed of K&R was all compiled with stroustrup's c++ compiler, as there wasn't a c compiler that could handle it.