- chicken and egg
- Posted by faeychild on October 17th, 2003
Probably a silly question but came from musing.
How do you compile the first compiler?
--
faeychild.
- Posted by Jørn Dahl-Stamnes on October 17th, 2003
In article <3f8fa279@news.comindico.com.au>, faeychild <nykysle@yah@@.com> wrote:
What about:
First write a simple compiler for language Z in assemble. Then write a new
compiler Z in language Z and compile it. Then recompile the compiler Z with
the new compiler Z.
Then use the compiler Z to write a C, C++, fortran or whatever compiler in
language Z...
Jørn Dahl-Stamnes, EDB Teamco AS
e-mail: Jorn.Dahl-Stamnes@nospam.novit.no (remove nospam first)
web: http://spiderman.novit.no/dahls/
- Posted by Peter T. Breuer on October 17th, 2003
faeychild <nykysle@yah@@.com> wrote:
Using a compiler-compiler.
Peter
- Posted by Alan Connor on October 17th, 2003
On Fri, 17 Oct 2003 08:04:10 GMT, faeychild <nykysle@yah> wrote:
I was thinking about that very question the other day, in a somewhat different
way:
What would be the smalles possible binary that you could install that could
be used to build a Linux from sourcecode?
Seems like you'd have to start with a minimal kernel/libs/shell/utilities/
assembler that had the barest possible functionality that would permit it to
create from assembly code a more sophisticated version of itself and a compiler
and so on.
Considering that I have a fully functioning Linux with networking capabilities
on a single 3.5" floppy, I can't imagine that it would be very big....
--
Alan C
- Posted by Andy Baxter on October 17th, 2003
On Fri, 17 Oct 2003 08:37:01 +0000, Jørn Dahl-Stamnes wrote:
But if you write in assembly, you also need an assembler...
A nice answer to the original question is - using your imagination.
andy.
--
remove 'n-u-l-l' to email me. html mail or attachments will go in the spam
bin unless notified with [html] or [attachment] in the subject line.
- Posted by Jørn Dahl-Stamnes on October 17th, 2003
In article <pan.2003.10.17.09.45.50.711963@earthsong.null.fre e-online.co.uk>, Andy Baxter <news3@earthsong.null.free-online.co.uk> wrote:
Sorry, it should have been machine code...
Jørn Dahl-Stamnes, EDB Teamco AS
e-mail: Jorn.Dahl-Stamnes@nospam.novit.no (remove nospam first)
web: http://spiderman.novit.no/dahls/
- Posted by spike1@freenet.co.uk on October 17th, 2003
faeychild <nykysle@yah@@.com> wrote:
Who says the first compiler needs to be written in a high enough level
language to compile it?
Tch, youngsters today, never dabbled with entering opcodes directly into a
ZX Spectrum and making the border stripey.

