f a l l and r i s e

49
F F A A L L L L and and R R I I S S E E Rafael Dueire Lins Rafael Dueire Lins Departamento de Informática Departamento de Informática Universidade Federal de Pernambuco Universidade Federal de Pernambuco Recife - PE - BRAZIL Recife - PE - BRAZIL The The of of FP FP

Upload: haruko

Post on 22-Feb-2016

30 views

Category:

Documents


0 download

DESCRIPTION

The. F A L L and R I S E. of FP. Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco Recife - PE - BRAZIL. Motivation for this talk:. FP is a well respected programming paradigm. Almost four decade old. Why FP languages are not of widespread use today? - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: F A L L and R I S E

FFAALLLL andand RRIISSEE

Rafael Dueire LinsRafael Dueire LinsDepartamento de InformáticaDepartamento de Informática

Universidade Federal de PernambucoUniversidade Federal de PernambucoRecife - PE - BRAZILRecife - PE - BRAZIL

TheThe

of of FPFP

Page 2: F A L L and R I S E

Motivation for this talk:Motivation for this talk:

FP is a well respected programming FP is a well respected programming paradigm.paradigm.

Almost four decade old.Almost four decade old. Why FP languages are not of widespread Why FP languages are not of widespread

use today?use today? Understanding the past one can find a Understanding the past one can find a

better way for the future!better way for the future!

Page 3: F A L L and R I S E

Title Inspired by: Title Inspired by:

The Fall and Rise The Fall and Rise of R.I.Perrin.of R.I.Perrin.

BBC comic series.BBC comic series.Aired from 1976/79Aired from 1976/79

Leonard Rossiter as R.I.PLeonard Rossiter as R.I.P

Page 4: F A L L and R I S E

1960: The Birth of a New Paradigm1960: The Birth of a New Paradigm LISP - John McCarthy LISP - John McCarthy

Theorem proverTheorem prover Formal differentiation and Formal differentiation and

integration.integration. Symbolic engineering calculations.Symbolic engineering calculations. Programming the Advice Taker.Programming the Advice Taker.

Page 5: F A L L and R I S E

1960: The Birth of a New Paradigm1960: The Birth of a New Paradigm LISP - John McCarthy LISP - John McCarthy

First programming language First programming language to implementto implement the the -Calculus.-Calculus.

Programming with functions.Programming with functions. Lists as primitive types.Lists as primitive types. Garbage Collection.Garbage Collection.

Page 6: F A L L and R I S E

From 1960 to 1978:From 1960 to 1978: The LISP eraThe LISP eraWhat is a functional language?What is a functional language?

Programming with functions.Programming with functions. Lists as primitive data type.Lists as primitive data type. Garbage CollectionGarbage Collection..

Page 7: F A L L and R I S E

The LISP era:The LISP era:

LISP was born pure. To make LISP faster and more

acceptable for users: imperative features were added. This became a trend followed by

other FP languages.

Page 8: F A L L and R I S E

From 1960 to 1978 -From 1960 to 1978 - The LISP eraThe LISP eraOther Functional Languages:Other Functional Languages:

APL - Iverson (1962)APL - Iverson (1962) ISWIM - Landin (1966)ISWIM - Landin (1966) PAL - Evans (1968)PAL - Evans (1968) McG - Burge (1968)McG - Burge (1968) Gedanken - Reynold (1969)Gedanken - Reynold (1969)

Page 9: F A L L and R I S E

Stachey’s Seven Questions:Stachey’s Seven Questions: What are DLs? What is their relationship to imperative

languages? Why do we need DLs? How can we use them to program? How can we implement them? How can we do this efficiently? Should we mix DLs with imperative

languages?

Page 10: F A L L and R I S E

From 1960 to 1978 -Signs of a New EraFrom 1960 to 1978 -Signs of a New EraSASL - Turner 1976:SASL - Turner 1976:

Based on PAL - Evans (1968)Based on PAL - Evans (1968) No imperatives.No imperatives. Referential transparency.Referential transparency. Nicer syntax.Nicer syntax. Lazy semantics!!!Lazy semantics!!!

