Beruflich Dokumente
Kultur Dokumente
Preliminaries
Our texts
Motivation
Programming Domains
Language Evaluation Criteria
Influences on Language Design
Language Categories
Language Design Trade-Offs
Implementation Methods
Programming Environments
3
Where we are?
4
Motivation: Why Study
Programming Languages?
Increased ability to express ideas
Improved background for choosing appropriate
languages
C vs. Modula-3 vs. C++ for systems
programming
Fortran vs. APL vs. Ada for numerical
computations
Ada vs. Modula-2 for embedded systems
7
Programming Domains
Scientific applications
Large numbers of floating point computations; use of arrays
Fortran
Business applications
Produce reports, use decimal numbers and characters
COBOL
Artificial intelligence
Symbols rather than numbers manipulated; use of linked lists
LISP
Systems programming
Need efficiency because of continuous use
Web Software
Eclectic collection of languages: markup (e.g., XHTML), scripting
(e.g., PHP), general-purpose (e.g., Java)
Special-purpose languages 8
Language Evaluation Criteria
Readability
The most important criterium
Factors:
Overall simplicity
Too many features is bad
Multiplicity of features is bad
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 exceptions to rules 9
Language Evaluation Criteria
Syntax considerations
Identifier forms
Special words
Form and meaning
10
Language Evaluation Criteria
Writability
Factors:
Simplicity and orthogonality
Support for abstraction
Expressivity
Reliability
Factors:
Type checking
Exception handling
Aliasing
Compiling programs
Executing programs
Reliability
Maintaining programs
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
14
Influences on Language Design
15
Von Neumann Architecture
16
Influences on Language Design
Programming methodologies
1950s and early 1960s: Simple applications; worry about
machine efficiency
Late 1960s: People efficiency became important;
readability, better control structures
Structured programming
Top-down design and step-wise refinement
Late 1970s: Process-oriented to data-oriented
data abstraction
Middle 1980s: Object-oriented programming
17
Language Categories
Imperative
Central features are variables, assignment
statements, and iteration
C, Pascal
Functional
Main means of making computations is by
applying functions to given parameters
LISP, Scheme
18
Language Categories
Logic
Rule-based
Rules are specified in no special order
Prolog
Object-oriented
Encapsulate data objects with processing
Inheritance and dynamic type binding
Grew out of imperative languages
C++, Java
19
Language Design Trade-Offs
20
Layered View of Computer
21
Compilation
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
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
22
Compilation
Process
23
Additional Compilation
Terminologies
24
Preprocessors
Preprocessor macros (instructions) are
commonly used to specify that code from
another file is to be included
A preprocessor processes a program
immediately before the program is compiled
to expand embedded preprocessor macros
A well-known example: C preprocessor
expands #include, #define, and similar
macros
25
Preprocessors
26
Preprocessor VS Compiler
27
Pure Interpretation
No translation
Easier implementation of programs (run-time
errors can easily and immediately displayed)
Slower execution (10 to 100 times slower than
compiled programs)
Often requires more space
Becoming rare on high-level languages
Significant comeback with some Web
scripting languages (e.g., JavaScript)
28
Pure Interpretation
29
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 run-time system (together, these are called Java
Virtual Machine)
30
Hybrid Implementation Process
31
Compilation vs. Interpretation
Interpretation:
Greater flexibility
Better diagnostics (error messages)
Compilation
Better performance
32
Compilation vs. Interpretation
33
Compilation vs. Interpretation
Implementation strategies:
Library of Routines and Linking
Compiler uses a linker program to merge the appropriate
library of subroutines (e.g., math functions such as sin,
cos, log, etc.) into the final program:
34
Compilation vs. Interpretation
Implementation strategies:
Post-compilation Assembly
Facilitates debugging (assembly language easier for
people to read)
Isolates the compiler from changes in the format of
machine language files (only assembler must be
changed, is shared by many compilers)
35
Compilation vs. Interpretation
Implementation strategies:
The C Preprocessor (conditional compilation)
Preprocessor deletes portions of code, which allows
several versions of a program to be built from the
same source
Implementation strategies:
Source-to-Source Translation (C++)
C++ implementations based on the early AT&T compiler
generated an intermediate program in C, instead of an assembly
language:
37
Compilation vs. Interpretation
Implementation strategies:
Bootstrapping
38
Compilation vs. Interpretation
Implementation strategies:
Compilation of Interpreted Languages
The compiler generates code that makes assumptions
about decisions that wont be finalized until runtime.
If these assumptions are valid, the code runs very fast.
If not, a dynamic check will revert to the interpreter.
Hybrid system
39
Compilation vs. Interpretation
Implementation strategies:
Dynamic and Just-in-Time Compilation
In some cases a programming system may deliberately
delay compilation until the last possible moment.
Lisp or Prolog invoke the compiler on the fly, to translate
newly created source into machine language, or to optimize the
code for a particular input set.
The Java language definition defines a machine-independent
intermediate form known as byte code. Byte code is the
standard format for distribution of Java programs.
The main C# compiler produces .NET Common Intermediate
Language (CIL), which is then translated into machine code
immediately prior to execution. 40
Compilation vs. Interpretation
41
An Overview of Compilation
42
An Overview of Compilation
43
An Overview of Compilation
44
An Overview of Compilation
45
An Overview of Compilation
Next slide
46
An Overview of Compilation
47
An Overview of Compilation
Syntax Tree
GCD Program Parse Tree
48
Programming Environments
The collection of tools used in software
development
UNIX
An older operating system and tool collection
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#,
or C++
Eclipse, Dev C, NetBean, XCode,
49
Genealogy of Common
Languages
50
51