Functional Programming

Download Report

Transcript Functional Programming

PROGRAMMING PARADIGMS
Jason Atkin and Graham Hutton
University of Nottingham
Exercise
Write down all the
languages you have
written a program in.
1
Background
In programming and algorithms, you learned the
basics of imperative programming in C:
Variables and assignments;
Basic control structures;
Basic data structures;
Functions and parameters;
Pointers and memory management.
2
Background
In this module, you’ll learn the basics of:
Object-oriented
programming
in Java
and
Functional
programming
in Haskell
3
Lectures
Tuesdays, 12.00 – 13.00, LT2 (Exchange);
Thursdays, 12.00 – 13.00, LT2 (Exchange);
Fridays, 16.00 – 17.00, C33 (Exchange).
Labs
Tuesdays, 14.00 – 16.00, A32 (Comp Sci).
4
Course Materials
Everything you need is available on moodle:
See: tinyurl.com/G51PGP
5
Textbook
In addition to our course materials, there is also a
recommended textbook for each paradigm:
6
Assessment
A series of 1-page exercise sheets (10%);
Two programming courseworks (15%);
One 2.5-hour written examination (75%).
The exercise sheets and courseworks
will mainly be assessed in the labs.
7
Functional Topics
Basic Concepts
Going Further
Types and classes
Interactive programming
Defining functions
Declaring new types
List comprehensions
The countdown problem
Recursive functions
Lazy evaluation
Higher-order functions
Functional style
Underlying principles are not specific to Haskell
8
Object-Oriented Topics
C code
Move to C++
C with classes (?)
Java
Things you
already know
Member functions,
statics, encapsulation
Hello World!
Text and GUI
OO Design
Inheritance,
Virtual functions
Simple Java
concurrency
Decomposition
Specialisation,
polymorphism
Threads,
synchronized,
volatile
Java UI
Common classes
Useful OO design principles
and design patterns
Swing, Collection
How to make a ‘good’ design
(also: ideal vs fast in Java)
Underlying
principles are not
specific to Java
Object-Oriented Demo