programming language concepts scripting languagesscripting languages i scripting is about producing...

Post on 05-Mar-2021

18 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Programming Language ConceptsScripting Languages

Janyl Jumadinova6 April, 2017

Scripting Languages

I Scripting languages have always been important in computersystems

I They are the glue that ties the different elements of the systemtogether

I Their origins go back to the days of card-based operatingsystems– JCL (OS360 JCL)– GEORGE II, GEORGE III

I And they were much used in minicomputer operating systemsI Data General’s AOSI Unix

2/15

Scripting Languages

I Scripting is about producing simple very-high-level-languagesthat are friendly to the programmer.

I Scripting languages are relatively simple, and often allow usersto do complex things.

I Java, C++, C#, etc. are extremely complex– they have a nasty tendency to get bigger and bigger asdesigners add more and more useful facilities, and interfacecomponents, and bells and whistles– take a long time to learn to use (but are wonderful when youreally understand them).

3/15

Scripting Languages

I Scripting is about producing simple very-high-level-languagesthat are friendly to the programmer.

I Scripting languages are relatively simple, and often allow usersto do complex things.

I Java, C++, C#, etc. are extremely complex– they have a nasty tendency to get bigger and bigger asdesigners add more and more useful facilities, and interfacecomponents, and bells and whistles– take a long time to learn to use (but are wonderful when youreally understand them).

3/15

Scripting Languages

I shell languages (e.g., “bash”, “csh”, “zsh”, “tcsh”, and manyothers)

I text-processing languages (e.g., “awk”, “perl”, and others)

I “glue” and general-purpose languages (e.g., Python, Perl, Ruby,etc.)

I “extension” languages (e.g., JavaScript, Visual Basic,VimScript, etc.)

Some languages fall under several categories

4/15

Scripting Languages

I shell languages (e.g., “bash”, “csh”, “zsh”, “tcsh”, and manyothers)

I text-processing languages (e.g., “awk”, “perl”, and others)

I “glue” and general-purpose languages (e.g., Python, Perl, Ruby,etc.)

I “extension” languages (e.g., JavaScript, Visual Basic,VimScript, etc.)

Some languages fall under several categories

4/15

Scripting Languages

I shell languages (e.g., “bash”, “csh”, “zsh”, “tcsh”, and manyothers)

I text-processing languages (e.g., “awk”, “perl”, and others)

I “glue” and general-purpose languages (e.g., Python, Perl, Ruby,etc.)

I “extension” languages (e.g., JavaScript, Visual Basic,VimScript, etc.)

Some languages fall under several categories

4/15

Scripting Languages

I shell languages (e.g., “bash”, “csh”, “zsh”, “tcsh”, and manyothers)

I text-processing languages (e.g., “awk”, “perl”, and others)

I “glue” and general-purpose languages (e.g., Python, Perl, Ruby,etc.)

I “extension” languages (e.g., JavaScript, Visual Basic,VimScript, etc.)

Some languages fall under several categories

4/15

Scripting Languages

I Mostly we have focused on features of the language itself ratherthan its use in “extending” the features of HTML, CSS, etc. inweb pages.

I In Chrome and just about any other browser, search for a menuitem called “Developer” or “Tools” or “View Source” and lookat the underlying code.

5/15

Scripting Languages

Here is what it looks like on my laptop:

6/15

Scripting Languages

7/15

Scripting Languages

We can augment the behavior of HTML elements “callbacks”, i.e.,functions that get passed into event handlers such as the one thathandles a “button click”

8/15

Scripting Languages

We can augment the behavior of HTML elements “callbacks”, i.e.,functions that get passed into event handlers such as the one thathandles a “button click”

8/15

What is client-side and server-side?

I Any machine can play the role of either a client or a server– You could even have a machine being both

I Some languages, e.g. Javascript, are said to be client-side– Run on the user’s browser/web client

I Other languages, e.g. PHP, are said to be server-side– Run on the server that is delivering content to the user

9/15

What is client-side and server-side?

I Any machine can play the role of either a client or a server– You could even have a machine being both

I Some languages, e.g. Javascript, are said to be client-side– Run on the user’s browser/web client

I Other languages, e.g. PHP, are said to be server-side– Run on the server that is delivering content to the user

9/15

Static Web Model

I You (the client) send a request to the server for a web page.

I The server looks up the web page using part of the URL youhave sent it, then returns the HTML page which your browsersubsequently displays on your machine.

10/15

A More Dynamic Web Model

I You (the client) send a request to the server and it dynamicallydetermines the HTML that is to be returned.

I The dynamics of the reply is achieved through extending theweb server with a program (script) that does some dataprocessing and creates HTML output based on the data yousent (e.g. contents of a form).

I The process of generating the HTML response is performedserver-side.

11/15

A More Dynamic Web Model

I You (the client) send a request to the server and it dynamicallydetermines the HTML that is to be returned.

I The dynamics of the reply is achieved through extending theweb server with a program (script) that does some dataprocessing and creates HTML output based on the data yousent (e.g. contents of a form).

I The process of generating the HTML response is performedserver-side.

11/15

A More Dynamic Web Model

I You (the client) send a request to the server and it dynamicallydetermines the HTML that is to be returned.

I The dynamics of the reply is achieved through extending theweb server with a program (script) that does some dataprocessing and creates HTML output based on the data yousent (e.g. contents of a form).

I The process of generating the HTML response is performedserver-side.

11/15

Server-side scripting

I One approach is the Common Gateway Interface (CGI) wherewe have a separate program that can be executed.

I An alternative is to have extra code in the HTML that can beexecuted on the server to determine the HTML that is to bereturned. That is how PHP works.

12/15

Server-side scripting

I One approach is the Common Gateway Interface (CGI) wherewe have a separate program that can be executed.

I An alternative is to have extra code in the HTML that can beexecuted on the server to determine the HTML that is to bereturned. That is how PHP works.

12/15

Client-side scriptingI The other (complementary) approach is to do the work on the

client machine.– Again we have extra code in the HTML, but now it isexecuted by the users browser (i.e. client-side). Most commonclient side script is Javascript.– An example of its use is when a web page has a form. We canuse Javascript to validate the input data client-side before it issent to a server.

I If we do the validation on the client, this reduces the work thatthe server has to do and reduces the time taken to respond tothe user.

I HTML5 essentially includes Javascript elements to enhance itspower.

13/15

Client-side scriptingI The other (complementary) approach is to do the work on the

client machine.– Again we have extra code in the HTML, but now it isexecuted by the users browser (i.e. client-side). Most commonclient side script is Javascript.– An example of its use is when a web page has a form. We canuse Javascript to validate the input data client-side before it issent to a server.

I If we do the validation on the client, this reduces the work thatthe server has to do and reduces the time taken to respond tothe user.

I HTML5 essentially includes Javascript elements to enhance itspower. 13/15

Client-side scripting

Javascript can also be used to create dynamic web page content.For example:

I We could change the content based on the fact that you visitedthe web page before.

I Time of day.

I JavaScript popup menus.

14/15

Scripting Languages

Back to the Bash

https://en.wikibooks.org/wiki/Bash_Shell_Scripting

15/15

top related