Introduction to F# 3.0
-
Upload
talbott-crowell -
Category
Technology
-
view
5.585 -
download
1
description
Transcript of Introduction to F# 3.0
![Page 1: Introduction to F# 3.0](https://reader035.fdocuments.us/reader035/viewer/2022070315/554ebf2fb4c905064d8b47ea/html5/thumbnails/1.jpg)
Introduction to F# 3.0
Talbott Crowell, MVP
@talbott
#BOSCCBoston Code Camp
October 20, 2012
![Page 2: Introduction to F# 3.0](https://reader035.fdocuments.us/reader035/viewer/2022070315/554ebf2fb4c905064d8b47ea/html5/thumbnails/2.jpg)
What is F#Statically typed, open
sourcefunctional programming
language that uses type inferencing
Unique features:Units of MeasureType Providers
![Page 3: Introduction to F# 3.0](https://reader035.fdocuments.us/reader035/viewer/2022070315/554ebf2fb4c905064d8b47ea/html5/thumbnails/3.jpg)
Static versus Dynamic
F# is statically typed like:
C++, Objective-C, Java, Scala
Compared to dynamically typed languages:
Python, JavaScript, Erlang, MATLAB
![Page 4: Introduction to F# 3.0](https://reader035.fdocuments.us/reader035/viewer/2022070315/554ebf2fb4c905064d8b47ea/html5/thumbnails/4.jpg)
Open SourceApache 2.0 licenseFree IDE on Windows from MicrosoftFree IDE on Mac (MonoDevelop)
http://blogs.msdn.com/b/fsharpteam/archive/2012/09/24/announcing-the-f-3-0-open-source-code-drop.aspx
![Page 5: Introduction to F# 3.0](https://reader035.fdocuments.us/reader035/viewer/2022070315/554ebf2fb4c905064d8b47ea/html5/thumbnails/5.jpg)
Functional Programming (FP)
Examples of FP languagesErlang, Haskell, Clojure and Scala (JVM)
Functions are first class citizenslike variables in imperative languages
Higher-order functionsfunctions a parameters or return values
![Page 6: Introduction to F# 3.0](https://reader035.fdocuments.us/reader035/viewer/2022070315/554ebf2fb4c905064d8b47ea/html5/thumbnails/6.jpg)
Type Inferencing
let x = 5let y = "hello"let z = new Form()let distance = 26.21875<mile>let f x = x + x
![Page 7: Introduction to F# 3.0](https://reader035.fdocuments.us/reader035/viewer/2022070315/554ebf2fb4c905064d8b47ea/html5/thumbnails/7.jpg)
Immutable by default
let x = 5let mutable y = 7y <- 8
let z = new Form()z.Show()z.Text <- “Hello”
![Page 8: Introduction to F# 3.0](https://reader035.fdocuments.us/reader035/viewer/2022070315/554ebf2fb4c905064d8b47ea/html5/thumbnails/8.jpg)
Array, List, and Seq
Arrays are mutable
Lists are not
Seq (sequences) only store one value at a time (lazy)
![Page 9: Introduction to F# 3.0](https://reader035.fdocuments.us/reader035/viewer/2022070315/554ebf2fb4c905064d8b47ea/html5/thumbnails/9.jpg)
Array, List, and Seq
let set1 = [|1..10|]let set2 = [1..10]let set3 = seq { 1..10 }
set1.[0] <- 999 //mutable
![Page 10: Introduction to F# 3.0](https://reader035.fdocuments.us/reader035/viewer/2022070315/554ebf2fb4c905064d8b47ea/html5/thumbnails/10.jpg)
Units of MeasureFloating point and signed integer values in F# can have associated units of measure, which are typically used to indicate length, volume, mass, and so on.
By using quantities with units, you enable the compiler to verify that arithmetic relationships have the correct units, which helps prevent programming errors.
![Page 11: Introduction to F# 3.0](https://reader035.fdocuments.us/reader035/viewer/2022070315/554ebf2fb4c905064d8b47ea/html5/thumbnails/11.jpg)
Units of Measure
[<Measure>] type mile[<Measure>] type km
let distance1 = 4.0<mile>let distance2 = 3.0<km>//compile errorlet total = distance1 + distance2
![Page 12: Introduction to F# 3.0](https://reader035.fdocuments.us/reader035/viewer/2022070315/554ebf2fb4c905064d8b47ea/html5/thumbnails/12.jpg)
Units of Measure
[<Measure>] type mile[<Measure>] type kmlet convert_mile2km (a : float<mile>) = a / 0.621371<mile/km>
let distance1 = 4.0<mile>let distance1a = convert_mile2km distance1let distance2 = 3.0<km>
let total = distance1a + distance2
![Page 13: Introduction to F# 3.0](https://reader035.fdocuments.us/reader035/viewer/2022070315/554ebf2fb4c905064d8b47ea/html5/thumbnails/13.jpg)
Type ProvidersF# 3.0 introduces Type Providers
Data rich programming for the Big Data Era
Enables massive schemas with strict typing
![Page 14: Introduction to F# 3.0](https://reader035.fdocuments.us/reader035/viewer/2022070315/554ebf2fb4c905064d8b47ea/html5/thumbnails/14.jpg)
Examples of Type Providers
SQL Data ConnectionOData Service Provider (Netflix)
FreebaseHadoop
RWMI
RegEx
![Page 15: Introduction to F# 3.0](https://reader035.fdocuments.us/reader035/viewer/2022070315/554ebf2fb4c905064d8b47ea/html5/thumbnails/15.jpg)
Type Provider Demo
![Page 16: Introduction to F# 3.0](https://reader035.fdocuments.us/reader035/viewer/2022070315/554ebf2fb4c905064d8b47ea/html5/thumbnails/16.jpg)
TryFsharp.org
![Page 17: Introduction to F# 3.0](https://reader035.fdocuments.us/reader035/viewer/2022070315/554ebf2fb4c905064d8b47ea/html5/thumbnails/17.jpg)
FPish.net
![Page 18: Introduction to F# 3.0](https://reader035.fdocuments.us/reader035/viewer/2022070315/554ebf2fb4c905064d8b47ea/html5/thumbnails/18.jpg)
Other Resourceshttp://stackoverflow.com/questions/tagged/f%23
http://fsharpsamples.codeplex.com/
http://fsharp.net
![Page 19: Introduction to F# 3.0](https://reader035.fdocuments.us/reader035/viewer/2022070315/554ebf2fb4c905064d8b47ea/html5/thumbnails/19.jpg)
Questions?
![Page 20: Introduction to F# 3.0](https://reader035.fdocuments.us/reader035/viewer/2022070315/554ebf2fb4c905064d8b47ea/html5/thumbnails/20.jpg)
Thank You
Follow me on Twitter
@Talbott