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

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

It’s easy to build up a small sand castle with just a single small bucket, and this is like binary. If you want to build something amazing, though, you’ll need to have more tools to make the job doable. You can technically use binary to create whatever you like, although it is much easier to program simple programs which encompass basic tasks like adding or subtracting. Then, using this new program as a ‘frame’ for a new program, you can layer on complexity (or remove complexity, depends how you look at it) for accomplishing more complex tasks. This is the difference between coding “bare metal” and using a high-level language like Java.

There was a first word, but instead of thinking of it as a baby learning English, think of it as how humanity learned to communicate – we’re talking ancient runic text instead of “mom” or “dad”. Compared to programming, English itself is like a high-level language.

Anonymous 0 Comments

Java is actually run by a “virtual machine” entirely written in C++. So it’s a pretty bad example.

But C++ is being compiled by compilers entirely written in C++. How do you compile such compiler? Well, with an older C++ compiler!

But, but, what about the first compiler? It was written in assembly, a long time ago. Although people like to bootstrap C++ from time to time, aka. start from scratch with a smaller language, easier to compile. But that’s just for the kicks of it.

By the way, did you know we need a mill to make a mill?

Lots of stuff in the world is built on previously built stuff, it’s kind of a fun chicken and egg problem. Almost all of them, originally started from painstaking manual work.

Edit: It’s even more fun when you realize C++ compilers have bugs, yet produce newer C++ compilers with less (hopefully) bugs.

Anonymous 0 Comments

The very first “words” on a computer were some poor, patient soul litterally plucking in every 1 and 0 by hand. They’d do this by baking it straight into the circuitry rather than programming it with a keyboard, because, well, how would a keyboard even work if programming doesn’t exist?

People still do this all the time, by the way. A common tool that lets you experiment rapidly is called a “breadboard”, which lets you plug and unplug wires and simple chips to create complex circuits.

After the first literal hard-coded computers were in place, they were extended to be more modular and accept arbitrary input from users via input peripherals, that could then be run as new code. Everything snowballed from there.

Anonymous 0 Comments

Many prior languages existed and some were similar to Java or c++.

I am a retired mainframe assembly language developer, I did that in the 80-90s. Assembly was the first mainframe language, it’s a step above the machine code executed by the chip. Assembly language is what many mainframe languages compiler generates as it’s native to the chipset.

Assembly is crude and rude, you better know WTF you’re doing or bad things happen. Sometimes you can have to read and understand the machine code to debug your code. Principles of Operation is the reference manual for the language.

ETA: One of our programs for class was to be written in machine code to demonstrate our knowledge of the language.

Anonymous 0 Comments

ELI5 answer:
It look very, very simple.
The code that makes up programming languages itself is very simple.

The language can then be quite complexe. Java is one of the worst example you could pick, because it is an interpreted language (this means than it relies on another programm, the interpreter, to run).

But the codes that build it is simple.

It starts with basic instructions:
I want to add data. Instruction: add
I want to store my result: store

You might want to creat type: a byte might be an integer, or a character.

Then, you need to repeat the same instructions in your language.
You start to put a label at the start of your instruction: label my_little_routine
Then you say that you want to go to your label again: goto my_little routine

Then you say that this set of instruction should be used everywhere, so you create a function. This is a mechanism where you store your current data somwhere, then go to your label, then extract your data back from storage once you finish.

You can use a compiler of compiler to create an advanced programming language out ofthese basic operations: [YACC](https://en.wikipedia.org/wiki/Yacc) is one of them

Modern languages implement natively many high level mechanism called design pattern, which is why you are confused: templates in C++, interfaces in java, iterators in python…
These design pattern are common solution to frequent problems.

So we grow programming language, from simple, obvious instruction, to a complexe toolbox.

[Bonus track](https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/generalprogramming/ie_prog_4lex_yacc.html)

Anonymous 0 Comments

You can think of it as layers of an onion. The lowest layer is machine code – functions of the 0’s and 1’s that computer data is stored as.

The next layer is Assembly language, which is just easier to read machine language – the simple functions of 0’s and 1’s are given a name, and grouped. It, like the machine language are specific to the computer chip that will run the program.

The next layer toward JAVA is C++, (which derived from the C programming language), and now it is no longer computer chip specific, it is a general language used to write code for any computer. You run this code through a “compiler”, that converts the C++ into the machine specific assembly language.

The outer layer is the JAVA, which is an easier to use language than the C++. Think of this like a paragraph of C++ does what you want, but you can just give that paragraph a JAVA name, like “A”. Instead of writing all that C++ to do the function you want, you just say in JAVA “do A”.

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.

Anonymous 0 Comments

There are many different “levels,” to programming. (Warning, lots of words, but pretty simple)

The lowest level of programming is transistors. We can build up simple logic gates such as AND and OR directly in the circuitry, and by turning certain switches on and off, we can get out certain behavior such as switching between different components, storing information, or doing simple math. These on and off switches can be represented as 1s and 0s or “binary.”

**01010101 01001111 01101011** -> Would give the instruction “store number 79 in memory slot 107.” The first block (or “byte”) would be the “store,” instruction, followed by the binary number for “79,” and finally the binary number for “107.” (the actual binary would differ depending on CPU architecture, so this is just pretend).

Writing complex programs in nothing but 1s and 0s would be a nightmare, so instead we wrote just enough 1s and 0s to build a program that translates a more readable language called “assembly,” directly into the 1s and 0s we need. So instead of binary, we now write:

**mov 79, 107**-> When run through our new assembler program, gets directly translated to the binary 1s and 0s from the first example. It basically just looks up what “mov,” translates to in a large dictionary and swaps it out for the needed binary. Basically just simple cut and paste.

An assembler is a *very* simple program, but allows us to start thinking closer to human language, and thus allows us to develop more complex software. From there we can write a “compiler,” which is a program that can read over a text file in whatever language we want to come up with and translate that into the binary we need.

**int myVariable = 79;** -> This gets read over by our compiler and translated into binary to be executed. This is how languages like C, C++ work.

From there it’s a self contained loop. A compiled language can be used to write new/better compilers, which in turn can be used to write new/better compilers, etc.

Languages like Java and C# are one level above this. They aren’t compiled into binary, but instead into “bytecode,” which is like binary but instead of being run by the CPU, it’s run using either the Java Virtual Machine or .NET framework which are programs on the users machine designed to read this special bytecode. This allows the individual software developer (like you or I) to write a Java/C# program once, and it will work on any computer system someone has programmed a virtual machine for (most likely programmed in C or C++) which is designed to read these instructions.

Finally we have “Interpreted,” languages like Python and Javascript which are the highest level. With these languages the actual text the programmer typed is what is sent to the end user, and the actual conversion to binary happens as each line is run on the users machine. This is why you can press “F12,” right now and see all of Reddit’s code, since HTML5/Javascript is interpreted.

Anonymous 0 Comments

Don’t think of it as a language, think of it as the evolution of a tool and its uses. Digging, for example. Originally, to dig one would use sharp objects. Eventually, the spade was invented, along with various sizes to accommodate different tasks. Larger tools for digging were invented until machinery allowed for even larger digging equipment and thus more tasks could be accomplished with this greater digging power. In the same way, programming started as soldering circuit boards, eventually moved to punch-cards and and tape reels. Then, with the advent of monitors and keyboards, people could do things like data entry and complex calculations and it just kept going from there.

Anonymous 0 Comments

Like teaching a kid. First the alphabet. Then combining them into words. Then combining them into sentences.