The Shell Language vs. Other Programming Languages


The shell is a high-level programming language, meaning that you do not have to worry about complex tasks such as memory management. This makes it easier to learn than a systems programming language such as C or C++. Shell programs are generally faster to write than corresponding C programs, and they are often easier to debug. However, C programs almost always run faster and more efficiently. Therefore, shell scripting and C programming are used for very different tasks. For quickly writing relatively short tools, shell is a much better choice, but for large systems programming projects, C is clearly superior.

One important feature of shell scripts is that they are interpreted rather than compiled. This means that when you run a shell script, the shell program itself is invoked to run the commands in your file. You can easily test shell scripts as you write them just by running them from the command line. In contrast, compiled languages such as C are written in source files, which must be converted to binary executables before they can be run. You cannot create binary executables from your shell scripts.

In comparison to other scripting languages, such as Perl, Python, or TCL, the shell programming language is tightly integrated into UNIX. It is designed to allow you to call UNIX commands and tools from within your scripts. This means that you already know many of the commands for writing shell scripts, since they are the UNIX commands you use frequently. If you are writing a script that relies heavily on existing UNIX commands, shell is an excellent choice.

However, the shell language was largely written when the Bourne shell was released in 1978. Because it is so important for shell scripts to be backward compatible (since shell scripts are used for so much existing UNIX code), the language cannot evolve as much as other scripting languages. This means that shell scripting lacks many new and powerful features that other languages have introduced more recently. Shell scripting remains an excellent introduction to scripting (and programming in general), and it can be the fastest choice when writing short UNIX-based scripts, but if you find yourself writing longer or more complex programs, you will eventually want to explore other languages (such as Perl or Python).




UNIX. The Complete Reference
UNIX: The Complete Reference, Second Edition (Complete Reference Series)
ISBN: 0072263369
EAN: 2147483647
Year: 2006
Pages: 316

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net