to view programming languages slides

advertisement
Computer Programs and Programming Languages
What are low-level languages and high-level languages?
Low-level
language
Machine-dependent
runs only on one type of computer
Machine and assembly languages
are low-level
High-level
language
Often machine-independent
can run on many different
types of computers
Generations of programming languages
The evolution of programming paradigms
Imperative or Procedural
Declarative
Functional
Object Oriented
Low-Level Languages
What is machine language?

Only language computer
directly recognizes
Low-Level Languages
What is assembly language?


Instructions made up of
symbolic instruction
codes, meaningful
abbreviations and codes
Source program contains
code to be converted to
machine language
Second-generation:
Assembly language
A mnemonic system for representing programs



Mnemonic names for op-codes
Names for all registers
Identifiers = descriptive names for memory locations,
chosen by the programmer
Assembly language characteristics
One-to-one correspondence between machine
instructions and assembly instructions

Programmer must think like the machine
Inherently machine-dependent
Converted to machine language by a program called
an assembler
Assembly language example
Machine language
Assembly language
156C
166D
5056
30CE
C000
LD R5, Price
LD R6, ShippingCharge
ADDI R0, R5 R6
ST R0, TotalCost
HLT
Third generation language
Uses high-level primitives

Similar to our pseudocode in Chapter 5
Machine independent (mostly)
Examples: FORTRAN, COBOL
Each primitive corresponds to a short sequence of
machine language instructions
Converted to machine language by a program called a
compiler
Procedural Languages
What is a procedural language?
Programmer writes
instructions that tell
computer what to accomplish
and how to do it
Uses series of English-like
words to write instructions
Often called third-generation Most widely used are BASIC,
language (3GL)
COBOL, and C
Procedural Languages
What is a compiler?

Program that
converts entire
source
program into
machine
language
before
executing it
Procedural Languages
What is an interpreter?


Program that
translates and
executes one
program code
statement at
a time
Does not produce
object program
Procedural Languages
What is COBOL?



Designed for business applications
English-like statements make code easy to read, write,
and maintain
COmmon
Business-Oriented
Language
Procedural Languages
What is C?


Powerful language originally designed to write system
software
Requires professional programming skills
The composition of a typical imperative
program or program unit
Variable declarations in C, C++, C#, and
Java
Control
structures
and their
representations
in C, C++, C#,
and Java
The for loop structure and its
representation in C++, C#, and Java
The flow of control involving a procedure
The procedure ProjectPopulation written
in the programming language C
Executing the
procedure Demo
and passing
parameters by
value
Executing the
procedure Demo
and passing
parameters by
reference
The translation process
A syntax diagram
of our if-then-else pseudocode statement
An object-oriented approach to the
translation process
Object-Oriented Programming Languages
What is an object-oriented programming (OOP) language?
Used to
implement
object-oriented
design
Object is
item that
contains
data and
procedures
that act on
data
Major benefit
is ability to
reuse existing
objects
Event-driven—
checks for
and responds
to set of events
Event is
action to
which
program
responds
C++ and Java
are complete
object-oriented
languages
Object-Oriented Programming Languages
What is C++?


Includes all elements of C, plus additional features
for working with object-oriented concepts
Used to develop
database and
Web applications
Object-Oriented Programming Languages
What is Java?


Developed by Sun
Microsystems
Similar to C++ but
uses just-in-time (JIT)
compiler to convert
source code into
machine code
Object-Oriented Programming Languages
What is a visual programming language?
Visual programming
environment (VPE)
allows developers to
drag and drop objects
to build programs
Provides visual or
graphical interface for
creating source code
Sometimes called
fifth-generation
language
Often used in RAD
(rapid application
development)
environment
Programmer writes
and implements
program in segments
Object-Oriented Programming Languages
What is Visual Studio .NET 2003?



Suite of visual programming languages and RAD tools
.NET is set of technologies that allows program to run on Internet
Visual Basic .NET 2003 is used to build complex object-based programs
Step 1. The
Step 2. The programmer
programmer
designs the
user interface.
assigns properties to each
object on the form.
Step 3. The
programmer
writes code
to define the
action of each
command button.
Step 4. The programmer
tests the application.
Objects and Classes
Object = active program unit containing both data and
procedures
Class = a template for all objects of the same type
An Object is often called an instance of the class.
Components of an object
Instance variable = variable within an object
Method = function or procedure within an object

Can manipulate the object’s instance variables
Constructor = special method to initialize a new object
instance
The structure of a class describing a coin
public class Coin
{
private final int HEADS = 0;
private final int TAILS = 1;
private int face;
Instance variable
// Sets up the coin by flipping it initially.
public Coin ()
{
flip();
constructor
}
// Flips the coin by randomly choosing a face value.
public void flip ()
{
face = (int) (Math.random() * 2);
}
}
Method
Nonprocedural Languages
and Program Development Tools

What are nonprocedural languages and program
development tools?
Nonprocedural
Language
Program Development
Tools
The programmer writes Englishlike instructions or interacts with
a visual environment to retrieve
data from files or a database
User-friendly programs
designed to assist both
programmers and users in
creating programs
Nonprocedural Languages
and Program Development Tools
What is RPG (Report Program Generator)?

Nonprocedural language used for generating reports,
performing computations, and updating files
Nonprocedural Languages
and Program Development Tools
What is a fourth-generation language (4GL)?


Nonprocedural language that allows access to data in
database
Popular 4GL is SQL, query language that allows users to
manage data in relational DBMS
Nonprocedural Languages
and Program Development Tools
What is an application generator?


Program that creates source code or machine code from
specification
Consists of report writer, form, and menu generator

Form provides areas for entering data
Nonprocedural Languages
and Program Development Tools
What is Visual Basic for Applications (VBA)?

Macro programming language

Macro—series of statements used to automate tasks
Download