r/programming • • Jul 17 '20

What it was like learning programming in the early 1970s

[deleted] — view deleted post

22 Upvotes

31 comments sorted by

View all comments

Show parent comment

2

u/caspper69 Jul 17 '20

You can parse source code and generate output to a file in just about any programming language worth its salt, ergo, you can create a compiler in any language worth its salt.

How fast it compiles and other limitations are, of course, at the mercy of the host language.

1

u/console-write-name Jul 17 '20

Yeah but how does the computer know how to run the Compiler code if it is written in C? Without a working compiler the source code is just another text file.

1

u/FatalElectron Jul 17 '20

using one of the university computers

They used a computer that had a C compiler to produce another compiler that produced CP/M executables. Then use that compiler to produce a CP/M executable version of the compiler.

1

u/console-write-name Jul 17 '20

Okay that makes sense, thanks

1

u/ElGringoMojado Jul 19 '20

Multi stage process:

  1. Modify the assembly generating modules of the compiler to generate 8080 assembly.
  2. Compile the compiler on another machine that already has a working C compiler.
  3. Use the result to compile the compiler producing 8080 assembly of the compiler.
  4. Take the generated 8080 assembly to the target CP/M machine.
  5. Assemble the 8080 code into an executable.
  6. Use the resulting executable to compile the compiler.
  7. Enhance as desired iteratively.

1

u/caspper69 Jul 17 '20

There's a lot of different ways to skin this cat. Bootstrapping, cross-compilers, even a Canadian cross.

You would be hard pressed to find hardware that has no working compiler toolchain.

1

u/anddam Jul 18 '20

I am curious about the Canadian cross, never heard that before.

1

u/caspper69 Jul 18 '20 edited Jul 18 '20

A Canadian cross is building a cross-compiler on arch A that is meant to run on arch B, but targets arch C.

For example, I might use x64 gcc to build an arm gcc that targets risc-v. Contrived example I know, but common in embedded.

Edit: for full disclosure, you can substitute "target" for "arch." Because if you want to be pedantic, any target that is not the native target implies cross compilation. So building a Windows app using GCC on Linux would be cross compilation, even though they may both be x64 binaries.