25
An Introduction to F# Horacio Nunez {[email protected], horatio.info}

dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

Embed Size (px)

DESCRIPTION

dotNet Miami - April 19, 2012: Presented by Horacio Nunez: In this talk we are going to learn the basics of programming with F# from Visual Studio 2010. After talking a bit about the genesis of F# we will go through some examples illustrating the functional ways of F# and how it aligns with the other citizens of the managed world. Among the F# features we will visit are High Order Functions, Pattern Matching and the Asynchronous workflows.

Citation preview

Page 1: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

An Introduction to

F#

Horacio Nunez

{[email protected], horatio.info}

Page 2: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

What is F#?

F# Interactive

F# 101 (less than 10 minutes!)

Walkthrough: Functional

Numerical Matrixes

Online Resources

Page 3: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

F# is multi-paradigm

programming language targeting

the .NET framework

Page 4: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

functional

object oriented

imperative

language oriented

F#

Page 5: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

Immutable values and data types

(No State => No Shared Memory)

let x = 10x = 10 //<!-- boolean

Page 6: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

High Order Functions

(functions can be parameters and

results of other functions)

Page 7: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

Type Inference

Think in C#’s var… everywhere

Page 8: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

Declarative

Express the desired result, not the

step-by-step recipe

Page 9: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

Lazy Evaluation

Use values only when you really

need it

Page 10: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

Pattern Matching

The compiler “understands” types

Page 11: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

Imperative

Page 12: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

Mutable values and data types

(State => Probable Shared Memory)

let mutable x = 10x <- 10

Page 13: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

Object Oriented

Page 14: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

F# can consume and create OOP

designs seamlessly

Page 15: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

also…

F# becomes MSIL, hard

to read, but MSIL

Page 16: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

F# is fully supported in Visual

Studio except for GUI Designers

Page 17: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

What is F#?

F# Interactive

F# 101 (less than 10 minutes!)

Walkthrough: Functional

Numerical Matrixs

Online Resources

Page 18: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

What is F#?

F# Interactive

F# 101 (less than 10 minutes!)

Walkthrough: Functional

Numerical Matrixs

Online Resources

Page 19: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

What is F#?

F# Interactive

F# 101 (less than 10 minutes!)

Walkthrough: Functional

Numerical Matrixs

Online Resources

Page 20: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

Functional Abstractions for

Numerical Matrixes

Page 21: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

Have you ever tried to create a

Matrix of order Int32.MaxValue?

Page 22: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

Out of Memory Exception!

Page 23: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

What is F#?

F# Interactive

F# 101 (less than 10 minutes!)

Walkthrough: Functional

Numerical Matrixs

Online Resources

Page 24: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

ONLINE RESOURCES

Don Syme’ Blog (F# Designer)

http://blogs.msdn.com/b/dsyme/

Tomas Petricek's’ Blog

http://tomasp.net/

Page 25: dotNet Miami - April 19, 2012: Horacio Nunez: Introduction to F#

ONLINE RESOURCES

F# Snippets

http://fssnip.net/

Channel 9

http://channel9.msdn.com/

StackOverflow

http://stackoverflow.com/