SlideShare a Scribd company logo
1 of 35
itcampro@ itcamp13# Premium conference on Microsoft technologies
Developing for Windows 8
with F# and WebSharper
Adam Granicz, CEO, IntelliFactory
#granicz, #websharper
http://fpish.net/blog/adam.granicz/all/0
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
MobileHuge thanks to our sponsors!
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
3x F# MVP – 2010, 2011, 2012
(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#
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
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
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
We see how to do the following:
• Doing web development in F#
• Binding JavaScript libraries for F# use
• Developing a Win 8/Surface application in F#
• Sneak preview of an online development
environment that enables quick exploration
and embedded applications
• .. that makes data visualization easy and fun
In this talk…
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
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#?
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
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
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
Open source project, available at:
https://bitbucket.org/IntelliFactory/websharper
Dual licensed for closed source use
Dedicated support – new features, bugfix
releases
WebSharper
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
open IntelliFactory.WebSharper
module Server =
[<Rpc>]
let MyServerFunction(...) = ...
module Client =
[<JavaScript>]
let MyClientFunction(...) =
...
let v = MyServerFunction(...)
...
Bridging the language mismatch
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
WebSharper sitelets
• Type-safe
• Composable
• First-class
Parameterized over a union type:
type Action =
| Home
| Contact
| Protected
| Login of option<Action>
| Logout
| Echo of string
Representing web applications as values
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
MobileSitelets – 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<Page>(path)
.With("body", fun x -> x.Body)
let WithTemplate body : Content<Action> =
Content.WithTemplate MainTemplate <| fun context ->
{ Body = body context }
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
Composing web applications from smaller ones
let EntireSite =
let home = Sitelet.Content ...
let authenticated = Sitelet.Protect filter <| ...
let basic = Sitelet.Infer <| fun action -> ...
Sitelet.Sum
[
home
authenticated
basic
]
Representing web applications as values
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
Describing client-side
APIs in F# via
WebSharper
Interface
Generator (WIG)
Binding JavaScript libraries
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
namespace IntelliFactory.WebSharper.Facebook
module Definition =
...
let FB =
Class "FB"
|+> [ ...
"login" => ...
"getLoginStatus" => ...
"api" => ...
]
|> Requires [Res.FacebookAPI]
let Assembly =
Assembly [
Namespace
"IntelliFactory.WebSharper.Facebook" [
...; FB
] ...
]
Binding JavaScript libraries
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
MobileBinding JavaScript libraries
Defining classes – useful operators
let FlashHidingArgs =
Class "FB.FlashHidingArgs"
|+> Protocol [
"state" =? T<string>
"elem" =? T<Element>
]
=? : Member
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
MobileBinding JavaScript libraries
Defining optional members
let InitOptions =
Pattern.Config "FB.InitOptions" {
Required = []
Optional =
[
"appId", T<string>
"cookie", T<bool>
...
"hideFlashCallback", FlashHidingArgs ^-> T<unit>
]
}
• Typical in most JavaScript libraries
• Used heavily in configuration objects
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
MobileBinding 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
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
MobileBinding JavaScript libraries
eDSL to describe JavaScript APIs
Type Provider for TypeScript definitions
F#
WebSharper
extension
TypeScript
TypeScript
Type Provider
WebSharper
extension
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
MobileBinding JavaScript libraries
Describing client-side
APIs via
TypeScript
declarations
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
Type Provider for TypeScript definitions
type Facebook =
IntelliFactory.TypeScript.Generator<"Facebook.d.ts">
Facebook.***
Binding JavaScript libraries
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
An F#/WebSharper application using jQuery
Mobile
Total size: 150 LOC in F#
My Facebook Wall for tablets
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
MobileMy Facebook Wall for tablets
WebSharper Facebook application showing wall posts
• Using the Facebook bindings generated via WIG and TypeScript.
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
MobileIntelliMath for WinRT/8
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
An F#/WebSharper application using WinJS
Size: 1100 LOC in F#
IntelliMath for WinRT/8
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
Promises
type Promise<'T> =
[<Inline "$this.then($f)">]
member this.Then(f: 'T -> 'U) = X<Promise<'U>>
[<Inline "$this.done($f)">]
member this.Done(f: 'T -> unit) = ()
Binding WinJS
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
module Application =
[<Inline "WinJSSetOnActivated($f)">]
let OnActivated(f: unit -> unit) = ()
module Local =
[<Inline "WinJS.Application.local.exists($f)">]
let Exists (f: string) = X<Promise<bool>>
[<Inline "WinJS.Application.local.readText($f)">]
let ReadText (f: string) = X<Promise<string>>
...
Binding WinJS
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
Going to TypeScript declarations or WIG is the
full solution
Binding WinJS
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
[<JavaScript>]
let rec (|Factor|_|) = function
| NUMBER (n, rest) ->
Some (Expr.Const (Const.Number n), rest)
| ID ("x", rest) ->
Some (Expr.Const Const.X, rest)
| ID ("pi", rest) ->
Some (Expr.Const Const.Pi, rest)
| ID ("e", rest) ->
Some (Expr.Const Const.E, rest)
| LPAREN (Expression (e, RPAREN rest)) ->
(e, rest) |> Some
| _ ->
None
Parsing with active patterns
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
/// Pixels on the screen
[<Measure>] type px
module Events =
type Point = { x: int<px>; y: int<px> }
[<Sealed>]
type PointerPoint =
[<Stub>]
member this.pointerId = X<int>
[<Stub>]
member this.position = X<Point>
Using units of measure
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
MobileExtras
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
Aggregates and catalogs FP content about:
Q&A
Events/Conferences
Courses
User Groups
Blogs
Jobs
Developers
etc…
FPish.net
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
• Full F# language support
• Multi-project solutions
• Web and mobile Apps
• Syntax highlighting
• On the fly type checking
• Interactive exploration
• Integration with data
• Support for type providers
CloudSharper
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
Develop, deploy, and run full web and mobile
applications with interactive programming
CloudSharper
itcampro@ itcamp13# Premium conference on Microsoft technologies
Development &
Mobile
Video…
CloudSharper
itcampro@ itcamp13# Premium conference on Microsoft technologies
Q & A
Get in touch
#granicz #websharper #fpishnet
http://websharper.com
http://intellifactory.com
http://fpish.net
http://www.facebook.com/intellifactory

More Related Content

Similar to ITCamp 2013 - Adam Granicz - Developing for W8 with F# and WebSharper

ITCamp 2013 - Petru Jucovschi - Application ecosystems
ITCamp 2013 - Petru Jucovschi - Application ecosystemsITCamp 2013 - Petru Jucovschi - Application ecosystems
ITCamp 2013 - Petru Jucovschi - Application ecosystems
ITCamp
 
ITCamp 2013 - Raffaele Rialdi - Windows Runtime (WinRT) deep dive
ITCamp 2013 - Raffaele Rialdi - Windows Runtime (WinRT) deep diveITCamp 2013 - Raffaele Rialdi - Windows Runtime (WinRT) deep dive
ITCamp 2013 - Raffaele Rialdi - Windows Runtime (WinRT) deep dive
ITCamp
 
ITCamp 2013 - Melania Danciu - HTML5 apps with LightSwitch
ITCamp 2013 - Melania Danciu - HTML5 apps with LightSwitchITCamp 2013 - Melania Danciu - HTML5 apps with LightSwitch
ITCamp 2013 - Melania Danciu - HTML5 apps with LightSwitch
ITCamp
 
Mihai Tataran - Building Windows 8 Applications with HTML5 and JS
Mihai Tataran - Building Windows 8 Applications with HTML5 and JSMihai Tataran - Building Windows 8 Applications with HTML5 and JS
Mihai Tataran - Building Windows 8 Applications with HTML5 and JS
ITCamp
 
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
Thomas Conté
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010
Satish Verma
 
ITCamp 2013 - Martin Kulov - Demystifying Visual Studio 2012 Performance Tools
ITCamp 2013 - Martin Kulov - Demystifying Visual Studio 2012 Performance ToolsITCamp 2013 - Martin Kulov - Demystifying Visual Studio 2012 Performance Tools
ITCamp 2013 - Martin Kulov - Demystifying Visual Studio 2012 Performance Tools
ITCamp
 
ITCamp 2011 - Paula Januszkiewicz - 10 deadly sins of Windows Administrators
ITCamp 2011 - Paula Januszkiewicz - 10 deadly sins of Windows AdministratorsITCamp 2011 - Paula Januszkiewicz - 10 deadly sins of Windows Administrators
ITCamp 2011 - Paula Januszkiewicz - 10 deadly sins of Windows Administrators
ITCamp
 
ITCamp 2011 - Melania Danciu - Mobile apps
ITCamp 2011 - Melania Danciu - Mobile appsITCamp 2011 - Melania Danciu - Mobile apps
ITCamp 2011 - Melania Danciu - Mobile apps
ITCamp
 
ITCamp 2011 - Mihai Tataran, Tudor Damian - Keynote
ITCamp 2011 - Mihai Tataran, Tudor Damian - KeynoteITCamp 2011 - Mihai Tataran, Tudor Damian - Keynote
ITCamp 2011 - Mihai Tataran, Tudor Damian - Keynote
ITCamp
 

Similar to ITCamp 2013 - Adam Granicz - Developing for W8 with F# and WebSharper (20)

ITCamp 2013 - Petru Jucovschi - Application ecosystems
ITCamp 2013 - Petru Jucovschi - Application ecosystemsITCamp 2013 - Petru Jucovschi - Application ecosystems
ITCamp 2013 - Petru Jucovschi - Application ecosystems
 
ITCamp 2013 - Raffaele Rialdi - Windows Runtime (WinRT) deep dive
ITCamp 2013 - Raffaele Rialdi - Windows Runtime (WinRT) deep diveITCamp 2013 - Raffaele Rialdi - Windows Runtime (WinRT) deep dive
ITCamp 2013 - Raffaele Rialdi - Windows Runtime (WinRT) deep dive
 
ITCamp 2013 - Melania Danciu - HTML5 apps with LightSwitch
ITCamp 2013 - Melania Danciu - HTML5 apps with LightSwitchITCamp 2013 - Melania Danciu - HTML5 apps with LightSwitch
ITCamp 2013 - Melania Danciu - HTML5 apps with LightSwitch
 
Mihai Tataran - Building Windows 8 Applications with HTML5 and JS
Mihai Tataran - Building Windows 8 Applications with HTML5 and JSMihai Tataran - Building Windows 8 Applications with HTML5 and JS
Mihai Tataran - Building Windows 8 Applications with HTML5 and JS
 
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2Elements of DDD with ASP.NET MVC & Entity Framework Code First v2
Elements of DDD with ASP.NET MVC & Entity Framework Code First v2
 
Introduction of Pharo 5.0
Introduction of Pharo 5.0Introduction of Pharo 5.0
Introduction of Pharo 5.0
 
Developing for Windows Phone 8.1
Developing for Windows Phone 8.1Developing for Windows Phone 8.1
Developing for Windows Phone 8.1
 
Developing for Windows Phone 8.1 (Dan Ardelean)
Developing for Windows Phone 8.1 (Dan Ardelean)Developing for Windows Phone 8.1 (Dan Ardelean)
Developing for Windows Phone 8.1 (Dan Ardelean)
 
ITCamp 2013 - Martin Kulov - Demystifying Visual Studio 2012 Performance Tools
ITCamp 2013 - Martin Kulov - Demystifying Visual Studio 2012 Performance ToolsITCamp 2013 - Martin Kulov - Demystifying Visual Studio 2012 Performance Tools
ITCamp 2013 - Martin Kulov - Demystifying Visual Studio 2012 Performance Tools
 
Mix 2010 twilight
Mix 2010 twilightMix 2010 twilight
Mix 2010 twilight
 
ITCamp 2011 - Paula Januszkiewicz - 10 deadly sins of Windows Administrators
ITCamp 2011 - Paula Januszkiewicz - 10 deadly sins of Windows AdministratorsITCamp 2011 - Paula Januszkiewicz - 10 deadly sins of Windows Administrators
ITCamp 2011 - Paula Januszkiewicz - 10 deadly sins of Windows Administrators
 
Programming on Windows 8.1: The New Stream and Storage Paradigm (Raffaele Ria...
Programming on Windows 8.1: The New Stream and Storage Paradigm (Raffaele Ria...Programming on Windows 8.1: The New Stream and Storage Paradigm (Raffaele Ria...
Programming on Windows 8.1: The New Stream and Storage Paradigm (Raffaele Ria...
 
ITCamp 2011 - Melania Danciu - Mobile apps
ITCamp 2011 - Melania Danciu - Mobile appsITCamp 2011 - Melania Danciu - Mobile apps
ITCamp 2011 - Melania Danciu - Mobile apps
 
Serverless Single Page Apps with React and Redux at ItCamp 2017
Serverless Single Page Apps with React and Redux at ItCamp 2017Serverless Single Page Apps with React and Redux at ItCamp 2017
Serverless Single Page Apps with React and Redux at ItCamp 2017
 
Busy Developers Guide to AngularJS (Tiberiu Covaci)
Busy Developers Guide to AngularJS (Tiberiu Covaci)Busy Developers Guide to AngularJS (Tiberiu Covaci)
Busy Developers Guide to AngularJS (Tiberiu Covaci)
 
ITCamp 2011 - Mihai Tataran, Tudor Damian - Keynote
ITCamp 2011 - Mihai Tataran, Tudor Damian - KeynoteITCamp 2011 - Mihai Tataran, Tudor Damian - Keynote
ITCamp 2011 - Mihai Tataran, Tudor Damian - Keynote
 
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010
 
Building modern web sites with ASP .Net Web API, WebSockets and RSignal
Building modern web sites with ASP .Net Web API, WebSockets and RSignalBuilding modern web sites with ASP .Net Web API, WebSockets and RSignal
Building modern web sites with ASP .Net Web API, WebSockets and RSignal
 

More from ITCamp

ITCamp 2019 - Ivana Milicic - Color - The Shadow Ruler of UX
ITCamp 2019 - Ivana Milicic - Color - The Shadow Ruler of UXITCamp 2019 - Ivana Milicic - Color - The Shadow Ruler of UX
ITCamp 2019 - Ivana Milicic - Color - The Shadow Ruler of UX
ITCamp
 

More from ITCamp (20)

ITCamp 2019 - Stacey M. Jenkins - Protecting your company's data - By psychol...
ITCamp 2019 - Stacey M. Jenkins - Protecting your company's data - By psychol...ITCamp 2019 - Stacey M. Jenkins - Protecting your company's data - By psychol...
ITCamp 2019 - Stacey M. Jenkins - Protecting your company's data - By psychol...
 
ITCamp 2019 - Silviu Niculita - Supercharge your AI efforts with the use of A...
ITCamp 2019 - Silviu Niculita - Supercharge your AI efforts with the use of A...ITCamp 2019 - Silviu Niculita - Supercharge your AI efforts with the use of A...
ITCamp 2019 - Silviu Niculita - Supercharge your AI efforts with the use of A...
 
ITCamp 2019 - Peter Leeson - Managing Skills
ITCamp 2019 - Peter Leeson - Managing SkillsITCamp 2019 - Peter Leeson - Managing Skills
ITCamp 2019 - Peter Leeson - Managing Skills
 
ITCamp 2019 - Mihai Tataran - Governing your Cloud Resources
ITCamp 2019 - Mihai Tataran - Governing your Cloud ResourcesITCamp 2019 - Mihai Tataran - Governing your Cloud Resources
ITCamp 2019 - Mihai Tataran - Governing your Cloud Resources
 
ITCamp 2019 - Ivana Milicic - Color - The Shadow Ruler of UX
ITCamp 2019 - Ivana Milicic - Color - The Shadow Ruler of UXITCamp 2019 - Ivana Milicic - Color - The Shadow Ruler of UX
ITCamp 2019 - Ivana Milicic - Color - The Shadow Ruler of UX
 
ITCamp 2019 - Florin Coros - Implementing Clean Architecture
ITCamp 2019 - Florin Coros - Implementing Clean ArchitectureITCamp 2019 - Florin Coros - Implementing Clean Architecture
ITCamp 2019 - Florin Coros - Implementing Clean Architecture
 
ITCamp 2019 - Florin Loghiade - Azure Kubernetes in Production - Field notes...
ITCamp 2019 - Florin Loghiade -  Azure Kubernetes in Production - Field notes...ITCamp 2019 - Florin Loghiade -  Azure Kubernetes in Production - Field notes...
ITCamp 2019 - Florin Loghiade - Azure Kubernetes in Production - Field notes...
 
ITCamp 2019 - Florin Flestea - How 3rd Level support experience influenced m...
ITCamp 2019 - Florin Flestea -  How 3rd Level support experience influenced m...ITCamp 2019 - Florin Flestea -  How 3rd Level support experience influenced m...
ITCamp 2019 - Florin Flestea - How 3rd Level support experience influenced m...
 
ITCamp 2019 - Emil Craciun - RoboRestaurant of the future powered by serverle...
ITCamp 2019 - Emil Craciun - RoboRestaurant of the future powered by serverle...ITCamp 2019 - Emil Craciun - RoboRestaurant of the future powered by serverle...
ITCamp 2019 - Emil Craciun - RoboRestaurant of the future powered by serverle...
 
ITCamp 2019 - Eldert Grootenboer - Cloud Architecture Recipes for The Enterprise
ITCamp 2019 - Eldert Grootenboer - Cloud Architecture Recipes for The EnterpriseITCamp 2019 - Eldert Grootenboer - Cloud Architecture Recipes for The Enterprise
ITCamp 2019 - Eldert Grootenboer - Cloud Architecture Recipes for The Enterprise
 
ITCamp 2019 - Cristiana Fernbach - Blockchain Legal Trends
ITCamp 2019 - Cristiana Fernbach - Blockchain Legal TrendsITCamp 2019 - Cristiana Fernbach - Blockchain Legal Trends
ITCamp 2019 - Cristiana Fernbach - Blockchain Legal Trends
 
ITCamp 2019 - Andy Cross - Machine Learning with ML.NET and Azure Data Lake
ITCamp 2019 - Andy Cross - Machine Learning with ML.NET and Azure Data LakeITCamp 2019 - Andy Cross - Machine Learning with ML.NET and Azure Data Lake
ITCamp 2019 - Andy Cross - Machine Learning with ML.NET and Azure Data Lake
 
ITCamp 2019 - Andy Cross - Business Outcomes from AI
ITCamp 2019 - Andy Cross - Business Outcomes from AIITCamp 2019 - Andy Cross - Business Outcomes from AI
ITCamp 2019 - Andy Cross - Business Outcomes from AI
 
ITCamp 2019 - Andrea Saltarello - Modernise your app. The Cloud Story
ITCamp 2019 - Andrea Saltarello - Modernise your app. The Cloud StoryITCamp 2019 - Andrea Saltarello - Modernise your app. The Cloud Story
ITCamp 2019 - Andrea Saltarello - Modernise your app. The Cloud Story
 
ITCamp 2019 - Andrea Saltarello - Implementing bots and Alexa skills using Az...
ITCamp 2019 - Andrea Saltarello - Implementing bots and Alexa skills using Az...ITCamp 2019 - Andrea Saltarello - Implementing bots and Alexa skills using Az...
ITCamp 2019 - Andrea Saltarello - Implementing bots and Alexa skills using Az...
 
ITCamp 2019 - Alex Mang - I'm Confused Should I Orchestrate my Containers on ...
ITCamp 2019 - Alex Mang - I'm Confused Should I Orchestrate my Containers on ...ITCamp 2019 - Alex Mang - I'm Confused Should I Orchestrate my Containers on ...
ITCamp 2019 - Alex Mang - I'm Confused Should I Orchestrate my Containers on ...
 
ITCamp 2019 - Alex Mang - How Far Can Serverless Actually Go Now
ITCamp 2019 - Alex Mang - How Far Can Serverless Actually Go NowITCamp 2019 - Alex Mang - How Far Can Serverless Actually Go Now
ITCamp 2019 - Alex Mang - How Far Can Serverless Actually Go Now
 
ITCamp 2019 - Peter Leeson - Vitruvian Quality
ITCamp 2019 - Peter Leeson - Vitruvian QualityITCamp 2019 - Peter Leeson - Vitruvian Quality
ITCamp 2019 - Peter Leeson - Vitruvian Quality
 
ITCamp 2018 - Ciprian Sorlea - Million Dollars Hello World Application
ITCamp 2018 - Ciprian Sorlea - Million Dollars Hello World ApplicationITCamp 2018 - Ciprian Sorlea - Million Dollars Hello World Application
ITCamp 2018 - Ciprian Sorlea - Million Dollars Hello World Application
 
ITCamp 2018 - Ciprian Sorlea - Enterprise Architectures with TypeScript And F...
ITCamp 2018 - Ciprian Sorlea - Enterprise Architectures with TypeScript And F...ITCamp 2018 - Ciprian Sorlea - Enterprise Architectures with TypeScript And F...
ITCamp 2018 - Ciprian Sorlea - Enterprise Architectures with TypeScript And F...
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 

ITCamp 2013 - Adam Granicz - Developing for W8 with F# and WebSharper

  • 1. itcampro@ itcamp13# Premium conference on Microsoft technologies Developing for Windows 8 with F# and WebSharper Adam Granicz, CEO, IntelliFactory #granicz, #websharper http://fpish.net/blog/adam.granicz/all/0
  • 2. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & MobileHuge thanks to our sponsors!
  • 3. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile 3x F# MVP – 2010, 2011, 2012 (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#
  • 4. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile 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
  • 5. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile We see how to do the following: • Doing web development in F# • Binding JavaScript libraries for F# use • Developing a Win 8/Surface application in F# • Sneak preview of an online development environment that enables quick exploration and embedded applications • .. that makes data visualization easy and fun In this talk…
  • 6. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile 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#?
  • 7. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile 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
  • 8. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile Open source project, available at: https://bitbucket.org/IntelliFactory/websharper Dual licensed for closed source use Dedicated support – new features, bugfix releases WebSharper
  • 9. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile open IntelliFactory.WebSharper module Server = [<Rpc>] let MyServerFunction(...) = ... module Client = [<JavaScript>] let MyClientFunction(...) = ... let v = MyServerFunction(...) ... Bridging the language mismatch
  • 10. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile WebSharper sitelets • Type-safe • Composable • First-class Parameterized over a union type: type Action = | Home | Contact | Protected | Login of option<Action> | Logout | Echo of string Representing web applications as values
  • 11. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & MobileSitelets – 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<Page>(path) .With("body", fun x -> x.Body) let WithTemplate body : Content<Action> = Content.WithTemplate MainTemplate <| fun context -> { Body = body context }
  • 12. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile Composing web applications from smaller ones let EntireSite = let home = Sitelet.Content ... let authenticated = Sitelet.Protect filter <| ... let basic = Sitelet.Infer <| fun action -> ... Sitelet.Sum [ home authenticated basic ] Representing web applications as values
  • 13. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile Describing client-side APIs in F# via WebSharper Interface Generator (WIG) Binding JavaScript libraries
  • 14. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile namespace IntelliFactory.WebSharper.Facebook module Definition = ... let FB = Class "FB" |+> [ ... "login" => ... "getLoginStatus" => ... "api" => ... ] |> Requires [Res.FacebookAPI] let Assembly = Assembly [ Namespace "IntelliFactory.WebSharper.Facebook" [ ...; FB ] ... ] Binding JavaScript libraries
  • 15. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & MobileBinding JavaScript libraries Defining classes – useful operators let FlashHidingArgs = Class "FB.FlashHidingArgs" |+> Protocol [ "state" =? T<string> "elem" =? T<Element> ] =? : Member
  • 16. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & MobileBinding JavaScript libraries Defining optional members let InitOptions = Pattern.Config "FB.InitOptions" { Required = [] Optional = [ "appId", T<string> "cookie", T<bool> ... "hideFlashCallback", FlashHidingArgs ^-> T<unit> ] } • Typical in most JavaScript libraries • Used heavily in configuration objects
  • 17. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & MobileBinding 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
  • 18. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & MobileBinding JavaScript libraries eDSL to describe JavaScript APIs Type Provider for TypeScript definitions F# WebSharper extension TypeScript TypeScript Type Provider WebSharper extension
  • 19. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & MobileBinding JavaScript libraries Describing client-side APIs via TypeScript declarations
  • 20. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile Type Provider for TypeScript definitions type Facebook = IntelliFactory.TypeScript.Generator<"Facebook.d.ts"> Facebook.*** Binding JavaScript libraries
  • 21. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile An F#/WebSharper application using jQuery Mobile Total size: 150 LOC in F# My Facebook Wall for tablets
  • 22. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & MobileMy Facebook Wall for tablets WebSharper Facebook application showing wall posts • Using the Facebook bindings generated via WIG and TypeScript.
  • 23. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & MobileIntelliMath for WinRT/8
  • 24. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile An F#/WebSharper application using WinJS Size: 1100 LOC in F# IntelliMath for WinRT/8
  • 25. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile Promises type Promise<'T> = [<Inline "$this.then($f)">] member this.Then(f: 'T -> 'U) = X<Promise<'U>> [<Inline "$this.done($f)">] member this.Done(f: 'T -> unit) = () Binding WinJS
  • 26. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile module Application = [<Inline "WinJSSetOnActivated($f)">] let OnActivated(f: unit -> unit) = () module Local = [<Inline "WinJS.Application.local.exists($f)">] let Exists (f: string) = X<Promise<bool>> [<Inline "WinJS.Application.local.readText($f)">] let ReadText (f: string) = X<Promise<string>> ... Binding WinJS
  • 27. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile Going to TypeScript declarations or WIG is the full solution Binding WinJS
  • 28. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile [<JavaScript>] let rec (|Factor|_|) = function | NUMBER (n, rest) -> Some (Expr.Const (Const.Number n), rest) | ID ("x", rest) -> Some (Expr.Const Const.X, rest) | ID ("pi", rest) -> Some (Expr.Const Const.Pi, rest) | ID ("e", rest) -> Some (Expr.Const Const.E, rest) | LPAREN (Expression (e, RPAREN rest)) -> (e, rest) |> Some | _ -> None Parsing with active patterns
  • 29. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile /// Pixels on the screen [<Measure>] type px module Events = type Point = { x: int<px>; y: int<px> } [<Sealed>] type PointerPoint = [<Stub>] member this.pointerId = X<int> [<Stub>] member this.position = X<Point> Using units of measure
  • 30. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & MobileExtras
  • 31. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile Aggregates and catalogs FP content about: Q&A Events/Conferences Courses User Groups Blogs Jobs Developers etc… FPish.net
  • 32. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile • Full F# language support • Multi-project solutions • Web and mobile Apps • Syntax highlighting • On the fly type checking • Interactive exploration • Integration with data • Support for type providers CloudSharper
  • 33. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile Develop, deploy, and run full web and mobile applications with interactive programming CloudSharper
  • 34. itcampro@ itcamp13# Premium conference on Microsoft technologies Development & Mobile Video… CloudSharper
  • 35. itcampro@ itcamp13# Premium conference on Microsoft technologies Q & A Get in touch #granicz #websharper #fpishnet http://websharper.com http://intellifactory.com http://fpish.net http://www.facebook.com/intellifactory