Why C++ ?




Many people may have heard of or have tried other procedural programming languages, such as Python, Visual Basic or C#. This site is devoted to the C++ programming language, specifically GNU C++, which is available for free for Linux users.

C++ is a high-level programming language. Any program code that you write in C++ must be translated into lower-level code by a "compiler". This is a program that converts your code into simpler instructions. Once compiled, programs typically execute extremely fast... usually faster than many other programming languages.

If you are a Raspberry Pi owner, or you have a PC with Ubuntu installed, then you can develop simple GNU C++ programs for free. Indeed, most Raspberry Pi users are completely unaware that the GNU C++ compiler is already installed on their Raspberry Pi machine and ready to use as part of Raspbian or Debian.

Whilst it is not included as part of a standard Ubuntu installation, Ubuntu users can install the GNU C++ compiler with a simple apt-get command:

    sudo apt-get install build-essential

C++ is the successor to another programming language: C. Many people often get confused between the two languages, especially as you can write C statements in your C++ programs. The style used in C programs can often appear more technical and even somewhat confusing, especially to the beginner. It is difficult to write C programs without being exposed to some of the technicalities of how computers work. Some beginners find C a little scary, even though it is very widely used.

C++ offers many extra features and improvements on the original C language that allow the beginner to write very "clean" and understandable code. Many of the things that you learn whilst writing C++ programs can be transferred to other programming languages, whether you are writing some C#, JavaScript or Java. The core parts of your programs may often resemble code from other languages, even Python, especially if you adopt a clean and disciplined style. Many programmers and software developers move between different languages and recognise the similarities between them.

C++ offers a wealth of features and constructs to solve problems and is ideal for students that are learning to program, whether they are Computer Scientists, Engineers, Mathematicians or involved in any other sphere:

variables and constants;
integer and real data;
boolean values;
character and string values;
simple screen output and ways to format data;
keyboard input and ways to check for sensible/valid data;
iteration using for, while and do-while loops;
decisions using if, if-else and switch-case statements;
1-D and 2-D arrays;
structures that can contain several items of simpler data;
functions and recursion;
reading, writing and appending text files;

More advanced features include:

pointers to memory locations and the ability to construct data-structures;
classes, object-orientation and inheritance.

It is surprising just how many programs you can create using features and constructs listed above. Anyone that grasps these ideas is in an ideal position to move on to more advanced techniques, or work with other programming languages.




Are C and C++ the same thing?
No. No. No. No. No. No. No.
You can write C source-code as part of your C++ programs, but C++ offers a few cleaner features to help you keep your programs easier to understand.


Shouldn't we all just use Python instead?
Well you can if you want, but you or your students might be missing out...


I regularly hear people telling me that students in school should all learn Python as their only language on the grounds that Python is somehow "easier". Others confuse older-style C code with C++, banging on about character arrays (as opposed to strings) and memory-leaks (suggesting that they don't really understand or appreciate the kind of programs that are often written in the classroom).


C++ allows you to write very clean source-code - it's all about your personal style, whichever programming language you choose to use. There is no single language that should be taught exclusively. Indeed, if your students are learning to program using Python, trying a bit of compiled C++ provides an ideal contrast. Students can be given an appreciation of the difference between compiled and interpreted code.




The overlap between different programming languages
Look at a few simple programs and you should notice that there is quite an overlap between them - if decisions jump out from the code, while loops are pretty straightforward in either language, many simple arithmetic and logical operators are the same. Both languages lend themselves to simple programs for the beginner. Indeed, C++ offers extra features that make lots of problems really easy to solve, such as using 2D or 3D arrays, as opposed to lists of tuples in Python, or switch-case statements. At a more advanced, professional level, both languages get pretty technical - take a look at "Learning Python" by Mark Lutz if you don't believe me. Good book, but MASSIVE. Are schools REALLY teaching all of that?!