LO2 - Portlethen Academy

vroomhuhSoftware and s/w Development

Nov 4, 2013 (3 years and 9 months ago)


Higher Computing
Software Development

LO2 – Software Development languages and environments

Ian Simpson
Inverurie Academy
Higher Computing
Software Development

The candidate must demonstrate knowledge and understanding, practical skills and
problem solving based on the following content statements:

Software Development languages and environments
• Description and comparison of procedural, declarative and event-driven
• Comparison of the functions, uses and efficiency of compilers and interpreters
• Description of the features and uses of scripting language (including creating
and editing a macro)
• Explanation of the need for and benefits of scripting languages
• Description of the use of module libraries
ISK 2006

Higher Computing

LO2: SD La
nguages and Environm
Types of Languages

In Higher Computing you have to know about three types of languages: procedural,
declarative and event-driven.

The table below describes, sets out the main features of and gives examples of each
type of language.

The user sets out a list
of instructions in the
correct sequence (an
algorithm) in order to
solve a problem. Has
a definite start and
end point. Also
known as imperitive
languages as
imperitive (in
computing) means
giving or expressing
May be thought of as
the opposite of a
procedural language.
States ‘what to do’
rather than ‘how to do
it’. Also known as a
rule-based language.
These programs have
no definite start or
end. Clicking on a
screen object (eg.
button) in the GUI
activates the program
code associated with
that object. An event
is the action of
clicking on a screen
object and because it
is detected by the
program it is called
ƒ Different variable
ƒ Arithmetic and
logical operations
ƒ Program control
using sequence,
iteration and
ƒ Subprograms and
ƒ Data flow using

ƒ Contain
statements or
clauses which
describe facts
ƒ Contain rules
which apply to the
ƒ Recursion
(equivalent to
in a procedural
ƒ Collection of facts
and rules known
as a knowledge
ƒ Quick to design a
program with a
ƒ Similar in
operation to
menu-driven OS
with a GUI as
program always
running in the
computer and
waiting for the
user to select a
screen object.
Visual Basic

Yes, Visual Basic
an event-driven language – even though it has all the features of
a procedural language.
ISK 2006

Higher Computing

LO2: SD La
nguages and Environm
Program control using sequence, iteration and selection

Procedural languages have three basic control structures: sequence, iteration and


Sequence is where a number of statements follow on from each other in sequential
order. For example:

Name = InputBox(“Please enter your name”)
Age = InputBox(“Please enter your age”)
lblDisplay.Caption = “Hello “ & Name & “, you are “ & Age & “
years old.”


Iteration (which also means repetition) is where looping is used to repeat a number of
lines of code. There are a number of different methods used, including FOR… NEXT,
DO LOOP… UNTIL and WHILE… WEND. For example:

FOR counter = 1 TO 100
picDisplay.Print “I must always do my homework”
NEXT counter

Selection is where a choice has to be made in a program. This is often done with an IF
control structure, although a CASE control structure could also be used. For example:

IF pupil_mark > 49 THEN
lstResults.AddItem(pupil_mark & “ = Pass”)
lstResults.AddItem(pupil_mark & “ = Fail”)

ISK 2006

Higher Computing

LO2: SD La
nguages and Environm
Scripting Languages

Scripting languages can be divided into two types:

a) those which are embedded within an application package and which make use
of only those commands that are available within the package
b) those which work with the operating system and across and between suitable
(scriptable) applications

A scripting language allows the user to customise an application package to carry out
additional operations other than those provided in the original menus. Scripting
languages use commands from application packages in order to do this.

Scripting languages are becoming more widely used within web pages, for example to
make them more accessible to each individual user. Scripts do this by detecting which
type of computer, operating system or even browser the user has and then change the
look of the web page to suit.

Examples of scripting languages

Examples of scripting languages include JavaScript, VBScript, CGI, Perl, AppleScript
and FileMaker Pro.

JavaScript is a scripting language that is used with web browsers. It was developed
by Netscape and Sun Microsystems but is different to the Java programming
language. The most common use of JavaScript is for client-side scripting in web
pages. Microsoft have their own version of this language called Jscript.

VBScript is a scripting language written by Microsoft. Similar to Visual Basic,
VBScript is widely used on the Web for both client-side processing with a Web page
and server-side processing in Active Server Pages (ASPs). VBScript can also be used
with the Windows Script Host (WSH) to perform functions on the user’s own
machine if they have a Windows OS installed.

Uses of scripting languages

An expert user of an application package would use a scripting language to automate
a repetitive task that had to be carried out. Programs written using a scripting
language are often called scripts. Once programmed, a script may be activated by
clicking on a button or by selecting from a menu.

If you perform a task repeatedly in Microsoft Word, you can automate the task by
using a macro. A macro is a series of Word commands and instructions that you
group together as a single command to accomplish a task automatically. Instead of
manually performing a series of time-consuming, repetitive actions in Word, you can
create and run a single macro — in effect, a custom command — that accomplishes
the task for you.

ISK 2006

Higher Computing

LO2: SD La
nguages and Environm
Here are some typical uses for macros:

ƒ To speed up routine editing and formatting
ƒ To combine multiple commands; for example, inserting a table with a specific size
and borders, and with a specific number of rows and columns
ƒ To make an option in a dialog box more accessible
ƒ To automate a complex series of tasks

See the handout LO2: VBScript macros for examples of macros created
in Microsoft Word.

Benefits of scripting languages

Scripting languages, whether used for macros or with web pages, have a number of

