Criticism of C++

From Wikipedia, the free encyclopedia

Criticism of the C++ programming language refers to critical commentary directed at the C++ programming language, an evolution of the C programming language. Some of the criticism of the C programming language is relevant to C++ as well.

Contents

[edit] Legacy C support

“Every C program is a valid C++ program”. This phrase has become very popular. Though in recent times with standardization of C++, this is not wholly true, the statement holds good for majority of the C++ language. Though C++ has managed to overcome many of the alleged defects of C, a novice can still use some features of C while coding in C++ that can lead to disastrous results.

[edit] Learning curve

C++ provides a vast array of features and paradigms for programming. Hence, a newcomer to the language will have to spend considerable time to learn the syntax and features. It is often stated it takes a developer years to master the feature set of C++.

[edit] Ambiguity

C++, being less explicit than other languages (like Java or C#) and allowing different solutions to similar problems, allows an experienced programmer to write code (relatively) quickly. However, this also reduces readability, maintainability and extensibility as well as making it hard to debug.

For example, C# has explicit keywords for virtual and override which must be used. In C++ both the base-class and the derived class use the virtual keyword - plus, the derived class is allowed to omit the keyword.

[edit] Multi-paradigm programming

C++ provides the ability to code using different programming styles. It supports procedural, Modular, object-oriented and generic programming. It also supports event-driven programming to a lesser extent. It moreover allows one to mix and match amongst these styles. This apparent flexibility, though a great boon, often leads to hordes of confusing styles (though this can be mitigated by enforcing project wide coding standards, the onus is on the developers themselves). Some proponents of C++ state this as an advantage, claiming that a programmer who has knowledge of any of the programming paradigms can easily switch over to C++. But the downside is programmers given a choice, code in their preferred styles than in the natural style of a language.

A C++ programmer can often confine himself to knowing only one of the paradigms thereby not having knowledge of many other potentially useful shortcuts provided by the language. This leads to programmers with limited knowledge (knowledge pools) within the language community.

[edit] Feature set

Because of the multiple paradigms supported by C++, the language has some obscure features that only very rarely find a legitimate use. It is generally agreed that C++ includes programming language features of two or three different languages put together and more. Some examples of features not often used are:

  • Pointers to class data members

[edit] Absent features

Since the language has been used in almost every conceivable area of hardware, the standardization committees’ support for libraries are often minimalistic. Though many open source libraries like Boost & Loki overcome the problems mentioned below, the features are mentioned because they are not part of the language standard.

[edit] See also

[edit] References

[edit] External links