Computer Languages
Computer Languages
Algorithms
and
Program Development
4-1
1. Communicating with a Computer
Communication cycle
• One complete unit of communication.
– An idea to be sent.
– An encoder. Speaker encodes Listener decodes
– A sender. information information
– A medium.
– A receiver.
– A decoder.
– A response. Listener returns
feedback to speaker
4-2
1. Communicating with a Computer …
Substituting a
computer for one of
User encodes
the people in the information Computer decodes
communication information
process.
• Process is basically
the same.
– Response may be Computer
symbols on the returns results
monitor. to user
4-3
1. Communicating with a Computer …
4-4
1. Communicating with a Computer …
Programming languages bridge the gap between human
thought processes and computer binary circuitry.
4-5
2. The Role of Languages in Communication
1) Semantics
2) Syntax
3) Participants
4-6
2. The Role of Languages in Communication …
4-7
2. The Role of Languages in Communication …
4-8
2. The Role of Languages in Communication …
3) Participants:
• Human languages are used by people to communicate with each
other.
• Programming languages are used by people to communicate with
machines.
4-9
3. The Programming Language Continuum
In the Beginning...Early computers consisted of special-
purpose computing hardware.
• Each computer was designed to perform a particular arithmetic task
or set of tasks.
4-10
3. The Programming Language Continuum …
4-11
3. The Programming Language Continuum :ENIAC
4-12
3. The Programming Language Continuum …
In the beginning… To use a computer, you needed to know how to program it.
Today… People no longer need to know how to program in order to use the
computer.
To see how this was accomplished, lets investigate how programming languages
evolved.
4-13
3. The Programming Language Continuum …
1) First Generation - Machine Language (code)
• Machine language programs were made up of instructions written in
binary code.
4-14
3. The Programming Language Continuum …
2) Second Generation - Assembly Language
• Assembly language programs are made up of instructions
written in mnemonics.
• Mnemonics: Uses convenient alphabetic abbreviations
to represent operation codes, and abstract symbols to
represent operands.
• Each instruction had two parts: Operation code,
Operand.
READ num1 • Hardware dependent.
READ num2 • Because programs are not written in 1s and 0s, the
LOAD num1
computer must first translate the program before it can
ADD num2
be executed.
STORE sum
PRINT sum
STOP
4-15
3. The Programming Language Continuum …
3) Third Generation - People-Oriented Programs
• Instructions in these languages are called statements.
– High-level languages: Use statements that resemble English
phrases combined with mathematical terms needed to
express the problem or task being programmed.
4-16
3. The Programming Language Continuum …
Program sum2(input,output);
var
num1,num2,sum : integer;
begin
read(num1,num2);
sum:=num1+num2;
writeln(sum)
end.
4-17
3. The Programming Language Continuum …
4) Fourth Generation - Non-Procedural Languages
• Programming-like systems aimed at simplifying the programmers
task of imparting instructions to a computer.
a) Query Languages:
b) Report Writers:
c) Application Generators:
4-18
3. The Programming Language Continuum …
4) Fourth Generation - Non-Procedural Languages
a) Query Languages:
a) Enables a person to specify exactly what information they
require from the database.
b) Usually embedded within database management programs.
b) Report Writers:
a) Takes information retrieved from databases and formats into
attractive, usable output.
c) Application Generators:
– A person can specify a problem, and describe the desired results.
– Included with many micro-computer programs (macros).
4-19
3. The Programming Language Continuum …
4) Fourth Generation - Non-Procedural Languages
• Object-Oriented Languages: A language that expresses a computer
problem as a series of objects a system contains, the behaviors of those
objects, and how the objects interact with each other.
4-20
3. The Programming Language Continuum …
5) Fifth Generation - Natural Languages
• Natural-Language: Languages that use ordinary conversation in one’s
own language.
4-21
Assembled, Compiled, or
Interpreted Languages
All programs must be translated before their
instructions can be executed.
Computer languages can be grouped according to
which translation process is used to convert the
instructions into binary code:
• Assemblers
• Interpreters
• Compilers
4-22
Assembled, Compiled, or
Interpreted Languages
Assembled languages:
• Assembler: a program used to translate Assembly
language programs.
• Produces one line of binary code per original program
statement.
– The entire program is assembled before the program
is sent to the computer for execution.
4-23
Assembled, Compiled, or
Interpreted Languages
Interpreted Languages:
• Interpreter: A program used to translate high-level
programs.
• Translates one line of the program into binary code at a
time:
– An instruction is fetched from the original source
code.
– The Interpreter checks the single instruction for
errors. (If an error is found, translation and execution
ceases. Otherwise…)
– The instruction is translated into binary code.
– The binary coded instruction is executed.
– The fetch and execute process repeats for the entire
4-24
program.
Assembled, Compiled, or
Interpreted Languages
Compiled languages:
• Compiler: a program used to translate high-level
programs.
• Translates the entire program into binary code before
anything is sent to the CPU for execution.
– The translation process for a compiled program:
• First, the Compiler checks the entire program for syntax
errors in the original source code.
• Next, it translates all of the instructions into binary code.
» Two versions of the same program exist: the original
source code version, and the binary code version
(object code).
• Last, the CPU attempts execution only after the
programmer requests that the program be executed. 4-25
Programming for Everyone
4-26
Programming for Everyone
Using Macros
• Macro: Set of operations within the computer application
that have been recorded for later execution.
– Once recorded, the macro can be used repeatedly on
any document within that application.
– In word processors, macros are commonly used to
speed up repetitive tasks.
• Example: SIG can be stored as a macro that
includes a signature message at the end of a
document.
James R. Emmelsohn
Director of Public Relations,
Martin Electronics, Detroit Division 4-27
Programming for Everyone
4-28
Programming for Everyone
Scripting
• Scripting: A series of commands, written to accomplish
some task.
– Very similar to the concept of a program.
– Extends the capabilities of the application where it is
being used.
– Examples of scripting languages:
• Perl, C++, VBScript, JavaScript
• JavaScript: A scripting language that allows the
Web page designer to add functional features to a
formatted web page created in HTML.
4-30
Building a Program
4-31
Building a Program
4-32
Building a Program
4-35
Building a Program
4-36
Software Development:
A Broader View
Measures of effort spent on real-life programs:
Comparing programs by size:
4-37
Software Development:
A Broader View
• Measures of effort spent on real-life programs:
Comparing programs by time:
• Commercial software is seldom written by individuals.
– Person-months - equivalent to one person working
forty hours a week for four weeks.
– Person-years - equivalent to one person working for
twelve months.
4-38
Web Page Design Software:
Dreamweaver
What is Web page design software?
• The programs that help create pages and their associated
HTML.
• Dreamweaver: A visual Web page editor primarily for use
by Web design professionals.
Why is it needed?
• Allows creation of Web pages without knowledge of HTML
.
4-39
Web Page Design Software:
Dreamweaver
What minimal functions must it have?
• WYSIWIG: “What you see is what you get.”
– Web page designers see exactly what it will look like.
• Allows selection of color scheme. (Background and text)
• Allows text manipulation. (Typing text where you want it,
changing the size, color or style)
• Allows importation and layout of images.
4-40
Web Page Design Software:
Dreamweaver
What types of support are available to enhance its
use?
• Applets extend the capabilities of HTML.
– Applet: A short application program, usually written
in Java, which adds enhancement and/or functionality
to a Web page.
Is special support hardware available?
• Creating audio/visual materials for the WWW:
– Photo digitizers or scanners, video digitizer, and audio
digitizer.
– Once these are in a standard digital format, they can be
imported to Web development programs.
4-41
Web Page Design Software:
Dreamweaver
One final note:
• Dreamweaver and other Web page design software create
Web pages. You still need a place to keep your Web page.
– ISP (Internet Service Provider): A company or
organization that is used as an access point to the
WWW.
• The ISP will put your Web page on its server.
• You will be given an address where you or others
can access your Web page.
4-42