ƒ Increased rate of work for the user through use of macros
ƒ Less training necessary as macros can automate complex tasks
ƒ Web pages or applications can be customised to suit the user’s computer system

ISK 2006

Higher Computing

LO2: SD La
nguages and Environm
Programming languages on the Internet

Scripting languages are not the only type of programming languages which are used
in Internetwork programming. Similarly the programs created are not always run on
the user’s computer. This section describes the where the program is executed when
the user is connected over the Internet and gives two further examples of
programming languages.

Note that Java is not a scripting language – JavaScript is!
Server-side solutions

CGI (Common Gateway Interface) is a specification for transferring information
between a World Wide Web server and a CGI script. CGI scripts are the most
common way for web servers to interact with users. Many HTML programs that
contain forms, for example, use a CGI program to process the data on the form after it
has been submitted.

CGI is known as a
server-side solution
because the process occurs on the web server
and not the client computer.

Client-side solutions

Java was developed to take advantage of the increasing use and importance of the
World Wide Web. Java source code is compiled into an intermediate code called
bytecode which can be executed by a Java interpreter called a Java Virtual Machine.
The advantage of Java is that it is platform independent, which means that it can run
on any operating system that has a Java Virtual Machine e.g. Unix, Windows and Mac
OS. Small Java applications are called Java applets and can be downloaded from a
web server and run on a user’s computer using a Java-compatible web browser such
as Microsoft Internet Explorer.

Using Java applets (or ActiveX control programs) to provide feedback to web users is
known as
client-side solutions
because processing takes place on the user’s own

ISK 2006

Higher Computing

LO2: SD La
nguages and Environm

A compiler translates a high level language program, the source code, into machine
code, the object code. After compilation is complete, the object code can then be run.

The object code runs very fast because it is in the computer’s own language, machine
code. The object code program may be saved and run separately. The source code
should also be saved because without it it is impossible to edit the program since the
object code, once produced, cannot be easily changed.

When a compiled program is being created, the source code and the compiler are
needed at the time of writing and editing stages; the source code, object code and
compiler are required at the testing stage, and only the object code is required to use
the completed program.

The compiler changes each single high-level language instruction into several
machine code instructions.

Compilation involves analysing the language structure of the source program,
checking to see if it is correct, and producing machine code. These separate
compilation stages are known as lexical analysis, syntax analysis and code


Compilation stages

Lexical analysis
: each recognised keyword in the source code is changed into a
token. This tokenising process resembles the representation of characters by their
ASCII values, in that each token is a unique code. The keyword PRINT for instance
has the token 11110001 (decimal 241) and IF has the token 1110 0111 (decimal 231).
Any errors detected at this stage are reported.

Syntax analysis
: the language statements are checked against the rules or grammar of
the language. This grammar checking process is known as parsing and that part of the
compiler program that carries it out is the parser. Typical errors that might be
detected and reported by the parser are missing brackets from an arithmetical
expression or inverted commas from a PRINT statement.

Code generation
: this stage produces the object code, which is a machine code
repesentation of the source code.

The programming language Pascal is an example of a language which is normally
compiled before it can be run.

ISK 2006

Higher Computing

LO2: SD La
nguages and Environm

An interpreter translates and runs a high-level language program one instruction or
statement at a time. No separate object code is produced. Interpreted programs run
slower than compiled programs because each line must be translated every time the
program is run.

When an interpreted program is being created both the source code and the interpreter
are required to write, edit, test and use the completed program.

If the program being interpreted contains a loop which is to be exectured, say 1000
times, then each line of code inside the loop will need to be repeatedly interpreted
1000 times. An interpreter will report any mistakes such as syntax errors in the code
immediately, rather than waiting until the end of the translation process the way
compilers do. Using an interpreter is a single process, unlike using a compiler, which
requires the program to be compiled separately and then run. For these reasons,
interpreted programming languages are popular with students and others who are
learning to program. Unlike compilers, it is not possible to save the translated version
which is produced by an interpreter since each program line is executed immediately
upon translation. Interpreted programs tend to use more memory than compiled
programs because the interpreter must also be present in the computer’s memory
when the program is run.

Programming languages such as BASIC and COMAL are normally interpretted,
although nowadays most languages are also provided with a compiler or similar
translator program capable of generating a stand alone version of the user’s program.

The efficiency of compilers and interpreters

Program speed
ƒ Once compiled, the
program runs much
faster than an
interpreted program as
it is in machine code.
ƒ Runs slower than
compiled programs
because each line must
be translated every
time the program is
Memory usage
ƒ Uses much less
memory than interpre
ted programs.
ƒ Takes up more
memory than compiled
programs as the
interpreter needs to be
running at the same
ƒ Harder to trace errors
as program waits until
end of compilation
process before
ƒ User can trace syntax
errors more quickly as
program stops
interpretting at the
offending line of code.

ISK 2006

Higher Computing

LO2: SD La
nguages and Environm
Module Libraries

A module library is part of a software library. A software library is a collection of
software held permanently accessible on backing storage. A software library will
typically include complete programs, a module library and a set of machine code
routines which may be loaded into user programs.

A module library will contain modules (procedures or pre-defined routines) which a
user can add to his or her programs when required. A programmer would not write a
procedure to sort numbers each time this was required in a new program, the
procedure would simply be loaded from a module library. This greatly speeds up the
software development process.

See the handout LO2: Using module libraries for examples of Visual
Basic programs which use module libraries.

ISK 2006