作者:cplusplus.com 出自:cplusplus.com
Programs
Nowadays computers are able to perform many different tasks, from simple mathematical operations to sophisticated graphical representations. These different tasks are not made by the computer itself, these are performed following a series of predefined instructions that conform what we call a program.
A computer does not have enough creativity to make tasks for which it is not programmed, so it can only follow the instructions of the programs which it has been programmed for. And the ones in charge to generate programs so that the computers may perform new tasks are the programmers, who use for that the instructions of a programming language.
Programming languages
When choosing a programming language to make a project, many different considerations can be had.
First one is what it is known as "level of the programming language". The level determines how near to the hardware the programming language is. In "low level" languages instructions are written thinking directly on the interperformance with hardware, while in "high level" ones a more abstract or conceptual code is written.
Generally, high level code is more portable, that means it can work in more different machines with smaller number of modifications, whereas a low-level language is limited by peculiarides of the hardware for which it was written. Nevertheless low level code is usually faster indeed due to that it is written taking advantage of the possibilities of a concrete machine.
The type of programming which we must choose for a concrete project depends on the type of program that we want to make. For example, when programming a driver for an operating system obviously we will use low level programming. Whereas when programming great applications usually a higher level it is used, or a combination of critic parts written in low level languages and others in higher.
Although there are languages that are clearly low level, like Assembler, whose instructions vary according to the processor which the code is made for, and others of high level, like the JAVA, that is totally independent from the platform. The C++ language is in a middle term, since it can interact directly with the hardware almost without any limitation, as well as with the support of suitable specific libraries, works like one of the more powerful high-level languages.
Why C++?
C++ has certain characteristics over other programming languages. Most remarkable are:
Object-oriented programming
The possibility to orientate programming to objects allows the programmer to design applications from a point of view more like a communication between objects that on a structured sequence of code. In addition it allows the reusability of code in a more logical and productive way.
Portability
You can practically compile the same C++ code in almost any type of computer and operating system without hardly making changes. C++ is one of the most used and ported to different platforms programming language.
Brevity
Code written in C++ is very short in comparison with other languages, since the use of special characters is preferred before key words, saving effort (and prolonging the life of our keyboards).
Modular programming
An application's body in C++ can be made up of several source code files that are compiled separately and then linked together. Saving time since it is not needed to recompile the complete application when making a single change but only the file that contains it. In addition, this characteristic allows to link C++ code with code produced in other languages like Assembler or C.
C Compatibility
Any code written in C can easily be included in a C++ program without hardly making changes.
Speed
The resulting code from a C++ compilation is very efficient, due indeed to its duality as high-level and low-level language and to the reduced size of the language itself.