0% found this document useful (0 votes)
9 views25 pages

Lecture 02 Scripts and Programs

Uploaded by

akdon031
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views25 pages

Lecture 02 Scripts and Programs

Uploaded by

akdon031
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Introduction

DR. SHWETA SHARMA


ASSISTANT PROFESSOR
DEPT. OF COMPUTER ENGINEERING
NIT KURUKSHETRA
1. INTRODUCTION TO SCRIPTING LANGUAGES

 All scripting languages are programming languages, but not all programming
languages are scripting languages
 Programming languages are a way for coders to communicate with computers
using compiled languages — source code compiled to convert into machine code

1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 2


2. SCRIPTING vs. PROGRAMMING
 Scripting languages are a type of programming language that is interpreted rather
than requiring compilation
 This means that, unlike languages that require compilation before execution (such as
C++), scripting languages are executed line by line by an interpreter at runtime
 Scripting languages are designed for specific runtime environments to provide
additional functions, integrate complex systems, and communicate with other
programming languages

1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 3


2. SCRIPTING vs. PROGRAMMING
 Example: JavaScript
 JavaScript is commonly used in web development to enhance the functionality and
interactivity of web pages
 Display Messages: JavaScript can be used to dynamically display messages on a
webpage, allowing for real-time updates and communication with users
 Perform Calculations: It can handle calculations on the client-side, reducing the need for
constant communication with the server for every computation
 Integrate User Interface Elements: JavaScript facilitates the integration of dynamic and
interactive elements into user interfaces, providing a more engaging and responsive
user experience.
 Web Development Focus: JavaScript is executed in web browsers, making it an essential
tool for creating dynamic and interactive web pages
1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 4
3. Origin of Scripting
 The use of the word ‘script’ in a computing context dates back to the early 1970s, when
the originators of the UNIX operating system create the term ‘shell script’ for sequence
of commands that were to be read from a file and follow in sequence as if they had
been typed in at the keyword. e.g. an ‘AWKscript’, a ‘perl script’ etc.
 The name ‘script ‘ being used for a text file that was intended to be executed directly
rather than being compiled to a different form of file prior to execution

1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 5


3. Origin of Scripting
 The term "scripting" itself reflects the idea of writing scripts or sequences of
instructions to automate tasks
 Over time, scripting languages have continued to evolve, adapting to the changing
needs of technology and becoming integral components of software development,
system administration, and various other fields

1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 6


3. Origin of Scripting
Shell Scripting (1960s-1970s):
 The concept of scripting can be linked to the development of command-line interfaces
and shell scripting
 Early operating systems, such as UNIX, featured command-line interfaces that allowed
users to interact with the system using commands
 Shell scripts, written in languages like C Shell, emerged as a way to automate sequences
of these commands

1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 7


3. Origin of Scripting
Shell Scripting (1960s-1970s):
 The concept of scripting can be linked to the development of command-line interfaces
and shell scripting
 Early operating systems, such as UNIX, featured command-line interfaces that allowed
users to interact with the system using commands
 Shell scripts, written in languages like C Shell, emerged as a way to automate sequences
of these commands

1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 8


3. Origin of Scripting
Awk (1970s):
 Awk is an early scripting language that were specifically designed for text processing
 Allow users to write scripts to manipulate and analyze text data
 Powerful for tasks like data extraction and transformation

1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 9


3. Origin of Scripting
Perl (1987):
 Created by Larry Wall in 1987
 Perl was designed to be a powerful language for text processing and system
administration
 Its regular expression support and flexibility made it popular for various scripting tasks

1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 10


3. Origin of Scripting
Bash (1989):
 A bash script is a file containing a sequence of commands that are executed by the bash
program line by line
 Allows to perform a series of actions, such as navigating to a specific directory, creating a
folder, and launching a process using the command line
 By saving these commands in a script, you can repeat the same sequence of steps
multiple times and execute them by running the script

1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 11


3. Origin of Scripting
JavaScript (1995):
 Invented by Brendan Eich in 1995. It was developed for Netscape 2, and became the
ECMA-262 standard in 1997
 Brought scripting to the client-side of web development
 Initially designed for enhancing web pages with interactive features, JavaScript has
evolved into a versatile language used for both client-side and server-side development

1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 12