Page 11: F A L L and R I S E

FP time line: FP time line: The LISP eraThe LISP era

1960 1978

General Interest on FPGeneral Interest on FP

timetime

The LISP eraThe LISP era

Page 12: F A L L and R I S E

Meanwhile, the world...Meanwhile, the world... Cold war increased (1980s). Star war programme. Need for Software reliability. Backus Turing lecture (1978). Massive investments in functional

programming and formal methods.

Page 13: F A L L and R I S E

FP time line: the FP boomFP time line: the FP boom

1960 1978

General Interest on FPGeneral Interest on FP

timetime

The LISP eraThe LISP era

1989

The FP boom

Page 14: F A L L and R I S E

From 1978 to 1987:From 1978 to 1987: The FP BoomThe FP BoomWhat is a functional language?What is a functional language?

Higher-order functions.Higher-order functions. Lazy evaluation.Lazy evaluation. Referential transparency Referential transparency

(pure)(pure) Garbage CollectionGarbage Collection..

Page 15: F A L L and R I S E

Higher level of abstraction and Higher level of abstraction and semantic elegance (semantic elegance (Higher-order Higher-order functionsfunctions and and lazy evaluationlazy evaluation))

Easier to write than their Easier to write than their imperative counterpartsimperative counterparts

Easier to read (Easier to read (compact notationcompact notation))

From 1978 to 1987:From 1978 to 1987: The FP BoomThe FP Boom PromisesPromises

Page 16: F A L L and R I S E

Easier to prove correct Easier to prove correct ((-Calculus)-Calculus)

Easier to go parallel: Easier to go parallel: (referential transparency)(referential transparency)

Executable specificationsExecutable specifications

From 1978 to 1987:From 1978 to 1987: The FP BoomThe FP Boom PromisesPromises

Page 17: F A L L and R I S E

Meanwhile, the world...Meanwhile, the world... End of the Cold War (1989). SW reliability did not matter! New name of the game:

efficiency Projects had to become

products within 6 months!!!

Page 18: F A L L and R I S E

Low performance figures: Low performance figures: “A minor detail”. “A minor detail”.

Parallelism is the way out!Parallelism is the way out! The world is functional: The world is functional:

imperative imperative programmers are blindly programmers are blindly wrong! wrong!

FP: The FallFP: The Fall

Page 19: F A L L and R I S E

The purity of the paradigm: The purity of the paradigm: no no compromising to meet users’ compromising to meet users’ needs. needs.

Let the mountain come to Let the mountain come to MohammedMohammed!!

FP: The FallFP: The Fall

Page 20: F A L L and R I S E

Higher-order function Higher-order function and and lazy lazy evaluationevaluation => Inefficient sequential code=> Inefficient sequential code

Unable to cope with Unable to cope with Input/OutputInput/Output

Function composition make Function composition make programs programs intricate to readintricate to read

FP: The FallFP: The Fall

Page 21: F A L L and R I S E

Size Size of large programs: of large programs: comparable to the imperative comparable to the imperative equivalentequivalent

Correctness:Correctness: not easy at all ! not easy at all !

Referential transparency:Referential transparency: too fine granularitytoo fine granularity

FP: The FallFP: The Fall

Page 22: F A L L and R I S E

Evaluation of actual parameters Evaluation of actual parameters before replacing them.before replacing them.

Combinator argument level.Combinator argument level.

Problems:Problems: -- Too fine grained parallelismToo fine grained parallelism - - Too high level abstract machinesToo high level abstract machines

The Fall: The Fall: ParallelismParallelism

Page 23: F A L L and R I S E

AApplicative pplicative LLanguage anguage IIdealised dealised CComputing omputing EEnginengine 40 transputer-based agents Pocket pools Connected by a multi-stage

switching network Performance disappointing

• Granularity too fine• Use of small packets

Page 24: F A L L and R I S E

The Fall: BechmarkingThe Fall: Bechmarking

Too small benchmarks:Too small benchmarks:

- - Inefficiency of the implementationsInefficiency of the implementations

- - Limitations of architecturesLimitations of architectures

-- fibs per secondfibs per second

