Anda di halaman 1dari 47

CMSC 124 (DESIGN AND

IMPLEMENTATION OF
PROGRAMMING LANGUAGES)
Lecture 1 Preliminaries

Perl Gasmen
Department of Physical Sciences and Mathematics
University of the Philippines Manila
OVERVIEW
 Motivation
 Programming Domains

 Language Evaluation Criteria

 Language Design Trade-Offs

 Influences on Language Design

 Language Categories

 Implementation Methods

 Programming Environments
WHY STUDY PROGRAMMING LANGUAGES
WHY STUDY PROGRAMMING LANGUAGES
 Increased ability to express ideas

 Improved background for choosing appropriate


languages

 Greater ability to learn new languages


WHY STUDY PROGRAMMING LANGUAGES
 Understand significance of implementation

 Ability to design new languages

 To increase your vocabulary of useful


programming constructs
PROGRAMMING DOMAINS
 Scientific applications
– Large number of floating point
computations

 Business applications
– Produce reports, use decimal numbers and
characters

 Artificial intelligence
– Symbols rather than numbers are
manipulated
PROGRAMMING DOMAINS
 Systems programming
– Need efficiency because of continuous use

 Scripting languages
– Put a list of commands in a file to be
executed

 Special-purpose languages
LANGUAGE EVALUATION CRITERIA
 Readability

 Writability

 Reliability

 Cost

 etc…
READABILITY (UNDERSTANDS PROGRAMS)
 The most important criterium
 Factors affecting readability:
 Overall simplicity
 Too many features is bad as well as the multiplicity of
features
 Orthogonality
 Makes the language easy to learn and read
 Meaning is context independent

 A relatively small set of primitive constructs can be

combined in a relatively small number of ways.


 Every possible combination is legal

 Lack of orthogonality leads to exception to rules (too much


exceptions are hard to remember)
READABILITY (UNDERSTANDS PROGRAMS)
 Control Statements
 Top-to-bottom rather than jumps
READABILITY (UNDERSTANDS PROGRAMS)
 Data Types and Structures
 The presence of adequate facilities for defining data
types and data structures in a language is another
significant aid to reliability.
 Ex: Boolean type.
 timeout = 1 or timeout = true
READABILITY (UNDERSTANDS PROGRAMS)
 Syntax Considerations
 The syntax of the elements of a language has a
significant effect on readability.
 Identifier norms - length
 Special words/Reserved words
 Form and meaning
 Semantic should follow directly from syntax, or form.
WRITABILITY
 It is a measure of how easily a language can be
used to create programs for a chosen problem
domain.

 Most of the language characteristics that affect


readability also affect writability.

 Factors:
 Simplicity and orthogonality
 Support for abstraction
 Expressivity
RELIABILITY
 A program is said to be reliable if it performs to
its specifications under all conditions.
 Factors:
 Type checking
 Exception handling
 Aliasing
 Readability and writability
COST
 Programmer training
 Writing programs (writability)

 Compiling programs

– compilation cost versus execution cost?


(optimization)
 Executing programs

 Language implementation system (“Free


compilers is the key, success of Java”)
COST
 Reliability (with great power comes great
responsibility. A simple system failure will affect
everyone!)

 Maintaining programs (tech support, upgrades…)


-Maintenance costs can be as high as two to four
times as much as development costs.
LANGUAGE DESIGN TRADE-OFFS
LANGUAGE DESIGN TRADE-OFFS
 Most criteria cannot be defined or measured
precisely
 Different perspectives by different people:
 Language designer
 Language implementer
 Language user

 Influenced by the state-of-the-art hardware and


programming methodologies
LANGUAGE CATEGORIES
 The Big Four
 Imperative or procedural (e.g., Fortran, C)
 Functional (e.g., Lisp, ML)
 Rule based (e.g. Prolog, Jess)
 Object-oriented (e.g. Smalltalk, Java)
IMPERATIVE OR PROCEDURAL
 Goal is to understand a machine state (set of
memory locations, each containing a value)
 Statement oriented languages that change
machine state
 Central features are variables, assignment
statements and iteration
 Syntax: S1, S2, S3,…

 C, Pascal, FORTRAN, COBOL, Visual Basic


FUNCTIONAL OR APPLICATIVE
 Goal is to understand the function that produces
the answer
 Function composition is major operation

 Syntax: P1(P2(P3(X)))

 LISP, ML/CAML, Scheme, Haskell


RULE-BASED OR LOGIC
 Specify rule that specifies problem solution
 Programming consists of specifying the attributes
of the answer
 Syntax: Answer -> specification rule

 Prolog, BNF Parsing, Jess


OBJECT-ORIENTED
 Imperative languages that merge applicative
design with imperative statements
 Encapsulation

 Inheritance and dynamic type binding

 C++, Java, Smalltalk


LAYERED VIEW OF COMPUTER
IMPLEMENTATION METHODS
 Compilation

 Pure Interpretation

 Hybrid implementation system


COMPILATION
 Translate high-level program to machine code
 Slow transition

 Fast execution

 Von Neumann bottleneck


COMPILATION
INTERPRETATION
 Software simulation only (fetch-execute cycle)
 No translation (deals with high-level languages)

 Easy reporting of error

 Slow execution

 Often requires more space

 Bottleneck: statement decoding


INTERPRETATION
HYBRID IMPLEMENTATION
 Small translation cost
 Medium execution speed

 Translation to an intermediate language


(compilation) that is easier to interpret
(interpretation)
 Java’s “byte code” is an example of an
intermediate language
HYBRID IMPLEMENTATION
PROGRAMMING ENVIRONMENTS
 The collection of tools used in software
development, often including an integrated
editor, debugger, compiler, collaboration tool, etc.

 Modern Integrated Development Environments


(IDEs) tend to be language specific, allowing the,
to offer support at the level at which the
programmer thinks.
PROGRAMMING ENVIRONMENTS
 Examples:
 UNIX – operating system with tool collection
 EMACS – a highly programmable text editor
 Smalltalk – a language processor/environment
 Microsoft Visual C++ - a large, complex visual
environment
 CodeBlocks – C/C++ IDE
 Eclipse – a generic IDE
 BlueJ, JBuilder, J++ - Java environment
PROGRAMMING ENVIRONMENTS
PROGRAMMING ENVIRONMENTS
PROGRAMMING ENVIRONMENTS
PROGRAMMING ENVIRONMENTS
PROGRAMMING ENVIRONMENTS
PROGRAMMING ENVIRONMENTS
THANK YOU!!!! 

Anda mungkin juga menyukai