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

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

The first general purpose computers were one-off machines. Their language were the lowest level opcodes, the binary bits that were used to drive what circuit paths the data inputs were going to undergo. There’s an opcode to add two values, to multiply, to load from a location, to store to a location, etc…

With that, programs were very simple and it was easy to think of programs in terms of CPU instructions alone. These programs were written in terms of punch cards or punch tape. The devices to do this had already existed due to the telegraph system. Indeed, Linux is directly compatible with telegraph teletype machines from the 1910s, you can see some guys on YouTube login to a Linux terminal on one.

Of course, that doesn’t scale. Eventually, especially by the later 1950s, computers already got large and powerful enough, not that programs HAD to get more sophisticated, but that they COULD. Then it became more valuable to manage the complexity by raising the level of abstraction from raw machine instructions to the first programming languages.

They existed in private before 1955, but that was the year the first commercial languages debuted. I can’t remember which came first, Lisp or FORTRAN. Both are still used today, and both represent nearly polar opposites of how to approach computation. FORTRAN is an abstraction of hardware, and Lisp is an abstraction of *a* calculus notation that can express computation, called Lambda Calculus.

The first compilers and interpreters were written on punch cards or punch tape in machine instructions. Once the compiler was loaded, source code in that language was text encoded in punch cards. Again, this sort of thing already existed in the telegraph industry. ASCII encoding was developed for telegraph, and so ASCII and even unicode are both backward compatible with late telegraph development, hence why those early telegraph devices still work with modern computers.

If you had a nice punch card key, it would even type, as a typewriter, the corresponding character on the card in ribbon ink. Each card would be a line of code, and you would try to cram as much code into a single card as possible. Verbosity was your friend when you had to keep thousands of cards in order. So instead of nice variables today, like “velocity”, you would just use “v”. It’s a habit we haven’t needed to have since the 80s and we’ve been trying to shed it as an industry since.

Well, you get yourself a shiny new mainframe, and when you turn the hulk on, New York dims. Ok, how do you write programs for the damn thing? Well, you already have that other mainframe over there, with compilers and programs… Use IT to “transcode”, to “cross-compile” a program for that new machine. Programs are just a form of data, and compilers merely interpret source code into *a* machine code, it doesn’t have to be for the machine the compiler is currently running on, it just means the program that’s output won’t run on *this* machine.

Ok, so then take your paper tape from that machine, bring it over to the new one, and feed it in. Bingo bango, you just compiled your compiler from source code to machine instructions for the new architecture. Now you can reuse all your source code from the other computers.

Oh, you have a new magnetic storage device? Cool, skip the punch cards and store your data on that. Now you can just copy floppies and sell them.

This whole process was repeated from scratch many times, because often enough it was easy enough to do in the early days. When the micro-computer was invented and people had their first Commodore 64s and ZX Spectrums, they even had interpreter firmware built into them. You could just boot them up with nothing and go straight into writing code, typically a form of BASIC or Forth.

Java is a language that is compiled into a universal byte code. These are machine level instructions, but for no machine that actually exists. The machine is virtual, a fiction that exists as a spec document. Java compilers conform to that spec. When you run a Java program, the instructions are first interpreted, so the program can start running all the sooner. Meanwhile, the byte code gets compiled again (Just In Time(tm), aka JIT) into the actual hardware native instructions. The next time that code is executed, it switches over to the machine native form.

The first Java byte code compiler and interpreter, because it didn’t start out with a JIT, was itself written in Lisp.

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