Functional programming: an alternative paradigm

 

Willamette Computer Science
ACM Student Chapter Lecture

Functional programming: an alternative paradigm
bullet Declarative versus imperative style
an emphasis on expressions (with values) rather than statements/commands (which have effects on the state); plus, the use of higher-order functions

Control bar


















































 

Willamette Computer Science
ACM Student Chapter Lecture

Functional programming: an alternative paradigm
bullet Declarative versus imperative style
bullet Pure versus "impure" functional semantics
some functional languages (Scheme, ML) allow side-effects, but still encourage a style which depends on them as little as possible

Control bar


















































 

Willamette Computer Science
ACM Student Chapter Lecture

Functional programming: an alternative paradigm
bullet Declarative versus imperative style
bullet Pure versus "impure" functional semantics
bullet Algebraic versus prefix
in Scheme (descended from LISP), syntax is uniform and simplistic, so that programs can be encoded as data

Control bar


















































 

Willamette Computer Science
ACM Student Chapter Lecture

Functional programming: an alternative paradigm
bullet Declarative versus imperative style
bullet Pure versus "impure" functional semantics
bullet Algebraic versus prefix
bullet Higher-order functions
functions which take functions as arguments and return functions as results

Control bar


















































 

Willamette Computer Science
ACM Student Chapter Lecture

Functional programming: an alternative paradigm
bullet Declarative versus imperative style
bullet Pure versus "impure" functional semantics
bullet Algebraic versus prefix
bullet Higher-order functions
bullet Static versus dynamic typing
static typing provides security (compile-time error checking), but limits flexibility (e.g., no reflection/reification as in Scheme)

Control bar


















































 

Willamette Computer Science
ACM Student Chapter Lecture

Functional programming: an alternative paradigm
bullet Declarative versus imperative style
bullet Pure versus "impure" functional semantics
bullet Algebraic versus prefix
bullet Higher-order functions
bullet Static versus dynamic typing
bullet Polymorphic types
we can allow more flexibility by allowing types themselves to vary parametrically

Control bar


















































 

Willamette Computer Science
ACM Student Chapter Lecture

Functional programming: an alternative paradigm
bullet Declarative versus imperative style
bullet Pure versus "impure" functional semantics
bullet Algebraic versus prefix
bullet Higher-order functions
bullet Static versus dynamic typing
bullet Polymorphic types
bullet Algebraic types and patterns
like a context-free grammar, but labelled explicitly to indicate alternative forms chosen

Control bar


















































 

Willamette Computer Science
ACM Student Chapter Lecture

Functional programming: an alternative paradigm
bullet Declarative versus imperative style
bullet Pure versus "impure" functional semantics
bullet Algebraic versus prefix
bullet Higher-order functions
bullet Static versus dynamic typing
bullet Polymorphic types
bullet Algebraic types and patterns
bullet Monads and continuations for effects and control
using some subtle semantic constructs, we can recover at least the illusion of side-effects

Control bar