| | |
Question Many Experts Do Not Answer It To Me! Is It that Hard?
![]() |
•
•
Join Date: Oct 2008
Posts: 33
Reputation:
Solved Threads: 0
I'm wondering, if compilers are written in human readable way, then how come the machine could read the compiler?
If machine could read the compiler - which is by itself is not a machine language, why don't the machine just read the high level programming language directly? As it is known, machine only can understand in binaries. If the compiler was written in binaries, in such a way that these binaries can fetch the high level language and translate it back to machine language, it would make more sense, but compilers are not in binaries, so there should be something else.
If a language needs a compiler, then how come a compiler is invented, since this compiler is a language and it will a compiler, see its confusing now!
A compiler is binary, so its been executed, so what compiled the compiler! And the compiler compiler's in what language was written?
I'm sure there are experts here who knows the answer. Waiting your reply.
If machine could read the compiler - which is by itself is not a machine language, why don't the machine just read the high level programming language directly? As it is known, machine only can understand in binaries. If the compiler was written in binaries, in such a way that these binaries can fetch the high level language and translate it back to machine language, it would make more sense, but compilers are not in binaries, so there should be something else.
If a language needs a compiler, then how come a compiler is invented, since this compiler is a language and it will a compiler, see its confusing now!
A compiler is binary, so its been executed, so what compiled the compiler! And the compiler compiler's in what language was written?
I'm sure there are experts here who knows the answer. Waiting your reply.
•
•
Join Date: Aug 2007
Posts: 165
Reputation:
Solved Threads: 18
•
•
•
•
I'm wondering, if compilers are written in human readable way, then how come the machine could read the compiler?
If machine could read the compiler - which is by itself is not a machine language, why don't the machine just read the high level programming language directly? As it is known, machine only can understand in binaries. If the compiler was written in binaries, in such a way that these binaries can fetch the high level language and translate it back to machine language, it would make more sense, but compilers are not in binaries, so there should be something else.
If a language needs a compiler, then how come a compiler is invented, since this compiler is a language and it will a compiler, see its confusing now!
A compiler is binary, so its been executed, so what compiled the compiler! And the compiler compiler's in what language was written?
I'm sure there are experts here who knows the answer. Waiting your reply.
A compiler *is* a binary machine-language program; it translates a high-level language program into machine (binary) language. A well-written compiler is often used to compile itself. This, of course, introduces the 'chicken (compiler binary) or egg (compiler source)' quandary; but the clear answer is that the chicken must come first. There *must* be an initial compiler to translate the compiler source into machine language; once that boostrap process is complete, the compiler can prepare its own future versions (if it is well-written).
Take the C compiler. Originally, it was written in assembler which is easily translated to machine language. When it was (largely) rewritten in C, the 'assembler' compiler was used to compile it. At some point, the 'C' version became good enough to compile its own source. About that time, the assembler-source version was retired.
As a real-world example, in a class many years ago, I had to write a VAX-11 assembler. Unbeknownst to the professor, I had access to a VAX where I worked at a co-op job. [Note, I no longer remember what I wrote it in, but I'll say VAX-11 Macro (assembler) for the purpose of this illustration.] When it was time to turn it in, it was producing *exactly* the output listing that DEC's assembler produced. A couple more weeks and I would've been able to generate proper binary output suitable for linking. Had I gotten to that point and had my assembler actually produced correct binary, I would have been able to use my assembler (binary) to assemble, you guess it, my assembler (source). And the two versions (Macro-32-assembled and MyOwn-assembled) would have produced identical output *if* I programmed it correctly. (FWIW, even though my assembler produced no binary output, I still got an 'A' on the project because my assembler's output listing showed that it correctly handled all of the labels, instructions and addressing modes available on the VAX; from there, producing linkable binary would've been trivial.)
Prolly more than you wanted to know, but I hope I adequately answered your question.
You're referring to the compiler bootstrapping process, which is a sort of chicken and egg scenario. The gist of it is that early compilers/assemblers were written in machine code in a very basic form, then used to compile more complex compilers. Nowadays there are usually more sophisticated methods for bootstrapping compilers, such as using a different platform with an existing compiler to cross-compile to your target platform. Because of this, you'll find that a lot of compilers are actually written in the language that they compile (for example, ghc is written almost entirely in Haskell). You can read more about this on the web:
http://en.wikipedia.org/wiki/Bootstrapping_(compilers)
http://en.wikipedia.org/wiki/Bootstrapping_(compilers)
"Technological progress is like an axe in the hands of a pathological criminal."
All my posts may be freely redistributed under the terms of the MIT license.
All my posts may be freely redistributed under the terms of the MIT license.
compiler high level language and machine language is like: English man Swahili man and one who knows both swahili and english. The one writes a paper in english and the compiler: who now knows both language takes that written and translate it all into swahili language. Then when took to any swahili speaking man can read that script. that english is HIGH LEVEL LANGUAGE and swahili is MACHINE LANGUAGE and translator of script is COMPILER
Hope you can understand now!
Hope you can understand now!
•
•
Join Date: Dec 2007
Posts: 36
Reputation:
Solved Threads: 0
Hi,
While the above responses are correct, I think they have missed one signifcant point. The reason for compilers is speed. Speed for both programming, and speed for for program execution.
If all programs were written in machine code using binary, they would take a very long time to write, as the programmer would have to do the translation themself. While effective, this, of course, would be incredibly inefficient from a time and/or resource cost perspective.
Further, while it is possible for the computer to read the source code directly, and therefore translate the source code into executable code, this is not the only function of the compiler. The compiler also checks the source code for obvious errors which would prevent the program from running, such as incorrect syntax, spelling errors (of control and/or command words), ensuring all if statements, especially nested ifs, have the correct end, etc., which the programmers often overlook, despite vigilant proofreading. I know this well, as I have programmed since the early 1970's in a number of languages, and I have proofread not only my own programs and documentation, from business analyses to business/program specifications to source code to user manuals, but those of others as well.
While the above responses are correct, I think they have missed one signifcant point. The reason for compilers is speed. Speed for both programming, and speed for for program execution.
If all programs were written in machine code using binary, they would take a very long time to write, as the programmer would have to do the translation themself. While effective, this, of course, would be incredibly inefficient from a time and/or resource cost perspective.
Further, while it is possible for the computer to read the source code directly, and therefore translate the source code into executable code, this is not the only function of the compiler. The compiler also checks the source code for obvious errors which would prevent the program from running, such as incorrect syntax, spelling errors (of control and/or command words), ensuring all if statements, especially nested ifs, have the correct end, etc., which the programmers often overlook, despite vigilant proofreading. I know this well, as I have programmed since the early 1970's in a number of languages, and I have proofread not only my own programs and documentation, from business analyses to business/program specifications to source code to user manuals, but those of others as well.
![]() |
Other Threads in the IT Professionals' Lounge Forum
- Previous Thread: Computer Asset Management tools advice
- Next Thread: How do u download a Youtube Video?
Views: 698 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for IT Professionals' Lounge
1gbit advertising advice amazon answers british broadband business businessprocesses career carrier censorship cern china cio collectiveintelligence connectivity consumer consumers corporateearnings css datatransfer debtcollectors dictionary digg ebay ecommerce email employment environment facebook food grid high-definition hottub infodelivery infotech intel internet interview ipod isp japan kindle library malware marketing mit moonfruit news onlineshopping php piracy piratebay porn program questions r&d religion remoteworking research retail schools security sex shopping simple skype smallbusiness smb socialmedia socialnetworking software softwareengineer spam speed spending ssl startrek statistics stocks study stumbleupon survey tabletpc technology touch-screen touchscreen training twitter uk vbulletin videoinprint voips vulnerability web webdesign webdeveloper windows words






