Functional Programming in an Imperative World

29
Functional Programming in an Imperative World! Michael Newton @mavnn Character illustrations: Storn Cook, Creative Commons: Attribution- NonCommercial-ShareAlike 2.5 see http://www.enworld.org/forum/showthread.php?161795-Storn-s-art-for-swipin-!/ page3&p=2874435&viewfull=1#post2874435

Transcript of Functional Programming in an Imperative World

Page 1: Functional Programming in an Imperative World

Functional Programming in an

Imperative World!

Michael Newton @mavnn

Character illustrations: Storn Cook, Creative Commons: Attribution-NonCommercial-ShareAlike 2.5 see http://www.enworld.org/forum/showthread.php?161795-Storn-s-art-for-swipin-!/page3&p=2874435&viewfull=1#post2874435

Page 2: Functional Programming in an Imperative World

Down in the trenches, the Agents of C# and their VB.net support bots have managed to keep out the dreaded Dr. Bankrupt so far.

But the Market never sleeps, and the challenges are growing. Some of the newer agents speak of super heroes that can be summoned to aid the cause - the Fearsome F#, Erlang the Messenger... if only the sacrifice is made of keeping the code pure.

The Story so far...

Page 3: Functional Programming in an Imperative World

Eyjafjallajökull

Setting the Scene

Page 4: Functional Programming in an Imperative World

Fear is the Mind Killer

• Change is hard - and risky

• Need to convince:

• Management

• Your peers

Page 5: Functional Programming in an Imperative World
Page 6: Functional Programming in an Imperative World

Don't confuse me with facts!

[Dan Liu's] post “The Empirical Evidence That Types Affect Productivity and Correctness” summarizes a large set of papers and goes through each one in order to describe what it is trying to measure and how well it does it. In almost every paper, he has valid critique of the experiment, methodology and approach.

The point is that while these papers shows almost no effect in either direction, they are often used to “Justify your view” in one direction or the other.

(https://medium.com/@jlouis666/proglang-design-with-evidence-1444213f3902#.ujwfbigvo)

Page 7: Functional Programming in an Imperative World

Dilute the Risk

• Fix the badly broken

Page 8: Functional Programming in an Imperative World

<TargetFrameworkProfile></TargetFrameworkProfile>

<FileAlignment>512</FileAlignment>

<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>

</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">

<PlatformTarget>x86</PlatformTarget>

<DebugSymbols>true</DebugSymbols>

<DebugType>full</DebugType>

<Optimize>false</Optimize>

<OutputPath>bin\Debug\</OutputPath>

<DefineConstants>DEBUG;TRACE</DefineConstants>

<ErrorReport>prompt</ErrorReport>

<WarningLevel>4</WarningLevel>

Page 9: Functional Programming in an Imperative World

Fake 'n' Shake

Page 10: Functional Programming in an Imperative World

Dilute the Risk

• Fix the badly broken

• Pick an interoperable language

Page 11: Functional Programming in an Imperative World

Together... They Fight Crime!

Page 12: Functional Programming in an Imperative World

C#F#

Page 13: Functional Programming in an Imperative World

VB.net

F#

Page 14: Functional Programming in an Imperative World

Scala Java

Page 15: Functional Programming in an Imperative World

Clojure

Java

Page 16: Functional Programming in an Imperative World

Elm

(Your Server)

Page 17: Functional Programming in an Imperative World

Do the Impossible!

• What's so risky... it's never been done?

• Can a functional language help?

Page 18: Functional Programming in an Imperative World

Do the Impossible!

Page 19: Functional Programming in an Imperative World

Type Providers

Page 20: Functional Programming in an Imperative World

Pattern Matching

Page 21: Functional Programming in an Imperative World

Concurrency

Page 22: Functional Programming in an Imperative World

Currying

Page 23: Functional Programming in an Imperative World

Metaprogramming

Page 24: Functional Programming in an Imperative World

Steal from the Best

• If you can't go to the functional language...

• ...bring the functional concepts to yours

• And then tell people where they came from!

Page 25: Functional Programming in an Imperative World

Actors

Page 26: Functional Programming in an Imperative World

Property Based Testing

Page 27: Functional Programming in an Imperative World

RX Redux

Lambdas

itertools

LINQ

Page 28: Functional Programming in an Imperative World

And finally... teach!

Page 29: Functional Programming in an Imperative World

Questions??

@mavnn ltd

http://mavnn.co.uk

http://blog.mavnn.co.uk