Programming language and interpreter
New:
- programming language
- syntax
- interpreter
A programming language is only an idea, like English. It's not a physical object, an app or a device. What is English? A set of words and rules. You understand me now because I use valid words and follow the rules. But if I say "jammbfer-flower underpantning 231", you won't understand me at all (I hope). A programming language is also a set of words and rules. If you use valid words and follow the rules, a special computer application will be able to understand it.
Luckily, programming languages contain very few words and rules. The set of words and rules is called syntax. Most languages have similar syntaxes. So, knowing Python will make it easier for you to learn JavaScript, C++ or Java.
Notice, we said "a computer application will understand it", not "a computer will understand it". Computers don't understand programming languages. They are rather dumb machines not capable of such complex tasks without special programs (apps). In the case of Python and a few other popular languages, the special program is called an interpreter. A Python interpreter is an app you can freely download and install. (You don't have to do this now, but you can if you want. It's not that obvious how to start using the interpreter if you don't have prior experience. As you'll soon see, we're going to use a simpler approach in this course.)
You, as a programmer, will write code into one or more text files. Then you'll run the interpreter app which would create a running program out of your code.
A Python interpreter is just a program, and any program can be written in any programming language. The most popular version of the Python interpreter is written in C, an old, powerful language. There are other versions of the interpreter. There's even one written in... Python.
Like other programs and apps, interpreters are updated regularly. Sometimes changes become so significant, existing Python code might stop working correctly. For example, there was a large step from Python version 2 to version 3. The change wasn't extremely drastic, it's not like Python 3 is a completely new language. But it's drastic enough so that version 2 interpreter cannot run code written specifically for version 3.
There are organizations with large code-bases designed for version 2 only. This isn't necessarily bad, technically that code can still run forever by using an outdated version of the interpreter. But over time, problems will accumulate: potential security and performance issues may arise and not be fixed because Python 2 is no longer supported and updated by Python developers. New programmers may have difficulty understanding and maintaining the old, unfamiliar code. Clients and customers could suffer as a result. Most organizations are upgrading all of their code from Python 2 to Python 3.
Other popular languages that usually require an interpreter to run are:
- JavaScript
- PHP
- Ruby
- Perl
Wait⦠so, computers require special apps to understand programming languages. But to make those apps, we need computers that understand programming languages. How can they even work then? Seems like a chicken-and-egg problem! Catch-22! This is an interesting topic and there is an ingenious solution to it. It's a topic for future courses. But if you can't wait, read about "bootstrapping" on Wikipedia.
Summary:
- A program is written in a programming language.
- In order for the program to work, code must follow the syntax rules of the language.
- A special app β an interpreter β understands code and actually launches the program (makes it alive).