Then please stop. It's because of people like you that the world is full of horrific, unmaintainable, and frankly....bad, "C++".
No, sorry.
Because I don't like pure C++ style. I really appreciate the efficiency, speed and small program size of C. But sometime, I like to encapsulate code in classes, to be more "clean" and architected.
No, my 'point' being that I would like to know what the people that say they would like to see C remove from C++ actually mean. Do they mean that they want only Class-based code, they want to get rid of the Procedural programming part of it. Or is a philosophical thing, The would like to see the C Philosophy removed from the C++ philosophy (or parts thereof). From what people are writing, I'm not sure if everyone is 'signing from the same song sheet'.
Therefore I request clarification for what people mean by when they are talking about "C in C++".
It is forbidden to just use some feature of C++ ? Is it written somewhere ?
Hope we still are free to use features we like in a programming language to produce good and efficient code, and to achieve the goal of our program (this is what matters ...).
There is no shame to not mastering classes template or each STL container, or even polymorphism and to avoid the use of exceptions (big topic, some people advise to use exception, others say that's bloody hell, so classical C-error handling is much better ... matter of taste ?).
Well, very good program can be made just in "C with classes", whatever some people think.
It is forbidden to just use some feature of C++ ? Is it written somewhere ?
There are some features that C++ should no longer have, because...
Hope we still are free to use features we like in a programming language to produce good and efficient code, and to achieve the goal of our program (this is what matters ...).
... the compiler should take care to generate good and efficient code while you only take care to generate correct code.
It should not be your job to optimize code in C++, in my opinion.
And even if you consider that it is, you should not be tempted to abuse a legacy subset which is there for backward compatibility.
@ CodeMonkey: Could you please define the C, and C++ Philosophy so that those who answer don't have to define it themselves?
No.
Catfish wrote:
As for paradigms, I think that is a false issue because C++ lets you choose what's best for your purposes.
Catfish, you yourself have said "Deprecating the C subset in C++ would be the right thing to..." this would suggest that you are not entirely happy with C++. The support for a given paradigm could be what you don't like about C++, hence you want to change it. [Edit] The You here is meant as you the reader not you Catfish
Catfish wrote:
...C++ lets you choose what's best for your purposes. I don't think anyone opposes this freedom.
...
There are some features that C++ should no longer have, because...
That seems to be a contrary view point. C++ lets you choose what is best but should be changed to restrict what you can choose.
----------------//----------------
To me it makes no sense even talking about the C in C++ unless you say what you mean. C++ is a language that is design to as compatible with C as possible, i.e. they are two separate entities.
Saying things like using std::string is the C++ way and char arrays is C is just wrong, the C++ way is to let you do what you want to do (as long as it is in the scope of the standard).
It should not be your job to optimize code in C++, in my opinion
But if you don't optimise your code, no C++ compiler will do it for you. C++ compilers are quite poor at optimising code compared to compilers of high level VM based languages. C++ gives so much freedom to the programmer, that not much is left to the compiler. E.g. it can't decide, whether to put objects on the stack or on the heap, it can't remove locks, it can't change calling by value to calling by reference, it can't move objects in memory to avoid fragmentation, it can't auto-specialize code basing on usage and so on.
Saying things like using std::string is the C++ way and char arrays is C is just wrong, the C++ way is to let you do what you want to do (as long as it is in the scope of the standard).
"Just wrong" because both ways are supported, because one of them has to do with backward compatibility?
I don't agree that the C++ way is about letting you abuse the C subset out of ignorance.
@rapidoder the C++ compiler is explicitly allowed to do all those things by the language specification, although existing implementations aren't as aggressive as they can be (switching between by-value and by-reference happens, though)
"Just wrong" because both ways are supported, because one of them has to do with backward compatibility?
No, just wrong because both ways are valid C++. There is no backward compatibility, the "C subset" (for want of a better phrase) is the heart of the language.
Catfish wrote:
I don't agree that the C++ way is about letting you abuse the C subset out of ignorance.
The ignorance comes from not learning. If you encourage people to avoid a valid part of C++, for whatever misguided reason, then you are helping to perpetuate the ignorance.
The ignorance comes from not learning. If you encourage people to avoid a valid part of C++, for whatever misguided reason, then you are helping to perpetuate the ignorance.
I don't agree with statement. There ARE parts of the language that are best avoided. For example, C-style casts. It could be argued that they only exist to perpetuate ignorance of their C++ replacement.
There is no backward compatibility, the "C subset" is the heart of the language.
C++ has outgrown its former C self. It can stand on its own. It needn't support legacy code for which there is a dedicated compiler anyway. Why do you consider old libraries such as string.h for ASCIZ arrays to be in the "heart of the language"?
If you encourage people to avoid a valid part of C++, for whatever misguided reason, then you are helping to perpetuate the ignorance.
Ignorance is bliss, especially when the "valid part" you're avoiding is there for historical reasons (backward compatibility), rather than practical reasons (for which we have the newer "valid parts" native to C++).
I don't agree with statement. There ARE parts of the language that are best avoided. For example, C-style casts. It could be argued that they only exist to perpetuate ignorance of their C++ replacement.
Wow...again you would only be ignorant of something if you didn't bother to learn it...for whatever reason.