First, I should begin by explaining how languages are divided up. To generalize languages, I will divide them into three categories: low-level, high-level, and natural language.
As you may know, computers are only able to understand machine language. Machine language is the lowest-level language out there, it consists of a series of 1’s and 0’s. Low-level languages are, in nature, tough to read and understand as they are as far as you can get from natural language (if you are unsure of what natural language is it will be coming up). Below I have included an image of Assembly Code.
This code runs the most common beginner code, “Hello World”. To explain the code in layman’s terms, we begin by setting constants which we use throughout the labels(labels are basically the equivalent to methods, but which are actually memory addresses, this will be clearer by the end of the program). From there we manipulate the machines internal registers to hold value while we perform arithmetics to print out the desired word, in this case, “Hello World”. When the program finishes it calls “_end” a label which runs points to its own memory address. The average person would not be able to understand what the code is doing on his own (truthfully I had to beg my brother to teach me, and frustrate him with my lack of understanding). For these reasons, programmers created high-level languages in an attempt to relate closer to the natural language.
High-level languages were created in an attempt to write more readable code. The goal was to create a language that beginners could quickly pick up due to its similarities with natural language. Still, issues would arise because of the ambiguity in natural language. Human’s are capable of understanding abstract ideas, whereas machines are not. High-level language requires the programmer to use specific vocabulary (keywords) and highly structured conventions. The code written in a high-level language will only run if written 100% in conjunction with the language requirements. Of course, this is very different from how humans communicate. A computer would only be able to understand code if it were written with the correct format.
For example in Ruby we write :
Even if you have no programming background in ruby this code should be very simple to follow. This code would be the equivalent of saying:
“If there’s a fire, pull the fire alarm”
However, the following would not work:
This code would be the equivalent of saying:
“Pull the fire alarm, if there’s a fire”
A human would be able to understand what was meant with those instructions. Even though, you told him to pull the fire alarm he was able to deduce you meant only if there was a fire. A computer, on the other hand, would not be able to process this. Firstly, this will result in a compiling or runtime error, as it is not in conjunction with the language syntactical requirements. If the machine could somehow compile this, it would read and follow the instructions directly as it is administered. Therefore, in this example, the computer would pull the fire alarm first and then check if there is indeed a fire.
Natural language consists of all the languages spoken in the world. As you can imagine with language: idioms, slangs, and new words are present. However, unlike machines, humans can deduce the meaning of unknown words based on the context of the sentence.
For example, a casket means two drastically different things in British English and American English. In Britain, a casket refers to a jewelry box whereas in America a casket is another word for a coffin. However, if an American were to tell a British man, “We got an oak casket for my grandpa’s funeral,” they would be able to deduce that you are not referring to a jewelry box.