Functional Programming and Procedural Programming

An error occurred trying to load this video.

Try refreshing the page, or contact customer support.

Coming up next: Using Pseudocode to Map Code

You're on a roll. Keep up the good work!

Take Quiz Watch Next Lesson
Your next lesson will play in 10 seconds
  • 0:06 Programming
  • 0:41 Procedural
  • 2:02 Functional
  • 2:54 Example
  • 6:12 Lesson Summary
Save Save Save

Want to watch this again later?

Log in or sign up to add this lesson to a Custom Course.

Log in or Sign up

Speed Speed Audio mode
Lesson Transcript
Instructor: Paul Zandbergen

Paul is a GIS professor at Vancouver Island U, has a PhD from U of British Columbia, and has taught stats and programming for 15 years.

There are several alternative approaches to the programming process, including procedural programming and functional programming. Learn about the differences between these two approaches.

Approaches to Programming

Programming is a creative process carried out by programmers to instruct a computer on how to complete a task. A program is a set of instructions that tells a computer what to do in order to come up with a solution to a particular problem. There are a number of alternative approaches to the programming process. Two very different approaches are procedural programming and functional programming. Each of these two approaches will be described in some detail.

Procedural Programming

Procedural programming uses a list of instructions to tell the computer what to do step by step. Procedural programming relies on procedures, also known as routines. A procedure contains a series of computational steps to be carried out. Procedural programming is also referred to as imperative or structured programming.

Procedural programming is intuitive in the sense that it is very similar to how you would expect a program to work. If you want a computer to do something, you should provide step-by-step instructions on how to do it. Many of the early programming languages are all procedural. Examples of procedural languages include Fortran, COBOL and C, which have been around since the 1960s and 70s.

A common technique in procedural programming is to repeat a series of steps using iteration. This means you write a series of steps and then tell the program to repeat these steps a certain number of times. This makes it possible to automate repetitive tasks.

Functional Programming

Functional programming is an approach to problem solving that treats every computation as a mathematical function. The outputs of a function rely only on the values that are provided as input to the function and don't depend on a particular series of steps that precede the function.

Functional programming relies heavily on recursion. A recursive function can repeat itself until a particular condition is reached. This is similar to the use of iteration in procedural programming, but now applied to a single function as opposed to a series of steps. Examples of functional programming languages include Erlang, Haskell, Lisp and Scala.

An Example for Comparison

Programming approaches can sound a little bit abstract, so let's look at an example. We'll use the same task and look at how each approach would carry out this task. The task is to calculate Fibonacci numbers. By definition, the first two numbers in a Fibonacci sequence are 0 and 1, and the following numbers are always the sum of the previous two. In mathematical terms, here is what the sequence looks like:

Fibonacci sequence equation

The result is a sequence that looks like this:

0  1  1  2  3  5  8  13  21  34  55  89

Fibonacci numbers are used for a wide range of applications, from describing patterns in nature to the structures of galaxies. So what is the Fibonacci number for n = 100? This is exactly the kind of task you want a computer program to do for you. Don't worry too much about understanding the math - the point is that we want a computer program to do the calculations.

In procedural programming, here is what the code would look like to get the 'nth' number in the Fibonacci sequence:

first = 0
second = 1
for i in range(n-1):
fib = first + second
first = second
second = fib
print fib

To unlock this lesson you must be a Member.
Create your account

Register to view this lesson

Are you a student or a teacher?

Unlock Your Education

See for yourself why 30 million people use

Become a member and start learning now.
Become a Member  Back
What teachers are saying about
Try it risk-free for 30 days

Earning College Credit

Did you know… We have over 200 college courses that prepare you to earn credit by exam that is accepted by over 1,500 colleges and universities. You can test out of the first two years of college and save thousands off your degree. Anyone can earn credit-by-exam regardless of age or education level.

To learn more, visit our Earning Credit Page

Transferring credit to the school of your choice

Not sure what college you want to attend yet? has thousands of articles about every imaginable degree, area of study and career path that can help you find the school that's right for you.

Create an account to start this course today
Try it risk-free for 30 days!
Create an account