- Posted by Eggert Ehmke on October 17th, 2003
Jørn Dahl-Stamnes wrote:
Yes, and the first machine code programs were pushed into the box by setting
switches for each each bit manually. Later came punched cards ...
Eggert
- Posted by mjt on October 17th, 2003
faeychild wrote:
..... run, dont walk, to www.google.com and search for the
term "compiler compiler" (be sure to quote it)
..
--
/// Michael J. Tobler: motorcyclist, surfer, skydiver, \\\
\\\ and author: "Inside Linux", "C++ HowTo", "C++ Unleashed" ///
Bipolar, adj.: Refers to someone who has homes in Nome,
Alaska, and Buffalo, New York
- Posted by Wolf Kirchmeir on October 17th, 2003
On Fri, 17 Oct 2003 13:29:06 +0100, spike1@freenet.co.uk
wrote:
=>faeychild <nykysle@yah@@.com> wrote:
=>> Probably a silly question but came from musing.
=>
=>> How do you compile the first compiler?
=>
=>Who says the first compiler needs to be written in a high enough level
=>language to compile it?
=>
=>Tch, youngsters today, never dabbled with entering opcodes directly into a
=>ZX Spectrum and making the border stripey.
=>
Hell, I learned programming with 2-digit (== 4 bit) binary
numbers. All instructions consisted of at least two binary
numbers, eg 01 11, 10 01, etc. We had printed forms on
which to enter the codes, on lines of up to four numbers
per line, IIRC.
And then we had to wait for a punch-card operator to
convert our scribbles into punched cards, that then were
sent to a punched-card reader which made a paper tape which
was read on a paper tape reader which sent the data to the
mainframe which then ran the program and output the result
to a paper tape which was read by a paper-tape reader which
was hooked up to a printer which printed the results.
Whew!
IIRC 00 00 meant Stop. Can't remember any of the other
codes, though. Probably just as well. :-)
Ah, those were the days, my friend!
--
Wolf Kirchmeir
If you didn't want to go to Chicago, why did you get on the train?
(Garrison Keillor)
<just one w and plain ca for correct e-mail address>
- Posted by Wolf Kirchmeir on October 17th, 2003
On Fri, 17 Oct 2003 11:15:38 GMT, Jørn Dahl-Stamnes wrote:
=>Sorry, it should have been machine code...
If by "machine code" you mean binary code, you are correct.
But note that the mainframe had to have a way of
interpreting the machine code. This was done by means of
paper tape by the time I learned programming for the first
time (with binary code). The paper-tape reader in effect
set and reset switches by passing or blocking currents in
different circuits depending on here the holes were. So the
whole thing began with circuitry. (Footnote 1) The first
"programmers" actually plugged and unplugged cables and/or
flipped switches to set the circuits. In fact, running a
program might entail doing this several times! A specific
pattern of circuits corresponded to a program or part of a
program. (Footnote2)
One of the first hobby computers built from a kit required
plugging and unplugging small cables, and flipping small
switches, too. Can't recall its name, but I recall thinking
what a chore it would be to use one. :-)
Footnote 1: all logical operations can be represented in
combinations of switches in electrical circuits. For
example "and" can be set up as two simple switches in row.
Only if both are closed does current flow; so current
flowing in that simple circuit could be interpreted as
meaning "A and B are both true." Programs are combinations
of logical statements, hence they can be represented as
combinations of switches.
Footnote 2: In a modern computer, transistors are the
switches that reconfigure the circuits. This is done
millions and billions of times per second. At the most
physical level, then, computing is the constant redirection
of electrical currents through constantly changing
circuitry. The structure or _form_ of the circuit
determines how it changes the in_form_ation passing through
it. IOW, computing is quite literally a physical process.
That fact in turn has consequences, one of them being that
there is an absolute limit to computing speed, and hence to
what can be done with computers.
HTH
--
Wolf Kirchmeir
If you didn't want to go to Chicago, why did you get on the train?
(Garrison Keillor)
<just one w and plain ca for correct e-mail address>
- Posted by Stefan Patric on October 17th, 2003
faeychild on Friday 17 October 2003 08:04 wrote:
By hand. You would write the compiler in assembly code, then, if no
assembler existed for the cpu you wanted to run the compiler on, look
up the opcodes and manually enter the corresponding hexadecimal (or
binary) numbers into the computer. Normally, you would have first
created the assembler using the same "by hand" method.
About 20 years ago, I actually did this for the first computer I
owned, a Commodore 64. Fortunately, someone else had done all the
hard work hand assembling the assembler. All I had to do was type in
about 20 pages of numbers. Took me 7 days working about 2 hours a
day -- about all I could handle.
The same author, who wrote the assembler, had also written a BASIC
language compiler (written in assembly) that you could use your new
assembler on and create compiled BASIC programs that were directly
executable eliminating the need of the computer's built-in BASIC
interpreter. (The compiled programs ran many times faster than the
interpreted ones; hence, the desire for a BASIC compiler.)
--
Stefan Patric
tootek2@yahoo.com
- Posted by Geoff on October 17th, 2003
On Fri, 17 Oct 2003 15:50:04 +0000, Stefan Patric wrote:
<snip>
Happy days. I was married by then and, with my wife reading whilst I
typed, it took about 3 loooong evenings. It was unutterably slow in use
but it whetted my appetite and I quickly replaced it with the
Micro-assembler cartridge, which was a really excellent piece of kit.
I don't recall that one.
Did you also get either of the C64 ROM dissasemblies - there was an
excellent one by the enigmatic "Milton Bathurst".
One of my favourite book dedications is that of the author of the guide to
the 1541 drive. "This book is undedicated to my 1541 drive. May it rot
in Hell"
Geoff
- Posted by Bill Unruh on October 17th, 2003
Stefan Patric <tootek2@yahoo.com> writes:
]faeychild on Friday 17 October 2003 08:04 wrote:
]> Probably a silly question but came from musing.
]>
]> How do you compile the first compiler?
First in what sense? First historically? Or first for a new
architecture? In the former case, probably by hand. In the latter case,
you write a cross compiler on a different architecture in C ,bison,...(or whatever
your favourite language is).
Ie, one which takes in the language and spits out numbers. There is
absolutely no reason why the output should run on the machine it was
compiled on.
- Posted by C. P. Weidling on October 17th, 2003
unruh@string.physics.ubc.ca (Bill Unruh) writes:
in from switches on the front of the early machines (In my early years
as a programmer, I sometimes toggled in quick patches on the front panels
of modcomp computers, and people toggled in programs on the front panels
of the Altair, arguably the first personal computer to be widely available).
Then assemblers were developed, which probably started out pretty simple.
I actually bought a listing of an assembler for the intel 8080 and toggled
it in, along with my brother into a homebrew computer that he had assembled.
We didn't do it all in one sitting, he had rigged up a cassette tape for
storage of data using what was called Kansas City Standard for converting
data into audio signals and back.
Nowadays computers don't come with switches on the front panel. I've been
in the situation of writing boot strap programs and burning them onto EROMs
with a special burner, to be plugged into prototype motherboards to read
bootstrap programs of off disk drives.
The first compilers were probably written in assembly language and were
no doubt quite crude and simple for early versions of FORTRAN, LISP, etc.
Two operations still used in Lisp ('car' and 'cdr') are derived from old
assembler terms. Once a compiler is up and running, it can be used for
writing cross compilers to other architectures, or for compiling to new
languages, for example, an Algol compiler could have been written in FORTRAN
or vice versa. Gradually, things bootstrapped up to the modern ways of
doing things.
- Posted by faeychild on October 18th, 2003
Peter T. Breuer wrote:
ROFL I did ask for that!
--
faeychild.
- Posted by Alan Connor on October 18th, 2003
On Sat, 18 Oct 2003 02:19:05 GMT, faeychild <nykysle@yah> wrote:
You sure did....Thanks for inspiring a really informative thread.
--
Alan C
Posts with sigs of > 4 lines, or not in plain text, are dumped by my filters.
- Posted by Ed Murphy on October 18th, 2003
On Sat, 18 Oct 2003 02:59:05 +0000, Alan Connor wrote:
You don't know the half of it.
Google for "Reflections on Trusting Trust"...
- Posted by student on October 18th, 2003
On Fri, 17 Oct 2003 15:50:04 +0000, Stefan Patric <tootek2@yahoo.com> wrote:
I actually wrote an assembler for the C64 'bout 20-25 years ago...
gave it away...wrote it in Basic first then translated it to
assembly and assembled the assembler...the most work I ever did
for no money....
[sorry about the thread drift, all, but couldn't resist]
- Posted by Eggert Ehmke on October 18th, 2003
Alan Connor wrote:
Yes.. interesting how a simple but meaningful question gets a lot of people
to tell "old stories" ... in fact this is one of the most interesting
aspects of computer science (self reference)
Eggert