r/programming • • Jul 17 '20

What it was like learning programming in the early 1970s

[deleted] — view deleted post

20 Upvotes

31 comments sorted by

View all comments

Show parent comment

5

u/elcrawfodor Jul 17 '20

I'm no expert, but I think this is the bootstrapping problem. The very first compiler couldn't be in C, but once you have a working compiler (say in assembly), you can then write a second compiler in C and compile it using the first compiler. Assuming their machine had a working version of the first compiler, they could use that. Someone correct me if I'm wrong or if there's more gotchas involved, I've also been interested in this since starting to learn a little more about compilers.

2

u/console-write-name Jul 17 '20

Okay that makes sense. So basically you can write an initial compiler in assembly (or another language for which the computer has a working compiler), and then use the initial compiler to compile the new compiler which may have more features or better optimization?

I was confused because it didnt say how he compiled the c compiler.

6

u/Herbstein Jul 17 '20

And an approach is to write a horrid compiler that barely works in something like assembly, and then use that horrid compiler to write a better compiler in the language, and then continually bootstrap your compiler with continually improving compilers. Rust was initially build in OCaml, and eventually they used an OCaml-built compiler to build a compiler that was written in Rust, and from there it has just been a spiral of Rust compilers all the way down.

1

u/anddam Jul 18 '20

But it did

using one of the university computers […] bootstrapping my way to […] run […] on an Intel 8080 based microcomputer.

1

u/console-write-name Jul 18 '20

Guess I just didn't understand what that entailed

1

u/georgeo Jul 18 '20

There's really no reason you couldn't write the C compiler with the BASIC interpreter. No Asm needed!