KEMBAR78
iOS App Development with F# and Xamarin | PPTX
T W I T T E R : @ R A C H E L R E E S E
B L O G : R A C H E L R E E . S E
G I T H U B : R A C H E L R E E S E
iOS App Development with
Xamarin and F#
Why F#?
“
”
Y A N C U I
L E A D S E R V E R E N G I N E E R , G A M E S Y S ( S O U R C E )
F#…offers us an order of magnitude
increase in productivity and allows one
developer to perform the work…of a
team of dedicated developers on an
existing Java-based solution...
F# Testimonials
“
”
D A R R E N P L A T T
A M Y R I S B I O T E C H N O L O G Y ( S O U R C E )
The UI work is especially gratifying,
because state of the art for a lot of
genomic data display is still PNG images
embedded in JavaScript and with F# I can
render half a million data points on a web
page without jumping through hoops.
F# Testimonials
StartNewGame <| GetNewGameBoard()
F# Fundamentals
|>
Significant whitespace
Immutable by default
//names is tuple of (name, id)
Array.Parallel.partition (fun g -> ids.Contains(snd g)) names
|> fst
|> Array.toList
[1..10]
|> List.filter (fun x -> x % 2 = 0)
|> List.map (fun x -> x + 3)
|> List.sum
operaHouses //(Name, Current Productions) for each opera house
|> Array.map (fun (x,y) -> x, y |> Seq.toArray))
|> Array.filter (fun (x,y) -> y.Length > 0)
Quote of the Week blog post
Option Types
F# Fundamentals
F# C#
type Transport =
| Car of Make:string * Model:string
| Bus of Route:int
| Bicycle
public abstract class Transport{ }
public abstract class Car : Transport {
public string Make { get; private set; }
public string Model { get; private set; }
public Car (string make, string model) {
this.Make = make;
this.Model = model;
}
}
public abstract class Bus : Transport {
public int Route { get; private set; }
public Bus (int route) {
this.Route = route;
}
}
public class Bicycle: Transport { }
...
F# Fundamentals: Concise Code with DUs
F# Fundamentals: Pattern Matching
type Transport =
| Car of Make:string * Model:string
| Bus of Route:int
| Bicycle
let getThereVia (transport:Transport) =
match transport with
| Car (make,model) -> ()
| Bus route -> ()
Several reasons why you should learn F#
Discriminated unions
Immutable by default
Pattern matching
Option type
Custom operators
REPL
F# vs. Swift
‘Enums’Discriminated unions
Constant or VariableImmutable by default
Enhanced switchPattern matching
OptionalsOption type
Custom operatorsCustom operators
REPLREPL
No type providers
Lacks full type
inference
No units of
measure
Requires “return”
Still void, no unit
No parallelism &
async!
Single platform Young language
No easy cloning
syntax for
structures (e.g.
records)
Literal data
structures are only
list and dict
Simpler garbage
collection process
Active Patterns
But Swift is still missing out
TYPE PROVIDERS!
UNITS OF MEASURE!
Why F#?
Some existing
type providers.
See here for a full list.
Minesweeper Azure
Choose your
own
adventure
Matla
b RSS
XAML Rock, Paper,
Scissors Oracle MVVMCross SignalR
FunScript
R File System Python Regex
CSV World Bank SQLite Don Syme XML
Squirrels LINQ
IKV
M
MS
Dynamics
CRM
Freebase
JSON SQL Server
SQL Server
with EF
powershell Dates
Hadoo
p
OData WSDL Apiary Facebook
Get data
from
Hadoop
SQL Server
SQLite
RSS
Freebase
Oracle
CSV
OData
World Bank
JSON
Process
with
Matlab
Powershell
Regex
R
SignalR
Python
LINQ
Visualize
with
F#
Matlab
R
Get creative.
Why Xamarin?
Fully
Native
Cross
Platform
iOS Fundamentals: AppDelegate
iOS Fundamentals: ViewController
Minesweeper
T W I T T E R : @ R A C H E L R E E S E
B L O G : R A C H E L R E E . S E
G I T H U B : R A C H E L R E E S E
iOS App Development with
Xamarin and F#

