intro_prelim
intro_prelim
What What
is a Programming Language?
is Programming?
Languages in CS
Programming Languages
Java, C, Python, Haskell, Prolog, …
Cover of the
Communications of
Domain-Specific Languages
The ACM 1961 SQL, HTML, R, LaTex, Excel, …
Metalanguages
BNF (grammars), Rule Systems, ..
Formal Models
Automata, Logic(s), …
Science vs. Engineering
Scienc
Newton’s Laws Principles of e
Maxwell’s Life Computational
Equations Biolo Limits
Phys gy Computer
Science
Programming
ics Lang
Fundamentals
Applied Knowledge
Programming vs Computer Science
What
What exactlyisis CS 381 About?
a programming language?
Recursion?
Functional
Programming
int x;
int f(int z) {x:= f(y)…};
{ int x;
f(3)
Value or Semantic
} Address? s
When to Based on
evaluate? what?
x:= f(y) * Parameter
g(z-1) Abstract Syntax
Which Passing AST
x? “Determine” value of RHS and
Scoping “assign it” to x
How to express
computation?
Programming Paradigms
The Role of Haskell in CS 381
Example of a non-imperative programming
paradigm
Tool for describing language concepts: syntax,
semantics, scope, typing
Executable PL Theory
Impacts of Languages & Programs
Practical Benefits of Studying
Programming Languages
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
Become more productive
Genealogy of Common Languages
Popularity
RedMonk has a language ranking scheme that combines pull requests on GitHub and
questions on StackOverflow. June 2021 .
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
C
Web Software
Eclectic collection of languages: markup (e.g., HTML), scripting (e.g., PHP),
general-purpose (e.g., Java)
Language Evaluation Criteria
Readability: the ease with which
programs can be read and understood
Writability: the ease with which a
language can be used to create programs
Reliability: conformance to
specifications (i.e., performs to its
specifications)
Evaluation Criteria: Readability
Overall simplicity
A manageable set of features and constructs
Minimum feature multiplicity
Minimum operator overloading
i = i +1
i += 1
i++
++i
Syntax considerations
Identifier forms: flexible composition
Special words and methods of forming compound statements
Form and meaning: self-descriptive constructs, meaningful keywords
Evaluation Criteria: Writability
Simplicity and orthogonality
Few constructs, a small number of primitives, a small set of rules
for combining them
Expressivity
A set of relatively convenient ways of specifying operations
Strength and number of operators and predefined functions
Evaluation Criteria: Reliability
Type checking
Testing for type errors
Exception handling
Intercept run-time errors and take corrective measures
Aliasing
Presence of two or more distinct referencing methods for the same memory
location
Readability and writability
A language that does not support “natural” ways of expressing an algorithm
will require the use of “unnatural” approaches, and hence reduced reliability
Evaluation Criteria: Cost
Training programmers to use the language
Writing programs (closeness to particular
applications)
Executing programs
Reliability: poor reliability leads to high
costs
Maintaining programs
Evaluation Criteria: Others
Portability
The ease with which programs can be moved
from one implementation to another
Generality
The applicability to a wide range of applications
Well-definedness
The completeness and precision of the language’s
official definition
Influences on Language Design
Computer Architecture
Languages are developed around the prevalent
computer architecture, known as the von
Neumann architecture
Program Design Methodologies
New software development methodologies (e.g.,
object-oriented software development) led to
new programming paradigms and by extension,
new programming languages
Computer Architecture Influence
Well-known computer architecture: Von Neumann
Imperative languages, most dominant, because of von
Neumann computers
Data and programs stored in 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
The von Neumann Architecture
The von Neumann Architecture
Fetch-execute-cycle (on a von Neumann
architecture computer)
initialize the program counter
repeat forever
fetch the instruction pointed by the counter
increment the counter
decode the instruction
execute the instruction
end repeat
Language Paradigms
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: Haskell, LISP, Scheme, ML, F#
Logic
Rule-based (rules are specified in no particular order)
Example: Prolog
Markup/programming hybrid
Markup languages extended to support some programming
Examples: JSTL, XML, HTML, LaTex
Language Design Trade-Offs
Reliability vs. cost of execution
Example: Java demands all references to array elements be checked
for proper indexing, which leads to increased execution costs
Pure Interpretation
Programs are interpreted by another program known as an
interpreter
Use: Small programs or when efficiency is not an issue
Environment of development
Computers were small and unreliable
Applications were scientific
No programming methodology or tools
Machine efficiency was the most important concern
Fortran I Overview
First implemented version of Fortran
Names could have up to six characters
Post-test counting loop (DO)
Formatted I/O
User-defined subprograms
Three-way selection statement (arithmetic IF)
No data typing statements
Fortran 77
Became the new standard in 1978
Character string handling
Logical loop control statement
IF-THEN-ELSE statement
Fortran 90
Most significant changes from Fortran 77
Modules
Dynamic arrays
Pointers
Recursion
CASE statement
Parameter type checking
Latest versions of Fortran
Fortran 95 – relatively minor additions, plus
some deletions
Fortran 2003 – support for OOP, procedure
pointers, interoperability with C
Fortran 2008 – blocks for local scopes, co-
arrays, Do Concurrent
Fortran Evaluation
Highly optimizing compilers (all versions
before 90)
Types and storage of all variables are fixed before
run time
Dramatically changed forever the way
computers are used
Functional Programming: Lisp
LISt Processing language
Designed at MIT by McCarthy
AI research needed a language to
Process data in lists (rather than arrays)
Symbolic computation (rather than numeric)
Only two data types: atoms and lists
Syntax is based on lambda calculus
Lisp Evaluation
Pioneered functional programming
No need for variables or assignment
Control via recursion and conditional expressions
Still the dominant language for AI
Common Lisp and Scheme are contemporary
dialects of Lisp
ML, Haskell, and F# are also functional
programming languages, but use very
different syntax
Scheme
Environment of development
UNIVAC was beginning to use FLOW-MATIC
USAF was beginning to use AIMACO
IBM was developing COMTRAN
COBOL Historical Background
Based on FLOW-MATIC
FLOW-MATIC features
Names up to 12 characters, with embedded
hyphens
English names for arithmetic operators (no
arithmetic expressions)
Data and code were completely separate
The first word in every statement was a verb
COBOL Design Process
First Design Meeting (Pentagon) - May 1959
Design goals
Must look like simple English
Must be easy to use, even if that means it will be less powerful
Must broaden the base of computer users
Must not be biased by current compiler problems
Design committee members were all from computer
manufacturers and DoD branches
Design Problems: arithmetic expressions? subscripts? Fights
among manufacturers
COBOL Evaluation
Contributions
First macro facility in a high-level language
Hierarchical data structures (records)
Nested selection statements
Long names (up to 30 characters), with hyphens
Separate data division
COBOL: DoD Influence
First language required by DoD
would have failed without DoD
Still the most widely used business
applications language
SNOBOL
Designed as a string manipulation language at
Bell Labs by Farber, Griswold, and Polensky in
1964
Powerful operators for string pattern
matching
Slower than alternative languages (and thus
no longer used for writing editors)
Still used for certain text processing tasks
The Beginning of Data Abstraction: SIMULA 67
Comments
Less usage than ALGOL 60
Had strong influence on subsequent languages,
especially Pascal, C, and Ada
Pascal - 1971
Developed by Wirth (a former member of the
ALGOL 68 committee)
Designed for teaching structured
programming
Small, simple, nothing really new
Largest impact was on teaching programming
From mid-1970s until the late 1990s, it was the
most widely used language for teaching
programming
C - 1972
Designed for systems programming (at Bell
Labs by Dennis Richie)
Evolved primarily from BCLP and B, but also
ALGOL 68
Powerful set of operators, but poor type
checking
Initially spread through UNIX
Though designed as a systems language, it has
been used in many application areas
Programming Based on Logic: Prolog
Developed, by Comerauer and Roussel (University of
Aix-Marseille), with help from Kowalski ( University
of Edinburgh)
Based on formal logic
Non-procedural
Can be summarized as being an intelligent database
system that uses an inferencing process to infer the
truth of given queries
Comparatively inefficient
Few application areas
History’s Largest Design Effort: Ada
Huge design effort, involving hundreds of
people, much money, and about eight
years
Sequence of requirements (1975-1978)
(Strawman, Woodman, Tinman, Ironman,
Steelman)
Named Ada after Augusta Ada Byron, the
first programmer
Ada Evaluation
Contributions
Packages - support for data abstraction
Exception handling - elaborate
Generic program units
Concurrency - through the tasking model
Comments
Competitive design
Included all that was then known about software engineering and
language design
First compilers were very difficult; the first really usable compiler came
nearly five years after the language design was completed
Ada 95
Ada 95 (began in 1988)
Support for OOP through type derivation
Better control mechanisms for shared data
New concurrency features
More flexible libraries
Ada 2005
Interfaces and synchronizing interfaces
Popularity suffered because the DoD no
longer requires its use but also because of
popularity of C++
Object-Oriented Programming: Smalltalk