Search code examples
language-design

When someone writes a new programming language, what do they write it IN?


I am dabbling in PHP and getting my feet wet browsing SO, and feel compelled to ask a question that I've been wondering about for years:

When you write an entirely new programming language, what do you write it in?

It's to me a perplexing chicken & egg thing to me. What do you do? Say to yourself Today I'm going to invent a new language! and then fire up. Notepad? Are all compilers built on previously existing languages, such that were one to bother one could chart all programming languages ever devised onto one monstrous branching tree that eventually grounded out at... I don't know, something old?


Solution

  • It's not a stupid question. It's an excellent question.

    As already answered the short answer is, "Another language."

    Well that leads to some interesting questions? What if its the very first language written for your particular piece of hardware? A very real problem for people who work on embedded devices. As already answered "a language on another computer". In fact some embedded devices will never get a compiler, their programs will always be compiled on a different computer.

    But you can push it back even further. What about the first programs ever written?

    Well the first compilers for "high level languages" would have been written in whats called "assembly language". Assembly language is a language where each instruction in the language corresponds to a single instruction to the CPU. Its very low level language and extremely verbose and very labor intensive to write in.

    But even writing assembly language requires a program called an assembler to convert the assembly language into "machine language". We go back further. The very first assemblers were written in "machine code". A program consisting entirely of binary numbers that are a direct one-to-one correspondence with the raw language of the computer itself.

    But it still doesn't end. Even a file with just raw numbers in it still needs translation. You still need to get those raw numbers in a file into the computer.

    Well believe it or not the early computers had a row of switches on the front of them. You flipped the switches till they represented a binary number, then you flicked another switch and that loaded that single number into the computers memory. Then you kept going flicking switched until you had loaded a minimal computer program that could read programs from disk files or punch cards. You flicked another switch and it started the program running. When I went to university in the 80's I saw computers that had that capacity but never was given the job of loading in a program with the switches.

    And even earlier than that computer programs had to be hard wired with plug boards!