Product docs and API reference are now on Akamai TechDocs.
Search product docs.
Search for “” in product docs.
Search API reference.
Search for “” in API reference.
Search Results
 results matching 
 results
No Results
Filters
The Pros and Cons of C++
Traducciones al EspañolEstamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
C++ stands as one of the oldest and most pervasive programming languages around. And with good reason. Its low-level control and high speed make it the top player for systems programming and other areas that demand tight efficiency.
So, what specifically sets C++ apart? What are the features that keep developers coming back to it? What features make newer languages more appealing in some cases?
This tutorial aims to answer those questions. Take a look at our overview of C++ and our breakdown of its pros and cons. Follow along to see where C++ proves most useful and whether you should consider learning it.
What is C++?
C++ is a general-purpose programming language, designed to extend on the C programming language. C++ has often been called “C with classes” because it introduces extensive object-oriented features to C.
Like C, C++ focuses on low-level control and efficiency. The language gives developers fine control of memory usage and performs close to the hardware limitations.
Its combination of high performance and object-oriented features makes C++ the go-to language where efficiency is concerned. Whether for systems programming or game development, C++ gives tools for organizing complex applications while maintaining bare-bones efficiency.
The History of C++
First released in 1985, C++ was designed by Bjarne Stroustrup to extend on the C programming language. Stroustrup found that object-oriented features of languages like Simula helped with developing large applications, but often lacked performance efficiency.
He sought to make a language with the low-level control and speed of C, but with the addition of object-oriented features. This is why C++ is still sometimes called “C with classes”.
Since then, C++ has become one of the most widely used programming languages ever. C++ is used for systems programming, application and game development, and education. The language itself has continued to evolve through the years, gaining support for additional programming paradigms and technologies.
Pros and Cons of C++
C++ certainly has its advantages, not only over C, but also over many other programming languages that have entered the field since. However, like any programming language, C++ also has its disadvantages, and there are use cases in which you should not use it.
These next two sections highlight the key pros and cons of C++. This should give you a clearer idea of where C++ shines and when you should look to other options.
Advantages of C++
Portability: Programs written in C++ can often be executed on other platforms without any further ado. This is especially the case when the C++ code follows a compiler-independent standard. Be aware, however, that there are limitations to C++’s portability, which you can find discussed in the section on disadvantages below.
Object-Oriented: C++ originally extended on C to add object-oriented features, and it shows in C++’s dedication to object-oriented principles. This gives developers all the advantages that come with object-oriented programming, such as classes, inheritance, polymorphism, and encapsulation. All with the low-level control and speed offered by C.
Multi-Paradigm: Over the years, the capabilities of C++ have expanded beyond just the procedural programming of C and its own focus on object-oriented programming. C++ now has some features of functional and generic programming. All of these combined make C++ a highly versatile language.
Low-Level Control, High-Level Features: C++ is considered a middle-level language because of its combination of low-level and high-level features. C++ gives developers low-level control for things like memory manipulation. At the same time, C++ enables high-level abstractions and comes with high-level features for convenient program design.
Efficiency: C++ runs close to metal, meaning that it runs close to hardware limits. This makes C++ programs capable of running faster and lighter than programs in many other languages. It also makes C++ ideal for developing programs under heavy hardware limitations, as is often the case for things like systems programming and game development.
Disadvantages of C++
Complex: Writing programs in C++ can be challenging, especially for developers more familiar with the niceties of modern programming languages. For one thing, modern languages often take care of a lot of details for you, details that C++ requires you to manually implement and keep track of. These include things like pointers and memory management.
Platform-Specific: While C++ is considered portable, this is often practically not the case for more complicated programs. Any program that needs to interface with graphical displays, for instance, is likely to use a platform-specific library. So, the C++ code for these programs actually ends up needing to be rewritten to work on other platforms.
Lack of Garbage Collection: This is also tied with C++’s complexity. Languages with garbage collection essentially manage memory allocation for you, tracking variables and disregarding what is no longer in use automatically. But garbage collection often comes with a high performance impact, and it removes a degree of low-level control. C++ opts to keep the performance and control, which leaves developers the task of carefully, conscientiously, and manually managing memory usage.
Unsafe: Because of the low-level memory management mentioned above, C++ programs tend to be considered unsafe from a memory perspective. C++’s use of pointers and its potential for incorrect typing of variables can lead to memory leaks.
Lack of Support for Multiple Threads: So far, C++ still does not have any built-in support for multi-threaded applications. Although C++ is adding support for threads, it is severely lacking when compared to languages like Java.
Should You Learn C++?
Learning any programming language can be a significant undertaking. More so when that language is as complex and low-level as C++. So you likely want to know whether it would be a good idea for you to learn C++ yourself.
Below, you can find some compelling reasons to learn C++. If these apply to you, it is a good indicator that you may want to learn C++.
Becoming a Better Developer
C and C++ have served as the forebears of numerous modern programming languages. From Java and JavaScript to Ruby and Python. For that alone, developers would do well learning C++. Often, doing so can grant a deeper understanding of the syntax and workings of a wide array of modern languages.
In the same line of thinking, learning C++ can be excellent for grasping low-level computing. Most modern languages do not give developers an interface with these low-level components. However, those components are still playing a role in program design and performance. Learning a language like C++ forces you to engage with low-level features. That process can make you more familiar with and better able to account for them.
Building Efficient Applications
More practically, C++ is the language to learn if you want to do systems programming or to work on programs that require fine-grained control. C++ is the premier language for this. Though C++ demands a lot from developers in terms of memory management and other complexity, all of that goes toward giving low-level control.
C++ provides that low-level control and efficiency along with all of the features of object-oriented languages. Object-oriented programming is especially well-suited to the enterprise, user interfaces, and other complex applications. So, consider learning C++ if you want to develop programs in an object-oriented approach yet want the speed and control of low-level languages.
Conclusion
This guide gives you an overview of C++ and how it measures up. It walks you through the language’s strengths & weaknesses, and also introduced you to use cases where you should consider learning C++.
C++ stands as a giant in the world of programming. Even if you do not learn it in depth, it is highly useful to grasp its place in that world. Hopefully this guide helps you to do so.
More Information
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
This page was originally published on