Your SlideShare is downloading. ×
Exploring SharePoint with F#
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Exploring SharePoint with F#


Published on

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. Exploring SharePoint with F#
    Talbott Crowell (MVP)
    SharePoint Saturday New York City
    July 30, 2011
  • 2. Learn something new (exercise for the brain)
    Trend in functional programming
    Java -> Clojure, Scala
    LINQ added to VB and C#
    Microsoft’s official (and only) functional programming language
    Why F#
  • 3. Functional programming has been around a long time
    Not new
    Long history
    Functional programming is safe
    A concern as we head toward manycore and cloud computing
    Why another language?
  • 4. 1930’s: lambda calculus (roots)
    1956: IPL (Information Processing Language) “the first functional language
    1958: LISP “a functional flavored language”
    1962: APL (A Programming Language)
    1973: ML (Meta Language)
    1983: SML (Standard ML)
    1987: Caml (Categorical Abstract Machine Language ) and Haskell
    1996: OCaml (Objective Caml)
    Functional programming has been around a long time
  • 5. Functional language developed by Microsoft Research
    By Don Syme and his team, who productized Generics
    Based on OCaml (influenced by C# and Haskell)
    2002: F# language design started
    2005 January: F# 1.0.1 releases to public
    Not a product. Integration with VS2003
    Works in .NET 1.0 through .NET 2.0 beta, Mono
    2005 November: F# 1.1.5 with VS 2005 RTM support
    2009 October: VS2010 Beta 2, CTP for VS2008 & Non-Windows users
    2010: F# is “productized” and baked into VS 2010
    What is F#
  • 6. Interactive Scripting
    Uses REPL (Read Evaluate Print Loop)
    Good for prototyping
    Succinct = Less code
    Type Inference
    Strongly typed, strict
    Automatic generalization (generics for free)
    Few type annotations
    1st class functions (currying, lazy evaluations)
    Pattern matching
    Key Characteristics of F#
  • 7. Functional first
    Mutable keyword
    Functions are first class values
    Blend of functional and imperative
    Object oriented capabilities
    Built on .NET Framework
    Leverage existing code
    What I like about F#
  • 8. What is manycore?
    Lots of processors on one chip
    Tens or hundreds
    Intel – Future (Task parallelism)
    NVIDIA GPU – Today (Data parallelism)
    500+ cores on chip
    Graphics, gaming, 3D rendering
    Use CUDA for financial or research computing
    Program in C or C++
  • 9. The Power Wall: CPU Clock Speed
    Single core
    From Katherine Yelick’s “Multicore: Fallout of a Hardware Revolution”
  • 10. Road to manycore
    1970 – 2005
    Single core on the “desktop” and laptop
    2006 – 2011
    Single core on the smartphone/tablet
    Multi core on the “desktop”
    Multi core in the cloud
    2012 – 2020
    Multi core on the smartphone/tablet
    Manycore probably will be common on many devices and computers
  • 11. Multicore for Smartphones/Tablets
    Android 2.2 already supports multicore
    NVIDIA dual core test with one core shut off
    1.5 to 1.6x faster with two cores
    NVIDIA quad core on its way
    Smartphones by holiday season 2011
    Faster than 2 GHz notebook Core 2 Duo (T7200)
    Qualcomm quad core SnapDragon
    Devices expected in 2013
    Intel announcing entry into Smartphone market
  • 12. Declarative programming style
    Easier to introduce parallelism into existing code
    Immutability by default
    Can’t introduce race conditions
    Easier to write lock-free code
    Functional Programming
  • 13. Type inference
    F# Basics
    let x = 5
    let y = 5.0
    let files = Directory.GetFiles(@"C:imagesoriginal")
    let x = 5 * 5
    let y = 5.0 / 3.0
    let width = image.Width / 8
  • 14. Function
    Anonymous functions
    F# Functions
    let sqr x = x * x
    sqr 5
    (fun x -> x * x) 5
  • 15. The |> Combinator “Pipe Forward”
    F# Combinators
    x |> f is the same as f x
    let sqr x = x * x
    sqr 5
    5 |> sqr
  • 16. The <| Combinator “Pipe Backward”
    F# Combinators
    f <| x is the same as f x
    let sqr x = x * x
    sqr 5
    sqr <| 3 + 2 not same as sqr 3 + 2
  • 17. Similar to operator overloading
    Symbolic Functions
    let (operatorName) left right = <function>
    open System.Text.RegularExpressions
    let (===) str regex =
    Regex.Match(str, regex).Success
  • 18. Client Object Model
  • 19.
  • 20. Adding References
  • 21. For more info on Client Object Model
    See “Using the SharePoint Foundation 2010 Managed Client Object Model”
  • 22. Load References FSX Script
    Open namespace
    Client Object Model Assemblies
    #r @"..ReferenceAssembliesMicrosoft.SharePoint.Client.dll"
    #r @"..ReferenceAssembliesMicrosoft.SharePoint.Client.Runtime.dll"
    open Microsoft.SharePoint.Client
  • 23. Create SharePoint Client Context
    Pass Credentials
    Client Context and Credentials
    let ctx = new ClientContext("")
    ctx.Credentials <-
    new NetworkCredential(
    user, password, domain)
  • 24. Helper function to Load and Query
    Retrieve Site Collection
    Load and Query Context
    let load(ctx:ClientContext)(item:'a) =
    let site = ctx.Site
    load ctx site
  • 25. Site Collection (Site) and Site (Web)
    Site Collection and Site
    let site = ctx.Site
    load ctx site
    let web = site.RootWeb
    load ctx web
    let title = web.Title
  • 26. Use for loop to iterate through lists
    Iterate through Lists
    load ctxweb.Lists
    for list in web.Lists do
    print <| "List Title: " + list.Title
  • 27. Query for list items using CAML
    Use for loop to iterate through list items
    Iterate through List Items
    let fsugMeetings = web.Lists.GetByTitle("FSUG Meetings")
    let query = new CamlQuery()
    query.ViewXml <- "<View><Query><OrderBy>...
    let listItems = fsugMeetings.GetItems(query)
    for meeting in listItems do
    print <| "Meeting: " + meeting.["Title"].ToString()
  • 28. Use for loop to iterate through lists
    Iterate through Lists
    load ctxweb.Lists
    for list in web.Lists do
    print <| "List Title: " + list.Title
  • 29. Demo
  • 30. Future of F#
    Solution for the Data Deluge
    Type Providers
    Video by Keith Battocchi
  • 31. Questions?
  • 32. Thank You
    Play with F# on browser
    Load and save files
    More information
  • 33. My Info
    Talbott Crowell
    F# MVP
    New England F# User Group @talbott
    Boston Area SharePoint User Group
    Third Millennium, Inc. Chief Architect