Information Technology Reference
In-Depth Information
Some common examples include Perl, Python, and Ruby. Perl is older and very popular
withsystemadministratorsbecauseitissimilartoCandawk,languagesthatUNIXsystem
administrators traditionally know. Python has a cleaner design and the code is much more
readable than Perl code. Ruby has a strong following in the system administrator commu-
nity. It is similar to Perl and Python in syntax, but adds features that make it easy to create
mini-languages,purpose-builtforaspecifictask.Moreprogramscanthenbewritteninthat
mini-language.
Scripting languages aremoreflexible andversatile thanshell scripts. Theyaremoreex-
pressive, permit better code organization, scale better, and encourage more modern coding
practices such as object-oriented coding and functional programming. Better testing tools
are available, and there are more prewritten libraries. Scripting languages have the abil-
ity to access networks, storage, and databases more easily than shell scripts. Better error
checking is also available.
Perl,Python,andRubyallhavelargelibraries ofmodulesthatperformcommonsystem
administration tasks such as file manipulation, date and time handling, transactions using
protocols such as HTTP, and database access. You will often find the program you write is
leveraging many modules, gluing them together to create the functionality you need.
A disadvantage of scripting languages is that they execute more slowly than compiled
languages.Thisdrawbackhasbeenmitigatedinrecentyearsbynew,fasterinterpretertech-
nology. Nevertheless, for the reasons described earlier, speed is not always essential in
automation.Thuslanguagespeedisoftennotafactorinsystemadministrationtoolswhose
speed is bounded by other factors. For example, if the program is always waiting on disk
I/O, it might not matter if the program itself is written in a fast or slow language.
The primary disadvantage of scripting languages is that they are inappropriate for very
largesoftwareprojects.Whilenothingpreventsyoufromwritingaverylargesoftwarepro-
ject in Perl, Python, or Ruby (and many projects have been done this way), it becomes lo-
gisticallydifficult.Forexample,theselanguagesarenotstronglytyped.Thatis,thetypeof
a variable (integer, string, or object) is not checked until the variable is used. At that point
the language will try to do the right thing. For example, suppose you are concatenating a
string and a number: the language will automatically convert the number to a string so that
it can be concatenated. Nevertheless, there are some situations the language can't fix, in
which case the program will crash. These problems are discovered only at run-time, and
often only in code that is rarely used or tested. Contrast this to a compiled language that
checks types at compilation time, long before the code gets into the field.
For this reason scripting languages are not recommended for projects that will include
tens of thousands of lines of code.
Search WWH ::




Custom Search