4 ms·
> Would someone mind giving a description of "writing C in C++"? For starters, write non-idiomatic code which employs (exclusively or not) a subset of features
by arinlen 4y ago
> Would someone mind giving a description of "writing C in C++"?
For starters, write non-idiomatic code which employs (exclusively or not) a subset of features.
Imagine writing Python and only using free functions, while vehemently refusing to use stuff like classes or list comprehension or exceptions or anything at all. Similar to "writing C in C++", this would be "writing shell scripts in Python".
> Like it or not, C++ does have things like raw pointers, null terminated arrays, setjmp/longjmp, and macros. That's part of being a superset of C. Using them in C++ is still C++ if it's compiled by a C++ compiler.
You're missing the whole point.
"Writing C in C++" is synonymous to "not using new C++ features that are safer and faster and better than the old C features".
It's completely irrelevant if the compiler supports raw pointers or preprocessor macros. The whole point is that, say, intentionally using raw pointers when you have smart pointers is hardly justifiable, and you're not doing yourself any favor.
- wheelerof4te 4y agoI can understand if people want to avoid using classes. But list/dict/set comprehensions make building complex data structures easier and more performant. Usually, if one avoids OOP features of Python, that means he/she likes to use more functional features. And vice-versa. I imagine it's the same with C vs C++. People use malloc/free, classic for loops and structs+functions only because that style fits their mindset better.