1
Software Development
Topic 2
Software Development Languages
and Environments
2
Translators
►
As mentioned in the CS topic computers can only
understand instructions and data that are written
in binary form.
►
Programs written in high level languages use lots
of English like terms and need to be translated
so that the computer can understand them.
►
This is done by a piece of systems software
called a
translator
.
►
We will look at 2 types of translator:
-
►
Compiler
►
Interpreter
3
Compiler
This program converts high
-
level language code into machine
code.
The compiler takes all the source code (the high
-
level language
program before anything is done to it) as one block and
translates it into machine code.
This translated program can be run at any time without the
source code or the compiler because the translated program is
stored as machine code and this machine code can be
understood by the processor.
4
If a change is made to the source code
then the program must be compiled
again so that the change is
incorporated
in the finished compiled program.
The finished compiled program is
called
object code
.
Object code is created every time the
source code is compiled.
5
Interpreter
An interpreter translates and executes
each program instruction one at a time
as the program is run.
In simple terms the interpreter does the following:
1.
Fetch instruction
2.
Translate instruction into machine language
equivalent(s)
3.
Execute
Programs translated using an interpreter can only be
run in conjunction with the interpreter.
If the interpreter is not present then the source
code instructions cannot be translated into their
machine code equivalents.
6
Compilers V Interpreters.
1.
Compilers produce executable programs.
E.g. They produce programs that can be run
on a computer system without the need for
the source code or the compiler/assembler
to be present in the system.
2.
Compiled programs run much faster than
interpreted programs.
This is because interpreted programs read
and translate each instruction in turn and
this takes time. Compiled programs already
have all their instructions converted to
machine code.
Loops run very slowly in interpreted programs
because every line in the loop has to be
translated every time it operates.
7
3.
Interpreted programs take less time to develop
(write) because if a change is made to the source
code then this change is included in the next
program run.
However, with compilers any changes to the
source code are not included in the executable
code until the source code is re
-
compiled.
Each time a change is made a new version of the
executable program must be made.
8
►
The choice of which type of translator
to use depends on the type of programs
being written and the experience of the
program writer.
►
E.g.
Complex programs written by
experienced programmers for system
software or applications tend to use
compilers.
Translator
S
peed
Easy to Alter
Easy to Understand
Interpreter
Slow
Yes
Yes
Compiler
Fast
No
Yes
Summary
9
Programming Languages
SDP Theory Booklet pages 34
-
35
►
There are 4 main classifications of
programming languages that we will
concentrate on. These are
Procedural Languages
Declarative Languages
Event Driven Languages
Scripting Languages
Procedural Languages
Key features
►
Carried out in a fixed
sequence with a start
and end point
►
Can be split into
separate functions and
procedures
►
Have control structures
such as If statements,
for..next loops and
do..while loops
Examples of procedural
languages are:
►
BASIC
►
Pascal
►
C
A lot of programmers
are familiar with at least
one procedural
language
Example Pascal Procedural Code
Declarative Languages
Key features
►
Consist of facts and rules
►
No fixed sequence of
instructions
►
Are queried (asked
questions) which they try
to find a solution to
►
Uses pattern matching to
answer queries
facts and rules combined in
different ways until a
solution, or no solution, is
found
Examples of declarative
languages are:
►
Prolog
►
LISP
►
ML
►
Scheme
►
Erlang
languages such as Prolog and
LISP are used predominantly
in the field of Artificial
Intelligence.
Here are some facts
:
Parent (Liz, Tom). means that Liz is a parent of Tom
Female (Liz). means that Liz is female
Male(Tom).
Parent(Bert, Tom).
Here is a rule
:
Mother(X, Y) :
-
means that X is a mother of Y IF
Parent(X, Y), Female(X) X is a parent of Y AND X is
female!
Query
could be
Mother(X, Tom)
which would give the answer
X=Liz
Example Prolog Declarative Code
Event Driven Languages
Key Features
►
no fixed order of
instructions
►
wait for user input
(clicking a button)
before performing an
action
►
front end for creating
graphical user
interfaces
►
share the same type of
language features as
procedural languages
Examples of event driven
languages are:
►
Visual Basic
►
Delphi (Object Pascal)
►
Smalltalk
Used for creating a wide
range of desktop
applications for modern
OS’s
such as Mac OSX and
Windows
Example Visual Basic Event Driven
Code
Scripting Languages
Key Features
►
usually built
-
in to existing
applications
►
automate or extend the
functionality of
applications
►
have extra functions,
procedures and data types
related to the application
Selection.Font.Name
Range(“A1”).
Select
►
run slower than other
programs because they’re
interpreted
►
share the same type of
language features as
procedural languages
Examples of scripting
languages are:
►
VBA (Visual Basic for
Applications)
►
Javascript
►
TCL
Lots of people create and
use
macros
who wouldn’t
consider themselves
programmers
Example VBA Scripting Code
Macros
Benefits of Macros
►
Can extend and add new
features to a program
that the developers didn’t
think of
►
Can simplify and repeat
complex or frequently
used commands
►
Can be assigned to a
keyboard shortcut to
make it easier to use
when required
Creating a Macro
1.
Record a series of actions in an
application you are using
2.
Code gets generated and
saved as a program script
3.
Script can then be assigned to
a keystroke
Or
1.
Write and save the script in an
editor
2.
Run the script in the
application and find and fix
any errors
3.
Script can then be assigned to
a keystroke
Example Exam Questions
1.
Describe two characteristics of a scripting language not commonly found
in a procedural language (2)
2.
A program contains the following statement:
Is_a(rover, dog).
State which type of programming language is being used. (1)
3.
State two benefits of using a macro to create an alphabetical list of
customers whose account balance is over £5000. (2)
4.
Macros are written in a high level language. State the type of high level
language that is used to write macros. (1)
5.
State two features of a declarative programming language (2)
6.
State two methods of creating a macro (2)
Enter the password to open this PDF file:
File name:
-
File size:
-
Title:
-
Author:
-
Subject:
-
Keywords:
-
Creation Date:
-
Modification Date:
-
Creator:
-
PDF Producer:
-
PDF Version:
-
Page Count:
-
Preparing document for printing…
0%
Σχόλια 0
Συνδεθείτε για να κοινοποιήσετε σχόλιο