TK2053
PROGRAMMING PARADIGM
Scripting Programming Languages
2
Why Scripting Languages
• Traditional programming languages are concerned with building a
self contained environment:
Receives Input Generate Output
• BUT, most uses of computers involves coordination of multiple
programs.
E.g.: Large organization payroll system
- time-reporting data from card reader
- scanned paper forms
- manual ‘keyboard’ entry
- database query …
A NEED for programs that coordinate other programs.
Programming Language Pragmatics 3rd Edition, Michael L. Scott
3
Why Scripting Languages
• It is possible to write coordination code in Java, C or other
conventional language
• BUT, conventional languages stress efficiency,
maintainability, portability, and the static detection of
errors.
• Their type systems are commonly based on hardware-
level concepts (i.e. fixed size integers, floating-point
numbers, characters, and arrays).
Programming Language Pragmatics 3rd Edition, Michael L. Scott
4
Why Scripting Languages
• CONTRARILY, Scripting Languages stress flexibility, rapid
development, local customization, and dynamic (run-time)
checking.
• Their type systems embrace high-level concepts (i.e. tables,
patterns, lists, and files).
• Scripting languages, specifically general-purpose scripting
languages (e.g. Perl, Python), are known as glue languages.
• glue existing programs to build a larger system.
Programming Language Pragmatics 3rd Edition, Michael L. Scott
5
Scripting Languages
“Scripting languages assume that a collection of useful components
already exist in other languages. They are intended not for writing
applications from scratch but rather for combining components.”
- John Ousterhout, the creator of Tcl -
Modern scripting languages have two principal sets of ancestors.
• Command interpreters or command-line computing
‒ IBM’s JCL, the MS-DOS command interpreter, and the Unix sh and csh
shell families
• Various tools for text processing and report generation
- IBM’s RPG and Unix’s sed and awk
- Evolved to general-purpose languages as Rexx, Perl, Tcl, Python, Ruby,
VBScript, AppleScript
Programming Language Pragmatics 3rd Edition, Michael L. Scott
6
Scripting Languages
• Some authors reserve the term “scripting” for the glue
(coordination) languages, but it also includes web
scripting and extension languages.
• Web scripting:
- Growth of the World Wide Web in the late 1990s, Perl was adopted to
become the language for server-side processing.
- One web-scripting enthusiast Rasmus Lerdorf, created a collection of
scripts (written in Perl) to track access to his home page. These scripts
eventually morphed into a fully fledged independent language known as
PHP (currently most popular server side scripting).
Programming Language Pragmatics 3rd Edition, Michael L. Scott
7
Scripting Languages
• Extension languages
- To extent the functionality of complex applications
- Several languages, including Tcl, Rexx, Python, and the Guile and Elk
dialects of Scheme, have implementations designed in such a way that
they can be incorporated into a larger program and used to extend its
features.
Programming Language Pragmatics 3rd Edition, Michael L. Scott
8
Common Characteristics
• Both Batch and Interactive use.
• Economy of Expression.
• Lack of declarations; simple scoping rules
• Flexible dynamic typing.
• Easy access to other programs.
• Sophisticated Pattern matching.
• High-level data types.
Programming Language Pragmatics 3rd Edition, Michael L. Scott
9
Common Characteristics
• Both Batch and Interactive use.
Code can be compile or interpret input line by line.
• Economy of Expression.
• Lack of declarations; simple scoping rules
• Flexible dynamic typing.
• Easy access to other programs.
• Sophisticated Pattern matching.
• High-level data types.
Programming Language Pragmatics 3rd Edition, Michael L. Scott
10
Common Characteristics
• Both Batch and Interactive use.
• Economy of Expression.
• Avoid extensive declaration and top-level structure common
to conventional languages
• Lack of declarations; simple scoping
Conventional language: Java
rules
Scripting language: Python
• Flexible
class Hello { dynamic typing.
print(‘Hello, world!\n’)
public static void main(String[] args) {
• EasySystem.out.println("Hello,
access to otherworld!"); programs.
}
• Sophisticated
} Pattern matching.
• High-level data types.
Programming Language Pragmatics 3rd Edition, Michael L. Scott
11
Common Characteristics
• Both Batch and Interactive use.
• Economy of Expression.
• Lack of declarations; simple scoping rules
• Most scripting language dispense with declaration and provide
simple rules to govern the scope of names. Example:
Perl everything is global by default, optional declaration can be used to
limit variable to a nested scope
Python Any variable that is assigned a value is local to the block in which
the assignment appears. Special syntax is required to assign to a
variable in a surrounding scope.
• Flexible dynamic typing.
• Easy access to other programs.
• Sophisticated Pattern matching.
• High-level data types.
Programming Language Pragmatics 3rd Edition, Michael L. Scott
12
Common Characteristics
• Both Batch and Interactive use.
• Economy of Expression.
• Lack of declarations; simple scoping rules
• Flexible dynamic typing.
• Most scripting languages are dynamically typed.
• For some (e.g. Python and PHP), the type of variable is
checked immediately prior to use.
• Easy access to other programs.
• Sophisticated Pattern matching.
• High-level data types.
Programming Language Pragmatics 3rd Edition, Michael L. Scott
13
Common Characteristics
• Both Batch and Interactive use.
• Economy of Expression.
• Lack of declarations; simple scoping rules
• Flexible dynamic typing.
• Easy access to other programs.
• Scripting languages provide a more fundamental, and have much
more direct support to request the underlying operating system to run
another program, or to perform some operation directly. .
• Sophisticated Pattern matching.
• High-level data types.
Programming Language Pragmatics 3rd Edition, Michael L. Scott
14
Common Characteristics
• Both Batch and Interactive use.
• Economy of Expression.
• Lack of declarations; simple scoping rules
• Flexible dynamic typing.
• Easy access to other programs.
• Sophisticated Pattern matching.
• Scripting languages tend to have extraordinarily rich facilities
for pattern matching, search, and string manipulation.
• High-level data types.
Programming Language Pragmatics 3rd Edition, Michael L. Scott
15
Common Characteristics
• Both Batch and Interactive use.
• Economy of Expression.
• Lack of declarations; simple scoping rules
• Flexible dynamic typing.
• Easy access to other programs.
• Sophisticated Pattern matching.
• High-level data types.
• High-level data types are like sets, bags, dictionaries, lists, and
tuples
• Scripting languages build high-level types into the syntax and
semantics of the language itself.
Programming Language Pragmatics 3rd Edition, Michael L. Scott
16
Common Characteristics
• Both Batch and Interactive use.
• Economy of Expression.
• Lack of declarations; simple scoping rules
• Flexible dynamic typing.
• Easy access to other programs.
• Sophisticated Pattern matching.
• High-level data types.
Programming Language Pragmatics 3rd Edition, Michael L. Scott