Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 18

Advanced Programming Language

Concepts
CT006-3-3-APLC and Version VC1

Functional Programming (FP)


Definition and Origin
Topic & Structure of the lesson

• Functional Programming Language


– Definition
– Origin
– Examples of functional programming
language

CT006-3-3-Advanced Programming Language Concepts Functional Programming: Definition and Origin Slide 2 of 18
Learning Outcomes

At the end of the lecture you should be


able to
• Define functional programming paradigm
• Explain functional programming from a
historical point of view

CT006-3-3-Advanced Programming Language Concepts Functional Programming: Definition and Origin Slide 3 of 18
Key Terms you must be able to use

If you have mastered this topic, you should be able to use


the following terms correctly in your lab assignments and
exams:
• Functional Programming
• Haskell
• Hugs

CT006-3-3-Advanced Programming Language Concepts Functional Programming: Definition and Origin Slide 4 of 18
Programming Paradigm

• A programming paradigm is a paradigmatic style of


programming (compare with a methodology, which is a
paradigmatic style of doing software engineering).
• A programming paradigm provides (and determines) the
view that the programmer has of the execution of the
program.
• For instance, in object-oriented programming,
programmers can think of a program as a collection of
interacting objects, while in functional programming a
program can be thought of as a sequence of stateless
function evaluations.

CT006-3-3-Advanced Programming Language Concepts Functional Programming: Definition and Origin Slide 5 of 18
Functional Programming Paradigm

• Functional programming is a programming paradigm that


conceives computation as the evaluation of
mathematical functions and avoids state and mutable
data.
• Functional programming emphasizes the application of
functions, in contrast with imperative programming,
which emphasizes changes in state and the execution of
sequential commands.
• Functional programming is a style of programming which
consists of functions applied to arguments, for example
the elements of a list, and to other functions.

CT006-3-3-Advanced Programming Language Concepts Functional Programming: Definition and Origin Slide 6 of 18
Functional Programming

• Surprisingly, you can write very sophisticated


programs quite easily.
• Functional programming allows us to deal with
lists and data structures efficiently, by
manipulating them as wholes, rather than by
taking each element and manipulating it
separately as procedural programming would.
• Haskell is a functional language.
• A functional program is a single expression,
which is executed by evaluating the expression.

CT006-3-3-Advanced Programming Language Concepts Functional Programming: Definition and Origin Slide 7 of 18
Functional Programming

• Anyone who has used a spreadsheet has


experience of functional programming.
– In a spreadsheet, one specifies the value of each cell
in terms of the values of other cells. The focus is on
what is to be computed, not how it should be
computed
• The focus on the high-level "what" rather than
the low-level "how" is a distinguishing
characteristic of functional programming
languages
• Another well-known nearly-functional language
is the standard database query language SQL

CT006-3-3-Advanced Programming Language Concepts Functional Programming: Definition and Origin Slide 8 of 18
What is Imperative Programming

• C, Java, Pascal, Ada, and so on, are all


imperative languages.
• They are "imperative" in the sense that
they consist of a sequence of commands,
which are executed strictly one after the
other.

CT006-3-3-Advanced Programming Language Concepts Functional Programming: Definition and Origin Slide 9 of 18
Origin of functional Programming

• Lambda calculus,
– invented by Alonzo Church in the 1930s
– provides a theoretical framework for describing functions and
their evaluation.
– Though it is a mathematical abstraction rather than a
programming language, lambda calculus forms the basis of
almost all functional programming languages today.
• Combinatory logic
– This is an equivalent theoretical foundation, developed by
Moses Schönfinkel and Haskell Curry.
– It was originally developed to achieve a larger goal: a clearer
approach to the foundations of mathematics.
– Combinatory logic, which is commonly perceived as more
abstract than lambda calculus, preceded lambda-calculus in
invention.

CT006-3-3-Advanced Programming Language Concepts Functional Programming: Definition and Origin Slide 10 of 18
Origin of functional Programming

• Information Processing Language (IPL)


– The first computer-based functional programming language
– Developed by Newell, Shaw, and Simon at RAND Corporation
for the JOHNNIAC computer in the mid-1950s.
• LISP
– An early functional-flavored programming language
– Developed by John McCarthy while at MIT for the
IBM 700/7000 series scientific computers in the late 1950s.
– LISP introduced many of the features now found in modern
functional programming languages, though LISP is technically a
multi-paradigm language.
– Scheme and Dylan were later attempts to simplify and improve
LISP.

CT006-3-3-Advanced Programming Language Concepts Functional Programming: Definition and Origin Slide 11 of 18
Origin of functional Programming

• APL programming language


– Kenneth E. Iverson developed in the early 1960s
– Described in his 1962 book "A Programming Language."
– APL was the primary influence on John Backus's
FP programming language (1977)
• J programming language
– In the early 1990s, Iverson and Roger Hui created
– A successor to APL.
• K programming language
– In the mid 1990s
– Created by Arthur Whitney, who had previously worked with
Iverson
– used commercially in financial industries.

CT006-3-3-Advanced Programming Language Concepts Functional Programming: Definition and Origin Slide 12 of 18
Origin of functional Programming

• ML programming language
– In the 1970s
– was created by Robin Milner at the University of Edinburgh
• Miranda
– David Turner developed the language at the
University of Kent.
• ML eventually developed into several dialects, the
most common of which are now Objective Caml and
Standard ML.
• The Haskell programming language was released in
the late 1980s in an attempt to gather together many
ideas in functional programming research.

CT006-3-3-Advanced Programming Language Concepts Functional Programming: Definition and Origin Slide 13 of 18
What is good about FP

• Brevity
• Ease of understanding
• No core dumps
• Code re-use
• Strong glue
• Powerful abstractions
• Built-in memory management
• Details :
http://www.haskell.org/haskellwiki/Introduction#D
oes_Anyone_Use_Functional_Programming.3F

CT006-3-3-Advanced Programming Language Concepts Functional Programming: Definition and Origin Slide 14 of 18
Quick and Review

• What is the programming paradigm?


• What are differences between imperative and functional
programming?

CT006-3-3-Advanced Programming Language Concepts Functional Programming: Definition and Origin Slide 15 of 18
Summary of Main Teaching Points

• Functional Programming Language


– Definition
– Origin
– Examples of functional programming
language

CT006-3-3-Advanced Programming Language Concepts Functional Programming: Definition and Origin Slide 16 of 18
Question and Answer Session

Q&A

CT006-3-3-Advanced Programming Language Concepts Functional Programming: Definition and Origin Slide 17 of 18
What we will cover next

• Comparison of functional programming


paradigm with other programming paradigm
– Overview

CT006-3-3-Advanced Programming Language Concepts Functional Programming: Definition and Origin Slide 18 of 18

You might also like