../_images/python_logo.jpg

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 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 may don’t even have to be run that many times.

Script are written “on the fly”

There are numerous scripting languages out there now

  • Perl
  • Php
  • Ruby
  • 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 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 and then investigate its effect. Only after gaining some understanding of how the pieces work will we run a program.