Published on by nick
I'm reading Kief Morris' book, Infrastructure as Code, and early on he refers to Python, lumped together with Bash, Perl, PowerShell and Ruby, as a general-purpose scripting language. While many developers (including myself) use Python to script things, I would conclude that, in general, Python is not a scripting language.
Some years ago, a colleague recommended an all-purpose tool for doing utility scripting. At the time, I was mostly working on Windows, so batch was an obvious choice. And similarly, since many of our servers were running some flavor of Linux, bash scripting was good too. At that time, I decided to learn bash, because I knew I was going to be working primarily in the Linux/Unix environment moving forward.
The way in which I use bash follows a common theme: I find myself needing to automate some task, and often it needs to run on a Linux system. This "script" should also be callable without human intervention, eg, started by another program or script. I might need to transfer data between servers; I might need to parse a test file and output to another file; I might need to automate system administration tasks. So what do I do? I open vim and start typing commands. It's so easy, and it's so intuitive, that it fits right in. I'm already performing many of these tasks manually in the terminal, so why not just collect them into a file for use later on...
Now obviously I can perform some if not all of these tasks with Python. For that matter, I could use Perl, Ruby, or several others for these kind of simple utility scripts. But I don't, because it's so quick and easy to use something like bash. But this is not why I believe Python is not a scripting language. It actually can be considered a scripting language, depending on how you define one. There are numerous articles and Stack Overflow discussions that deep-dive into this topic, so I will not go into much detail here. Suffice it to say, if the script/program is interpreted it's often considered a scripting language; if it's compiled, it's not. OK, that's a clean distinction right? Wrong... It seems there is debate even on this definition.
The thing about Python is that it "sit[s] in both camps: Python is widely used without a compilation step, but the main implementation (CPython) does that by compiling to bytecode on-the-fly and then running the bytecode in a VM, and it can write that bytecode out to files (.pyc, .pyo) for use without recompiling. (T.J. Crowder, 2013)"
The more I learn about Python, the more I realize that this programming language is capable of quite a lot. Take, YouTube, Dropbox, and Pinterest for example. These large-scale web applications rely on Python for key pieces of their stack, and they handle large amounts of traffic and data.
Python is also a favorite among the scientific and cybersecurity communities. Michael Kennedy (@mkennedy) over at the Talk Python to Me podcast, described as "[a] podcast on Python and related technologies" has guest after guest on who discuss how Python is basically revolutionizing the technology world with its pervasiveness and power. It's used so widely and for so much, that calling it merely a scripting language is no longer accurate. Sure, it can be used to script tasks and automate anything, but it's also so much more. It has been called a scripting language quite a lot, but I think it's time to stop doing so... Just because lots of people do something, doesn't mean it's the right thing to do.
Take bash, on the other hand... it can only really ever be used to script tasks -- sure, it can be used to write more complex programs; but, by and large, developers and technologists who use it, use it for its ease of use, it's ubiquity, it's fusion and integration with the most widely used operating system in the server and application world: Linux.
My goal in writing this article is not to start an argument. It's mainly to make a distinction that I believe is becoming more apparent. I think that part of the reason Python is still referred to as a scripting language by some folks is that it had this stigma associated with it for many years. But when frameworks like Django came around, and then the distributed nature of large-scale web applications began taking the world by storm, Python stepped up and filled a very important niche -- simple, easy-to-use, yet powerful and widely supported, not to mention the enormous community of open source projects on GitHub, and the nearly 100000 packages available through PyPi...