Slide 41
Slide 41 text
Functional Programming
Transforming Data
Using Expressions (Functions)
Without Side Effects
Immutable Data
Pure Functions
Higher-Order Functions
From “Research Topics in Functional Programming” ed. D. Turner, Addison-Wesley, 1990, pp 17–42.
1
Why
Functional Programming
Matters
John Hughes
The University, Glasgow
Abstract
As software becomes more and more complex, it is more and more
important to structure it well. Well-structured software is easy to write
and to debug, and provides a collection of modules that can be reused
to reduce future programming costs. In this paper we show that two fea-
tures of functional languages in particular, higher-order functions and lazy
evaluation, can contribute significantly to modularity. As examples, we
manipulate lists and trees, program several numerical algorithms, and im-
plement the alpha-beta heuristic (an algorithm from Artificial Intelligence
used in game-playing programs). We conclude that since modularity is the
key to successful programming, functional programming o↵ers important
advantages for software development.
1 Introduction
This paper is an attempt to demonstrate to the larger community of (non-
functional) programmers the significance of functional programming, and also
to help functional programmers exploit its advantages to the full by making it
clear what those advantages are.
Functional programming is so called because its fundamental operation is
the application of functions to arguments. A main program itself is written as
a function that receives the program’s input as its argument and delivers the
program’s output as its result. Typically the main function is defined in terms of
other functions, which in turn are defined in terms of still more functions, until
at the bottom level the functions are language primitives. All of these functions
are much like ordinary mathematical functions, and in this paper they will be
1
An earlier version of this paper appeared in the The Computer Journal, 32(2):98–107,
April 1989. Copyright belongs to The British Computer Society, who grant permission to
copy for educational purposes only without fee provided the copies are not made for direct
commercial advantage and this BCS copyright notice appears.
https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf