Jan 18, 2015

C++ Programming


C++ is arguably the most versatile language in common use. C++ allows for both high-performance code as well as expressive abstractions and design constructs. The language is not perfect but it does represent an excellent compromise between these potentially conflicting language capabilities. C++ combines "low-level" programming tailored to specific machine architectures with "high-level" programming, which can allow code to be completely abstracted from any particulars of the machine executing the program. Both approaches have pros and cons that we'll cover in this tutorial. If interested Wikibooks also has material on this subject.

Why should you learn C++?

The C++ language originally derives from the imperative language C. The defining feature which distinguishes C++ from C is support for Object-Oriented Programming (OOP). This makes C++ a multi-paradigm programming language. An example that can help to demonstrate what OOP means:

If you were writing a program to track the statistics of a racing cyclist, you might make different parts of the program for their age, years of racing, wins, falls, what teams they've raced with and so on. In real life, though, that's not how we think. Instead, we would think of the cyclist as a whole, and the different statistics as being part of him. We could also apply that general "model" of a cyclist, maybe with a few modifications, to any cyclist, and have a complete representation of them. This is the essence of object-oriented programming, and as you understand it more fully, it will allow you to create powerful, but yet easily-understood programs. Instead of relying on data that is scattered throughout a program, you can create a block of code that defines everything you need, and then you reuse that throughout the code.

As a further example, think of a motor car. You unlock it with the key, and get in. Then, you turn the ignition, put the car in reverse, release the brake, and press the accelerator. As you drive, you use the steering wheel, the brake, and the accelerator (and maybe the clutch). You don't know or need to know all the specifics of the car to make it work. You just use what you need, and it's simple, too. Object-oriented programming is like that. You can make powerful code, but it's all hidden, and you can interact and reuse that code using the simple controls.

Other languages, such as Java, Python, Smalltalk and C#, allow the programmer to write code in this object-orientated way. The key difference between C++ and these languages is that C++ is designed to be compiled into efficient low-level code which can run directly on the processor of a computer. This ability means that C++ differs in many ways from these other languages, and lacks many of the advanced facilities you might be familiar with if you already know one of them.

No comments:

Post a Comment