You are not logged in.

#1 2014-04-03 16:49:12

henriqueleng
Member
Registered: 2014-02-18
Posts: 77

Which compiler compiled the compiler?

Hi, i have a crazy question!

I don't unsderstand to much of programming but i thought about something!

If i need gcc to compile some software, and gcc is a software, wich software compiled gcc if it is a compiler.
Ok i know that have other compilers that can compile software, but need to have at least that was ther first.

How they did it?


Emacs - tmux - Cmus - Mutt - Lynx/w3m - ....

Offline

#2 2014-04-03 17:00:00

progandy
Member
Registered: 2012-05-17
Posts: 5,307

Re: Which compiler compiled the compiler?

I guess it goes something like this. Cross-compiling is probably an important part of it:
Machine Code -> assembler -> compiler in assembler -> self compiling compiler.
Somewhere along this line the os kernel changed, too. From pure machine code to written in assembler to written in the compiler language. The compiler had to be ported each time.
Edit: This is not necessarily true. There may be some grammar compiler involved that takes a grammar and throws out a compiler.
http://en.wikipedia.org/wiki/History_of … nstruction

Last edited by progandy (2014-04-03 17:05:22)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#3 2014-04-03 17:03:36

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: Which compiler compiled the compiler?

Ooh! I just read about this.

Originally, "code" was written then "assembled" by hand, and by assembled I mean converted from instructions into ones and zeros and fed into the computer. Then someone assembled a program that would convert text files automatically and called it an "assembler". The assembler could then create a new assembler from a text file full of instructions ("assembly language") and so on, which could then be used to create higher level languages like C.

That's my super duper limited knowledge on the subject. smile The book was AMAZING though: Code: The Hidden Language of Computer Hardware and Software

Last edited by drcouzelis (2014-04-03 17:04:57)

Offline

#4 2014-04-03 17:05:36

anatolik
Developer
Registered: 2012-09-27
Posts: 458

Re: Which compiler compiled the compiler?

Before gcc there were other C compiler, e.g. K&R compiler. And it was truly the first C compiler. I believe that compiler was written in assembler and later rewritten to C itself.This process called compiler bootstrapping.

Last edited by anatolik (2014-04-03 17:06:15)


Read it before posting http://www.catb.org/esr/faqs/smart-questions.html
Ruby gems repository done right https://bbs.archlinux.org/viewtopic.php?id=182729
Fast initramfs generator with security in mind https://wiki.archlinux.org/index.php/Booster

Offline

#5 2014-04-07 05:44:13

ANOKNUSA
Member
Registered: 2010-10-22
Posts: 2,141

Re: Which compiler compiled the compiler?

I read the same thing as drcouzelis (not the same book, but the same idea) when I first started learning about programming. A compiler is bootstrapped or "skyhooked." Say you're writing a C compiler. A program is first written in the assembly language which reads basic C (or whatever the language needing a compiler is), the first bit of the compiler is written in C and the assembly program is used to compile it. That super-simple compiler is then used to compile the next bit of code for the compiler, then a third bit is written and compiled and so on, until there's eventually enough functionality for the compiler to work on its own. It is one of those cool concepts you don't really think of until a Plato's Cave moment strikes you. smile

Offline

#6 2014-04-07 07:37:20

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,490

Re: Which compiler compiled the compiler?

Now, gcc is simply compiled with (possibly an older version of) gcc; If the processor is new (I mean a new processor with different instructions), we first cross-compile on another processor. The first compiler was written in assembly language (but this is history, nobody does that now) and the first assembler (assembly language itself must be converted into binary processor instructions) was written directly in binary, probably on manually punched cards.

Last edited by olive (2014-04-07 07:38:07)

Offline

Board footer

Powered by FluxBB