31
Functional Leap of Faith Tomer Gabel, Wix JDay Lviv 2014

Functional Leap of Faith (Keynote at JDay Lviv 2014)

Embed Size (px)

DESCRIPTION

Keynote talk given at JDay Lviv 2014 in Ukraine (http://www.jday.com.ua/). Video coming soon. Abstract: Some say that there's nothing new under the sun. However, looking back on five to six decades of computing, it's easy to see that things progress at their own leisurly pace. Structured programming, originating in the '60s, did not gain mainstream adoption until the '80s; object-oriented programming was hotly debated in the '70s and '80s but only gained widespread acceptance in the '90s. Every couple of decades sees an engineering leap that radically improves the software engineering discipline across the board. I believe we are now at such an inflection point, with functional programming concepts slowly sifting into the mainstream. After this talk, I hope you will too.

Citation preview

Page 1: Functional Leap of Faith (Keynote at JDay Lviv 2014)

Functional Leap of Faith

Tomer Gabel, WixJDay Lviv 2014

Page 2: Functional Leap of Faith (Keynote at JDay Lviv 2014)

Through the Looking Glass

20 years ago…

• C/C++ rule the

market [1]

• First release of

Java

[1] TIOBE Index (historical data)

Page 3: Functional Leap of Faith (Keynote at JDay Lviv 2014)

… since then?*

• C and Java are neck-and-neck• Virtual machines are everywhere• Garbage collection is everywhere• OOP is everywhere

* Not exhaustive

Page 4: Functional Leap of Faith (Keynote at JDay Lviv 2014)

Virtual Machines

1967 BCPL

1978 UCSD p-System

1994 JVM

2014 Everywhere!

Page 5: Functional Leap of Faith (Keynote at JDay Lviv 2014)

Garbage Collection

1960 Formalized[1]

1970s Research

1994 JVM

2014 Everywhere!

[1] Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I

Page 6: Functional Leap of Faith (Keynote at JDay Lviv 2014)

Object-Oriented Programming

1967 Simula 67

1980 Smalltalk 80

1983 C++

2014 Everywhere!

Page 7: Functional Leap of Faith (Keynote at JDay Lviv 2014)

Advances take decades to become mainstream

Page 8: Functional Leap of Faith (Keynote at JDay Lviv 2014)

Market Growth[1]

1975 1980 1985 1990 1995 2000 2005 2010 2015* 2020*0

500000000

1000000000

1500000000

2000000000

2500000000

3000000000

[1] eTForecasts Worldwide PC Market Research Report

Page 9: Functional Leap of Faith (Keynote at JDay Lviv 2014)

1975 1980 1985 1990 1995 2000 2005 2010 2015* 2020*0

500000000

1000000000

1500000000

2000000000

2500000000

3000000000

Market Growth

• Structured Programming

• Module Systems

• Dynamic Memory

Allocation

Page 10: Functional Leap of Faith (Keynote at JDay Lviv 2014)

1975 1980 1985 1990 1995 2000 2005 2010 2015* 2020*0

500000000

1000000000

1500000000

2000000000

2500000000

3000000000

Market Growth

• Garbage Collection

• OOP

• VMs and JIT

Page 11: Functional Leap of Faith (Keynote at JDay Lviv 2014)

1975 1980 1985 1990 1995 2000 2005 2010 2015* 2020*0

500000000

1000000000

1500000000

2000000000

2500000000

3000000000

Market Growth

You are here!

Page 12: Functional Leap of Faith (Keynote at JDay Lviv 2014)

What’s holding us back?

Page 13: Functional Leap of Faith (Keynote at JDay Lviv 2014)

The Market has Shifted

• SaaS is the norm

• Shorter time to market

• Latency requirements are stricter

• Availability is business-critical

Page 14: Functional Leap of Faith (Keynote at JDay Lviv 2014)

The Free Lunch is Over[1]

[1] The Free Lunch is Over, Herb Stutter (Dr. Dobb's Journal, 2005)

• CPUs aren’t getting (much) faster

• Rather, they’re getting parallel

• Concurrency is the new kid on the block

Page 15: Functional Leap of Faith (Keynote at JDay Lviv 2014)

Datasets are Getting Bigger

• Terabyte-scale data is common

• Computation demand – NoSQL– Big Data

• Specialized hardware (SAN) is a hindrance

Page 16: Functional Leap of Faith (Keynote at JDay Lviv 2014)

We need new abstractions.

Page 17: Functional Leap of Faith (Keynote at JDay Lviv 2014)

Three desirable attributes:

Page 18: Functional Leap of Faith (Keynote at JDay Lviv 2014)

Today’s systems

are highly available & reliable.

Tomorrow’s abstraction must…

encourage correct code.

Page 19: Functional Leap of Faith (Keynote at JDay Lviv 2014)

Complexity is the Mind Killer

• Complex system bigger

codebase

• More code more bugs

• We want less code

• We want correct code

Page 20: Functional Leap of Faith (Keynote at JDay Lviv 2014)

Control flow Data flow

We need to invert our thinking.

Page 21: Functional Leap of Faith (Keynote at JDay Lviv 2014)

How What

We need to invert our thinking.

Page 22: Functional Leap of Faith (Keynote at JDay Lviv 2014)

Control flow describes the how

List<Person> adults(List<Person> in) {

ArrayList<Person> out = new ArrayList<>();

for (Person p : in) if (p.getAge() >= 18) out.add(p);

return out;}

Page 23: Functional Leap of Faith (Keynote at JDay Lviv 2014)

Data flow describes the what

List<Person> adults(List<Person> in) { return in.stream() .filter(p -> p.age >= 18) .collect(Collectors.toList());}

Page 24: Functional Leap of Faith (Keynote at JDay Lviv 2014)

“What” is Better

• Focuses on the problem

• Reduces accidental complexity

• Decouples intent from execution

I WANT YOU

TO STOPWORRYING

ABOUT TRIVIA

Page 25: Functional Leap of Faith (Keynote at JDay Lviv 2014)

Today’s systems

are highly concurrent.

Tomorrow’s abstraction must…

encourage immutability.

Page 26: Functional Leap of Faith (Keynote at JDay Lviv 2014)

The Case for Immutability

• Inherently thread-safe

• Referentially transparent

• Easier to reason about!

Page 27: Functional Leap of Faith (Keynote at JDay Lviv 2014)

Today’s systems

are horizontally scalable.

Tomorrow’s abstraction must…

simplify workload distribution.

Page 28: Functional Leap of Faith (Keynote at JDay Lviv 2014)

Distribution 101

1. Take a core computation

2. Split it out

3. Run on many nodes

4. Profit

Page 29: Functional Leap of Faith (Keynote at JDay Lviv 2014)

Why is this hard?

• Behavior-as-data

• Side effects

• High-performance

frameworks

Lambdas

Immutability

Akka, Hadoop,

Storm…

Page 30: Functional Leap of Faith (Keynote at JDay Lviv 2014)

The future is functional.

1. Data flow-oriented

2. Immutable3. Easy to

distribute