Computer Languages: Empowering Algorithms - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

Computer Languages: Empowering Algorithms

Description:

Listener decodes information. Listener returns. feedback to speaker. The Computer Continuum ... Computer decodes. information. Computer. returns results to user ... – PowerPoint PPT presentation

Number of Views:194
Avg rating:3.0/5.0
Slides: 30
Provided by: charle88
Category:

less

Transcript and Presenter's Notes

Title: Computer Languages: Empowering Algorithms


1
Computer Languages Empowering Algorithms
  • How is it computers know what we want them to do?
  • In this chapter
  • What makes up a language and how do we use
    language to communicate with each other and with
    computers?
  • How did computer programming languages evolve?
  • How do computers recognize what we type in as
    programs?
  • What do most programming languages have in
    common?
  • What are the steps in building a program?

2
How does a person communicate with a computer?
  • Communication cycle between humans.

Speaker encodes information
Listener decodes information
Listener returns feedback to speaker
3
How does a person communicate with a computer?
  • Communication cycle between a human and a
    computer.

User encodes information
Computer decodes information
Computer returns results to user
4
How does a person communicate with a computer?
  • Programming languages bridge the gap between
    human thought process and computer binary
    circuitry.

5
Are computer languages the same as human
languages?
  • Similarities and differences between human
    (natural) and computer (programming) languages
  • Semantics, Syntax, and Participants.
  • Semantics
  • Refers to the meaning.
  • Human the concept a group of words represents.
  • Computer the commands you wish the computer to
    perform.

6
Are computer languages the same as human
languages?
  • Syntax
  • Refers to the grammatical structure of a
    language.
  • Both human and computer sentence structure,
    spelling, and punctuation.
  • Participants (Most obvious differences)
  • Humans use human languages to communicate with
    each other.
  • Humans use programming languages to communicate
    with computers.
  • Computers only use binary code.

7
A Programming Language Family Tree
Generation Class Description Examples Dates

1st Machine Binary representation of
operation ROBOT 1940s Generation Language codes
in 1s and 0s. Instruction Machine
specific Set 2nd Assembly Mnemonic
representation of Pencil Paper 1950s-60s Genera
tion Language operation codes Instruction
Set Machine specific 3rd High level
Code resembles English COBOL, 1960s Generation La
nguages language-like structure FORTRAN, to
present Transportable from one
machine BASIC, Pascal to another Ada 4th Non
- Query languages, PROLOG, QBE, 1980s-90s Gene
ration Procedural Application Generators, SQL,
Hypertalk Languages Report
Writers Smalltalk, QUEL 5th Natural
Incorporates spoken language, No common 1990s
to Generation Languages Relies on voice
recognition, and examples yet 21st speech
generation Century External appearance of
a human language
8
A Programming Language Family Tree
  • Parts of example programs

Machine Language 10000001 00001110 Load contents
of memory location num1 01100000 00001101 Add
the contents of memory location
num2 10100000 00001111 Store results into memory
location sum
High-level program sums(input,
output) language var num1, num2, sum
Integer begin read(num1, num2) sum
num1 num2 writeln(sum) end.
Assembly Read num1 Language Read num2 Load num1
Add num2 Store sum Print sum Stop
9
A Programming Language Family Tree
  • Comparative characteristics of computer language
    translators
  • Assemblers, Interpreters, and Compilers.
  • Assembled languages
  • Assembler a program used to translate Assembly
    language programs.
  • Produces one line of binary code per original
    program statement.

10
A Programming Language Family Tree
  • Interpreted languages
  • Interpreter a program used to translate
    high-level programs.
  • Translates one line of the program into binary
    code at a time.
  • As each line is translated
  • First, the Interpreter checks the one instruction
    for errors (source code).
  • Next, it translates the instruction into binary
    code (object code).
  • Last, it attempts to execute the binary coded
    instruction.
  • The process repeats for the entire program.

11
A Programming Language Family Tree
  • 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 for errors in the
    entire program (source code).
  • Next, it translates all of the instructions into
    binary code (object code).
  • Last, the CPU attempts execution only after the
    programmer requests that the program be executed.

12
Minimal Language Requirements The Bare Essentials
  • Three generalized goals we humans wish for the
    computer to accomplish
  • Organize data
  • Calculate results
  • Present results
  • Five categories of computer language essentials
    if we are able to program computers to accomplish
    these three goals
  • Program formatting, Data formatting, Data
    manipulation, Program Input/Output.

13
Minimal Language Requirements The Bare Essentials
  • Program formatting rules used to recognize
    tasks.
  • Beginnings and endings of program units.
  • Statement format rules including punctuation,
    capitalization, line numbering, and relationships
    to one another.
  • Reserved words are terms used by the programming
    language for pre-defined purposes.
  • Comments allow the programmer to provide
    information notations within a program.

