Are Python Scripts Programs?

Python scriptWe have often heard Python referred to as a scripting language; in fact, often the terms “Python program” and “Python script” used interchangeably. So is Python a true scripting language?

Python Script: What a Scripting Language Is

In order to answer this question, we must first determine what a scripting language is. A scripting language is a language that incorporates support for scripts, and by scripts we mean programs written for a run-time environment (as opposed to programs that are compiled) and that automate the execution of tasks that could otherwise be executed one-by-one by a human operator. Examples of environments that incorporate support for scripting include software applications (programs like Excel and mIRC come to mind), web pages within a web browser, the shells of operating systems, and embedded systems. A scripting language can be viewed as a domain-specific language for a specific environment. Scripting languages can also be viewed as very high-level programming language (as opposed to a low-level programming language such as Assembly), as they operate at a high level of abstraction, or as control languages, particularly for job control languages on mainframes. Thus, we have at least two somewhat distinct ideas of what a scripting language is: [1] a run-time language that only works in a specific environment, such as a software application, or [2] a “glue” or control layer used to control and direct other application components. These categories are not mutually exclusive, but hopefully, the distinction will serve its purpose. To cover the first case, Python programs can indeed serve the role of a domain-specific language, and therefore such a program could be called a Python script. Python programs can be launched from console command lines and perform such tasks as processing text files and launching other programs, which is what we would expect a shell script to be able to do. But this is just one of dozens of common Python application domains, and Python is more than just a shell-script language. To cover the second case, Python programs are indeed often used as the control layer. To test hardware devices, Python programs may call out to components that give low-level access to a device; thus, changes made to the low-level drivers need not affect the control layer. In addition, programs may run Python code at certain points to support end-user product customization. This way, software can be tailored to a customer’s needs without having to recompile and ship the entire system’s source code. However, this is just a common Python role and a subset of what Python can do. Although we could call such code a Python script, Python is more than just a control language. Another sense in which we think of a scripting language is as a simple language for quickly coding tasks. In this sense, perhaps we can think of Python as a scripting language and a program as a Python script. It allows much faster program development than compiled languages like C/C++. But again, Python is not just for simple tasks, and programs can scale up in sophistication as required. That brings us back to the question posed in the beginning of this article: is Python a scripting language? Clearly it can be used as a scripting language, and it supports a rapid and flexible mode of development, but it is much more than just a scripting language. In future articles, I will explore some of the basics of writing a Python script, while also unleashing some of the more powerful functionality of this programming language.

External Links:

Python documentation at python.org