Choosing a Scripting Language

/getting-started/scripting-languages/choosing-a-scripting-language/

There are hundred, perhaps thousands, of programming languages in the world. Some of them are specialized for specific hardware (iPhones, for example), others are notoriously difficult (c++), and others are general-purpose scripting languages.

Python, Ruby, and several others fall into the “scripting” language category. Scripting languages are designed with flexibility and the end-user in mind. They are built for easy script writing. Because they are so popular, there are often thousands of 3rd party modules available.

This site is all about scripting with the Python programming language. Nevertheless, I thought it might useful to think about import features to consider when choosing a scripting language

Platform Support

The programming language you use must run on your computer. Most scripting languages can run on both Mac and Windows. A few are specific to or run better on one or the other.

  Runs on Windows Runs on Mac
AppleScript no yes
Bash no yes
JavaScript yes yes
Perl yes yes
Python yes yes
R yes yes
Ruby yes yes
Powershell yes no

Readability

While readability doesn’t affect how well a programming language runs, it is a huge factor in how well you learn, view, and understand it.

Here is an example. A simple for-loop in Python typically looks like this.

for n in range(1000):
    print(n)

Granted, A Python for loop could also look like this:

[print(n) for n in range(1000)]

or

print(*range(1000), sep='\n')

or even

[*map(print, range(1000))]

We won’t worry about these less-than-obvious methods, however, because they are not as readable. You probably won’t have to worry about learning them unless you are playing CodeGolf.

CodeGolf XKCD

source: https://xkcd.com/1960/

In Javascript, that same loop might be

for(var n=0; n< 1000; n++){
    console.log(n);
}

In Ruby it would likely look like:

999.times do |n|
    puts "#{n}"
end
  Readability (1-5)
AppleScript 3
Bash 2
JavaScript 3
Perl 2
Python 5
R 2
Ruby 4
Powershell 3

External Module Availability

The language you choose will not have everything built-in you need for every script. You will occasionally need to install and import external libraries. The Python and Ruby communities for external libraries are both vibrant and well used.

  • Python external tools library at https://pypi.python.org/pypi
  • Ruby external tools at https://rubygems.org/

Editor Support

Using a proper code editor is critical. You cannot edit code in any language effectively without a good code editor. Most editors work fine with any language you choose. That being said, some are better than others.

Syntax Highlighting

Make sure the editor of your choice has support for the language you select. If you choose Python, take a look at my 2017 list of recommended editors.

Short List of Scripting Languages

Here is a short list of common scripting languages you may come across:

  • AppleScript
  • Bash
  • JavaScript
  • Perl
  • Python
  • R
  • Ruby
  • Powershell

Don’t let someone go on and on about the merits of compiled languages or how fast they are. The truth is they are moderately faster but the learning curve is much, much higher and the return on investment is just not there for the person that needs to write a quick and dirty script to get something done.

I could go into depth on each one, pros and cons. They are all very similar, with similar features and strengths. Long story short, you just need to pick one. They will all do most of what you need and are easy to get started with.

You are here, reading my guides. I assume this means you want to learn scripting with Python. It is a great choice. I am biased, but Python is easy to learn and extremely flexible. There is a reason it always ranks among the top most popular languages.