16
The power of F#

The Power of F#

Embed Size (px)

DESCRIPTION

Slideset being used for my Power of F# talk designed for delivery to C# and VB .NET developers.

Citation preview

Page 1: The Power of F#

The power of F#

Page 2: The Power of F#

About me…

• .NET dev / contractor / consultant since .NET 1.0•Now works CTO of Elastacloud and as a freelance consultant

• Twitter @ isaac_abraham• Blog @ http://cockneycoder.wordpress.com• Email @ [email protected]

Page 3: The Power of F#

A confession…

Page 4: The Power of F#

Functional programming?!?

•Why hasn’t functional programming taken off until now?•Do we need to re-evaluate what problems OO is best placed to solve?

Page 5: The Power of F#

Objects now and then

Objects in the 90s

•Inheritance •State•Identity

Objects today

•Composition•Immutability•Structural equality

Page 6: The Power of F#

The beginning of the end…

• CPU clock speed has reached a peak• Multicore programming is not going away• Multithreading

• Single machine computing no longer sufficient for data-intensive problems• Distributed computing

• Azure, AWS etc. etc. compute platforms

• Same problem but x10,000

• Systems are becoming more complex• Harder to reason about• More expensive to build• More expensive to maintain

Page 7: The Power of F#

Features and Benefits of FP

Page 8: The Power of F#

FP with .NET today

• Lambda expressions• Func<T>• Anonymous Types• Extension methods allow method chaining

• LINQ• Task Parallel Library

Page 9: The Power of F#

Languages today

Object Oriented Functional

Java

Haskell

C#VB .N

ET Scala

F#

Page 10: The Power of F#

What is F# designed for?

•Writing simple code to solve complex problems

• F# 2.0 (Visual Studio 2010)• Business domain logic• Financial and maths-heavy problem solving• General problem domain exploration• Asynchronous coding

• F# 3.0 (Visual Studio 2012)• “Information Rich” data access• Improved tooling etc.

Page 11: The Power of F#

Where does F# fit into .NET?

.NET CLR / VM

MSIL

Compiler

C# VB Compiler

F#

Page 12: The Power of F#

Demo

Page 13: The Power of F#

Lots that I didn’t cover!

• Pattern Matching•Discriminated Unions•Option Types• Events• Classes and Interfaces• Custom Operators•Units of Measure

Page 14: The Power of F#

Want to learn more?

•Web• http://www.tryfsharp.org/• http://fsharpforfunandprofit.com/• http://fsharp.org/

•User Groups• http://www.meetup.com/FSharpLondon/

Page 15: The Power of F#

Summary

• C# / VB offers some functional constructs• Definitely useful!• But they are somewhat limited and / or clunky

• F# offers a smarter compiler to give us many advantages• Quicker• Easier to reason about• Safer• Interoperates with other .NET languages + framework• Fall back to “classic” OO-style if you want

Page 16: The Power of F#

DON’T FEAR THE FUNCTION!