Title: CS5205: Foundation in Programming Languages Lecture 0 : Overview
1CS5205 Foundation in Programming Languages
Lecture 0 Overview
Language Foundation, Extensions and Reasoning
Lecturer Chin Wei Ngan Email
chinwn_at_comp.nus.edu.sg Office COM2 4-32
2 Course Objectives
- graduate-level course with foundation focus
- languages as tools for programming -
foundations for reasoning about programs -
explore various language innovations
3 Course Outline
- Lecture Topics (13 weeks)
- Advanced Typed Language (Haskell)
- http//www.haskell.org
- Lambda Calculus (Core Language)
- Interpreters
- Untyped Scripting Language (Python)
- http//www.python.org
- Type System for Lightweight Analysis
- http//www.cs.cmu.edu/rwh/plbook/book.pdf
- Semantics
4 Administrative Matters
- mainly IVLE - Reading Materials (mostly
online) www.haskell.org Robert Harper
Foundations of Practical Programming Languages.
Free PL books http//freeprogrammi
ngbooks.com - Lectures Assignments Paper
Reading Exam - Assignment/Project (35) -
Paper Reading (10) - Quiz (10) - Exam (45)
5 Paper Presentation
- Focus on Language Innovation/Application
- Select A Paper (Week 2)
- Give Presentation (Week 4/5)
- Possible Topics
- Concurrent and MultiCore Programming
- Software Transaction Memory
- GUI Programming
- Testing with QuickCheck
- IDE for Haskell
- SELinks (OCaml)
- etc
- A List of Papers/Conferences will be given next
week.
6 Assignments/Project (35)
- Small Exercises
- Mini-Project
- List of possible projects (Week 5)
- Your own project
- A useful tool
- Use advanced languages, such as
- Haskell, Ocaml, F, Python, Boo, etc
- Evaluation
- (i) presentation/demo
- (ii) draft report/paper
7 Why Study Foundations of PL?
- Language used to organize programming thoughts.
- Language can describe and organize computation.
- Language features affect how ideas are expressed.
- Foundation needed to support the design of good
language features
8 Benefits of Good PL Features
- Readability
- Extensible Software.
- Modifiability.
- Reusability.
- Correctness.
9Benefits of Studying Foundations of PL
- Design new languages for your work/research?
- Inside any successful software system is a PL
- Emacs Elisp
- Word, PPT VBScript
- Quake QuakeC
- Facebook FBML, FBJS
- Twitter Ruby on Rails/Scala
- Also Latex, XML, SQL, PS/PDF
10Benefits of Studying Foundations of PL
- Different language paradigm can support different
approaches to a given problem. - Can choose a solution that is best (or good
enough) for the given problem. - PL is the primary tool of choice for programmers.
If properly selected, it can amplify your
programming capability. - Era of domain-specific programming languages.
11Many Dimensions of PL
- Syntax verbose vs succint. prefix vs distfix.
- Computational model functional, imperative, OO
or constraint-based. - Memory Model explicit deallocation, garbage
collection or region-based. - Typing static vs dynamic typing strong vs weak
typing. - Execution Model compiled (C/C), interpreted
(Perl), hybrid (Java). - Scoping static vs dynamic scoping.
12 Advanced Language - Haskell
- Strongly-typed with polymorphism
- Higher-order functions
- Pure Lazy Language.
- Algebraic data types records
- Exceptions
- Type classes, Monads, Arrows, etc
- Advantages concise, abstract, reuse
- Why use Haskell ?
13 Some Applications of FP/Haskell
- Hoogle search in code library
- Darcs distributed version control
- Programming user interface with arrows..
- How to program multicore?
- map/reduce and Cloud computing
- Bioinformatics
- Cryptography
14 Example - Haskell Program
- Apply a function to every element of a list.
- data List a Nil Cons a (List a)
- map f Nil Nil
- map f (Cons x xs) Cons (f x) (map f xs)
a type variable
map sqr(Cons 1 (Cons 2 (Cons 3 Nil))) gt
(Cons 1 (Cons 4 (Cons 9 Nil)))
15 Example - Haskell Program
- Built-in List Type with syntactic sugar
- data a aa
- map (a ? b) ? a ? b
- map f
- map f (xxs) (f x)(map f xs)
map sqr 1(2(3)) gt 1(4(9)) map sqr
1,2,3 gt 1,4,9
16Paradigm Functional Expression
- Problem sum the square of a list of numbers
- sumsq 1,2,3,4 11 22 33 44.
- Problem sum the square of a list of numbers
- sumsq 0
- sumsq (xxs) (sqr x) (sumsq xs)
17Paradigm Imperative Loop
- Problem sum the square of a list of numbers
- sumsq 1,2,3,4 11 22 33 44.
- In F (Ocaml dialect)
- sumsq Int Int
- sumsq xs let s ref 0 in
- for x in xs
- s !s x
- s
18Paradigm Function-Level Composition
sum 0 sum (xxs) x (sum xs)
square xs map sqr xs