It's a good question.
Bootstrapping, it's called. Nowadays everything can be done with cross-compilation. You can also build emulators, so you can write and debug code in a virtual machine environment before any target hardware is built. We used to do this when I worked on mainframes.
So at the root, when you have no compiler, no assembler, no OS to drive keyboard/screen - how do you get the code running ?
You can write an OS or compiler in assembly language. Without an assembler, you have to translate the assembler to octal (or hex) machine code - there were programmers who could do this in their head, and didn't need to look up codes in the handbook.
Now you have code in octal or hex, how do you get that into the computer? The answer is a switch panel. You enter the address, the data, and press store, and the value is written to RAM (or core store
) This is how we bootstrapped our mainframes. The bootloader was entered by hand, after power up. Some engineers memorized the whole sequence (it was not many instructions).
The bootloader would then read code from a paper tape say, to fill RAM with a longer bootloader or mini-OS to drive more peripherals. The paper tape can be created with a dumb electromechanical machine, or in the days of punched cards you could do it with a hand punch.
Other ways of getting code into memory were hand weaving - http://en.wikipedia.org/wiki/Core_rope_memory
The same method was used for mini computers and early microcomputers e.g. http://www.pdp8.net/pdp8i/pics/pdp8i_frontpanel.shtml?large