October 3rd, 2003, 02:04 AM
General Compiler Question
I just wanna clear this up a lil bit becuz I am kinda confused here.
Ok, when I compiler something in C++, the compiler compiles it and then runs it. The program pop ups on my screen, I go throught it and it closes.
Lets say someone makes a program and like puts it on the net for download. Now say I go and download this program, whatever it may be, and I dont have a C++ compiler. But the whole program is made out of C++ code.
How does this work. I asked my dad and he said some compilers compile the code into machine langauge and then any computer can read and run that program. But if you compile something into machiene language, doesnt it stay that way.
I think I need a breif over view of this general process, becuz I am a bit confused.
October 3rd, 2003, 02:39 AM
Programming with Interpreters and Compilers
Assembly Language started the ball rolling. A computer program had been created to make the job of creating a machine language program simpler. This process could be continued and a more sophisticated program could translate a program that is very similar to human language. One person, who must be mentioned, is the late Grace Hopper. Grace Hopper was a lieutenant in the Navy when she first worked extensively with computers. She was largely instrumental for developing translating programs that allow programming in a human-style language. She was one of the main developers of the popular program language, COBOL, and was very influential in the development of early translators.
Two types of translating programs were created, interpreters and compilers. An interpreter takes a program and translates the program one line at a time. After each line is translated, the resulting machine code is executed. A compiler translates the entire program into a machine code file and then executes the file. It is easier to create an interpreter, but the execution speed is slower than a compiler. A compiler is far more complex to create, but it executes much faster than an interpreter. The majority of today’s program languages use compilers for translators. The language you will learn, Java, oddly enough is both a compiled and an interpretive language. How this is possible will be explained soon.
Low-Level and High-Level Program Languages
Languages that are very close to computer binary code are called low-level. Machine code and Assembly Language are low-level languages. Languages that are closer to human languages are called high-level languages. Some languages are very high-level today, and many programming tasks have already been performed. With many languages, it is possible to click and drag on program objects that have already been created and insert them inside your program.
So why not simply write your programs in English? Is that not a matter of creating some kind of translating program that takes English instructions and creates a machine code file for the computer? This is certainly what has been attempted for many years, but translating human languages has been very elusive. Consider the following example. In the sixties, computer scientists tried to write a program that would translate English into Russian and Russian into English. This is really the same problem of properly understanding the meaning of human language. The scientists decided to test their program by entering an English sentence. The resulting Russian sentence was then entered back into the computer and the final result should be the original English sentence. Should, that is, if the computer could translate correctly in both directions. The original sentence entered was:
The spirit is willing but the flesh is weak
I do not have a clue what the Russian result was, but I do know the final English result. Our computer scientists were quite surprised with
The Vodka is great but the meat is rotten
This little experiment showed the major problem with human languages. Human languages like English are idiomatic. We use all these idioms and proverbs, and slang and special nuances that are meaningless to the computers. How can computers figure out human language, when humans are confused?
The bottom line is that programming requires a restricted language. This language can have human type words, but the words selected, the symbols and punctuation used, all must have a very precise meaning. The manner in which the program language structures its statements is called syntax. Program languages must have very precise syntax. Compilers first check to see if a program has correct syntax. Only after the syntax checks out, is the next step of translating into binary code performed.
Source Exposure Java Part I by Leon Schram
October 3rd, 2003, 04:40 AM
In a nutshell...
When you compile a program, say program.cpp, your compiler will compile the program (provided there are no compile time errors), and create a new file called a run image (or executable file). You still have the program.cpp file, but in that directory you also have another file called program (notice no .cpp). I only write c++ in linux, and I know that in linux, or any other .nix , the .cpp file and the run image (executable) will look different in the directory, different color, highlighting, or font.
October 3rd, 2003, 07:33 AM
Okay, programming languages are BASICLY separated into two types:low-level and high-level. In the beggining of programing, programmers wrote with their computers defined machine langauge (low-level). The bad thing about this was that they couldn't trade their code with anyone else and they had to learn how to program on each machine they encountered. To fix this, all the programmers began trying to make languages that were closer to English and that would work on any machine. So basically langauges over time have become higher and higher till now we have machine independent languages like C, C++, Fortran, Cobol, Pascal etc..
What happens with your compiler is that it transfers the high-level language to your computers machine language.
So in short, most of the code that you get online is in high-level form and it isn't compiled yet; when you compile it on your system, then well there you go.
BTW, don't quote me on being uber precise on this. Just a really rough guide.
You shall no longer take things at second or third hand,
nor look through the eyes of the dead...You shall listen to all
sides and filter them for your self.