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

1.16K 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

There’s two important ideas you’re hitting here, and I want to talk about both of them.

First, there’s history. Each early language was usually made the same way: lazy programmers. Ugh, who wants to write all this binary when I could make a program that converts words to the binary patterns I want for me! <fast forward a few years> Ugh, who wants to write all these assembly instructions when I could just write a program that converts higher level abstract code into assembly for me!

Then later: Ugh, people keep making mistakes in this code- I’ll write a program that forces people to follow good patterns, a ‘computer language’. This is followed by decades of research into the very concept of ‘computer languages’ and some wonderfully rich and interesting history. Each compiler was written in some lower language compiler, typically.

But the second concept is, I think, more interesting: self-hosted compilers. Rust (a pretty new language) had a compiler originally that was written in OCaml (a very hard language to learn, believe me). Then one day, they wrote a Rust Compiler in Rust, used the OCalm compiler to make that program, and then threw away the OCalm compiler.

The Rust compiler is written in Rust. When they improve the compiler, they use the old one to make the new one.

There’s no magic here. Any programming language that is ‘Turing Complete’ can compute any function that any other language can. Compiling is just a function from text (code) to a binary (executable program). In theory, you can write any compiler in any language, including itself.

Source: I knew this Computer Science degree would come in handy someday.

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