Getting Started with C + + (1): Programs, compilers, and operating systems __c++

Source: Internet
Author: User
Tags visual studio 2010
programs, compilers, and operating systems

Bibliography "C + + Primer" "Fundamentals of Compiling Principles"

Before starting any language study, many people are accustomed to using a "software" (such as Visual Studio 2010), the function of which is that you can write your "Hello World" program, click Compile, run successfully, and a black box appears, showing "Hello World. " Many people take this process as a habit, but may not have thought about the relationship between the code you write and Visual Studio and Windows.
But I think you still need to understand the logical relationship between them and the simple way of running. In this blog, I will simply share with you the relationship between the program, the compiler and the operating system, not to mention the principles, but to tell you how they work together. Each of these three content is a very deep direction, if you really want to understand, you can refer to the "Compiler principle" and "computer operating system." Program (machine language)

We talk to people around us every day, and we use language . The classic word is: People's language, machines have the language of the machine. the language of the machine is the program .

People want to talk to the machine, let the machine to do things, then you have to understand the machine language is how to say, computer language is not 0 and 1 well (crying smiley). But when the computer just came out, it was really someone with only 0 and 1 programming, very powerful, then appeared the assembly, computer language is a great progress, but programmers still need to follow the machine instructions to work the way to think. Later appeared the C language these accord with the human thought characteristic language, but these languages have the very high abstraction degree, your own logic of thought needs strong enough, can design the good machine language.
See a section of C + + program

int main ()
{
    int a=0;
    int b=1;
    int sum=0;
    sum = a+b;
    cout<< "a+b=" <<sum<<endl;
    return 0;
}

Can see, in fact, we can easily understand the meaning of this code, this is the progress of the program.
However, the above program computer is impossible to understand, in order to be able to write the human Mind Program "translation" into the machine can understand the program, the computer field of "translation officer"- Compiler (Compiler) was invented, later will talk about the compiler.
In short, to learn programming, you must first have to do a psychological preparation of translation, and you have to have strong logic and abstract thinking. compiler (Compiler-IDE relationship)

said the compiler before, but also need to add a knowledge of the programming language, many people have heard of the compiler, but did not hear the interpreter, in fact, these two things need to be discussed together.
The compiler's running process is to give a source program (written by the programmer)-Compiler compile-build target program, target program-data input-program to run output results. Here you can see that the source and target programs are two separate phases.
The interpreter's running process is that the source program-Translation Section-executes a paragraph.
For example, a compiler is like translating a book, translating it, giving it to the reader, and the author of the book does not need to be present, and the interpreter is equivalent to simultaneous interpretation, the author says, the interpreter translates a sentence, and the reader is present to listen. Although the two translation methods are different, but it should be noted that all can be used in the way of compilation, almost all can be used in the interpretation of the way.
Programming languages sometimes vary according to the way they are translated into compiled languages (such as C + +) and interpreted languages (such as java/c#), languages and languages have advantages, and the way they are translated has advantages.

Having said that for so long, some people will ask, how I have never felt the existence of the compiler, where the compiler. In fact, many beginners are accustomed to using the "software" mentioned above, this software has a professional name-ide, integrated development environment.

The compiler is integrated into the IDE as one of the tools, so you may not feel it, but if you compile the Java code with JAVAC under the Windows console, or if you compile the program under the Linux command line, you are using the compiler directly.

Operating System

When it comes to programming languages, such as Java, some people would say that this is a cross-platform language, in fact, across the computer system.
From what I have now understood, when a programming language is running on a computer, many of its code can be directly controlled by a compiler to control the corresponding operation of the hardware, but since you are running on this computer system, your input and output may need to rely on the operating system (such as the graphical interface under Windows). NET or MFC).

So the operating system and the degree of close to the program depends on the functionality of your program to implement , if you are doing UI, then you may want to delve into the Windows system mechanism, if you are the core algorithm, you may not need to spend too much time on the operating system.

Of course, specific issues to be analyzed, because the operating system is a learning, how to make your program better run on the system, you need to have enough knowledge of him. If you have questions, leave a message. or send mail to: lifeliyan@163.com

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.