What does the code that makes up programming languages look like?

1.17K views

Take a language like Java. How was it originally created? I can’t wrap my head around how someone invented a computer language to run without having some “prior” language that it allows the first lines to function. Is it just Java all the way down, like someone wrote a single line of Java and then every other line was built on that?

What about the first computer language? What was the basis that that functioned on?

Thanks for any help, I hope that was phrased in a mildly intelligible way.

Edit; I’m trying to think of it like human language: at some point there was a first “word” spoken by someone and understood by another and from there the structure started to be born. What were the first “words” on a computer that led to where we are now?

In: Technology

36 Answers

Anonymous 0 Comments

You don’t need a computer to create a programming language. A programming language is at its most basic just a set of rules defining the syntax and behaviour of the code.

What you need the computer for is the write the compiler (and/or in the case of an interpreted language, the interpreter/runtime environment) and libraries/API. Once you have the compiler, the libraries *can* be written in the same language, but often they are written in an another language (usually a lower-level language or even partly assembly).

Compilers/Interpreters are very often written in the same language they compile (self-hosting), but obviously that’s a cyclic dependency – the first/earliest versions would have been written in prior existing programming languages.

Taking Java as an example: the official Java API is mostly written in Java, with parts of it in C or C++. The official compiler (Javac) which converts Java source code to Bytecode, is today written in Java but originally was written in C and C++. The official Java Virtual Machine (JVM) which runs the bytecode on the various platforms that Java supports, as far as I know is always written in C. Note that I keep saying official – anyone is able to write their own version. Oracle’s licensing shenanigans aside, nothing stops you writing the JVM in C#, or Javac in JavaScript.

C++ is a special case; the first C++ compiler was written in C++, but my understanding is there were some ugly hacks and conversions to actually get it compiled in a C compiler. The first C compiler originally evolved from a language called BCPL. Go up the chain far enough, and eventually you reach someone who was programming a computer by writing assembly language, pulling wires, flipping switches, or typing on a punch card.

You are viewing 1 out of 36 answers, click here to view all answers.