You are on page 1of 60

BEEE3, BEEE3E, BETE3 and BECE3-

Honours

Lesson: Programming Languages

Introduction to Software Engineering (ISE-311)

Prepared by:
T. Chadza and F. Masi
School of Engineering – Department of Electrical Engineering
Malawi University of Business and Applied Sciences (MUBAS)
Intended learning outcome
By the end of this lesson, the student should be
able to discuss the fundamentals for
programming languages in software engineering

5/9/2022 TChadza&FMasi2022 2
Outline
• Programming and software terms
• Scripting and system languages
• Object oriented programming
• Server-side and client-side scripting
• Platform independence
• Java virtual machine
• Standard generalised markup language
• Unix operating software
• Summary

5/9/2022 TChadza&FMasi2022 3
Programming and Software
Terms
i. Computational Model
ii. Computation
iii. Program
iv. Programming language
v. Syntax
vi. Semantics
vii. Pragmatics

5/9/2022 TChadza&FMasi2022 4
Computational Model
• Mathematical model that requires extensive
computational resources to study the
behavior of a complex system by computer
simulation.
• Examples: weather forecasting models, earth
simulator models etc

5/9/2022 TChadza&FMasi2022 5
Computation
• A process following a well-defined model
that is understood and can be expressed in
an algorithm, protocol, network topology,
etc.

5/9/2022 TChadza&FMasi2022 6
Program
• Sequence of instructions that a computer can
interpret and execute.
• It is simply a plan: a series of steps to be
carried out or goals to be accomplished.

5/9/2022 TChadza&FMasi2022 7
Programming Language
• Machine-readable artificial language designed
to express computations that can be
performed by a machine, particularly a
computer.
• They are used to create programs
• Examples: C, C++, Java, Basic, Fortlan, MaTlab,
TCL, Pascal, Cobol …

5/9/2022 TChadza&FMasi2022 8
Syntax
• Set of rules that define the combinations of
symbols that are considered to be syntactically
correct programs in a programming language.
• Example: if, for, while,
• Syntax highlighting is often used to aid
programmers recognise them

5/9/2022 TChadza&FMasi2022 9
Semantics
• Relationship between the syntactical elements
and the computation model in a programming
language.
• Concerned with the meaning of words,
expressions and sentences.

5/9/2022 TChadza&FMasi2022 10
Pragmatics
• Study of programming language use in
particular situations.

5/9/2022 TChadza&FMasi2022 11
Programming Languages
-Scripting and System languages
A scripting language
• programming language that allows control of
one or more software applications.
• nearly always embedded in the applications
they control
• Scripts are often interpreted from source code
or bytecode, whereas the applications they
control are traditionally compiled to native
machine code.
5/9/2022 TChadza&FMasi2022 12
• Examples:
– JavaScript, ASP, JSP, PHP, Perl, TCL and Python)
– Extension/embeddable languages e.g. Adobe Acrobat
– General-purpose dynamic languages e.g. old Perl
– Text processing languages e.g. AWK, sed,
– Web servers e.g. PHP, JSP and ASP
– Web browsers e.g. JavaScript
– Application-specific languages
– GUI Scripting
– Job control languages and shells e.g. Unix shell, MS-
DOS and AppleScript,

5/9/2022 TChadza&FMasi2022 13
System languages
• programming languages that are statically typed,
allow arbitrarily complex data structures,
compiled, and meant to operate largely
independently of other programs.
• Examples:
– C
– Modula-2
– Bliss
– BCPL(Basic Combined Programming Language)
– extended Algol

5/9/2022 TChadza&FMasi2022 14
Server-side and Client-side scripting
Server-side scripting
• web server technology in which a user's
request is fulfilled by running a script directly
on the web server to generate dynamic web
pages
• usually used to provide interactive web sites
that interface to databases or other data
stores
• Example: Perl Hypertext Pre-Processor (PHP)
5/9/2022 TChadza&FMasi2022 15
Client-side scripting:
• generally refers to the class of computer
programs on the web that are executed client-
side, by the user's web browser, instead of
server-side (on the web server).
• Examples:
– JavaScript (Client-side JavaScript) and VBScript.

