Sei sulla pagina 1di 49

Chapter 1:

Preliminaries
Jhune Hay L. Mitra
Instructor 1
Reason for Studying Concepts of
Programming Language
Increased ability to express ideas
Improved background for choosing appropriate languages
Increased ability to learn new languages
Better understanding of significance of implementation
Better use of languages that are already known
Overall advancement of computing
Programming Domains
Scientific Applications
Have a simple Data Structure like arrays and matrices.
Have control structures such as counting loops and selections.
Require large numbers of floating point arithmetic computations
Some languages designed for this were Fortran, Algol60.
Programming Domains
Business Application
Need Production of elaborate reports
Precise ways of describing and storing decimal numbers and
character data.
Have Ability to specify decimal arithmetic operations
Some of languages designed for this were COBOL and SAS
Programming Domains
Artificial Intelligence
Use of linked lists is preferred over arrays
Required more flexibility
A language designed specifically for this is LISP
Programming Domains
System Programming
Must have execution efficiency
Must have low-level features that allow software interface to external
devices to be written.
Some languages designed for this were PL/1, Bliss, and C
Programming Domains
Web Software
Eclectic collection of languages: markup (e.g., XHTML,
HTML), scripting (e.g., PHP), general-purpose (e.g., Java)
Language Criteria
Readabilityis the ease of which programs can read and understood
and can be directly related to:
The Overall simplicity, which can be determined by number of basic
components and whether is has one or more ways to accomplish a
particular operation.
The Orthogonality, which is the degree to which a set of primitive
constructs can be combined to build the control and data structures of
the language.
The number of control statements in a language.
Then number of data types and structures.
The Syntax or form of the elements of a language. Three types of syntax
after readability: Identifier forms, special words, and form and meaning
Language Criteria
Writability
is a measure of how easily a language can be
used to create programs for a chosen problem domain and
can be directly related to:
Simplicity and Orthogonality (Defined in readability)
Support Abstraction, which is the ability to define and use
complicated structures or operations in a way that allows many
details to be ignored
Expressivity, which is when a language has a convenient way
of specifying computations.
Language Criteria
Reliability
is when a language performs to its specifications
under all conditions and is directly related to:
Type Checking, which is simple testing for type errors in a
program either by the compiler or run-time.
Exception handling, which is the ability of a program to intercept
run-time errors, take corrective action, and then continue on
Aliasing, which is having two or more distinct referencing
methods or names for the same memory location
Influences on Language Design
Other factors may also influence the design of a
programming language
Computer Architecture
Programming Methodologies
Influences on Language Design
Other factors may also influence the design of a programming
language

Computer Architecture
Languages are developed around the prevalent computer architecture,
known as the von Neumann architecture
Programming Methodologies
New software development methodologies (e.g., object-oriented
software development) led to new programming paradigms and by
extension, new programming languages
Language Categories
Imperative
Central features are variables, assignment statements, and iteration
Include languages that support object-oriented programming
Include scripting languages
Include the visual languages
Examples: C, Java, Perl, JavaScript, Visual BASIC .NET, C++
Functional
Main means of making computations is by applying functions to given
parameters
Examples: LISP, Scheme
Logic
Rule-based (rules are specified in no particular order) Example:
Prolog
Markup/programming hybrid
Markup languages extended to support some programming. (HTML,
XML) Examples: JSTL, XSLT
Language Design Trade-Offs
Some of the criteria used to rate languages are themselves
conflicting; the increase of one generally means that the other
is degenerate, some of these conflicts are as follows:
Reliability
vs. Cost of Execution if the program is reliable it probably
executes slowly and vice versa.
Examples: Java demands all references to array elements
be checked for proper indexing, which leads to increased
execution costs
Language Design Trade-Offs
Readability vs. writability - if the program is readable it is
probably not as writable and vice versa.
Example: APL provides many powerful operators (and a large
number of new symbols), allowing complex computations to
be written in a compact program but at the cost of poor
readability
Writability (flexibility) vs. reliability - if the program is flexible it
is probably not as reliability and vice versa
Example: C++ pointers are powerful and very flexible but are unreliable
Language Design Trade-Offs
Readability vs. writability - if the program is readable it is
probably not as writable and vice versa.
Example: APL provides many powerful operators (and a large
number of new symbols), allowing complex computations to
be written in a compact program but at the cost of poor
readability
Writability (flexibility) vs. reliability - if the program is flexible it
is probably not as reliability and vice versa
Example: C++ pointers are powerful and very flexible but are unreliable
Implementation Methods
Compilation Programs are translated into Machine
language.

Pure Interpretation Programs are interpreted by another


programs known as an interpreter.

Hybrid Implementation Systems a compromise between


compilers and pure interpreters.
Layered View of
Computer
The operating system and language
implementation are layered over
machine interface of a computer
Compilation Process
Translate high-level program
(source language) into machine
code (machine language)
Slow translation, fast execution
Compilation process has several
phases:
lexical analysis: converts
characters in the source program
into lexical units. (Tokens) syntax
analysis: transforms lexical units
into parse trees which represent
the syntactic structure of program
Semantics analysis: generate
intermediate code
code generation: machine code is
generated
Pure Interpretation
Process
No translation
Easier implementation of programs
(run-time errors can easily and
immediately be displayed)
Slower execution (10 to 100 times
slower than compiled programs)
Often requires more space
Now rare for traditional high-level
languages
Significant comeback with some
Web scripting languages (e.g.,
JavaScript, PHP)
Hybrid Implementation
Systems
A compromise between compilers and
pure interpreters
A high-level language program is
translated to an intermediate language
that allows easy interpretation
Faster than pure interpretation
Examples
Perl programs are partially
compiled to detect errors before
interpretation
Initial implementations of Java
were hybrid; the intermediate
form, byte code, provides
portability to any machine that
has a byte code interpreter and a
runtime system (together, these
are called Java Virtual
Machine)
Programming Envinronments
The collection of tools used in software development
UNIX
An older operating system and tool collection
Nowadays often used through a GUI (e.g., CDE, KDE, or GNOME) that
runs on top of UNIX
Borland JBuilder
An integrated development environment for Java
Microsoft Visual Studio.NET
A large, complex visual environment
Used to program in C#, Visual BASIC.NET, Jscript, J#, and C++
The Von Neumann
Architecture
Fetch-execute-cycle (on a von Neumann
architecture computer)

Potrebbero piacerti anche