[compiler-construction] How was the first compiler written?
The idea is to write a very simple compiler directly in machine code, use it to write a more sophisticated compiler, use the second one to build a third one and so on until you can have a full featured compiler.
I heard about the chicken and the egg and bootstrapping. I have a few questions.
What wrote the first compiler that converted something into binary instructions?
Is assembly compiled or translated into binary instructions?
...I'd find it hard to believe they wrote a compiler in binary.
The first programs were written in machine code (not assembly language) - actual numbers plugged into the computer memory using switches. We've come a long way...
Sometimes this still happens to a small extent - to patch small bits of code or create thunks. I recall punching in numbers into Basic strings that were then executed as small, fast subroutines on early micros. I also remember toggling switches on a PDP-11's front panel to enter a bootloader program into its memory for a university course.
These programs would sometimes be used to process text files to create other programs, and voila programming languages were created.
Woz said in one of his public talks that when he started, he couldn't afford a compiler so he compiled to binary by hand on paper. If you want to see something even more wild, read about the conditions under which Bill Gates and Paul Allen wrote the BASIC for the Altair 8800.
Regarding "writing a computer in binary" -- take a step back from being a programmer and think about what the early computers were. High level stuff didn't yet exist -- you thought about everything in the low level because that's all it was. You had hardware that could do basic logic and arithmetic that you manipulate via machine code (which is just compiled assembly -- Amber explains why this part isn't hard to do by hand) and you wanted this hardware to perform certain mathematical feats. You didn't worry about the non-existent operating system, you just told the hardware (in assembly) how to manipulate the numbers you feed it. It was a just big calculator. The computer of today was built one abstraction at a time.
If you want to break down the barrier that keeps computers feeling like magic, I HIGHLY recommend reading CODE by Charles Petzold and/or The Elements of Computing Systems. With just a basic knowledge of programming, these wonderfully accessible books will have you understanding computers from top to bottom. Obviously, one can't get a comp. sci. or EE degree after just 2 books, but I can say as a self-taught programmer who missed out on the formal training: these books rocked my world!