Title: CS 363 Comparative Programming Languages
1CS 363 Comparative Programming Languages
2Chapter 1 Topics
- Motivation
- Language Paradigms
- Programming Domains
- Language Design and Evaluation
- Influences
- Tradeoffs
- Implementation options
3Programming Languages
- Languages are
- an abstraction used by the
- programmer to express an idea
- interface to the underlying
- computer architecture
Sebesta Fig. 1.2
4Why study Programming Languages?
- Increases ability to express ideas in a language
- wide variety of programming features
- Improves ability to choose appropriate language
- Each language has strengths and weaknesses in
term of expressing ideas - Improves ability to learn new languages
- different paradigms, different features
- What does the future of programming languages
hold? - Improves understanding of significance of
implementation - Provides ability to design new languages
- Domain specific languages increasingly popular
5Language Paradigms
- Imperative
- Central features are variables, assignment
statements, and iteration - Ex C, Pascal, Fortran
- Object-oriented
- Encapsulate data objects with processing
- Inheritance and dynamic type binding
- Grew out of imperative languages
- Ex C, Java
- Functional
- Main means of making computations is by applying
functions to given parameters - Ex LISP, Scheme, Haskell
6Language Paradigms
- Logic
- Declarative ? Rule-based implicit control flow
- Ex Prolog
- Dataflow
- Declarative ? Model computation as information
flow implicit control flow - Inherently parallel
- Event-Driven
- Continuous loop with handlers that respond to
events generated in unpredictable order, such as
mouse clicks - Often an add-on feature
- Ex Java
- Concurrent
- Multiple interacting processes
- Often an add-on feature
- Ex Java, High Performance Fortran (HPF), Linda
7Programming Domains
- Scientific applications
- One of the earliest uses of computers
- Large number of floating point computations
- Long running
- Imperative (Fortran, C) and Parallel (High
Performance Fortran) - Business applications
- Produce reports, use decimal numbers and
characters - Increasingly toward web-centric (Java, Perl,
XML-based languages) - Imperative (Cobol) and domain specific (SQL)
- Artificial intelligence
- Model human behavior and deduction
- Symbol manipulation
- Functional (Lisp) and Logical (Prolog)
- Systems programming
- Need efficiency because of continuous use
- Parallel and event driven
- Imperative (C)
-
8Language Design
- Principles of Design
- Influences on Design
- Evaluation of a design
9Principles of Language Design
- Basic Vocabulary
- Syntax what constitutes a correctly written
program - Type Systems and Semantics these allow us to
provide a meaning to a syntatically correct
program. - Memory management data mapping, static and
dynamic memory, stack, heap, object lifetime,
garbage collection - Exception handling how to deal with unexpected
problems at runtime
10Influences on Language Design
- Von Neumann architecture Data and programs
stored in same memory - Memory is separate from CPU
- Instructions and data are piped from memory to
CPU - Basis for imperative languages
- Variables model memory cells
- Assignment statements model piping
- Iteration is efficient
11Influences 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
12Influences on Program Design
- Special Purpose (Domain Specific)
- Abstraction closer to problem domain
- Personal Preferences
- terse vs. verbose
- recursion vs. iteration
- user controlled vs. language controlled dynamic
allocation
13Language Evaluation Criteria
- Readability most important!
- Overall simplicity
- Orthogonality A relatively small set of
primitive constructs that can be combined in a
relatively small number of ways - Makes the language easy to learn and read
- Meaning is context independent
- Every possible combination is legal
- Lack of orthogonality leads to exceptions to
rules - Control statements
- Defining data types and structures
- Syntax considerations identifier forms, special
words, meaning
14Language Evaluation Criteria
- Writability
- Simplicity and orthogonality
- Support for abstraction
- Expressivity
- Reliability
- Conformance to specs.
- Type checking
- Exception handling
- Aliasing
- Readability and writability
15Language Evaluation Criteria
- Cost
- Categories
- Training programmers to use language
- Writing programs
- Compiling programs
- Executing programs
- Language implementation system
- Maintaining programs (readability)
- Safety prevention of unchecked errors
- Others portability, generality, well-definedness
16Language Implementation Options
- Compilers
- Interpreters
- Hybrid options
17Compilers
Syntactic/semantic structure
tokens
Syntactic structure
Scanner (lexical analysis)
Parser (syntax analysis)
Semantic Analysis (IC generator)
Code Generator
Source language
Machine language
Code Optimizer
Input Data
Computer
Symbol Table
Output
18Interpreters
Interpreter
Source language
Output
Input Data
19Compilation vs. Interpretation
- Compilation
- Translate HL code directly into machine
- Translation can be slow
- Resulting code is fast (typically optimized)
- Interpretation
- Execute HL code directly
- No translation costs
- Execution can be slow
20Hybrid
tokens
Syntactic structure
Scanner (lexical analysis)
Parser (syntax analysis)
Semantic Analysis (IC generator)
Source language
Input Data
Intermediate Code
Interpreter
Symbol Table
Output
21What makes a language successful?
- Expressive Power
- Included features impact programmer use
- Ease of use for Novice
- Pascal, Basic, Logo
- Ease of Implementation
- Excellent Compilers
- Economics, Patronage, Legacy