2.2. What is Python?

Python is a special kind of computer language called a scripting language. A scripting language is/has

  • Built in memory management

  • Good facilties for calling and communicating with other programs

These properties are pretty geeky so let’s take each of them in turn and explain why they are desirable.

  • Built in memory management. This one is easy. C is a wonderful programming language that is in many ways the the performance king of programming languages. But it requires you to allocate space in advance for all the components. This is a key feature in acheiving maximal performance but as programs grow and interact with other programs, there is a huge overhead in debugging arcane sounding problems such as pointer aliasing, buffer overruns and memory leaks. Modern machines make paying the performance price required to eliminate a few of these headaches quite feasible. Hence the growing importance of scripting languages in a variety of domains.

  • Good facilities for calling and communicating with other programs.

The Wikipedia page on scripting languages adds some slightly less geeky features to the list

  • Ease of use

  • Operating system facilities (especially file system related)

  • Relatively loose structure. This concept is easiest to understand with a contrast. So contrast Java, which has all kinds of rules about “which classes exist in which files.” This is fine and even healthy for big projects but kind of a pain for simple one-off programs designed for a special purpose task, which often don’t even have to be run more than once.

Script are written “on the fly”.

There are numerous scripting languages out there now

  • Javascript

  • Ruby

  • Perl

  • Php

  • Shell (Unix scripting language): More or less the orginal scripting language, developed on Unix systems to help users and system administrators automate repetitive system maintenance chores, in the days when there were no speciliazed software packages to do each othem.

  • Tcl

In addition languages like R are programming languages originally developed for specialized purposes which over time have evolved to have many of the capabilities of a scripting language.

In understanding the concept of a scripting language it’s useful to contemplate heavy-lifting program languages that aren’t scripting languages, such as C, C++, Java, and Rust. These are industrial-strength languages intended for the implementation of programs that will be used many times, often by a large community of users, sometimes by a community that is paying for the program (which changes the developer-community relationships considerably). Features like efficiency in time and memory, memory management, and maintainability are not only emphasized; they are essential. Heavy-lifting program languages may also come with infrastructure intended to facilitate the collaboration of a large team of developers on a single program. Features like these take time to understand and more time to master. So the price for all these good things is more difficulty in writing and revising programs.

In addition to its basic scripting language properties, Python is interpreted. What this means is that executing a Python progam does not require compiling, ans it does not require linking to previously compiled programs. Although any good program may want to make use of previously existing programs, the lack of any need for compiling makes it easy to just load programs as needed.

In addition, being interpreted means that you can interact with Python’s interpreter as you are building programs, testing out bits of code on their own before assembling them into a complete program. We will make heavy use of this feature. In fact our early interactions with Python will all be interactions with the Python prompt, like this:

>>>  X = 2

We type an expression to the Python prompt or in a Python notebook code cell and then investigate its effect. Only after gaining some understanding of how the pieces work will we run a program.