iOS App Development with F# and Xamarin

  • 1.
    T W IT T E R : @ R A C H E L R E E S E B L O G : R A C H E L R E E . S E G I T H U B : R A C H E L R E E S E iOS App Development with Xamarin and F#
  • 2.
  • 3.
    “ ” Y A NC U I L E A D S E R V E R E N G I N E E R , G A M E S Y S ( S O U R C E ) F#…offers us an order of magnitude increase in productivity and allows one developer to perform the work…of a team of dedicated developers on an existing Java-based solution... F# Testimonials
  • 4.
    “ ” D A RR E N P L A T T A M Y R I S B I O T E C H N O L O G Y ( S O U R C E ) The UI work is especially gratifying, because state of the art for a lot of genomic data display is still PNG images embedded in JavaScript and with F# I can render half a million data points on a web page without jumping through hoops. F# Testimonials
  • 5.
    StartNewGame <| GetNewGameBoard() F#Fundamentals |> Significant whitespace Immutable by default //names is tuple of (name, id) Array.Parallel.partition (fun g -> ids.Contains(snd g)) names |> fst |> Array.toList [1..10] |> List.filter (fun x -> x % 2 = 0) |> List.map (fun x -> x + 3) |> List.sum operaHouses //(Name, Current Productions) for each opera house |> Array.map (fun (x,y) -> x, y |> Seq.toArray)) |> Array.filter (fun (x,y) -> y.Length > 0)
  • 6.
    Quote of theWeek blog post Option Types F# Fundamentals
  • 7.
    F# C# type Transport= | Car of Make:string * Model:string | Bus of Route:int | Bicycle public abstract class Transport{ } public abstract class Car : Transport { public string Make { get; private set; } public string Model { get; private set; } public Car (string make, string model) { this.Make = make; this.Model = model; } } public abstract class Bus : Transport { public int Route { get; private set; } public Bus (int route) { this.Route = route; } } public class Bicycle: Transport { } ... F# Fundamentals: Concise Code with DUs
  • 8.
    F# Fundamentals: PatternMatching type Transport = | Car of Make:string * Model:string | Bus of Route:int | Bicycle let getThereVia (transport:Transport) = match transport with | Car (make,model) -> () | Bus route -> ()
  • 9.
    Several reasons whyyou should learn F# Discriminated unions Immutable by default Pattern matching Option type Custom operators REPL
  • 10.
    F# vs. Swift ‘Enums’Discriminatedunions Constant or VariableImmutable by default Enhanced switchPattern matching OptionalsOption type Custom operatorsCustom operators REPLREPL
  • 11.
    No type providers Lacksfull type inference No units of measure Requires “return” Still void, no unit No parallelism & async! Single platform Young language No easy cloning syntax for structures (e.g. records) Literal data structures are only list and dict Simpler garbage collection process Active Patterns But Swift is still missing out
  • 12.
    TYPE PROVIDERS! UNITS OFMEASURE! Why F#?
  • 13.
    Some existing type providers. Seehere for a full list. Minesweeper Azure Choose your own adventure Matla b RSS XAML Rock, Paper, Scissors Oracle MVVMCross SignalR FunScript R File System Python Regex CSV World Bank SQLite Don Syme XML Squirrels LINQ IKV M MS Dynamics CRM Freebase JSON SQL Server SQL Server with EF powershell Dates Hadoo p OData WSDL Apiary Facebook
  • 14.
    Get data from Hadoop SQL Server SQLite RSS Freebase Oracle CSV OData WorldBank JSON Process with Matlab Powershell Regex R SignalR Python LINQ Visualize with F# Matlab R Get creative.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
    T W IT T E R : @ R A C H E L R E E S E B L O G : R A C H E L R E E . S E G I T H U B : R A C H E L R E E S E iOS App Development with Xamarin and F#

Editor's Notes

  • #2 Play Minesweeper game. I work at FFL using iOS and F#. Just helped start the Nash F# UG & am involved in the Nashville Xamarin UG. One of the LambdaLadies founders. Slides up after the talk. You should all move to Nashville!!! :D
  • #3 Maybe you’re a C# dev or maybe you’re an iOS dev right now. Why should you switch?
  • #5 Clarity & conciseness of code.
  • #6 F# gets flack for lack of UI support. Not using editors: true for every gui technology. Winforms & ASP.NET, amirite?
  • #7 Start with |> Like unix shell scripting pipe Flow works better backwards sometimes. Note whitespace.
  • #8 NullReferenceException can be obviated because of option types. Similar to nullable<int> but different because: Can be used on any type (strings, functions) When pattern matched on, forces you to consider None case Can use map, iter, etc. functions. Nestable: Option<Option<int>> is valid.
  • #9 Sort of like enums. Can model smaller obj hierarchies with them, like here.
  • #10 Can pattern match on values, tuples, records, DUs.
  • #14 Type providers are a way to return typed data from an external data source. UoM because game physics Phil tags some integers as <pixel> to represent actual screen space – plus self-documenting. <Tasky Data demo> <UoM demo> <Freebase demo>
  • #17 Why not swift. Why not PhoneGap.
  • #18 If currently an ios dev, this should look familiar because of all the UI-prefaced things. AppDelegate must be registered Main needs to be labeled as an Entry Point. <- is assignment FinishedLaunching: Set root view controller.
  • #19 Inherit from UIViewController() Override ViewDidLoad, ViewWillAppear, ViewDidAppear…
  • #21 Work at FFL using iOS and F#. Just helped start the Nash F# user group. Previously ran VT Fun. This was a difficult talk to put together. Half the room knows F#, but not iOS or Xamarin, and the other half’s the opposite. Start w/ covering why you should consider F# Then some language basics And Xamarin basics.