Page 25: F A L L and R I S E

The Fall: BechmarkingThe Fall: Bechmarking Parallel:Parallel: ClassicClassic divide-and-conquer divide-and-conquer

program, a variant on the program, a variant on the naive Fibonacci naive Fibonacci program:program:

nfib n = if n <= 1 then 1nfib n = if n <= 1 then 1 else 1 + nfib(n-1) + nfib(n-2)else 1 + nfib(n-1) + nfib(n-2)

Page 26: F A L L and R I S E

FP time line: FP time line: the Fallthe Fall

1960 1978

General Interest on FPGeneral Interest on FP

timetime

The LISP eraThe LISP era

1989

The FP boom

1993

The Fall

Page 27: F A L L and R I S E

• LearnedLearned how to compilehow to compile functional languages in functional languages in sequential machines.sequential machines.

• Need for Need for larger benchmarks.larger benchmarks.• Monads:Monads: easier to express easier to express

I/O and state. I/O and state.

FP: The RiseFP: The RiseDTI workshop (London/93)DTI workshop (London/93)

Page 28: F A L L and R I S E

� ““Real-world” applications:Real-world” applications:• AMACO:AMACO: oil reservoiroil reservoir• ECRC:ECRC: chemical pollutionchemical pollution• SISAL:SISAL: numerical numerical

computationcomputation

FP: The RiseFP: The RiseDTI workshop (London/93)DTI workshop (London/93)

Page 29: F A L L and R I S E

The Rise:The Rise: The G-MachineThe G-Machine - - Johnsson & Augustson Johnsson & Augustson

(1987) - Chalmers(1987) - Chalmers

- Works as an interpreteter with - Works as an interpreteter with lazy lazy graph generation graph generation

- First fast implementation for lazy - First fast implementation for lazy functional languagesfunctional languages

- Graph generated only if needed- Graph generated only if needed

Page 30: F A L L and R I S E

Lazy Graph GenerationLazy Graph Generation

Page 31: F A L L and R I S E

The Rise:The Rise: The G-MachineThe G-Machine

- - Served as the Basis for:Served as the Basis for: Spineless G-MachineSpineless G-Machine Spineless Tagless G-MachineSpineless Tagless G-Machine TIMTIM GM-CGM-C

Page 32: F A L L and R I S E

The Rise:The Rise: HaskellHaskell

Developed by a committee: Developed by a committee: Augustson, Hudak, Hughes, Augustson, Hudak, Hughes, Johnsson, Peyton-Jones, et al.Johnsson, Peyton-Jones, et al.

First widely accepted lazy First widely accepted lazy functional language one had functional language one had access to source code. access to source code.

Page 33: F A L L and R I S E

The Rise:The Rise: HaskellHaskell

Glasgow Haskell: Glasgow Haskell: • FAST FAST • Robust Robust

Monads: Monads: neat I/Oneat I/O

Page 34: F A L L and R I S E

The Rise: The Rise: ParallelismParallelism 1980’s proved that:1980’s proved that:

• Special purpose Hw is Special purpose Hw is costlycostly and too and too slowslow meet the meet the development of general development of general purpose Hwpurpose Hw

New parallel machines and New parallel machines and languages are based on languages are based on available available parallel architectures.parallel architectures.

Page 35: F A L L and R I S E

The Rise: The Rise: ParallelismParallelism Built on top of Built on top of efficient efficient

sequential compilers.sequential compilers. Tested on Tested on large benchmarks and large benchmarks and

real-world applications. real-world applications.

Page 36: F A L L and R I S E

The Rise:The Rise: Concurrent HaskellConcurrent Haskell Suport I/O-performing Suport I/O-performing

programsprograms ImplicitImplicit, semantically , semantically

transparent parallelism.transparent parallelism. Version available now uses Version available now uses

explicitexplicit parallelism. parallelism.

Page 37: F A L L and R I S E

The Rise: The Rise: GUMGUM

PortablePortable PVMPVM Available on Available on shared-memoryshared-memory

and and distributed-memorydistributed-memory Initial performance figures Initial performance figures