5/9/2022 TChadza&FMasi2022 16
Object-oriented
programming (OOP)
• programming paradigm that uses "objects" – data
structures consisting of datafields and methods –
and their interactions to design applications and
computer programs.
• Components:
– Objects
– Inheritance
– Relationship
– Delegation
– class

5/9/2022 TChadza&FMasi2022 17
• Object:
– A pattern (exemplar) of a class.
– The class of Dog defines all possible dogs by listing
the characteristics and behaviors they can have;
– The object Lassie is one particular dog, with
particular versions of the characteristics. A Dog
has fur; Lassie has brown-and-white fur.

5/9/2022 TChadza&FMasi2022 18
• Inheritance
– way to form new classes using classes that have
already been defined.
• A class:
– Abstraction of a concept within a computer
program.
– may represent a person, place, or thing
– used as a blueprint to create objects.

5/9/2022 TChadza&FMasi2022 19
• Delegation:
– process by which an object sends data to another object or
asks the other object to invoke a method
• Relationship:
– indicates how objects in a particular class change when the
status of one object changes whether in the same
direction or in opposite direction

5/9/2022 TChadza&FMasi2022 20
Platform Independence
• software or program that does not rely on any
special features of any single platform, or, if it
does, handles those special features such that it
can deal with multiple platforms.
• To be Platform Independent, the application that
runs on the server must be capable of being
installed and run on many different platforms
• One of the methods of obtaining platform
independence is Java Virtual Machine (JVM)
5/9/2022 TChadza&FMasi2022 21
Java Virtual Machine (JVM)
• a set of computer software programs and data
structures that use a virtual (like a real) machine
model for the execution of other computer
programs and scripts.
• Machine language for a Sun computer is not the
same as for a Macintosh, or a Windows machine.
You cannot use the same machine code program
on different kinds of machines.
• Most compilers produce code for a real machine.
• Java compiler produces code for a virtual
machine.
5/9/2022 TChadza2022 22
5/9/2022 TChadza&FMasi2022 23
• Java compilers translate applets in two steps.
– Translation is from Java source to JVM machine code.
– Translation to real machine instructions using the browser on the
user's machine.
• Browser takes the applet JVM code from the server and
translates from JVM code to the machine code the browser is
using, eg a Pentium.
• compiler in the browser is often called a Just In Time(JIT)
compiler
– JIT means that the last part of the compilation is done just before
running the program.

5/9/2022 TChadza&FMasi2022 24
Standard Generalised Markup
Language (SGML)
• ISO Standard technology for defining generalized
markup languages for documents.
• originally designed to share machine-readable
documents in large projects in government, law and
industry
• Primarily intended for text and database publishing
• Subsets
– XML
– HTML

5/9/2022 TChadza&FMasi2022 25
XML HTML
designed to describe data and to focus on designed to display data and to focus on
what data is how data looks
allows the author to define his own tags tags used to markup HTML documents
and his own document structure and the structure of HTML documents are
predefined
not case-sensitive case-sensitive
neither a programming nor presentation presentation language
language but used to transfer data
between applications and databases.
mandatory to close each and every tag not required
data is stored in separate XML files data is stored inside the files
white Spaces is preserved in XML files not preserved (are combined)
uses XSL to display data Uses CSS to display data
5/9/2022 TChadza&FMasi2022 26
UNIX Operating system

5/9/2022 TChadza&FMasi2022 27
• Presently there are substantial Linux
distributions
– most popular:
• CentOS, Damn Small Linux, Debian, Fedora, Freespire,
Knoppix, Linspire, Linux Mint, Mandriva Linux,
openSUSE, PCLinuxOS, Slackware and Ubuntu.

5/9/2022 TChadza&FMasi2022 28
• General OS

5/9/2022 TChadza&FMasi2022 29
• UNIX OS

