Say you have an idea for MyLang, a brand-new programming language.
You write the first version of the MyLang compiler in an already-existing programming language, like Go for example. You compile it with the Go compiler.
Then the *second* version of the MyLang compiler can be written in MyLang and compiled with version 1 of the MyLang compiler.
The first version of the MyLang compiler doesn’t need to support all of MyLang. If you can write a MyLang compiler in MyLang without using all of MyLang’s features, you don’t need to implement those unused features in Go in the version 1 compiler — you can save them for later, when you have the ability to write the MyLang compiler in MyLang.
“Okay that’s fine for 2022 when we have Go and Java and Rust and C++ and all these high-level languages we could write a compiler in. But how did they do it back in the day, in the 50’s / 60’s / 70’s when you’re making the first high-level language for an early computers where there *was* no previous language / compiler you could use?”
The answer to that is you can always program a computer in its native language, machine code. Programmers usually don’t do that today since it’s super tedious, but you can definitely write a simple high level language in machine code. (Especially if you write tools to help you work with machine code first, like an assembler and a debugger.)
Latest Answers