If you're tired of mousing around on your computer and doing the same thing over and over or want to build applications for the Web, you might want to check out the various scripting languages available. The good news is they are relatively easy to learn, at least as far as programming languages go. Plus, because they can automate repetitive tasks, the time spent learning them really pays off.
History of ScriptingScripting has been around as long as computers. In fact, scripting was the only way to use a computer back in the early days. In the 1950s and '60s, programmers submitted punch cards to mainframe operators, and the machines ran in batch mode. IBM's Job Control Language (JCL) is often cited as one of the first scripting languages. But while scripting languages were functional, their response time wasn't nearly as fast as modern computers - it often took at least a day to get results!
When interactive time-sharing systems started to be developed in the 1960s, the idea of scriptable shells came into practice. One of the earliest was the MULTICS project. When a few Bell Labs programmers pulled out of the project, they decided to implement their own system, which they dubbed UNIX. One innovation in the Unix shells was the ability to send the output of one program into the input of another, making it possible to do complex tasks in one line of shell code. Other scripting languages have followed in the Unix world, such as AWK and Sed, for manipulating text.
Another major scripting language, Perl, was invented by Larry Wall in 1987, and became popular in the World Wide Web boom of the '90s for creating Web applications. Other languages, like Python and Ruby, have followed. We'll take a closer look at some of these later. (Learn some more about the history of programming languages in Computer Programming: From Machine Language to ArtificIal Intelligence.)
The Uses of ScriptingA typical example of how a scripting language is used is in renaming lots of files. These languages make it easy to find files matching certain names via wild card patterns, and include operations for copying, renaming and deleting files, or running programs with the file names as arguments.
Another major use of scripting languages, as mentioned previously, is in developing Web applications. Scripting languages used this way really take advantage of their rapid application development abilities. They're not as fast as using languages like C, C++ or Java, but with the steady increase in processing power thanks to Moore's Law, it's better to save programmer time than computer time anyway. Since these languages operate at a very high level, developers don't have to worry about managing memory, another source of bugs and delays. What this means is that compared to a system language, a single programmer can develop a very powerful application with less code using a scripting language.
Diving Deeper: Serious Applications with ScriptingSince many of these scripting languages are full-fledged programming languages, you can create complete applications if that's what you want to do. The biggest advantage to this is that instead of having to wait for your program to compile, if you have an idea, you can bang out some code and get results. Of course, when the inevitable mistakes and bugs creep in, it's easy to fix your program as well. This allows for rapid application development and rapid prototyping of software. This is valuable on the Web, where startups have to add new features quickly to stay ahead of their competitors.
Scripting languages are often distinguished from "system programming" languages like C. Computer scientist John Ousterhout (himself a creator of a popular scripting language, TCL) made the categories famous in a 1998 article published in IEEE Computer Magazine, in what's become known as Ousterhout's Dichotomy between system and programming languages. System languages are compiled and designed for maximum efficiency, while scripting languages are interpreted, and made for "gluing" together pre-existing components. In fact, scripting languages are often called "glue languages."
Programmers, however, don't necessarily have to choose between using system languages and scripting languages exclusively. It's common to start out by implementing an initial idea in a scripting language before rewriting part or all of an application in a system language for improved performance. A scripting language serves the same role for a programmer that a sketch pad does for a sculptor.
Why Scripting?Technical computer users ranging from system administrators to professional programmers and dedicated computer enthusiasts employ scripting languages simply because they save so much time. The learning curve is a lot shallower than other languages and this allows people to get productive quickly, without having to deal with a develop/compile/debugging cycle. This frees them up to automate away the drudgery and work on the things that really matter.
Scripting Languages RoundupHere is a look at the various scripting languages in use today:
- Unix Shells: One of the original scripting languages in the Unix and Linux world, and still a good choice for working with files and programs. The "standard" in the Linux world is Bash, or the Bourne Again shell. (It's a play on the Bourne shell developed at AT&T in the 1970s.)
- Perl: Another popular choice. Perl is installed on a lot of systems, especially Unix and Linux systems. Its fans love its flexibility. One popular saying in the Perl community is that "There's more than one way to do it," often abbreviated to TMTOWTDI. Perl became known as a way to run Web applications on the server back in the dot-com boom, and its ubiquity has caused it to be known as "the duct tape of the Internet."
- Python: One of Perl's main rivals for popularity. The Python community, however, prides itself on its clean, readable code.
- Ruby: Has gained attention for its use on the Web, especially the Ruby on Rails framework that powers sites like Twitter.
- PHP: Also used heavily on the Web because its integrates very well with HTML. However, it also has a reputation for producing messy code.
- Powershell: Microsoft's latest scripting language in the Windows world, this one allows administrators and power users to automate tasks.
Take Back the PowerIf you feel like your computer's using you instead of the other way around, why not get some control back by automating your work with a scripting language? Or perhaps you want to enter the exciting world of Web development? If so, learning one or more of these languages will make the programming world your oyster.
Tell us what scripting language floats your boat by tweeting us using the hashtag #bestscripting.