5/9/2022 TChadza&FMasi2022 30
UNIX Kernel
• heart of the UNIX OS.
• performs the tasks that create and maintain
the UNIX environment.
• keeps track of the disks, tapes, printers,
terminals, communication lines and any other
devices attached to the computer.
• interfaces between the computer's hardware
and the users.
5/9/2022 TChadza&FMasi2022 31
The Shell
• a program that interfaces between the user
and the UNIX Operating System.
• It listens to the user's terminal and translates
the actions requested by the user.
• There are a number of different Shells that
may be used e.g. csh (C Shell), ksh (Korn Shell)
and sh (Bourne Shell).

5/9/2022 TChadza2022 32
Utilities and Application Programs
• Utilities are the UNIX Command.
• Application Programs, such as Word
Processors, Spreadsheets and Database
Management Systems, may be installed
alongside the UNIX Commands.
• A user may run a utility or application through
the shell

5/9/2022 TChadza&FMasi2022 33
System calls
• method of programming in the UNIX
environment.
• functions that a programmer can call to
perform the services of the operating system.
• It is a request for the operating system to do
something on behalf of the user's program.

5/9/2022 TChadza&FMasi2022 34
• system calls are functions used in the kernel
itself.
• To the programmer, the system call appears as
a normal C function call.
• since a system call executes code in the kernel,
there must be a mechanism to change the
mode of a process from user mode to kernel
mode.

5/9/2022 TChadza&FMasi2022 35
• The C compiler uses a predefined library of
functions (the C library) that have the names
of the system calls.
• Examples: open, create, read, kill, chmod, exit,
kill, chdir, pipe, semget, shmdt

5/9/2022 TChadza&FMasi2022 36
UNIX File system
• UNIX OS is built around filesystem that stores
all information constituting long-term state of
the system.
• Any item stored in UNIX OS belongs to one of
four filesystem types namely: Ordinary files,
directories, devices and links.

5/9/2022 TChadza&FMasi2022 37
• Ordinary files
– contain text, data, or program information and do
not contain other files or directories.
• Directories
– act like containers or folders holding files, and
other directories.
• Devices
– handled like ordinary files to provide applications
for easy access to hardware devices.

5/9/2022 TChadza&FMasi2022 38
• Links
– pointers to other files and can be hard or soft.
• Despite the different file types, UNIX does not
distinguish between different file types.

5/9/2022 TChadza&FMasi2022 39
UNIX directories and pathnames
• The UNIX filesystem is laid out as a
hierarchical tree structure which is anchored
at a special top-level directory known as the
root (designated by a slash '/').
• Because of the tree structure, a directory can
have many child directories, but only one
parent directory.

5/9/2022 TChadza&FMasi2022 40
Figure: Typical UNIX/Linux File System

5/9/2022 TChadza&FMasi2022 41
• /root – Home directory of the superuser (often just /)
• /bin – All Core operating system commands
• /etc – Critical startup and configuration files
• /home – Default home directories for users
• /mnt – Temporary mount points, mounts for
removable media
• /usr – Hierarchy of secondary files and commands ]
• /sbin – Commands needed for minimal system
operability
• /tmp – Temporary files that may disappear between
reboots

5/9/2022 TChadza&FMasi2022 42
• /var –System specific data and configuration files
• /opt – Optional software packages (not
consistently used)
• /dev – Device entries for disks, printers, pseudo-
terminals, etc.
• /opt – Optional software packages (not
consistently used)
• /proc – Information about all running processes

5/9/2022 TChadza&FMasi2022 43
• To specify a location in the directory hierarchy,
one must specify a path through the tree.
• Path to a location can be defined by an
absolute path from the root /, or as a relative
path from the current working directory.

5/9/2022 TChadza&FMasi2022 44
• To specify a path, each directory along the route
from the source to the destination must be
included in the path, with each directory in the
sequence being separated by a slash.
• To help with the specification of relative paths,
UNIX provides the shorthand "." for the current
directory and ".." for the parent directory.
• absolute path to the directory “share" is
/usr/share
5/9/2022 TChadza&FMasi2022 45
• A path or pathname is simply the set of
directories that have to be traversed to get to
a file.
• In other words, it is a way of giving an address
for the location of a file, like a mailing address
for a letter

