Introduction • Computer science is the discipline that seeks to build a scientific foundation for a variety of topics. • Computer science provides the underpinnings for today’s computer applications as well as the foundations for tomorrow’s applications.
27
Embed
Introduction Computer science is the discipline that seeks to build a scientific foundation for a variety of topics. Computer science provides the underpinnings.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Introduction
• Computer science is the discipline that seeks to build a scientific foundation for a variety of topics.
• Computer science provides the underpinnings for today’s computer applications as well as the foundations for tomorrow’s applications.
Ch. 5 Programming Languages
• Historical perspective.• Traditional programming concepts.• Program units.• Language implementation.• Parallel computing.• Declarative programming.
Historical Perspective
• Machine language - binary form; directly control the hardware.
• Assembly language - mnemonic form of the machine language.
• From machine language to assembly language– still low level– still machine-dependent
Historical Perspective
• Higher level language– machine-independent
• portability
– English-like language• Total=Price+Tax
– compiler Vs. interpreter
Historical Perspective
Compiler
Assembler 1
Arch 1 Arch n
Assembler n
HLL Machine independent
Machinedependent
Historical Perspective
• 1st-generation - machine language.• 2nd-generation - assembly language.• 3rd-generation - machine independent.• 4th-generation - software packages that all
ow users to customize computer software to their applications without needing technical expertise.
Historical Perspective
1st 4th
Problems solved in anenvironment in which the human must conformto the machine’s characteristics
Problems solved in anenvironment in which the machine conformsto the human’s characteristics
Programming Paradigms
• Imperative paradigm: based on CPU’s fetch-decode-execute cycle.– development of a sequence of commands
which manipulate data to produce the result– procedure paradigm– machine languages, FORTRAN, COBOL,
ALGOL, BASIC, APL, C, PASCAL, ADA
Programming Paradigms
• Declarative paradigm implements a general problem-solving algorithm.– GPSS, Prolog– what is the problem? NOT how to solve the pr
• Lexical analysis - recognizing which strings of symbols from the source program represent a single entity.
Language Implementation
• Parsing - identifying the grammatical structure of the program and recognizing the role of each component.– The man the horse that lost the race threw was not
hurt
– Fixed-format languages Vs. free-format languages• punctuation marks/key words/reserved words
– Syntax rules by diagrams (Figures 5.13 and 5.14)
Language Implementation
– Parse tree (Figure 5.15)• parsing -> constructing parse trees
• one string -> one parse tree (Figure 5.16)
– Parsing declarative statements -> symbol table (data types)
– Total = Price + Tax• integer addition op-code
• floating-point addition op-code
• coercion
• strongly typed
Language Implementation
• Code generation - constructing the machine language instructions to simulate the statements recognized by the parser.
• Code optimization.– x = y + z; w = x + z;– x and z need not be loaded from memory for
computing w
Language Implementation
• Linker - link all necessary object programs to produce a complete, executable program.– Load module
• Loader - place the program in memory for execution.– Multitasking– Relocatable module
• a jump instruction must jump to the correct address within the program
• Figure 5.18.
Object-Oriented Programming
• class SmallBusiness { … }• SmallBusiness BusinessX;• class MailOrder Business extends SmallBusiness
{ … }• MailOrderBusiness BusinessY;
– Inheritance– Polymorphism Vs. overloading
• Encapsulation: restrict access to an object’s internal properties
Parallel Computing
• Developing languages for describing processes that execute simultaneously.
• Process spawning.• Interprocess communication• Monitor controls access to shared data
– Object-oriented paradigm
Declarative Programming
• Logical deduction - resolution.– From P OR Q and R OR -Q, we conclude P OR R
– From -P -> Q and Q -> R, we conclude -P -> R
• Resolution can be applied only to pairs of statements that appear in clause form.
• Inconsistent collection of statements– P and -P
– Repeated application of resolution produces an empty clause (Figure 5.20)
Declarative Programming
• To conform that a collection of statements implies P => to contradict -P => to apply resolution to the original collection of statements and -P to produce an empty clause
• From (Mary is at X) -> (Mary’s lamb is at X) and Mary is at home, we conclude (Mary’s lamb is at home)– unification
Declarative Programming
• Prolog (PROgramming in LOGic) - a declarative programming language based on repeated resolution.