COMP284 Scripting Languages
Lecture 1: Overview of COMP284
Handouts
Ullrich Hustadt
Department of Computer Science
School of Electrical Engineering, Electronics, and Computer Science
University of Liverpool
Contents
1 Introduction
Motivation
Scripting languages
2 COMP284
Aims
Learning outcomes
Prerequisites
Delivery
Assessment
Background Reading
COMP284 Scripting Languages Lecture 1 Slide L1 1
Introduction Motivation
How many programming languages should you learn?
1 Academic / Educational viewpoint:
Learn programming language concepts and
use programme languages to gain practical experience with them
imperative / object-oriented C, Java
functional OCaml, Haskell
logic/constraint Prolog, DLV
concurrent Go
then all (other) programming languages can be learned easily
2 An employer’s viewpoint:
Learn exactly those programming languages that the specific employer
needs
3 Compromise: Spend most time on 1 but leave some time for 2 to
allow more than one language from a class/paradigm to be learned
4 Problem: Which additional language do you cover?
; Look what is used/demanded by employers
COMP284 Scripting Languages Lecture 1 Slide L1 2
Introduction Motivation
Our domain
In this module we are particularly interested in scripting languages used
for the development of web-based applications
Web-based applications are client-server systems where
the client software, consisting of user interface and client-side logic,
runs in a web browser
the client software issues HTTP requests to a web server to retrieve
information or to update parts of itself
a web server acts as conduit for the HTTP requests from the client software
and the HTTP responses from the server software
the server software, implementing the server-side logic, handles the request
and produces a HTTP response, in the form of a HTML document or data
the server software often interacts with a database to produce its response
COMP284 Scripting Languages Lecture 1 Slide L1 3
Introduction Motivation
Websites and programming languages
Website Client-Side Server-Side Database
Google JavaScript,
TypeScript
C, C++, Go, Java,
Python, PHP,
BigTable, MariaDB
Facebook JavaScript Hack, PHP, Python,
C++, Java, . . .
MariaDB, MySQL,
HBase, Cassandra
YouTube Flash,
JavaScript
C, C++, Python, Java,
Go
BigTable, MariaDB
Yahoo JavaScript PHP MySQL, PostgreSQL
Amazon JavaScript Java, C++, Perl Oracle Database
Wikipedia JavaScript PHP, Hack MariaDB
Twitter JavaScript C++, Java, Scala, Ruby MySQL
Bing JavaScript C++, C# MS SQL Server
Wikipedia Contributors: Programming languages used in most popular websites. Wikipedia, The Free Encyclopedia,
11 December 2019, at 16:24. https://en.wikipedia.org/wiki/Programming_languages_used_in_most_popular_websites
[accessed 21 December 2019]
COMP284 Scripting Languages Lecture 1 Slide L1 4
Introduction Scripting languages
Scripting languages
PHP and JavaScript are scripting languages
Script
A user-readable and user-modifiable program that performs simple
operations and controls the operation of other programs
Scripting language
A programming language for writing scripts
Classical example: Shell scripts
#!/ bin / sh
for file in *; do
wc -l " $file "
done
Print the number of lines and name for each file in the current directory
COMP284 Scripting Languages Lecture 1 Slide L1 5
Introduction Scripting languages
Scripting languages: Properties
Program code is present at run time and starting point of execution
compilation by programmer/user is not needed
compilation to bytecode or other low-level representations
may be performed ‘behind the scenes’ as an optimisation
Presence of a suitable runtime environment is required for the execution
of scripts
includes an interpreter, or just-in-time compiler, or bytecode compiler plus
virtual machine
typically also includes a large collection of libraries
Executation of scripts is typically slower then the execution of code that
has been fully pre-compiled to machine code
#!/ bin / sh
for file in *; do
wc -l " $file "
done
COMP284 Scripting Languages Lecture 1 Slide L1 6
Introduction Scripting languages
Scripting languages: Properties
Rich and easy to use interface to the underlying operating system,
in order to run other programs and communicate with them
rich input/output capabilities, including pipes, network sockets, file I/O,
and filesystem operations
Easy integration within larger systems
often used to glue other systems together
can be embedded into other applications
#!/ bin / sh
for file in *; do
wc -l " $file "
done
COMP284 Scripting Languages Lecture 1 Slide L1 7
Introduction Scripting languages
Scripting languages: Properties
Variables, functions, and methods
typically do not require type declarations
(automatic conversion between types, e.g. strings and numbers)
Lots of pre-defined functions and libraries
Lots of pre-defined functions for the specific purpose
the language was designed for
Ability to generate, load, and interpret source code at run time
through an eval function
JavaScript:
var x = 2;
var y = 6;
var str = " if (x > 0) { z = y / x } else { z = -1 }";
con sole . log(' z is ', eval ( str )); // Output : z is 3
x = 0;
con sole . log(' z is ', eval ( str )); // Output : z is -1
COMP284 Scripting Languages Lecture 1 Slide L1 8
Introduction Scripting languages
Scripting languages: Properties
The evolution of a scripting language typically starts
with a limited set of language constructs for a specific purpose
Example: PHP started as set of simple ‘functions’
for tracking visits to a web page
The language then accumulates more and more language constructs
as it is used for a wider range of purposes
These additional language constructs may or may not fit well together
with the original core and/or may duplicate existing language constructs
During this evolution of the language, backward compatibility
may or may not be preserved
; Language design of scripting languages is often sub-optimal
COMP284 Scripting Languages Lecture 1 Slide L1 9
COMP284 Aims
Aims
1 To provide students with an understanding of
the nature and role of scripting languages
2 To introduce students to some popular scripting languages
and their applications
3 To enable students to write simple scripts using these languages
for a variety of applications
COMP284 Scripting Languages Lecture 1 Slide L1 10
COMP284 Learning outcomes
Learning Outcomes
At the end of the module students should be able to
1 develop server-side web-based applications
using an appropriate scripting language,
with emphasis on concurrent use of such applications
2 develop computer-based or client-side web-based applications
using an appropriate scripting language
COMP284 Scripting Languages Lecture 1 Slide L1 11
COMP284 Prerequisites
Prerequisites
COMP101 Introduction To Programming
Python
COMP122 Object-oriented Programming
Control structures, Object-oriented programming languages, Types,
Exceptions and exception handling, Graphical user interfaces,
Event-driven programming, Java
COMP107 Designing Systems For The Digital Society
Database design, SQL (Insert, Select, Update)
COMP207 Database Development
Transactions, SQL (Transactions)
HTML/CSS
COMP284 Scripting Languages Lecture 1 Slide L1 12
COMP284 Delivery
Delivery of the module: Lectures
Structure:
14 lectures
Schedule:
1–2 lectures per week spread over 9 weeks
See your personal timetable and e-mail announcements for details
Lecture notes and screencasts are available at
https://cgi.csc.liv.ac.uk.uk/
~
ullrich/COMP284/notes
Additional self study using the recommended textbooks
and the on-line material is essential
COMP284 Scripting Languages Lecture 1 Slide L1 13
COMP284 Delivery
Delivery of the module: Practicals
Structure:
1 practical to re-familiarise you with Linux
1 practical on HTML
4 practicals on PHP
3 practicals on JavaScript
All practicals involve working through exercises related to the previous
one/two lectures,
guided by a worksheet, with the help of demonstrators
Schedule:
1 practical per week for 9 weeks
Practicals start in week 1
Practicals assume familiarity with the related lecture material
COMP284 Scripting Languages Lecture 1 Slide L1 14
COMP284 Delivery
How to learn a new programming language
Once you know how to program in one programming language,
additional programming languages are best learned by a process of
enquiry and practice guided by existing experience
Typically, the questions that guide you are
What kind of . . . are there?
Example: What kind of control structures are there?
What is the syntax for . . . ?
Example: What is the syntax for conditional statements?
What happens if . . . ?
Example: What happens if 1 is divided by 0?
How do I . . . ?
Example: How do I catch an exception?
Talk to other people who are currently trying to learn the same
language or have already learned it
; Ask what has surprised them most
COMP284 Scripting Languages Lecture 1 Slide L1 15
COMP284 Delivery
How to learn a new programming language
Once you know how to program in one programming language,
additional programming languages are best learned by a process of
enquiry and practice
The best kind of learning is learning by doing
; The questions posed on the previous slide are often best explored
by experimenting with small sample programs (‘toy’ programs)
Work on substantive programs
; You need to convince employers that you have worked on programs
more substantive than ‘toy’ programs
; The assignments are ‘pretend’ substantive programs
but in reality are too small
Employers value experience, in particular, the experience that you get
from overcoming challenges
; Assignments that are not challenging are of limited value
COMP284 Scripting Languages Lecture 1 Slide L1 16
COMP284 Delivery
Delivery of the module: Office Hours and Announcements
Office hours
Fridays, 14:00 Ashton, Room 1.03
Fridays, 16:00 Ashton, Room 1.03
but always arrange a meeting by e-mail first
(U.Hustadt@liverpool.ac.uk)
Announcements will be send by e-mail
You should check you university e-mail account at least every other day
Always use your university e-mail account
if you want to contact me or any other member of staff
COMP284 Scripting Languages Lecture 1 Slide L1 17
COMP284 Delivery
Recommended texts
Core reading
R. Nixon:
Learning PHP, MySQL, & JavaScript: with jQuery, CSS & HTML5.
O’Reilly, 2018.
Harold Cohen Library: QA76.73.P224.N73.5 or e-book
Further reading
M. David:
HTML5: designing rich Internet applications, 2nd ed.
Focal Press, 2013.
Harold Cohen Library: QA76.76.H94.D24.2 or e-book
J. Niederst Robbins: Learning web design: a beginner’s guide to
HTML, CSS, Javascript, and web graphics.
O’Reilly, 2018.
Harold Cohen Library: e-book.
N. C. Zakas:
Professional JavaScript for Web Developers.
Wiley, 2009.
Harold Cohen Library: TK5105.888.J38.Z21.3 or e-book
COMP284 Scripting Languages Lecture 1 Slide L1 18
COMP284 Assessment
Assessment
This is a coursework-based module
(no exam)
Two assessment tasks need to be completed throughout the semester:
PHP Deadline: Friday, 20 March, 10:00
JavaScript Deadline: Friday, 24 April, 10:00
Effort required: about 15 hours each
(assuming you have kept up with lectures and practicals)
Available at: https://cgi.csc.liv.ac.uk/
~
ullrich/COMP284/
COMP284 Scripting Languages Lecture 1 Slide L1 19
COMP284 Assessment
Academic Integrity
Plagiarism occurs when a student misrepresents, as his/her own work,
the work, written or otherwise, of any other person (including another
student) or of any institution
Collusion occurs where there is unauthorised co-operation between a
student and another person in the preparation and production of work
which is presented as the student’s own
Fabrication of data occurs when a student enhances, exaggerates, or
fabricates data in order to conceal a lack of legitimate data
If you are found to have plagiarised work, colluded with others, or
fabricated data, then you may fail COMP284
Serious ‘offenders’ may be excluded from the University
Do not try to take a ‘shortcut’
You must do the work yourself!
COMP284 Scripting Languages Lecture 1 Slide L1 20
COMP284 Assessment
Academic Integrity: Lab rules
Do not ask another student to see any part of their code for a
COMP284 assignment
; contravention of this leads to collusion
Do not show or make available any part of your code relating for a
COMP284 assignment to any other student
; contravention of this leads to collusion
Do not share (links to) on-line material that might help with a
COMP284 assignment
; contravention of this leads to collusion
Lock your Lab PC when you leave it alone
Where you use any material/code found on-line for a COMP284
assignment, you must add comments to your code indicating its origin
by a proper academic reference
; contravention of this is plagiarism
; acknowledged code re-use may still result in a lower mark
COMP284 Scripting Languages Lecture 1 Slide L1 21
COMP284 Background Reading
Background Reading
Over the next four weeks, read
Part I: Getting Started
Part II: HTML for Structure
Part III: CSS for Presentation
of J. Niederst Robbins: Learning web design:
a beginner’s guide to HTML, CSS, Javascript, and web graphics.
O’Reilly, 2018.
COMP284 Scripting Languages Lecture 1 Slide L1 22