Programming Languages:Introduction and Overview
borning@cs.washington.edu
University of Washington, Seattle
Course topics
- Miranda (a pure functional language)
- CLP(R) (constraint logic programming)
- General programming language concepts
Required work
- Moderate sized programs in Scheme, Perl, Miranda, CLP(R)
- Course project (implementation and paper) on a language of your choosing (other than Java)
Organizational
- when in doubt, check the class web page
- please sign up for the cse341 mailing list:mail to majordomo@cs.washington.eduin body of message: subscribe cse341
History of Programming Languages
History ofProgramming Languages
History ofProgramming Languages
History ofProgramming Languages
What is a programming language for?
- Communicating among programmers?
- Expressing high level designs?
- Tool for experimentation?Languages are for both humansand computers!
Effective Use of Programming Languages
“Learning the fundamentals of a programming language is one thing: learning how to design and write effective programs in that language is something else entirely.”
Why do we care?
- Whorf-Sapir hypothesis for natural languages
- Tradeoffs among languages
- reusability, maintainability
- performance, robustness
- flexibility, dynamicism
- libraries
- aesthetics (i.e., “fun-ness”)
Language classification
- Imperative (Fortran, Algol, C)
- Functional (“Pure” Scheme/Lisp, Miranda)
- Logic/Constraint (Prolog, CLP(R))
- Object-oriented (Smalltalk, Java, C++)
- Languages may encourage a certain style even if they do not force it on you!
Complexity vs. Expressiveness
What’s wrong with imperative?
Assignments makereasoning difficult!
Imperative programming
- Nice for execution, translation… BUT:
- Harder for humans tounderstand and reason about
- Harder for sophisticated software tools
- Proving correctness is harder
- Restricts code motion, limits optimizer(especially important for parallel machines)
The Functional Approach
- Eliminates assignments (side effects),focus on expressions
- Tell what to compute, not how(leave order of computation unspecified)
- Higher level programming model—leave more details to machine
Scheme
- Very simple syntactically
- Still an imperative language, though
- But encourages a functional style
- Can write in a purely functional subset
- we will do this in the beginning
- still has assignments
Miranda (and Haskell)
- Pure functional languages
- “Lazy” evaluationSample Miranda function definition:factorial n = product [1..n]
Constraint Logic Programming
- Metaphor: theorem proving and equation solving
- Variables are like those in mathematicsSample CLP(R) rule:centigrade_fahrenheit(C,F) :- 1.8*C=F-32.Use:?- centigrade_fahrenheit(X,212).