Data-First Online Functional Programming with F# (Adam Granicz)

  • View
    38

  • Download
    2

Embed Size (px)

DESCRIPTION

The world around us is producing data at an enormous speed and in huge quantities. Processing this complex, multifaceted data, turning it into information and visualizing it to drive business decision making is the paramount challenge for today’s corporate software developers. In this talk, I will demonstrate the unique data-driven capabilities of F# and how these can be used to connect to a multitude of heterogeneous data sources to obtain structured, strongly-typed data that can be processed in a functional style, and presented and visualized in stunning HTML5 output that is guaranteed to win everyone’s attention. By the end of the talk, you will become familiar with CloudSharper, the world’s first online F# development environment, and will have mastered key data visualization techniques that will make you a better and more informed developer.

Text of Data-First Online Functional Programming with F# (Adam Granicz)

  • Premium community conference on Microsoft technologies itcampro@ itcamp14#
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# Data-First Online Functional Programming with F# Adam Granicz, CEO, IntelliFactory @granicz, @websharper, @cloudsharper http://fpish.net/blog/adam.granicz/all/0
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# Huge thanks to our sponsors & partners!
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# 4x F# MVP 2010-2014 (Most Valuable Professional) Coauthor of 4 F# books, 3 of them with Don Syme, the designer of F# CEO of IntelliFactory, The F# Company Regular speaker in numerous conferences and developer workshops About me Steering Committee member of the Commercial Users of Functional Programming (CUFP) workshop, representing F#
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# Expert F# - 2007 Expert F# 2.0 2010 Visual Studio 2010 and .NET 4 Six-in-One 2010 Expert F# 3.0 2012 F# Books I coauthored
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# How to do interactive, data-driven, web programming In an online development environment that enables quick data exploration and visualization In this talk you will learn about
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# Why F#?
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# Functional core language Powerful functional abstractions Functional data structures Immutability Cool features Active patterns Units of measure Type Providers Object-orientation to interoperate with other .NET languages Why F#?
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# FSharp.Data provides quick, type-safe access to all sorts of data sources CSV files Relational databases REST data sources World Bank database Freebase databases etc. Type Providers
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# Mature, enterprise-ready framework Write all your server+client code in F# Get a complete web or mobile application Interface with any client-side JS library via F# Powerful functional abstractions Automatic resource management Safe URLs, type-safe URLs and much-much more WebSharper
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# Open source project, available at: https://bitbucket.org/IntelliFactory/websharper Dual licensed for closed source use Dedicated support new features, bugfix releases WebSharper
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# open IntelliFactory.WebSharper module Server = [] let MyServerFunction(...) = ... module Client = [] let MyClientFunction(...) = ... let v = MyServerFunction(...) ... Bridging the language mismatch
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# WebSharper What do I get with WebSharper? 1. Automatic resource management => no need to include dependencies by hand => each page loads only the resources it needs 2. Type-safe access to JavaScript libraries via F# => dozens of extensions available (visualizations, charts, ) => has its own eDSL for describing JavaScript APIs => TypeScript type provider (in supported version)
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# WebSharper What do I get with WebSharper? 3. Uniform programming model (everything is F#) => write all server and client code in F# 4. Client-Server applications => [] vs [] annotations => Seamless communication via RPC => No need to worry about how to pass data
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# WebSharper What do I get with WebSharper? 5. Composable functional programming abstractions => Pagelets: to represent dynamic markup and behavior => Sitelets: to represent web applications => Formlets: to represent complex and dependent web forms => Flowlets: to represent sequences of user forms, wizzards
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# WebSharper sitelets Type-safe Composable First-class Parameterized over a union type: type Action = | Home | Contact | Protected | Login of option | Logout | Echo of string Representing web applications as values
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# Sitelets dynamic templating Runtime-checked, safe URLs module Skin = type Page = { Body : Content.HtmlElement list } let MainTemplate = let path = Path.Combine(__SOURCE_DIRECTORY__, "Main.html") Content.Template(path) .With("body", fun x -> x.Body) let WithTemplate body : Content = Content.WithTemplate MainTemplate { Body = body context }
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# Composing web applications from smaller ones let EntireSite = let home = Sitelet.Content ... let authenticated = Sitelet.Protect filter [ ... "login" => ... "getLoginStatus" => ... "api" => ... ] |> Requires [Res.FacebookAPI] let Assembly = Assembly [ Namespace "IntelliFactory.WebSharper.Facebook" [ ...; FB ] ... ] Binding JavaScript libraries
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# Binding JavaScript libraries Defining classes useful operators let FlashHidingArgs = Class "FB.FlashHidingArgs" |+> Protocol [ "state" =? T "elem" =? T ] =? : Member
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# Binding JavaScript libraries Defining optional members let InitOptions = Pattern.Config "FB.InitOptions" { Required = [] Optional = [ "appId", T "cookie", T ... "hideFlashCallback", FlashHidingArgs ^-> T ] } Typical in most JavaScript libraries Used heavily in configuration objects
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# Binding JavaScript libraries Describing client-side APIs via TypeScript declarations
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# Binding JavaScript libraries Defining safe enumerations let UserStatus = Pattern.EnumStrings "FB.UserStatus" ["connected"; "not_authorized"; "unknown"] Typical in most JavaScript libraries Used heavily in configuration objects
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# Type Provider for TypeScript definitions type Facebook = IntelliFactory.TypeScript.Generator Facebook.*** Binding JavaScript libraries
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# CloudSharper
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# What is CloudSharper? An online integrated development environment (IDE) for developing web and mobile applications. Language neutral - can be used with any language First phase targets .NET (F#) development F# - full language support C# - not yet, but coming JavaScript full language support Syntax highlighting for dozens of languages
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# What is CloudSharper? An online, cloud-hosted IDE with interactive exploration and An SaaS platform for developing and running applications
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# Enables you to develop, deploy, and run full web and mobile applications with interactive programming CloudSharper
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# What is CloudSharper? Multi-project solutions with full build support Web and mobile applications On-the-fly type checking Integration with data and other providers Interactive data exploration, REPL
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# Its extensible even with full applications It can be configured with custom renderers with custom editors What is CloudSharper?
  • Premium community conference on Microsoft technologies itcampro@ itcamp14# CloudSharper Has three screens to help y