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.
Simple answer: When a program is written in C, Fortran, Pascal, Algol, Ada or any of a number of other languages, it must be compiled into machine-readable language before the machine can run it. The same goes for almost every compiler; it must be compiled into machine language before a machine can run it. Only a compiler written in machine language would need no translation and could be executed directly. And yes, this does mean that the first compilers, the first assemblers, the first OSen were written directly in machine language. (Actually, they might've been written in an assembler-like pseuo-language, assembled by hand and toggled into the machine using the front-panel switches. Look at pics of most any computer from before 1975 or so; you'll find that pert near all of them had front-panel switches for toggling in data and programs, and for running programs and stepping through memory.)
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.