3. Origin of Scripting
Python (1991):
 Python, created by Guido van Rossum in the late 1980s and officially released in 1991,
was designed to be a readable and general-purpose scripting language
 Programmable as well as scripting language
 Its syntax aimed at making code more readable and maintainable
 Python's versatility has led to its adoption in various domains, including web
development, automation, and data analysis

1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 13


3. Origin of Scripting
Ruby (1993):
 Ruby, developed by Yukihiro Matsumoto in the mid-1990s, emphasized simplicity and
productivity
 It gained popularity as a scripting language, particularly with the advent of the Ruby on
Rails web framework, which streamlined web application development
 Ruby on Rails is used for both front end back end, it is like a complete package to develop
a web application

1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 14


4. Scripting Today
 Diversity of Scripting Languages: Python, JavaScript, Ruby, Perl, PHP, and Shell scripting
languages like Bash
 Python Dominance: Python has experienced significant growth and adoption across
various domains. Its readability and extensive standard library have made it a go-to
language for tasks ranging from web development to data science and machine learning
 JavaScript Everywhere: JavaScript has become essential for web development, powering
interactive and dynamic user interfaces on both the client and server sides. The advent of
Node.js has allowed developers to use JavaScript for server-side scripting
1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 15
4. Scripting Today
 Web Development Frameworks: Frameworks and libraries in scripting languages, such as
Flask and Django for Python, Ruby on Rails for Ruby, and Express.js for JavaScript, have
streamlined web development by providing reusable components and abstractions
 Data Science and Machine Learning: Python, with libraries like NumPy, pandas, and scikit-
learn, has become a prominent language in the field of data science and machine learning.
Scripting is used for tasks like data manipulation and analysis

1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 16


4. Scripting Today
 Containerization and Orchestration: Scripting is vital in the containerization space, with
tools like Docker using Dockerfiles (script-like configuration files) to define container
images. Orchestration tools like Kubernetes also leverage scripting for configuration and
management
 Serverless Architectures: Serverless computing relies on scripting languages for writing
functions that are executed in response to events. Python, JavaScript (Node.js), and other
scripting languages are commonly used in serverless architectures.

1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 17


DOCKER
HUB

(Hardware) (Hardware)

1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 18


5. Characteristics of Scripting Languages
 Interpretation: Scripting languages are typically interpreted rather than compiled. The
code is executed line by line by an interpreter at runtime, offering flexibility and ease of
debugging
 Dynamic Typing: Many scripting languages use dynamic typing, where variable types are
determined at runtime rather than explicitly declared. The interpreter assigns variables a
type at runtime based on the variable's value at the time

1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 19


Static vs. Dynamic Type checking
Static Type checking Dynamic Type Checking
Type checking is performed during compile Type checking is performed at runtime
time
Variables generally are not allowed to change Type of a variable is allowed to change over
types its lifetime
Languages: C, C++, Java etc. Languages: Python, Perl, Ruby, PHP,
Javascript etc.
Example: Example:
String a; a ="hello"
a = "Java is good"; print(type(a))
a=5
print(type(a))
1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 20
Discussion

1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 21


The Python compiler first reads the human code
and optimizes it to some intermediate code
before interpreting it into machine code.
PYTHON INTERPRETER

1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 22


Compiler and Interpreter
Under the hood, though, a bit more happens. Specifically, code is first compiled to something called “byte
code” and then it is passed to a “virtual machine”
Byte code is basically a low-level representation of source code
The source code is translated to byte code because byte code can run much more quickly than the original
source code
The interpreter does not expose this translation process to the Python programmer

This newly generated byte code goes off for execution to the Python Virtual Machine (PVM). PVM is not a
separate program, it is in fact always present as a part of Python’s system

Python Virtual Machine is the runtime engine of Python. It goes through your byte code instructions one by
one and carries out the operations stated in those instructions

Technically, the execution of byte code by PVM is the ‘Python Interpreter’ last step
1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 23
Compiler and Interpreter

 When we run a python code, it is first compiled and then interpreted line by line
 The compilation part is mostly hidden from the user
 While running the code, Python generates a byte code internally, this byte code
is then converted using a Python Virtual Machine (PVM) to generate the output

1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 24


Thank you!

1/9/2024 DR. SHWETA SHARMA, NIT KURUKSHETRA 25

You might also like