14
Minimal Language Requirements The Bare Essentials
  • Data formatting rules used by the programming
    language to store information within the
    computers memory.
  • Data types and Data structures.
  • Data types identifying the type of a piece of
    information.
  • Integer - Whole numbers
  • Real - Numbers that contain fractional parts
  • Character - Symbols
  • Boolean - A way to store TRUE or FALSE

15
Minimal Language Requirements The Bare Essentials
  • Data Structures a way to connect data types
    together into more complex structures.
  • Character string - stringing symbols together
    into words and sentences.
  • Array - a list of data elements, all of the same
    type, which are stored one right after another in
    the computers memory, and which can be accessed
    by using just one memory-location name.
  • Record - Groups together data items under one
    name that can be of different types and all
    pertain to one instance or individual.

16
Minimal Language Requirements The Bare Essentials
  • Representation examples of Data Structures

Character string This is a string of
characters! Array Friends list (contents of
array elements 1 - 3) 1) Sam 2) Lisa 3)
George Record Phone directory (contents of
records 1 2) 1) George Blass
2) Rick Marcus 14192 Ridgewood Dr. 29600
State Street South Lyon, MI 48178 Ypsilanti, MI
48197 248-555-1234 734-545-4321
17
Minimal Language Requirements The Bare Essentials
  • Data Manipulation
  • Declaration statements (or data definition) -
    tells the computer which data types and
    structures will be used.
  • Executable statements - series of instructions
    used to manipulate and transform various kinds of
    data.
  • Control statements - series of statements that
    change the physical sequence order of instruction
    execution - Includes Conditional statements
    Iteration statements.

18
Minimal Language Requirements The Bare Essentials
  • Schematic representation of a simple conditional
    control statement

IF
True
False
Statement
Program Continues
19
Minimal Language Requirements The Bare Essentials
  • Schematic representation of a looping
    (repetition) programming structure

Count 0
Is Count Less Than 100?
Write Will not be late
Add 1 to Count
Done
20
Minimal Language Requirements The Bare Essentials
  • Program Input/Output
  • Input - One or more statements instructing the
    computer to read the data from some appropriate
    device.
  • Output - Needed in a program to tell the computer
    to send its program results to some appropriate
    output device.

21
Building a Program
  • Whatever type of problem needs to be solved, a
    careful thought out plan of attack, called an
    algorithm, is needed before a computer solution
    can be determined.
  • 1) Understanding the problem.
  • 2) Developing the algorithm.
  • 3) Writing the program.
  • 4) Testing and debugging.

22
Building a Program
  • 1) Understanding the problem.
  • Need to analyze the problem and devise a plan for
    its solution
  • Example What is needed to write a program that
    will print out the names of the students in your
    class?

23
Building a Program
  • 2) Developing the algorithm.
  • Algorithm A detailed description of the exact
    methods used for solving a particular problem.
  • Flow charts - series of visual symbols
    representing the logical flow of a program.
  • Nassi-Schneidermann charts - uses specific shapes
    and symbols to represent different types of
    program statements.
  • Pseudo code - a verbal shorthand method that
    closely resembles a programming language, but
    does not have to follow a rigid syntax structure.

24
Building a Program
  • Example of a flow chart method of describing an
    algorithm

Count 0
Is Count Less Than 100?
Write Will not be late
Add 1 to Count
Done
25
Building a Program
  • Example of a Nassi-Schneidermann chart for
    describing an algorithm

Start name-counter at zero False
name-counterlt30?
True Do Get a name from the keyboard Nothing Add
1 to the name-counter Print name-counter, name
26
Building a Program
  • Example of a Pseudo code solution of an algorithm

Start namecount 0 repeat until namecount
30 read name namecount namecount 1 print
namecount, name end repeat stop
27
Building a Program
  • After the program has been written
  • 4) Testing and Debugging the Program.
  • The program must be free of syntax errors.
  • The program must be free of logic errors.
  • The program must be reliable.
  • (correctly produces correct results)
  • The program must be robust.
  • (able to detect execution errors)
  • Alpha testing - within the company
  • Beta testing - sophisticated users

28
Real-World Programming Today
  • Comparative sizes of real-life programs

Type of program Number of Lines The ROBOT
simulator Over 1000 lines The compiler for a
language with a limited instruction set Tens
of thousands of lines A full-featured word
processor Hundreds of thousands of lines A
microcomputer operating system Approximately
2,000,000 lines A military weapon management
program (controlling missiles, for
example) Several million lines
29
Real-World Programming Today
  • 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.
  • Team of 5 working 40 hours for 8 weeks ten
    person-months.
Write a Comment
User Comments (0)
About PowerShow.com