SI413 Scheme Lab 0: Functional Programming & Scheme

Properties that define functional languages
The big difference between the functional programming paradigm and the the other pradigms we've seen - structured/procedural and object oriented - is that functional programming seeks to take references to time out of the program. That probably sounds wierd. Time permeates our programs, because any idea of execution order automatically brings time into the picture. When you write
int x = 0;
x = 3;
x = x + 1;
you are stating that "int x = 0" should be performed before "x = 3" which should come before "x = x + 1". Programs like this proceed by evaluating each statement in turn, and each evaluation may have side effects, meaning that the state of the program (roughly the values of its variables) changes. Functional programming tries to remove this dependency on side effects, and to remove these explicit references to time (i.e. ordering of statements). After we get a bit more comfortable with functional programming in a specific language - Scheme is the language we'll use - we'll try to talk about what benefits there are in the functional approach.

Here are the basic properties that define a language as being functional:

Additionally, there are several properties that functional languages traditionally have, mostly because realizing the above properties would be difficult without them.

We often call functional programs "declarative" instead of "imperative". In declarative programming we describe the object to be computed. In imperative we give a sequence of commands - the actions that accomplish the computation. In other words, declarative programming describes the result of the computation, while imperative describes the computation itself.

Christopher W Brown
Last modified: Wed Aug 27 09:04:21 EDT 2008