5/9/2022 TChadza&FMasi2022 46
File access methods and permissions
• A file can be accessed by using the reading or
open command.
• It may also be accessed by using editors.
– Three familiar editors are gedit, Emacs and Vi.
• You can also access the contents of a file by
using the ls or most commonly ls –l
command.

5/9/2022 TChadza&FMasi2022 47
Command Meaning
cat filename Dump a file to the screen in ascii.
more filename Progressively dump a file to the
screen: ENTER = one line down
SPACEBAR = page down q=quit

less filename Like more, but you can use Page-Up


too. Not on all systems.
vi filename Edit a file using the vi editor. All UNIX
systems will have vi in some form.
emacs filename Edit a file using the emacs editor.
Not all systems will have emacs.
head filename Show the first few lines of a file.
head -n filename Show the first n lines of a file.
tail filename Show the last few lines of a file.
tail -n filename Show the last n lines of a file.

5/9/2022 TChadza&FMasi2022 48
• Any file type can have three permissions

5/9/2022 TChadza&FMasi2022 49
5/9/2022 TChadza&FMasi2022 50
• The read bit adds 4 to its total (in binary 100),
• The write bit adds 2 to its total (in binary 010),
• The execute bit adds 1 to its total (in binary
001).
• Just remember 421 as rwx

5/9/2022 TChadza&FMasi2022 51
Example
• Write a command for changing a file with a
name software.c to have the permission:
i) read , write and execute for owner
ii) Read and write for group
iii)Read only for others

5/9/2022 TChadza&FMasi2022 52
Unix commands for manipulating files
• emacs: `Using the emacs text editor‘
• mkdir: `Creating a directory‘
• cd: `Changing your current working directory‘
• ls: `Finding out what files you have‘
• cp: `Making a copy of a file‘
• mv: `Changing the name of a file'
• rm: `Getting rid of unwanted files‘
• chmod: `Controlling access to your files'
• cmp: Comparing two files
• wc: Word, line, and character count
• compress: Compress a file

5/9/2022 TChadza&FMasi2022 53
File descriptor
• abstract value/number used by a UNIX
program used when reading from and writing
to the file.
• contains information necessary to use a file: a
pointer to the file, the access rights, the
access modes (read or write), the current
position in the file, etc.

5/9/2022 TChadza&FMasi2022 54
• When a UNIX program wants to use a file, it
must first open that file.
– When it does so, UNIX will associate a number
with the file.

5/9/2022 TChadza&FMasi2022 55
A typical UNIX program will automatically open
three files when it starts:
• standard input or stdin: used for reading
conventional input;
• standard output or stdout: used for writing
conventional input
• standard error or stderr: used for writing
diagnostic output

5/9/2022 TChadza&FMasi2022 56
References
• Chadza, T. 2009, City and Guilds Software Engineering Lecturer
Notes, MUBAS
• Darwin, I, 2005, TCP Informatics
• Http://Searchwindevelopment.techtarget.com/sDefinition/0,,sid8_
gci1196645,00.html
• http://searchsoftwarequality.techtarget.com/sDefinition/0,,sid92_g
ci1170180,00.html
• http://en.wikipedia.org/wiki/Scripting_language
• http://www.webopedia.com/TERM/S/scripting_language.html
• http://www.leepoint.net/notes-
java/deployment/applications_and_applets/05intro/25jvm.html
• http://www.geekinterview.com/question_details/58751
• http://www.artima.com/insidejvm/ed2/jvm2.html
• https://www.geeksforgeeks.org/unix-file-system/

5/9/2022 TChadza&FMasi2022 57
Summary
In this lesson, we have discussed the
fundamentals for programming languages in
software engineering

5/9/2022 TChadza&FMasi2022 58
Next Lesson
In the next lesson we shall discuss the
fundamental for programming languages in
software engineering

5/9/2022 TChadza&FMasi2022 59
Thank you!
Src: IFC 2002

5/9/2022 TChadza&FMasi2022 60

You might also like