PP Innovative Features of Scripting Languages
PP Innovative Features of Scripting Languages
of
Scripting Languages:-
1
Scripting Languages
• Scripting is the action of writing scripts using a scripting language
• scripting languages is just another kind of programming
• The use of the word ‘script’ in a computing used for the sequence of commands
that were to be read from a file and follow in sequence.
• This style of programming frequently uses a scripting language to interconnect ‘off
the shelf ‘ components that are themselves written in conventional language.
• Applications built in this way are called ‘glue applications’ ,and the language is
called a ‘glue language
2
Types of Scripting Languages
• Server-side Scripting Language
• Can use huge resources of the server
• Complete all processing in the server and send plain pages to the client
• Reduces client-side computation overhead
• Client-side Scripting Language
• Does not involve server processing
• Complete application is downloaded to the client browser
• Client browser executes it locally
• Are normally used to add functionality to web pages e.g. different menu styles, graphic displays
or dynamic advertisements
3
Different Scripting Languages
4
Different Scripting Languages
• PHP (Hypertext Pre-Processor)
• Especially good at connecting to MySQL
• Very popular language
• Runs on UNIX and Windows
• HTML-embedded scripting language
• Syntax looks like C, JAVA, and PERL
• Generate Dynamic content and good User Interface
• Server side execution
• JSP (Java Server Pages)
• Developed by Sun
• Uses Java
• Provide server-specific framework like Microsoft’s ASP
5
Different Scripting Languages
● VBScript
○ Microsoft’s scripting language
● JavaScript
○ Client-side Scripting language
○ Allows to perform calculation, write interactive games, add special effects, customize graphic selections, create security passwords
Glue Languages
8
Scripting Language Evolution
• Modern scripting languages have two principal sets of ancestors.
• command interpreters or “shells” and “terminal” (command-line)
• IBM’s JCL, MS-DOS command interpreter, Unix sh and csh
• various tools for text processing and report generation
• IBM’s RPG, and Unix’s sed and awk.
• From these evolved
• Rexx, IBM’s “Restructured Extended Executor,” which dates from 1979
• Perl, originally devised by Larry Wall in the late 1980s, and now the most
widelyused general purpose scripting language.
• Other general purpose scripting languages include Tcl (“tickle”), Python,
Ruby, VBScript (for Windows) and AppleScript (for the Mac)
9
Scripting Language Evolution
• Scripting on Microsoft platforms
• Most of the Microsoft scripting applications are based on VBScript
• Microsoft has also developed a very general scripting interface (Windows
Script) that is implemented uniformly by the operating system, the web
server, and the Internet Explorer browser
• A Windows Script implementation of JScript, the company’s version of
JavaScript, comes pre-installed on Windows machines
• Many other Microsoft applications use VBScript as an extension language
• Given Microsoft’s share of the desktop computing market, VBScript is one
of the most widely used scripting languages
10
Characteristics of scripting languages:
1. both batch and interactive use
2. economy of expression
3. lack of declarations; simple scoping rules
4. flexible dynamic typing
5. easy access to other programs
6. sophisticated pattern matching and string manipulation
7. high level data types
11
1.Both batch and interactive use
- While a few languages (e.g. Perl) have a compiler that requires the entire
source program, almost all scripting languages either compile or interpret line by
line.
2.Economy of expression
• Two variants: some make heavy use of punctuation and short identifiers
(like Perl), while others emphasize “English-like” functionality
• Either way, things get shorter. Java versus Python (or Ruby or Perl):
class Hello {
public static void main(String[] args) {
System.out.println(“Hello, world!”);
}
print “Hello, world!\n”
12
• Lack of declarations; simple scoping rules.
• While the rules vary, they are generally fairly simple and additional
syntax is necessary to alter them.
• In Perl, everything is of global scope by default, but optional parameters can
limit the scope to local
• In PHP, everything is local by default, and any global variables must be explicitly
imported.
• In Python, everything is local to the block in which the assignment appears, and
special syntax is required to assign a variable in a surrounding scope.
13
■ Flexible dynamic typing
– In PHP, Python and Ruby, the type of a variable is only checked right before use
– In Perl, Rexx, or Tcl, things are even more dynamic:
$a = “4”
print $a . 3 . “\n”
print $a + 3 . “\n”
Outputs the following:
43
7
14
■ Easy access to other programs
– While all languages provide support for OS functionality, scripting languages
generally provide amazing and much more fundamental built-in support.
– Examples include directory and file manipulation, I/O modules, sockets, database
access, password and authentication support, and network commmunications.
■ Sophisticated pattern matching and string manipulation
– Perl is the master of this, but it traces back to the text processing sed/awk ancestry.
– These are generally based on extended regular expression
15
■ High level data types
– In general, scripting languages provide support for sets, dictionaries, lists
and tuples (at a minimum).
– While languages like C++ and Java have these, they usually need to be
imported separately.
– optimizations like arrays indexed using hash tables are quite common.
– Garbage collection is always automatic, so user never has to deal with
heap/stack issues.
Innovative Features: Scope and Names
■ Most scripting languages do not require variables to be declared
– Perl and JavaScript permit optional declarations - sort of compiler-checked
documentation
– Perl can be run in a mode (use strict ’vars’) that requires declarations
■ With or without declarations, most scripting languages use dynamic typing
– The interpreter can perform type checking at run time, or coerce values when
appropriate
– Tcl is unusual in that all values—even lists—are represented internally as strings
17
Innovative Features: Scope and Names
■ Nesting and scoping conventions vary quite a bit
– Scheme, Python, JavaScript provide the classic combination of nested subroutines
and static (lexical) scope
– Tcl allows subroutines to nest, but uses dynamic scope
– Named subroutines (methods) do not nest in PHP or Ruby
– Nested blocks are statically scoped in Perl
– In Ruby, they are part of the named scope in which they appear
– Scheme, Perl, Python provide for variables captured in closures
– PHP and the major glue languages (Perl, Tcl, Python, Ruby) all have sophisticated
namespace rules
18
Innovative Features: Scope and Names
■ Undeclared variables with static scope present an interesting issue: how do
we know if x is local, global, or in-between (if scopes can nest)?
– In Perl, all variables are global unless otherwise specified.
– In PHP, local unless explicitly imported.
– Ruby has only two levels: $foo is global, foo is local; @foo is instance of current
object, and @@foo is instance variable of current object’s class
– In Python, all variables are local by default, unless explicitly imported:
i=1; j=3
def outer()
19
Innovative Features: Scope and Names
■ Scope in Python
– By default, there is no way for a nested scope to write to a
non-local or non-global scope
■ R has an interesting convention:
– Normal assignment puts value into the local variable:
i <- 4
– Superassignment puts value into whatever variable would be found
under normal (static) scoping rules:
i <<- 4
20