It is like "who first? hen or egg? " :)
Hope somebody has the answer.
Check out Yacc and Bison. I think it's more Yacc but I remember writing a Pascal compiler that was translated through one or both of them to get C++ code...
The first compilers for any language were first written in another language.
When that initial bootstrap step was over and done with one can write a compiler
in the language itself and compile it using the previous version of the compiler.
After that one can throw away that first version of the compiler and you'd end up
with a compiler for a language written in that very same language.
Then, I'm not kidding here, you build an electronic compiler from electronic parts that will convert assembly code to machine language. The assembly code used as input to this electronic compiler is the logic of the circuits themselves.
Once the the assembly code can reproduce itself in machine language, you reach the "self-sustaining" point and discard the the electronic compiler. The you have been using is now a compiler called an assembler.
You now implement other processor commands using the features of the current assembler.
So, to do a C compiler, you write an assembly program that will translate C code into the assembly program itself. When this is successful, you discard the assembly program and you have your C compiler written in C.
Compilers are usually written in the language they compile.
Then, I'm not kidding here, you build an electronic compiler from electronic parts that will convert assembly code to machine language. The assembly code used as input to this electronic compiler is the logic of the circuits themselves.
Once the the assembly code can reproduce itself in machine language, you reach the "self-sustaining" point and discard the the electronic compiler. The you have been using is now a compiler called an assembler.
You now implement other processor commands using the features of the current assembler.
So, to do a C compiler, you write an assembly program that will translate C code into the assembly program itself. When this is successful, you discard the assembly program and you have your C compiler written in C.
Compilers are usually written in the language they compile.
Hmmm, this sounds familiar...
On the first day, God created the electronic processor, and it was good...
On the second day....
Genesis 1:41 and on the day immediately following the fourty first day and
just before the fourty third day, Eve was happily trotting down the river Tigris:
trottety-trottety-trot when, by Jove, the Serpent Intel reared its ugiy head
from the malodorous Microsoft tree.
Genesis 1:42 it was more subtle than any other beast created by god; it said
unto Eve: "Yea, hath God said, Ye shall not buy my multi core processor?
Genesis1:43 Because Adam was still recovering from his holy rib operation,
until this day Earth, a valley of tears, is in deepeth misery. Wooo on us all.
Genesis 1:41 and on the day immediately following the fourty first day and
just before the fourty third day, Eve was happily trotting down the river Tigris:
trottety-trottety-trot when, by Jove, the Serpent Intel reared its ugiy head
from the malodorous Microsoft tree.
Genesis 1:42 it was more subtle than any other beast created by god; it said
unto Eve: "Yea, hath God said, Ye shall not buy my multi core processor?
Genesis1:43 Because Adam was still recovering from his holy rib operation,
until this day Earth, a valley of tears, is in deepeth misery. Wooo on us all.
A Reading from the Book of Armaments, Chapter 4, Verses 16 to 20:
Then did he raise on high the Holy Disk Manager of Antioch, saying, "Bless
this, O Lord, that with it thou mayst blow the Filing Sytem to tiny bits, in thy
mercy." And the people did rejoice and did feast upon the lambs and toads and
tree-sloths and fruit-bats and orangutans and breakfast cereals ... Now did the
Lord say, "First thou syncest the disks. Then thou must count to three. Three
shall be the number of the syncing and the number of the syncing shall be
three. Four shalt thou not sync, neither shalt thou count two, excepting that
thou then proceedeth to three. Five is right out. Once the number three, being
the number of the syncing, be reached, then turnest thou the Holy System Key
in the direction of thine foe, who, being naughty in my sight, shall snuff it."
A Reading from the Book of Armaments, Chapter 4, Verses 16 to 20:
Then did he raise on high the Holy Disk Manager of Antioch, saying, "Bless
this, O Lord, that with it thou mayst blow the Filing Sytem to tiny bits, in thy
mercy." And the people did rejoice and did feast upon the lambs and toads and
tree-sloths and fruit-bats and orangutans and breakfast cereals ... Now did the
Lord say, "First thou syncest the disks. Then thou must count to three. Three
shall be the number of the syncing and the number of the syncing shall be
three. Four shalt thou not sync, neither shalt thou count two, excepting that
thou then proceedeth to three. Five is right out. Once the number three, being
the number of the syncing, be reached, then turnest thou the Holy System Key
in the direction of thine foe, who, being naughty in my sight, shall snuff it."
On that note...I wonder if the good lord would choose C or C++...or maybe he'd just turn both languages into actual beings and have them fight to the death.....
Comment