LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


View Poll Results: Do you find this interesting to think about?
Yup 4 50.00%
Nope 4 50.00%
Voters: 8. You may not vote on this poll

Reply
  Search this Thread
Old 12-02-2004, 12:14 PM   #1
DaZjorz
LQ Newbie
 
Registered: Nov 2004
Distribution: SuSE, LMC
Posts: 23

Rep: Reputation: 15
I was thinking about compiling a compiler.


Hello,

I was thinking about some problem that probably was there at the beginning of Linux.

To use a program, you first need to compile it.

But a compiler is a program itself! And to get a compiler, you need a compiler!

So how did people make the first compiler (if there wasn't any compiler before)?!

Thanks,

DaZjorz
 
Old 12-02-2004, 12:32 PM   #2
itsjustme
Senior Member
 
Registered: Mar 2003
Location: Earth
Distribution: Slackware, Ubuntu, Smoothwall
Posts: 1,571

Rep: Reputation: 47
Found this:
Quote:
John Backus headed the IBM team of researchers, at the Watson Scientific Laboratory, that invented Fortran. On the IBM team were the notable names of scientists like; Sheldon F. Best, Harlan Herrick (Harlan Herrick ran the first successful fortran program), Peter Sheridan, Roy Nutt, Robert Nelson, Irving Ziller, Richard Goldberg, Lois Haibt and David Sayre. The IBM team didn't invent HLL or the idea of compiling programming language into machine code, but Fortran was the first successful HLL and the Fortran I compiler holds the record for translating code for over 20 years. The first computer to run the first compiler was the IBM 704, which John Backus helped design.
For Fortran.

Also found this:
Quote:
It is worth summarizing compactly the roles of the direct contributors to today's C language. Ken Thompson created the B language in 1969-70; it was derived directly from Martin Richards's BCPL. Dennis Ritchie turned B into C during 1971-73, keeping most of B's syntax while adding types and many other changes, and writing the first compiler. Ritchie, Alan Snyder, Steven C. Johnson, Michael Lesk, and Thompson contributed language ideas during 1972-1977, and Johnson's portable compiler remains widely used.
For C.

Just some bits of info...

Last edited by itsjustme; 12-02-2004 at 12:33 PM.
 
Old 12-02-2004, 02:27 PM   #3
DaZjorz
LQ Newbie
 
Registered: Nov 2004
Distribution: SuSE, LMC
Posts: 23

Original Poster
Rep: Reputation: 15
Ah, I guess that the first compilers didn't need to be compiled then..
 
Old 12-02-2004, 03:10 PM   #4
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Moved: Not directly related to LFS.
 
Old 12-02-2004, 04:50 PM   #5
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 53
Grace Brewster Murray Hopper
Born: December 9, 1906 in New York City
the creator of the first compiler, and creator of COBOL
coining the term "bug"
worked for the us navy on computers

anyway it is still possible to write machine code directly and that's how they did it.
it's not like a true chicken and egg thing. Machine code existed already before the idea of compiler.
compilers are just translators.
first compiler just interpreted numbers and translated into machine code
Using call numbers, the compiler would retrieve machine code subroutines stored on tape.
this might by todays standards be an interpreter not a true compiler ?
but anyway compilers don't create anything new they are just a convenience like a car.
even without the car we can still get places it just takes longer
 
Old 12-02-2004, 04:53 PM   #6
95se
Member
 
Registered: Apr 2002
Location: Windsor, ON, CA
Distribution: Ubuntu
Posts: 740

Rep: Reputation: 32
Computers take instructions in the form of a string of bits. These bits are not meaningless, they do different things. For instance, let's make up an imaginarey machine, and give it 2 instructions, 0 & 1. 0 does a HALT... halts the computer, 1 does a LR, loads some register with a bit in memory. Pretend our computer has a 2 word ram, each word 1 bit. So when using LR we also provide an address (either 0 or 1 for one of our 2 words). You can write a complete program for the computer using only 0s and 1s. Each instruction is 2 bits, the first our op code (HALT or LR), and the next the memory address. For instance, 101100. (10) Loads the bit in memory at address 0, (11) then loads the bit at address 1, (00) then halts the computer. Now, obviously our computers today have a lot more instructions, Your computer probably has less than 256, but that's still alot. And it probably has tons or ram. So, you can actually start writing programs using a strings of 0s and 1s. So the first program were actually created setting sets of bits to either 0 or 1 and that would be a program. Next came assembly language. This basically just changed each instruction (0 or 1 in our case) into a word, called a mnemonic. An example of our program would be like this:
LR 0
LR 1
HALT
Which could be "assembled" into this 101100
We could then write an "assembler" using binary strings (machine code), obviously not with our imaginary computer, since it lacks the capibility to do so, but a halfway decent computer could. Once we have an assembler created, we can start writing much more complex programs (or atleast write them a lot easier). We could even start writing better assemblers with our assembler. Using an assembly language we could create compiler for even higher level languages, like FORTRAN or C. We can than use these compilers to compile even better compiler for these languages using these languages. Hope this made sense.

Last edited by 95se; 12-02-2004 at 04:55 PM.
 
Old 12-02-2004, 05:05 PM   #7
crashmeister
Senior Member
 
Registered: Feb 2002
Distribution: t2 - trying to anyway
Posts: 2,541

Rep: Reputation: 47
Just like in the old days - I got an uncle that can read and write machine code.
 
Old 12-02-2004, 05:26 PM   #8
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 53
Quote:
compilers are just translators
well,not exactly....
Writing an efficient compiler is more difficult that writing an OS Kernel.
Compilers, in contradiction to assemblers, are extremely sophisticated programs.
different compilers, output different assembly code for the same source.

Last edited by perfect_circle; 12-02-2004 at 05:30 PM.
 
Old 12-02-2004, 10:49 PM   #9
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Just a side note, but the 'compile a compiler' problem is called bootstraping. The name comes from the phrase "to pull yourself up by your bootstraps". That's also why starting a computer is called 'booting', because you need a program to load the OS, but you need an OS to run a program.

Dave
 
Old 12-02-2004, 10:55 PM   #10
Strixy
Member
 
Registered: Apr 2004
Location: Nowhere, Oblivion
Distribution: Ubuntu
Posts: 48

Rep: Reputation: 15
So the chicken:(_rubber) came first?

Last edited by Strixy; 12-02-2004 at 10:56 PM.
 
Old 12-03-2004, 03:44 AM   #11
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 53
Quote:
We could even start writing better assemblers with our assembler
what do you mean by better?

e.x.
MOV something,something

the assembler just translates MOV to the binary opcode of the command and the something,something to the binary values of those numbers.

There are no good or bad assemblers, unless you mean having extra features
 
Old 12-03-2004, 10:31 AM   #12
DaZjorz
LQ Newbie
 
Registered: Nov 2004
Distribution: SuSE, LMC
Posts: 23

Original Poster
Rep: Reputation: 15
Thanks guys for your help! And for the moderator, I know it wasn't really an LFS something, but I didn't know where to put it elsewhere.

If I understand good, the first compilers didn't need to be compiled. Kinda. A compiler needs an assembler, an assembler needs a compiler... So if they are both made at the same time (or something) then it will outcome good.

Thanks!
 
Old 12-03-2004, 11:11 AM   #13
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 53
Quote:
an assembler needs a compiler...
Thats not true.

assembler: A program that converts an assembly code to the corresponding machine code(really easy task).
compiler: A program that converts a programming language code to a corresponding assembly code(hard task).

Last edited by perfect_circle; 12-03-2004 at 11:16 AM.
 
Old 12-03-2004, 11:25 AM   #14
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,304

Rep: Reputation: 65
machine code is directly executed by the computer. assembler is the first step up from that. the first C compiler could have been written in any language first. probably assembler, but you could write one in anything. the gcc source has code in it, script and assembler i think, that can make enough of itself to build itself if it has to. you compile gcc 2 or 3 times to get it fully done that way. best i remember anyway.
 
Old 12-15-2004, 11:27 AM   #15
95se
Member
 
Registered: Apr 2002
Location: Windsor, ON, CA
Distribution: Ubuntu
Posts: 740

Rep: Reputation: 32
Quote:
Originally posted by perfect_circle
what do you mean by better?

e.x.
MOV something,something

the assembler just translates MOV to the binary opcode of the command and the something,something to the binary values of those numbers.

There are no good or bad assemblers, unless you mean having extra features
Yes, what else would I mean? I've written assembler's for a couple "toy" computers I've created at school (using design software), and there are tons of things you can add to them to make them better. There are lots of features that you probably take for granted, that you don't need in an assembler at all and that don't just "tranlate" "to the binary opcode", especially if your creating one out of machine code.
On top of that, there are improvements. You can speed up the assembler greatly as well. Would this not be better?

Last edited by 95se; 12-15-2004 at 11:36 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
checking for C compiler default output... configure: error: C compiler cannot create fiorejm Linux - Software 6 11-12-2009 12:35 PM
Compiling gcc without compiler? davuuud Linux - Software 6 02-03-2009 11:16 AM
Where does compiler look for libraries when compiling Evolution? dhave Linux - Software 2 01-18-2005 11:22 AM
Compiler conundrum: Which came first, a compiler, or it's source code? fr0zen Programming 21 01-29-2004 04:31 AM
Gnu C Compiler, and compiling c++ in slackware? Volcom Programming 1 06-13-2003 01:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration