Programming
Paradigms
CSI2120
Jochen Lang
EECS, University of Ottawa
Canada
Course Syllabus
• Complete syllabus at
http://www.eecs.uottawa.ca/~jlang/csi2120.html
• Course notes, laboratory exercises and assignments will be
made available through Virtual Campus.
• Labs in six sessions plus one tutorial
– Make sure to attend your session
– Academic regulations: “Attendance at courses of instruction,
laboratory periods and discussion groups is mandatory. To
be admitted to the final examination in a subject, a student
must attend a minimum of 80% of classes”
CSI2120: Programming Paradigms
Summary of Topics
• An introduction to programming paradigms
• Object-oriented paradigm: Self-review with Java
• Imperative and concurrent programming paradigm: Go.
• Logic paradigm: Prolog. Syntax and lists, satisfying goals
and backtracking, arithmetic, structures, and recursion,
input/output, trees and databases, the cut operator, built-
ins, grammars and parsing
• Functional paradigm: Scheme. Simple expressions,
evaluation, arithmetic, lists, conditional expressions, simple
recursion, I/O, assignment, vectors, trees, functions as first-
class data values
CSI2120: Programming Paradigms
Student Evaluation
• Midterm exam, March 3rd (in class) 26 marks
• Final exam 38 marks
• 4 Assignments 30 marks
• Lab Quizzes 6 marks (8 Quizzes in total, best 6 count)
– You must be present in the lab to receive a lab quiz mark.
*) If the student's grade in the exam component (midterm and final) is less than
50% then the student's marks for the assignments will be zero. The mark will
then be (Midterm + Final) / 64.
**) A student who has an official medical certificate (from the University Health
Services) for the absence on the day of the midterm will have the final exam
mark scaled up accordingly. In those cases the student will not receive 25% of
the marks before the drop-date.
CSI2120: Programming Paradigms
Assignments and Academic Fraud
• Assignments
– There will be four programming assignments which must be
submitted via Virtual Campus. No other form of submission
will be accepted.
– Late hand-ins will NOT be accepted.
– All assignments and labs will be posted on Virtual Campus.
• Academic Fraud and Plagiarism
– Any copying in an assignment will result in an automatic zero
for the assignment (we will check with a software tool).
– For any plagiarism or fraud possible university sanctions still
apply.
CSI2120: Programming Paradigms
Recommended Textbooks
• Allen B. Tucker and Robert E. Noonan, Programming
Languages: Principles and Paradigms, McGraw Hill, 2nd ed.,
2007.
• Maurizio Gabbrielli and Simone Martini, Programming
Languages: Principles and Paradigms, Springer, 2010.
• William F. Clocksin and Christopher S. Mellish, Programming in
Prolog, Springer, 5th ed., 2003.
• Patrick Blackburn, Johan Bos, and Kristina Striegnitz,
Learn Prolog Now!, College Publications, 2006. on-line .
• R. Kent Dybvig, The Scheme Programming Language, MIT
Press, 4th ed., 2009. on-line.
• Ivo Balbaert, The Way To Go: A Thorough Introduction To The
Go Programming Language, iUniverse, 2012.
CSI2120: Programming Paradigms
On-Line Resources
• Go concurrent programming language. Open source with
binary distributions for Linux, MacOS and Windows.
• SWI Prolog Open source prolog compiler available for all
major platforms.
• MIT/GNU Scheme Full scheme system for Linux, MacOS
and Windows but the dedicated emacs editor is broken on
Windows. Use racket instead.
• Racket Racket is an extension of Lisp and Scheme with a
decent IDE.
CSI2120: Programming Paradigms
Student Participation
• Mandatory attendance of and participation in lectures, labs
and tutorials
• Group work and interactive feedback
– Using web clicker.
– You must register for an account (details on Virtual Campus)
– No marks but there to help with learning and retention
– Also used to determine if you complied with the Faculty of
Engineering rule of minimum attendance of 80% of lectures.
• First discussion in groups of 4
– What is a programming paradigm?
CSI2120: Programming Paradigms
Paradigms and Programming
• Paradigm:
“a theory or a group of ideas about how something should be
done, made, or thought about" (Merriam-Webster, accessed
Jan, 2014).
• Computer Programming:
" Computer programming … is a process that leads from an
original formulation of a computing problem to executable
computer programs. (Wikipedia, accessed Jan, 2018).
CSI2120: Programming Paradigms
More Comprehensive View of
Programming
• Programming
“… involves activities such as analysis, developing
understanding, generating algorithms, verification of
requirements of algorithms including their correctness and
resources consumption, and implementation (commonly
referred to as coding) of algorithms in a target programming
language. (Wikipedia, accessed Jan, 2018).
CSI2120: Programming Paradigms
Programming Language
• A Programming Language
" is a formal language that specifies a set of instructions that
can be used to produce various kinds of output. Programming
languages generally consist of instructions for a computer.
Programming languages can be used to create programs that
implement specific algorithms. “(Wikipedia, accessed Jan,
2018).
CSI2120: Programming Paradigms
Programmer (Software Engineer)
• A Programmer,
– computer programmer, developer, coder, or software
engineer is a person who writes computer software. "
(Wikipedia, accessed Jan, 2018).
Source: German Bundesarchiv
Source: US Army
CSI2120: Programming Paradigms
Best Programming Language
Implementing the Best Paradigm
• There is no single best paradigm for all applications.
• Problems can be solved based on one or the other
paradigm.
• Many Paradigms exist:
– object-oriented programming,
– logic programming,
– functional programming,
– imperative programming,
– scripting or dynamic programming,
– declarative programming,
– aspect-oriented programming,
– concurrent programming, and others …
CSI2120: Programming Paradigms
Familiar Programming Paradigms
• Imperative paradigm
– views program as a sequence of commands which change
the state of the program
– Prominent example language: C
• Object-oriented paradigm
– Solution is described by a set of classes providing
encapsulation.
– Class relationships include inheritance and message
passing.
– Polymorphism
– Prominent example language: Java
CSI2120: Programming Paradigms
Logic Programming Paradigm
• Describes the facts and rules about a problem and the
desired program outcome and not the individual steps of
the solution.
• Logic programming paradigm
– views programs as a set of constraints,
– requires programs to produce different (or even all)
solutions,
– and considers programs non-deterministic
• Prominent example language covered in this course
– Prolog
CSI2120: Programming Paradigms
Functional Programming Paradigm
• Functional programming is inspired by mathematical
functions as a mapping from an input domain to an output
range.
• Functional paradigm
– compose different functions to achieve a solution
– uses often recursive solutions
– functions without side effects
• Prominent example language covered in this course:
– Scheme
CSI2120: Programming Paradigms
Functional Programming
• The following definitions can be found on Bill Kinnersley
language list site:
– “Functional Language: In the narrow sense, a functional
language is one that operates by use of higher-order
functions, building operators that manipulate functions
directly without ever appearing to manipulate data.”
– “Applicative Language: A language that operates by
application of functions to values, with no side effects. A
functional language in the broad sense.”
CSI2120: Programming Paradigms
Why study different paradigms?
• Understanding programming at the abstract level will lead
to a better overall understanding of programming
• Different problems, different challenges benefit from
different approaches
• Knowing many languages helps to learn new languages
• To be able to chose the best paradigm and language for a
new task
CSI2120: Programming Paradigms
imperative
Some History
functional
object-oriented
logic
concurrency
CSI2120: Programming Paradigms
Influential Programming Languages
(until 1990, according to Bill Kinnersley)
1957 FORTRAN 1977 OPS5 1988 Oberon
1958 ALGOL 1978 CSP 1989 HTML
1960 LISP 1978 FP 1990 Haskell
1960 COBOL 1980 dBASE II
1962 APL 1983 Smalltalk-80
1962 SIMULA 1983 Ada
1964 BASIC 1983 Parlog
1964 PL/I 1984 Standard ML
1966 ISWIM 1986 C++
1970 Prolog 1986 CLP(R)
1972 C 1986 Eiffel
1975 Pascal 1988 CLOS
1975 Scheme 1988 Mathematica
CSI2120: Programming Paradigms
Alphabetical High-level Language
Overview
• ADA: created at Honeywell Bell for the American DoD,
supports concurrency, synchronous message passing
• Algol: close to mathematical notation, machine-independent
description of algorithms
• ANSI C: standardized C increasing portability and prototyping
• APL: K. Iverson, mathematical programming (matrices,
vectors) but difficult to read
• B: K. Thompson, simple compilation, original language for
UNIX
• BASIC: J. Kemeny, T. Kurtz, Simple language, made
programming widely accessible to engineering
• C: B.W. Kernigham, D.M. Ritchie, system programming, non-
restrictive language, close to machine instructions
• C++: B. Stroustrup, object-oriented C, hybrid language,
abstract data types, templates.
CSI2120: Programming Paradigms
Alphabetical High-level Language
Overview
• C#: hybrid between C++ and Java, used for Microsoft platform .Net
• COBOL: COmmon Business-Oriented Language (created by Grace
Hopper), business, finance, management; verbose to ease general
understanding.
• COMMONLISP: LISP dialect that unifies the different LISP dialects,
tentative standard.
• CPL: North American equivalent of Algol, but closer to machine
instructions.
• Eiffel: B. Meyer, object-oriented language, created to support “design by
contract”
• FORTRAN: created by J. Backus for the IBM704, effective coding.
• Go: Created by Robert Griesemer, Rob Pike, and Ken Thompson at
Google. Compiled and statically typed language with garbage collection
and concurrent programming features.
• Java: designed as a “better” C++ with closer adherence to OO paradigm;
created by J. Gosling at Sun.
• JavaScript:
• LISP: J. McCarthy, artificial intelligence, theorem proving, (emacs); based
on a single data structure, lists.
CSI2120: Programming Paradigms
Alphabetical High-level Language
Overview
• Miranda: D. Turner: first commercial purely functional language, lazy
evaluation.
• ML: R. Milner, strongly typed, functional language with inference
• Pascal: functional, originally created by N. Wirth for teaching.
• PL/I: IBM and Share 3by3, universal language, originally developed for
mainframe computers.
• Prolog: Created by Alain Colmerauer with Philippe Roussel, mainly expert
systems, artificial intelligence and data bases, now ISO standard.
• Python: Created by Guido van Rossum (1991), interpreted, dynamic type
system and automatic memory management. Multiple programming
paradigms.
• R: For statistical data analysis with graphics. Simple, effective and
extensible programming language.
• Scheme: MIT, LISP dialect, originally created for teaching.
• Simula: K. Nygaard, O.J. Dahl, simulation, introduced the notion of a class.
• SmallTalk: A. Kay, first object-oriented language, objects, message
passing. Designed for graphical environments (windows).
• Swift: Apple’s successor to Objective-C. Multi-paradigm.
CSI2120: Programming Paradigms
Conclusion
• Why are there so many similar languages?
• Isn’t Java (or C++, or your favorite) a
programming language for everything?
Analyze new programming paradigms
Learn new languages
Get an overview of other paradigms.
CSI2120: Programming Paradigms