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

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.

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