What is C++?

The one small disadvantage with Pelles C is that it is `only' a C compiler. That is good in that this is a C tutorial, however, C is not the absolutely best language for every kind of project. There is an extension of the C language, called C++ which definitely has its uses. It's always nice when your C compiler also happens to compile C++. But finding a good C++ compiler is even harder than finding a good one for C, so give up on that for now.

Again, we'll hopefully have a decent C++ tutorial on FriedSpace some time soon, but if you don't yet know C, it can do plenty, so learn that first. In fact the main advantage of C++ is that it allows-na you to do what is called Object Oriented Programming (OOP). This can be tremendously useful if you want to write a program which has to do many similar things.

One example might be a program which displays a large number of buttons on the screen, all of which perform some function and each of which has a slightly different kind of data associated with it. Now in C, if you wish to write some code which changes each of the buttons or pieces of data, most likely you will have to write something different for each button and each piece of data, regardless of how similar all these pieces might be. C++ and OOP allow you to get around this. They allow you to define a basic button functionality and associated data structure and then create buttons which differ slightly from this basic one. However, since they `inherit' the same basic design, they can all essentially be treated as `instances' of the same thing.

But let me get you enthused about C again. Since C++ is a higher level language than C, it can be much less efficient, especially if used incorrectly. Whilst it has its uses and some tasks become extremely difficult without it, many programs suffer a significant performance hit in C++ and in some cases the programs can be quite a bit larger. It is a case of choosing the right tool for the job most of the time.

Technically, anything that can be done in C++ can be done in C anyway, but writing the same program in C may take a lot longer. Thus, C++ can be a good aid to producing programs efficiently, but it is often not the best choice for producing efficient programs. Needless to say, for this reason, ordinary old C is the language of choice for a great many programming tasks. It also happens to be easier to learn!