Scripting Languages -Ms. Swati Varma Scripting Languages • Traditional programming languages are intended primarily for the construction of self-contained applications: • programs that accept some sort of input, manipulate it, and generate appropriate output. • Also most actual uses of computers require the coordination of multiple programs. • Also the creation of a dynamic web page may require authentication and authorization, database lookup,image manipulation, remote communication, and the reading and writing of HTML text. All these scenarios suggest a need for programs that coordinate other programs. Scripting Languages • Conventional languages tend to stress efficiency, maintainability, portability, and the static detection of errors. • Their type systems tend to be built around such hardware-level concepts as fixed size integers, floating-point numbers, characters, and arrays. • By contrast scripting languages tend to stress flexibility, rapid development, local customization, and dynamic (run-time) checking. Their type systems, tend to embrace such high-level concepts as tables, patterns, lists, and files. Scripting Languages • General-purpose scripting languages like Perl and Python are sometimes called glue languages, because they were originally designed to “glue” existing programs together to build a larger system. • With the growth of the World Wide Web, scripting languages have gained new prominence in the generation of dynamic content. What Is a Scripting Language? • With the growth of the World Wide Web, Perl was widely adopted for “server-side”web scripting, in which a web-server executes a program (on the server’s machine) to generate the content of a page. • Originally written in Perl but soon redesigned into PHP • Other languages- JSP (Java Server Pages), Ruby on Rails, VBScript. • For scripting on the client computer, all major browsers implement JavaScript, Characteristics • While it is difficult to define scripting languages precisely, there are several characteristics that they have in common. Simple scoping rules. • In some languages (e.g., Perl) everything is global by default • In other languages (e.g., PHP), everything is local by default; globals must be explicitly imported. • Python adopts the interesting rule that any variable that is assigned a value is local to the block in which the assignment appears. Characteristics • Flexible dynamic typing- In keeping with the lack of declarations, most scripting languages are dynamically typed. (e.g., PHP, Python, Ruby, and Scheme), the type of a variable is checked immediately prior to use. • Easy access to system facilities • In scripting languages, however, requests to OS have direct support. • Perl, provides well over 100 built-in commands that access operating system functions for input and output, file and directory manipulation, process management, database access, sockets, inter-process communication and synchronization, protection and authorization, time-of-day clock, and network communication. Characteristics • Sophisticated pattern-matching and string manipulation. • High-level data types. High-level data types like sets, bags, dictionaries, lists, and tuples. Client Side and Server Side Scripting • Client-side means that the action takes place on the user’s (the client’s) computer. Server-side means that the action takes place on a web server. Client-side Environment • The client-side environment used to run scripts is usually a browser. The processing takes place on the end users computer. The source code is transferred from the web server to the users computer over the internet and run directly in the browser Client Side and Server Side Scripting Server-side Environment • A server is a computer system that serves as a central repository of data and programs and is shared by clients • The server-side environment that runs a scripting language is a web server. • A user's request is fulfilled by running a script directly on the web server to generate dynamic HTML pages. This HTML is then sent to the client browser. It is usually used to provide interactive web sites that interface to databases or other data stores on the server. Server-side Programming • Server-side Programming: It is the general name for the kinds of programs which run on the Server. • Uses: • Process user input. • Display pages. • Structure web applications. • Interact with permanent storage (SQL, files). • Example Languages: • PHP • Python • ASP.Net in C#, Visual Basic. Client-side programming • Client-side programming – it is the name for all of the programs which run on the Client. • Uses: • Make interactive webpages. • Interact with temporary storage, and local storage (Cookies, localStorage). • Send requests to the server, and retrieve data from it. • Example languages: • JavaScript (primarily) • HTML • CSS