The C++ Programming Language
C++ is for desktop applications and server-side infrastructure software what C is for operating systems and low-level systems development. Let's see together why
C++ is a computer programing language first appeared on the scene 36 years ago (1985). It is a statically, strongly typed, object-oriented, generic, functional and procedural programing language with manual memory management whose main purpose, as per the words of its creator Bjarne Stroustrup: "was to design a language in which I could write programs that were both efficient and elegant. Many languages force you to choose between those two alternatives. The specific tasks that caused me to start designing and implementing C++ (initially called "C with Classes") had to do with distributing operating system facilities across a network."
Additional goals while designing the language were to give programmers the freedom to pick their own programming style and be fully supported in that style by the language itself, as well as providing all features that were judged useful no matter how likely they would be prone to be misused.
The result is a language that is the compromise between many different expectations and that tries to implement whatever those days seemed useful, no matter how much features were added. In the end here we have a very extended and flexible language that is used in resource-constrained systems as well as in large ones, which offers performance, efficiency and flexibility of use at the point to be employed in many kind of software developments from server-side infrastructure to desktop applications, from e-commerce, web search and database servers to performance-critical applications like telephone switches and space probes. At the same time C++ is considered one of the most complex, if not the most complex, programming language ever created at the point that usually team of programmers in a project establish a priori which features of the language are forbidden to be used.
C++ is a compiled language. The language, together with its C++ Standard Library, is standardized by the International Organization for Standardization (ISO) and compilers for it are available for almost every hardware and operating system in existence today and are implemented by many vendors including the Free Software Foundation, Microsoft, Intel, IBM and others.
First glance at the code
Example: The classic "Hello world" program written in C++:
Main features of C++
Statically, strongly typed
Like C C++ has a static type system. Variables have always a type and the compiler always checks the type correctness. The programmer can override this behavior forcing casts even between incompatible types, but the compiler is more strict than in C and avoids implicit violations of the type system with more accuracy. C++ data types can be divided in the following categories: boolean, characters, wide characters, integers, floating-point types, enumerations, arrays, structures, unions, classes, pointers and valueless or void. C++ supports C strings, arrays of chars of one byte terminating with the character '\0', but also introduces the wide characters type wchar_t to represent text in fixed-width, multi-byte encodings (like Unicode UTF-16) and introduces the standard library type string.
|wchar_t||16 or 32 bits||1 wide character|
|unsigned char||8 bits|
|signed char||8 bits|
|int||16 or 32 bits||size of int types depends on if the hardware/operating system is 32 or 64 bits|
|unsigned int||16 or 32 bits|
|unsigned shart||16 bits|
|unsigned long||32 bits|
|float||32 bits||6 decimal places|
|double||64 bits||15 decimal places|
|long double||80 bits||19 decimal places|
C++ is object-oriented. A class can inherit characteristics and features from many classes as multiple inheritance is supported by the language. Classes can also be abstract and have abstract methods. abstract classes are usually used as equivalent of the interface of other languages since C++ has no interfaces.
Memory management in C++ is similar to that of C. The language offers four main low-level way to manage the memory for the data that programs use, but introduces the operators new and delete which are completely overridable by the programmer. This way it's possibile to install a garbage collector or other kind of automatic memory manager on top of the C++'s built-in memory management system, and in fact external garbage collectors are available for C++ programs. Furthermore from C++11 on the standard libraries provides a serie of smart pointer classes which can help managing objects memory.
C++ officially supports multi-threading programming since C++11 standard published in 2011.
The C++ standard includes both the language itself and its standard library. C++ standard library consists of a slightly modified version of the C standard library and many other C++ specific extensions like extensive group of classes for generic collections, smart pointers, regular expression, multi-threading, atomics, time utilities and so on. Standard conforming implementations of the C++ standard library are available from all the major providers of C++ compilers.
Third party C++ frameworks and libraries are also availble even as open source, being C++ used for the development of both desktop applications as well as server-side. For example most of the desktop productivity applications are developed in C++, the same is for the most adopted internet browsers like those from Google, Microsfot, Apple and Mozilla. If this was not enough, C++ programs can easily use C libraries being C++ very compatible with C.
C++ execution performance are very similar to those of C programs. While the internal mechanisms to handle the object-oriented aspects of the language surely have a negative impact on the overall execution speed, C++ remains a compiled language and programs are directly translated into machine code for direct execution from the CPU. Furthermore during the years many compiler optimizations have been developed and today there are even new kind of compilers, like those derived from LLVM, that are capable to produce extremely well optimized executable programs.
Like C to run C++ programs there is no need of any runtime support. The programs are compiled to machine code and the code from libraries are also inserted into the same program which in the end results is a unique file that contains in itself all the things that the program needs in order to run. Same reusable parts of the code can also be organized in platform dependant external libraries, like the DLLs in Windows systems or the Shared Objects (*.so) files in Linux systems, but then again these are machine code compiled too.
Higher salary for C++ programmers
According to PayScale: C++: http://www.payscale.com/research... Java: http://www.payscale.com/research... C++ and Java programmers have an average salary very very similar to each other, which means they are in absolute the most paid computer programming jobs. On indeed similar results are found.
Notable softwares/platforms/products written in C++
Most of the biggest desktop applications and server-side infrastructure platforms are written in C++. Really it is impossible to list them all. Wherever there is need for execution speed and it's not something related to operating systems (which is C arena) then it's developed in C++. Following is an absolute minimalist list just to give an idea:
- All the major browsers are written in C++ including Google Chrome, Mozilla Firefox, Apple Safari and Microsoft both Internet Explorer and Edge.
- Microsoft Office is written in C++
- MySQL, the most used database server of the world, is written in C++
- Most of Adobe applications are written in C++ including Photoshop, Illustrator and Premier
- Autodesk Maya is written in C++
- Java and .NET themselves are written in C++
- really, really, really, this list could be endless
Best books for learning C++
|Programming: Principles and Practice Using C++|
An Introduction to Programming by the Inventor of C++The book explains fundamental concepts and techniques in greater depth than traditional introductions. This approach will give you a solid foundation for writing... (continue on Amazon)
For experienced programmers
|Effective C++: 55 Specific Ways to Improve Your Programs and Designs (3rd Edition)|
Every C++ professional needs a copy of Effective C++The first two editions of Effective C++ were embraced by hundreds of thousands of programmers worldwide. The reason is clear: Scott Meyers’ practical approach to C++ describes the rules of thumb used by the experts — the things they... (continue on Amazon)
"Within C++, there is a much smaller and cleaner language struggling to get out" these are the words from the C++ creator himself Bjarne Stroustrup, and they say it all: C++ is an immense language, it is very performant, effective and totally flexible and adaptable, but this also means it is very, very, very complex. To work with C++ is a little bit like to work with fire. Especially if you are in a team it is absolutely necessary to set some boundaries, limits and serious rules to be respected by the whole team before even trying to start a new project. The language has to be tamed, features should be carefully selected and team should rigorously conform to the decided rules, otherwise it is very easy to get lost in the language. Having said that only someone who has developed a project of some hundreds of thousands of lines of code all in C++ can understand what immense professional joys this language can gift to those who really love software programming.