What Do Programming Languages Do?
Programs are recipes that make your computer do things.
Under the hood, computers are controlled by machine instructions. These are direct commands which tell the computer how to arrange switches and gates in the processor, memory and other parts.
In the beginning, all computers were programmed in machine instructions. It was possible to write simple programs in machine code, but it quickly became very difficult to write complex ones.
Programming a computer this way is like directing traffic by hand; it works, but it’s exhausting and expensive!
The programming community started to invent languages to make programming easier. At first, these languages were just English versions of machine instructions. Such a language is called an assembly language. Each computer chip had its own machine instructions, so each computer had its own assembly language.
This was way too difficult! Over time, programming languages evolved into something much closer to natural language (the language you speak in real life).
So why not just use natural languages? Natural languages are full of ambiguities. Consider the sentence “we saw her duck“. In this sentence, duck can be the noun (a bird) or the verb (to get out of the way). The sentence could mean “we saw the bird she owns“, or it could mean “we saw her crouch to the floor to get out of the way“.
Computers are really bad at ambiguity. They follow instructions perfectly but stupidly:
Python is a modern programming language, meant to be very close to English language, but still clear enough to turn into machine instructions for the computer.
Of course, we have been using the term programming language ambiguously!
When we say Python, we mean two things:
First, Python is a language, which means a set of rules.
Human languages have vocabularies and grammar rules; lächerlich is not a word in the English language, but it is a word in the German language. In English, it is not okay to say “apples buy I”, but it is okay to say “I buy apples”.
Programming languages also have vocabulary (in the form of keywords, and variables, which we will learn about later) and grammar rules (or syntax). In Python, it is okay to write:
print "Hi, Everybody!"
but it is not okay to write:
"Hi, Everybody!" print
When you program, you write code, which is just text that fits the Python rules.
Second, Python is a program which takes your code (the human readable stuff) and turns it into machine instructions (the computer stuff) and runs your computer.
So Python is a language (like English or German) for writing code, and also a program which interprets that code, using it to control your computer.