Click here to Skip to main content
15,878,852 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: is it okeedokee to include defining headers hither and yon all over the place Pin
BernardIE53179-Feb-23 7:46
BernardIE53179-Feb-23 7:46 
GeneralRe: is it okeedokee to include defining headers hither and yon all over the place Pin
Mircea Neacsu9-Feb-23 8:06
Mircea Neacsu9-Feb-23 8:06 
GeneralRe: is it okeedokee to include defining headers hither and yon all over the place Pin
BernardIE53179-Feb-23 8:46
BernardIE53179-Feb-23 8:46 
AnswerRe: is it okeedokee to include defining headers hither and yon all over the place Pin
jschell9-Feb-23 9:34
jschell9-Feb-23 9:34 
QuestionCompilers Pin
Calin Negru2-Feb-23 9:24
Calin Negru2-Feb-23 9:24 
AnswerRe: Compilers Pin
Mircea Neacsu2-Feb-23 9:56
Mircea Neacsu2-Feb-23 9:56 
AnswerRe: Compilers Pin
Dave Kreskowiak2-Feb-23 10:08
mveDave Kreskowiak2-Feb-23 10:08 
GeneralRe: Compilers Pin
trønderen2-Feb-23 12:41
trønderen2-Feb-23 12:41 
A compiler for "any" programming language can be written in "any" language.

Quite a few compilers throughout history has been written in themselves. Usually, you cannot start out with that (I'll come back to that below): You must write the very first compiler in some other language. Often, that first compiler handles only a small subset of the new language. When developing Pascal, Wirth tried to write this very first complier in Fortran, but gave up: While you can write a compiler in Fortran, it certainly isn't a language well suited for the task. So Wirth changed to assembly for the very first small-subset-Pascal compiler.

(I know of an operating system that was written in Fortran, but most people refuse to believe that!)

Once you've got that subset-Pascal (or whatever language we are talking about) up and running, you program the next compiler version in that subset-Pascal, but now you make a more advanced compiler, maybe for the entire, un-subsetted language. Now you have a full compiler written in itself.

Most likely, that subset-Pascal was so limited that you had to program in less elegant ways to get around the limitations. So maybe you program a third Pascal compiler, but since you have now got a full-featured compiler at your hand, you can program version 3 using all the great new features of your new language.

This process of going from a first (here: programmed in assembly) compiler to the second (programmed in subset-Pascal) to a third (programmed in full-featured Pascal) is referred to as 'bootstrapping'.

I know of one case where a full-featured compiler was written in itself, using all the features of the language, and there never was another compiler involved: The language was even more primitive than K&R C, called 'NPL'. Its developer wrote the NPL compiler in NPL, so he knew very well what an NPL line would compile to. So he started at the top of the NPL compiler source code, and typed into a new file the machine instructions that the compiler should generate for the first line. And for the second line. And for the third ... Down to the last line of the NPL compiler source code. When he ran the compiler source through that program he had just been typing in, he got a new file with same contents that what he had typed in, instruction by instruction. So the compiler worked as expected!

(That guy was slightly crazy: I was once complaining to him about a bug in the OS, which was written in NPL. He dug up the OS source code - this was in the days of hardcopy printout - and found the function I was complaining about. After some grunting and huffing, he spotted the error, and dug out a ball point pen to write a correction into the printout. Did he write the corrected statements in NPL, the language of the printout? No. Did he write it in symbolic assembly code? No. Did he write it as the the octal representation of the binary instruction codes? Yes, with offsets and all as octal values!)
GeneralRe: Compilers Pin
Dave Kreskowiak2-Feb-23 12:43
mveDave Kreskowiak2-Feb-23 12:43 
GeneralRe: Compilers Pin
jschell3-Feb-23 5:17
jschell3-Feb-23 5:17 
GeneralRe: Compilers Pin
Calin Negru2-Feb-23 21:29
Calin Negru2-Feb-23 21:29 
GeneralRe: Compilers Pin
Dave Kreskowiak3-Feb-23 11:32
mveDave Kreskowiak3-Feb-23 11:32 
GeneralRe: Compilers Pin
trønderen3-Feb-23 12:40
trønderen3-Feb-23 12:40 
AnswerRe: Compilers Pin
trønderen2-Feb-23 13:54
trønderen2-Feb-23 13:54 
GeneralRe: Compilers Pin
Calin Negru2-Feb-23 22:27
Calin Negru2-Feb-23 22:27 
GeneralRe: Compilers Pin
Richard MacCutchan2-Feb-23 23:16
mveRichard MacCutchan2-Feb-23 23:16 
GeneralRe: Compilers Pin
Calin Negru4-Feb-23 5:47
Calin Negru4-Feb-23 5:47 
AnswerRe: Compilers Pin
jschell3-Feb-23 5:21
jschell3-Feb-23 5:21 
AnswerRe: How it came to be. Pin
Jeremy Falcon6-Feb-23 9:11
professionalJeremy Falcon6-Feb-23 9:11 
GeneralRe: How it came to be. Pin
jsc426-Feb-23 23:14
professionaljsc426-Feb-23 23:14 
GeneralRe: How it came to be. Pin
Jeremy Falcon7-Feb-23 3:25
professionalJeremy Falcon7-Feb-23 3:25 
AnswerRe: Compilers Pin
BernardIE53179-Feb-23 8:51
BernardIE53179-Feb-23 8:51 
QuestionMessage Closed Pin
1-Feb-23 14:01
Member 149687711-Feb-23 14:01 
AnswerRe: English , please.... Pin
Victor Nijegorodov1-Feb-23 20:25
Victor Nijegorodov1-Feb-23 20:25 
QuestionRe: English , please.... Pin
CPallini1-Feb-23 20:50
mveCPallini1-Feb-23 20:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.