r/programminghelp • • Nov 23 '22

R Eli5 how can people code a coding software? When the first coding “language” was created. How did they code that if there was no other language to code the new language

I didnt know where to post this, in r/explainlikeimfive it got removed and in r/programming it wasnt possible. Idk where else to post this

4 Upvotes

6 comments sorted by

6

u/Ok-Wait-5234 Nov 23 '22 edited Nov 23 '22

Originally, computers were programmed by physically entering instructions into their instruction memory. Programming was a case of writing the program by hand on paper as assembly language instructions, converting those by hand into machine code instructions and writing those down, and then using a machine to punch holes representing those instructions into special cards. The cards would be loaded into a reader which would read them into the computer's memory.

Eventually, computers became good enough and cheap enough that it was worthwhile using them to run a program that would let you enter assembly language onto the computer, and have it do all the conversion into machine code (and maybe even output the punch cards to be taken elsewhere). From there, people wrote compilers for primitive higher-level languages, building on the work that was previously done.

2

u/[deleted] Nov 23 '22

So they basically “manually” switched the electrodes from on to off and made a coding language with that?

1

u/Ok-Wait-5234 Nov 24 '22

Yeah. There's always a "bootstrapping" problem with computers - how do you tell a computer how to understand what you're telling it to do. If you are starting from nothing, you need to have some way of getting a computer to accept instructions so it can start working. Essentially every computer ever made has hardware that reads initial instructions from some particular source. For example, early computers perhaps just had a hardware mode where the hardware just reads from a punch card reader into memory, and then when the deck of cards was read, you'd flick a switch (or it would happen automatically) and the computer would start executing instructions out of memory.

To write a compiler like this, you write the compiler as machine instructions on paper, and punch that onto punch cards and feed it to your computer. Then you write your program to be compiled and punch its source code into the punch cards, and feed that to the running computer so that the compiler can read and process it. The computer would output the compiled program onto, probably, more punch cards.

I have definitely also seen pictures of computers that had rows of switches that you would use to manually enter the instructions to execute. However, it would be very tedious indeed and I think you'd typically only use that to instruct the computer how to read from a more convenient source.

Modern computers usually read initial instructions from a ROM (or other semi-permanent memory), which tells it how to start reading the real operating system from disk (or wherever). This is the BIOS or UEFI in PCs.

The are other ways of bootstrapping computers. For example the Apollo guidance computers ran instructions from a read-only memory called core rope memory. The programs were written by researchers at MIT, compiled into their machine code values (not sure if this was done by hand or on MIT's computers or other machines), and these values were written out in binary. And then, the binary codes were literally sewn into ropes of tiny wires by hand, in such a way that they could be read electrically! I don't know whether this was used for more terrestrial applications, but it is a very good example of how one can write the initial instructions for a computer without necessarily having a computer to do it.

Punch cards to hold "programs" or "data" is a much older technology than computers, btw: they were used as a way of storing patterns for automatic(ish) weaving looms from as early as 1725! It's only natural that such a mature data-storage technology would be used for storing programs and program data.

1

u/WikiSummarizerBot Nov 24 '22

Core rope memory

Core rope memory is a form of read-only memory (ROM) for computers, first used in the 1960s by early NASA Mars space probes and then in the Apollo Guidance Computer (AGC) and programmed by the Massachusetts Institute of Technology (MIT) Instrumentation Lab and built by Raytheon. Software written by MIT programmers was woven into core rope memory by female workers in factories. Some programmers nicknamed the finished product LOL memory, for Little Old Lady memory.

[ F.A.Q | Opt Out | Opt Out Of Subreddit | GitHub ] Downvote to remove | v1.5

2

u/CorporalRustyPenis Nov 23 '22

All code gets converted to binary instructions the machine can understand. The machine cannot understand any programming language any more than it can understand English, it can only understand binary instructions in the CPU instruction set. Through a process called compilation, the code you write gets converted to binary instructions that the machine can understand. Compilers are essentially translators that can translate whatever language it compiles into native machine instructions. The first compiler was written by hand with machine instructions.

2

u/qlkzy Nov 23 '22

This is a problem called bootstrapping. You can do it by hand, from scratch, provided your programming language is simple enough, by working through each step of compilation on pencil and paper.

Once you had the necessary machine code written out by hand, you could then get it into the memory of your computer using punched cards or paper tape.

Obviously this process is very laborious, so if you did have to start from scratch, the general procedure would be to build up gradually: hand-compile a very small and simple programming language, then use that to implement a larger and more useful language, and so on.

This approach was still occasionally used into the 1980s, but it's mainly a hobby curiosity these days. The advantage is that you can start immediately writing a self-hosting compiler (which is often the end goal for systems languages), rather than having to write an initial compiler in another language then throw it away.