The relationship between C + + and other programming languages

Source: Internet
Author: User

Readers may be familiar with the basic concepts of programming and programming languages, and below are a general description of some of the terms that will be used in this book, as well as the relationship between C + + and other programming languages.

No matter which programming language you use, the programs you write are made up of individual instructions. These directives are called source code and are stored in the source file of the disk. There are many programming languages, each with its own pros and cons, with its touts and critics. In addition to C + +, readers must have heard of basic, COBOL, FORTRAN, Pascal, and C programming languages.

For example, the Fortran language has a history of nearly 40 years and is still widely used in science and engineering calculations, but C + + and other languages are gradually entering these fields. The COBOL language is designed for business data processing applications, and its history is almost as long as a Fortran language. It is now almost impossible to write new code in COBOL, but a lot of the code that was written years ago is still in use. C + + is also becoming an alternative language for many business data handlers.

C is the predecessor of C + +, because these two languages have many common syntax and functions. In fact, the C programming language is a subset of C + +. However, C + + has made many extensions and improvements in the development process, making it a mature language, and C + + is more powerful and more versatile than it is capable of.

1.1.1 The process of interpreting and compiling programs

The purpose of a programming language is to describe the actions that you want your computer to perform more simply than the programs that your computer can perform. The computer can only execute programs that contain machine instructions (also known as machine code) and cannot directly execute programs that we write. There are basically two ways to execute a program written in the language mentioned earlier, and in most cases a language chooses one of these methods of execution. For example, a program written in the basic language is usually interpreted, that is, another program called an interpreter examines the basic source code, determines what the program does, and then lets the computer complete the action. See Figure 1-1.

Figure 1-1

and C + + is a compiled language. Before you execute a C + + program, you must convert it to the machine language using another program (the compiler). The compiler checks the C + + program and generates machine instructions to perform the actions specified by the source code. Of course, interpretation and compilation are not as simple as described here, but that's how it works.

With an explanatory language, the execution process is indirect, that is, each time you execute a program, you need to determine the intent of the source code. Therefore, this language is much slower and sometimes 100 times times slower than the counterpart of the compiled language. Any language is either interpretive or compiled, which is usually determined by the design and use of the language.

One exception to this rule is Java, which is a fairly new language that has many features of C + +. Because Java is primarily used to migrate between different computers and to be used on the Internet, it is essentially an interpretive language. Still, there is a just-in-time compiler that can generate the corresponding machine code for Java source code during execution, greatly increasing the execution speed.

1.1.2 Library

Every time you write a program, if you always have to write from the beginning, it is quite cumbersome. In many programs, some of the same functionality is often required, such as entering data from the keyboard or displaying information on the screen. To solve this problem, the programming language provides a lot of pre-programmed code to perform standard input-output operations so that you don't have to rewrite the code.

Standard code that can be used with any program is saved in a library. The library that comes with the programming language is as important as the language itself because the quality and scope of the library have a significant impact on the time it takes to complete a programming task

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.