Your SlideShare is downloading. ×
0
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
Exploring SharePoint with F#
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#

2,214

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,214
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
15
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

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

×