demonstrate speedups to best demonstrate speedups to best sequential compiler technologysequential compiler technology

Page 38: F A L L and R I S E

The Rise: PseudoknotThe Rise: Pseudoknot Organised by Organised by Pieter Hartel Pieter Hartel and and

Martin Alt.Martin Alt.

““Real World”problem from Real World”problem from molecular chemistry.molecular chemistry.

Medium-size: Medium-size: several thousands several thousands operations performed.operations performed.

Page 39: F A L L and R I S E

The Rise: PseudoknotThe Rise: Pseudoknot First benchmark used to First benchmark used to

compare over compare over 20 different 20 different languages and implementations.languages and implementations.

First real exercise in First real exercise in cooperation amongst the FP cooperation amongst the FP community.community.

Page 40: F A L L and R I S E

The Rise: The Rise: Haskell NoFib SuiteHaskell NoFib Suite Organised by Will Partain Organised by Will Partain

Written in standard Haskell.Written in standard Haskell.

Someone trying to get a job Someone trying to get a job done.done.

Useful tasks!Useful tasks!

Page 41: F A L L and R I S E

The Rise: The Rise: Haskell NoFib SuiteHaskell NoFib Suite Not too small, not too big.Not too small, not too big.

Able to run on today’s Able to run on today’s workstations.workstations.

Subsets:Subsets:

Real, Imaginary & SpectralReal, Imaginary & Spectral

Page 42: F A L L and R I S E

The Rise: The Rise: New Applications of FPNew Applications of FP Erlang (Ericsson)Erlang (Ericsson)

Phone switchesPhone switches

Natural Expert (Software AG)Natural Expert (Software AG)database-oriented environmentdatabase-oriented environment20 custumer sites.20 custumer sites.Factor of ten in productivityFactor of ten in productivity

Page 43: F A L L and R I S E

The Rise: The Rise: Some like it Some like it HOTHOT!! Bob Harper called FP Bob Harper called FP

HHigher-igher-OOrder and rder and TTyped.yped.

Broader reading of terms.Broader reading of terms.

HOTHOT languages: languages:

JavaJava, , HaskellHaskell, , MLML and and SchemeScheme

Page 44: F A L L and R I S E

FP time line: FP time line: the Risethe Rise

1960 1978

General Interest on FPGeneral Interest on FP

timetime

The LISP eraThe LISP era

1989

The FP boom

1993 2000

The RiseThe Fall

Page 45: F A L L and R I S E

FP: a lot to offer to software FP: a lot to offer to software engineering:engineering:

- - Easier to prove Easier to prove programs correct than programs correct than in any other paradigm in any other paradigm

- - Executable specifications: Executable specifications: prototypes for freeprototypes for free

- - Program transformation: Program transformation: Code optimization mechanisms Code optimization mechanisms in in sequential and parallel architecturessequential and parallel architectures

ConclusionsConclusions

Page 46: F A L L and R I S E

FFAALLLL andand RRIISSEE

Rafael Dueire LinsRafael Dueire LinsDepartamento de InformáticaDepartamento de Informática

Universidade Federal de PernambucoUniversidade Federal de PernambucoRecife - PE - BRAZILRecife - PE - BRAZIL

TheThe

of of FPFP

Page 47: F A L L and R I S E

3rd LatinAmerican Conference 3rd LatinAmerican Conference on Functional Programmingon Functional Programming

7 to 9th March 1999

Recife - BrazilRecife - Brazil

together withtogether withIFIP WG2.8 Working MeetingIFIP WG2.8 Working Meeting

Page 48: F A L L and R I S E

Where is Recife?Where is Recife?

Rio

Recife

State:State: Pernambuco PernambucoPopulation:Population: 2.000.000 inh. 2.000.000 inh.

Historic Cities: Historic Cities: Recife - 1600Recife - 1600 Olinda - 1535 Olinda - 1535 (Patrimony of mankind UNESCO)(Patrimony of mankind UNESCO)

Cultural Heritage:Cultural Heritage: PortuguesePortuguese, African, Native , African, Native indians, Dutch, Jewish.indians, Dutch, Jewish.

Page 49: F A L L and R I S E