490 likes | 597 Views
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?
E N D
The FALLandRISE 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? • Understanding the past one can find a better way for the future!
Title Inspired by: • The Fall and Rise of R.I.Perrin. • BBC comic series. • Aired from 1976/79 Leonard Rossiter as R.I.P
1960: The Birth of a New ParadigmLISP - John McCarthy • Theorem prover • Formal differentiation and integration. • Symbolic engineering calculations. • Programming the Advice Taker.
1960: The Birth of a New ParadigmLISP - John McCarthy • First programming language to implement the -Calculus. • Programming with functions. • Lists as primitive types. • Garbage Collection.
From 1960 to 1978:The LISP eraWhat is a functional language? • Programming with functions. • Lists as primitive data type. • Garbage Collection.
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.
From 1960 to 1978 -The LISP eraOther Functional Languages: • APL - Iverson (1962) • ISWIM - Landin (1966) • PAL - Evans (1968) • McG - Burge (1968) • Gedanken - Reynold (1969)
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?
From 1960 to 1978 -Signs of a New EraSASL - Turner 1976: • Based on PAL - Evans (1968) • No imperatives. • Referential transparency. • Nicer syntax. • Lazy semantics!!!
FP time line: The LISP era General Interest on FP The LISP era time 1960 1978
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.
FP time line: the FP boom General Interest on FP The FP boom The LISP era time 1960 1978 1989
From 1978 to 1987:The FP BoomWhat is a functional language? • Higher-order functions. • Lazy evaluation. • Referential transparency (pure) • Garbage Collection.
From 1978 to 1987:The FP Boom Promises • Higher level of abstraction and semantic elegance (Higher-order functions and lazy evaluation) • Easier to write than their imperative counterparts • Easier to read (compact notation)
From 1978 to 1987:The FP Boom Promises • Easier to prove correct (-Calculus) • Easier to go parallel: (referential transparency) • Executable specifications
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!!!
FP: The Fall • Low performance figures: “A minor detail”. • Parallelism is the way out! • The world is functional: imperative programmers are blindly wrong!
FP: The Fall • The purity of the paradigm: no compromising to meet users’ needs. • Let the mountain come to Mohammed!
FP: The Fall • Higher-order function and lazy evaluation=> Inefficient sequential code • Unable to cope with Input/Output • Function composition make programs intricate to read
FP: The Fall • Size of large programs: comparable to the imperative equivalent • Correctness: not easy at all ! • Referential transparency:too fine granularity
The Fall: Parallelism • Evaluation of actual parameters before replacing them. • Combinator argument level. • Problems: -Too fine grained parallelism - Too high level abstract machines
Applicative Language Idealised Computing Engine • 40 transputer-based agents • Pocket pools • Connected by a multi-stage switching network • Performance disappointing • Granularity too fine • Use of small packets
The Fall: Bechmarking • Too small benchmarks: - Inefficiency of the implementations - Limitations of architectures -fibs per second
The Fall: Bechmarking • Parallel:Classicdivide-and-conquer program, a variant on the naive Fibonacci program: nfib n = if n <= 1 then 1 else 1 + nfib(n-1) + nfib(n-2)
FP time line: the Fall General Interest on FP The FP boom The Fall The LISP era time 1960 1978 1989 1993
FP: The Rise DTI workshop (London/93) • Learnedhow to compilefunctional languages in sequential machines. • Need for larger benchmarks. • Monads: easier to express I/O and state.
FP: The Rise DTI workshop (London/93) • “Real-world” applications: • AMACO:oil reservoir • ECRC:chemical pollution • SISAL:numerical computation
The Rise:The G-Machine - Johnsson & Augustson (1987) - Chalmers - Works as an interpreteter with lazy graph generation - First fast implementation for lazy functional languages - Graph generated only if needed
The Rise:The G-Machine - Served as the Basis for: • Spineless G-Machine • Spineless Tagless G-Machine • TIM • GM-C
The Rise:Haskell • Developed by a committee: Augustson, Hudak, Hughes, Johnsson, Peyton-Jones, et al. • First widely accepted lazy functional language one had access to source code.
The Rise:Haskell • Glasgow Haskell: • FAST • Robust • Monads: neat I/O
The Rise: Parallelism • 1980’s proved that: • Special purpose Hw is costly and too slow meet the development of general purpose Hw • New parallel machines and languages are based on available parallel architectures.
The Rise: Parallelism • Built on top of efficient sequential compilers. • Tested on large benchmarks and real-world applications.
The Rise:Concurrent Haskell • Suport I/O-performing programs • Implicit, semantically transparent parallelism. • Version available now uses explicit parallelism.
The Rise: GUM • Portable • PVM • Available on shared-memory and distributed-memory • Initial performance figures demonstrate speedups to best sequential compiler technology
The Rise: Pseudoknot • Organised by Pieter Hartel and Martin Alt. • “Real World”problem from molecular chemistry. • Medium-size: several thousands operations performed.
The Rise: Pseudoknot • First benchmark used to compare over 20 different languages and implementations. • First real exercise in cooperation amongst the FP community.
The Rise: Haskell NoFib Suite • Organised by Will Partain • Written in standard Haskell. • Someone trying to get a job done. • Useful tasks!
The Rise: Haskell NoFib Suite • Not too small, not too big. • Able to run on today’s workstations. • Subsets: Real, Imaginary & Spectral
The Rise: New Applications of FP • Erlang (Ericsson) Phone switches • Natural Expert (Software AG) database-oriented environment 20 custumer sites. Factor of ten in productivity
The Rise: Some like it HOT! • Bob Harper called FP Higher-Order and Typed. • Broader reading of terms. • HOT languages: Java, Haskell, ML and Scheme
FP time line: the Rise General Interest on FP The FP boom The Rise The Fall The LISP era time 1960 1978 1989 1993 2000
Conclusions • FP: a lot to offer to software engineering: - Easier to prove programs correct than in any other paradigm - Executable specifications: prototypes for free - Program transformation: Code optimization mechanisms in sequential and parallel architectures
The FALLandRISE of FP Rafael Dueire Lins Departamento de Informática Universidade Federal de Pernambuco Recife - PE - BRAZIL
3rd LatinAmerican Conference on Functional Programming 7 to 9th March 1999 Recife - Brazil together withIFIP WG2.8 Working Meeting
Where is Recife? State: Pernambuco Population: 2.000.000 inh. Historic Cities: Recife - 1600 Olinda - 1535 (Patrimony of mankind UNESCO) Cultural Heritage: Portuguese, African, Native indians, Dutch, Jewish. Recife Rio