SlideShare a Scribd company logo
F# for Startups
Joel Grus
@joelgrus
Chief Scientist,
Hello!
• About me:
– Chief Scientist at VoloMetrix
– Previously at Decide, Bing, Farecast
– Started using F# a little over a year ago, am an
enthusiast/addict but not an expert
– Also write a lot of Python, a fair amount of
JavaScript, and a tiny amount of Clojure
VoloMetrix
“Social Enterprise Intelligence”
• Analyze email and calendar data to learn
– Who’s connected to whom, and
– Where is people’s time going
• In order to help them do their jobs better!
• http://www.volometrix.com
• We’re hiring 
What is F#?
F# is a succinct, expressive, and
efficient functional and object-
oriented language for Microsoft .NET
that helps you write simple code to
solve complex problems.
http://research.microsoft.com/en-us/projects/fsharp/
My F# Journey
• Once upon a time the VoloMetrix application
back-end was written entirely in C#
• One day I used Ruby (ick!) to prototype very
“functional” (and slow) analytics platform
• Feel was very F#-y, so started learning and
porting
• Can develop in F# a lot faster than in C#
• Can develop in F# a lot happier than in C#
• Today application is a mix of F# and C# projects
– Analytics mostly written in F#
– Plumbing mostly written in C#
Some nice things about F#
• Conciseness
– Whitespace formatting
– Type inference
• Convenience
– First-class functions
– Interactive shell
• Correctness
– No NULLs (in the normal course of things)
– Immutable values
• Concurrency
– I don’t typically use this, so I’m not going to talk about it!
• Completeness
– Access to .NET libraries + Visual Studio
– Can mutate/iterate when necessary
I stole this list from http://fsharpforfunandprofit.com/
Functional Programming
• Is fun!
• No single definition, but some combo of
– First-class functions
– Immutable variables
– No side-effects
– Lazy evaluation
F# Basics
• Type inference
• Functions
• Combinators
• Tuples
Goal is not to teach you F# tonight, but to prime your
brains so that my examples sort of make sense
Type Inference
• F# is strictly typed, but usually you don’t have
to tell it the types
It figures them out like magic!
• If you need to specify types, they go after
val f : x:int -> int
val g : x:float -> float
val h : x:string -> string
Functions
• Functions are just objects
• Anonymous functions are easy too
val applyTwice : f:('a -> 'a) -> x:'a -> 'a
val square : x:int -> int
val fourthPower : (int -> int)
Combinators
• |> pipes values into functions
• Easy to build elaborate data-processing
pipelines
• (Which are difficult to debug)
Take the array [1,2,3] Send it through an “even filter” Send that to a length function
Tuples
• Easy way of creating compound types
• Available (but wordier + less common) in C#
– var pair = new Tuple<int,string>(1,”1”)
Let’s Do Some Examples
Punchline will always be some variation of
“Hey, look how clean and safe and simple my code is
and how fast I wrote it!”
Every one of these things is nice in a start-up
Contrived Example – Discriminated Unions
• Imagine we had no bool type
• Could define one in C# using an enum:
Definition is simple
enough
You’d hope we’d
never get here
This can’t end well
Contrived Example – Discriminated Unions
• In F# would do the following:
• Punchline: F# version is cleaner and safer
Types for Business Logic
• Want to represent “meetings”
• A meeting has
– Start Date
– End Date
– Subject
– Invitees
• Each invitee is a Person, and a Response
• A Person can be have a Name or be Anonymous
• A Response can be “Accept” or “Decline”
Types for Business Logic
Types for Business Logic
Given a meeting, how many Invitees accepted?
How many Invitees were anonymous?
val NumAccepts : m:Meeting -> int
Discriminated Unions for Business Logic
Given a meeting, how many Invitees accepted?
How many Invitees were anonymous?
What can we factor out?
val CountInvitees : predicate:(Invitee -> bool) -> m:Meeting -> int
Discriminated Unions for Business Logic
Given a meeting, how many Invitees accepted?
How many Invitees were anonymous?
val NumAccepts2 : m:Meeting -> int
val NumAccepts3 : m:Meeting -> int
Use currying!
Discriminated Unions for Business Logic
• Punchline:
– Types make business logic simple to implement
– First-class functions make abstraction and
refactoring quick and easy
Contrived Example – ValueOrDefault
• Want to get a value out of a dictionary, or a
default if the key’s not there
Contrived Example - ValueOrDefault
• What if we want it generic?
Contrived Example - ValueOrDefault
• Same code in F#
Don’t have to specify types to
use generic!
val ValueOrDefault : dict:Dictionary<'a,'b> -> key:'a -> defaultValue:'b -> 'b
Punchline: Takes less code than C#, is more
readable (for me)
Fun Example – JSON Type Provider
• Want to get tweets in a lightweight way
• Sounds like a job for Python!
Fun Example – JSON Type Provider
Or for F#!
Fun Example – JSON Type Provider
• Punchline
– Easy to bang out really quick prototypes
– Get flexibility of a scripting language like Python
but with type safety
– .NET integration means easy to build your
prototypes into full-fledged applications
Useful Example – SQL Type Provider
This was the most generic database schema I could think of!
Useful Example – SQL Type Provider
• Punchline: Get to work with typed database
objects for free, great for complex analytics
(or external libraries) with no SQL equivalent
F# is not Perfect
• Life is dull without NullReferenceException
• Tooling is not on par with C#
• Hard to organize projects, file order matters
• Everyone knows C#, no one knows F#
• P(zealot | knows F#) is very high!
• Your code will be so unexpectedly good that
people will mistake you for some sort of guru
and then invite you to give talks that are way
outside of your comfort zone!
Resources
• http://www.tryfsharp.org/
• http://fsharp.org
• http://fsharpforfunandprofit.com/
• http://en.wikibooks.org/wiki/F_Sharp_Programming
• Lots of F# people on Twitter
• There are some good books out there: Expert F# and
F# Programming are two that I like
• Ask me, I know a few things

More Related Content

Similar to F# for startups v2

F# for startups
F# for startupsF# for startups
F# for startups
joelgrus
 
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Skills Matter
 
The Final Frontier
The Final FrontierThe Final Frontier
The Final Frontier
jClarity
 
C# .NET - Um overview da linguagem
C# .NET - Um overview da linguagem C# .NET - Um overview da linguagem
C# .NET - Um overview da linguagem
Claudson Oliveira
 
"Introduction to F#" - South Dakota Code Camp, November 5, 2011
"Introduction to F#" - South Dakota Code Camp, November 5, 2011"Introduction to F#" - South Dakota Code Camp, November 5, 2011
"Introduction to F#" - South Dakota Code Camp, November 5, 2011
Blend Interactive
 
Give A Great Tech Talk 2013
Give A Great Tech Talk 2013Give A Great Tech Talk 2013
Give A Great Tech Talk 2013
PostgreSQL Experts, Inc.
 
CPP02 - The Structure of a Program
CPP02 - The Structure of a ProgramCPP02 - The Structure of a Program
CPP02 - The Structure of a Program
Michael Heron
 
Preparing for a technical interview
Preparing for a technical interviewPreparing for a technical interview
Preparing for a technical interview
pocketgems
 
Tips to Kick-start your Software Engineering Career
Tips to Kick-start your Software Engineering CareerTips to Kick-start your Software Engineering Career
Tips to Kick-start your Software Engineering Career
Ferdous Mahmud Shaon
 
Introduction to Functional Programming and Clojure
Introduction to Functional Programming and ClojureIntroduction to Functional Programming and Clojure
Introduction to Functional Programming and Clojure
Soumendra Daas
 
Tips to kick-start your Software Engineering Career - Ferdous Mahmud Shaon
Tips to kick-start your Software Engineering Career - Ferdous Mahmud ShaonTips to kick-start your Software Engineering Career - Ferdous Mahmud Shaon
Tips to kick-start your Software Engineering Career - Ferdous Mahmud Shaon
Cefalo
 
Break Free with Managed Functional Programming: An Introduction to F#
Break Free with Managed Functional Programming: An Introduction to F#Break Free with Managed Functional Programming: An Introduction to F#
Break Free with Managed Functional Programming: An Introduction to F#
IndyMobileNetDev
 
Break Free with Managed Functional Programming: An Introduction to F#
Break Free with Managed Functional Programming: An Introduction to F#Break Free with Managed Functional Programming: An Introduction to F#
Break Free with Managed Functional Programming: An Introduction to F#
Dave Fancher
 
Write a better FM
Write a better FMWrite a better FM
Write a better FM
Rich Bowen
 
Metaprogramming Go
Metaprogramming GoMetaprogramming Go
Metaprogramming Go
Weng Wei
 
Perl5 meta programming
Perl5 meta programmingPerl5 meta programming
Perl5 meta programming
karupanerura
 
Recon-Fu @BsidesKyiv 2016
Recon-Fu @BsidesKyiv 2016Recon-Fu @BsidesKyiv 2016
Recon-Fu @BsidesKyiv 2016
Vlad Styran
 
The best system for object-oriented thinking
The best system for object-oriented thinkingThe best system for object-oriented thinking
The best system for object-oriented thinking
Pharo
 
How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....
Mike Harris
 
Developing mobile apps with f sharp
Developing mobile apps with f sharpDeveloping mobile apps with f sharp
Developing mobile apps with f sharp
Gustavo Guerra
 

Similar to F# for startups v2 (20)

F# for startups
F# for startupsF# for startups
F# for startups
 
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
 
The Final Frontier
The Final FrontierThe Final Frontier
The Final Frontier
 
C# .NET - Um overview da linguagem
C# .NET - Um overview da linguagem C# .NET - Um overview da linguagem
C# .NET - Um overview da linguagem
 
"Introduction to F#" - South Dakota Code Camp, November 5, 2011
"Introduction to F#" - South Dakota Code Camp, November 5, 2011"Introduction to F#" - South Dakota Code Camp, November 5, 2011
"Introduction to F#" - South Dakota Code Camp, November 5, 2011
 
Give A Great Tech Talk 2013
Give A Great Tech Talk 2013Give A Great Tech Talk 2013
Give A Great Tech Talk 2013
 
CPP02 - The Structure of a Program
CPP02 - The Structure of a ProgramCPP02 - The Structure of a Program
CPP02 - The Structure of a Program
 
Preparing for a technical interview
Preparing for a technical interviewPreparing for a technical interview
Preparing for a technical interview
 
Tips to Kick-start your Software Engineering Career
Tips to Kick-start your Software Engineering CareerTips to Kick-start your Software Engineering Career
Tips to Kick-start your Software Engineering Career
 
Introduction to Functional Programming and Clojure
Introduction to Functional Programming and ClojureIntroduction to Functional Programming and Clojure
Introduction to Functional Programming and Clojure
 
Tips to kick-start your Software Engineering Career - Ferdous Mahmud Shaon
Tips to kick-start your Software Engineering Career - Ferdous Mahmud ShaonTips to kick-start your Software Engineering Career - Ferdous Mahmud Shaon
Tips to kick-start your Software Engineering Career - Ferdous Mahmud Shaon
 
Break Free with Managed Functional Programming: An Introduction to F#
Break Free with Managed Functional Programming: An Introduction to F#Break Free with Managed Functional Programming: An Introduction to F#
Break Free with Managed Functional Programming: An Introduction to F#
 
Break Free with Managed Functional Programming: An Introduction to F#
Break Free with Managed Functional Programming: An Introduction to F#Break Free with Managed Functional Programming: An Introduction to F#
Break Free with Managed Functional Programming: An Introduction to F#
 
Write a better FM
Write a better FMWrite a better FM
Write a better FM
 
Metaprogramming Go
Metaprogramming GoMetaprogramming Go
Metaprogramming Go
 
Perl5 meta programming
Perl5 meta programmingPerl5 meta programming
Perl5 meta programming
 
Recon-Fu @BsidesKyiv 2016
Recon-Fu @BsidesKyiv 2016Recon-Fu @BsidesKyiv 2016
Recon-Fu @BsidesKyiv 2016
 
The best system for object-oriented thinking
The best system for object-oriented thinkingThe best system for object-oriented thinking
The best system for object-oriented thinking
 
How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....
 
Developing mobile apps with f sharp
Developing mobile apps with f sharpDeveloping mobile apps with f sharp
Developing mobile apps with f sharp
 

Recently uploaded

The Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF GuideThe Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF Guide
Shiv Technolabs
 
(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
Priyanka Aash
 
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-InTrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc
 
(CISOPlatform Summit & SACON 2024) Orientation by CISO Platform_ Using CISO P...
(CISOPlatform Summit & SACON 2024) Orientation by CISO Platform_ Using CISO P...(CISOPlatform Summit & SACON 2024) Orientation by CISO Platform_ Using CISO P...
(CISOPlatform Summit & SACON 2024) Orientation by CISO Platform_ Using CISO P...
Priyanka Aash
 
Introduction-to-the-IAM-Platform-Implementation-Plan.pptx
Introduction-to-the-IAM-Platform-Implementation-Plan.pptxIntroduction-to-the-IAM-Platform-Implementation-Plan.pptx
Introduction-to-the-IAM-Platform-Implementation-Plan.pptx
313mohammedarshad
 
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
aslasdfmkhan4750
 
WhatsApp Spy Online Trackers and Monitoring Apps
WhatsApp Spy Online Trackers and Monitoring AppsWhatsApp Spy Online Trackers and Monitoring Apps
WhatsApp Spy Online Trackers and Monitoring Apps
HackersList
 
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes..."Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
Anant Gupta
 
Vertex AI Agent Builder - GDG Alicante - Julio 2024
Vertex AI Agent Builder - GDG Alicante - Julio 2024Vertex AI Agent Builder - GDG Alicante - Julio 2024
Vertex AI Agent Builder - GDG Alicante - Julio 2024
Nicolás Lopéz
 
Computer HARDWARE presenattion by CWD students class 10
Computer HARDWARE presenattion by CWD students class 10Computer HARDWARE presenattion by CWD students class 10
Computer HARDWARE presenattion by CWD students class 10
ankush9927
 
Acumatica vs. Sage Intacct _Construction_July (1).pptx
Acumatica vs. Sage Intacct _Construction_July (1).pptxAcumatica vs. Sage Intacct _Construction_July (1).pptx
Acumatica vs. Sage Intacct _Construction_July (1).pptx
BrainSell Technologies
 
Tailored CRM Software Development for Enhanced Customer Insights
Tailored CRM Software Development for Enhanced Customer InsightsTailored CRM Software Development for Enhanced Customer Insights
Tailored CRM Software Development for Enhanced Customer Insights
SynapseIndia
 
Feature sql server terbaru performance.pptx
Feature sql server terbaru performance.pptxFeature sql server terbaru performance.pptx
Feature sql server terbaru performance.pptx
ssuser1915fe1
 
Data Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining DataData Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining Data
Safe Software
 
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptxUse Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
SynapseIndia
 
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdfAcumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
BrainSell Technologies
 
(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf
(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf
(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf
Priyanka Aash
 
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
sunilverma7884
 
Connector Corner: Leveraging Snowflake Integration for Smarter Decision Making
Connector Corner: Leveraging Snowflake Integration for Smarter Decision MakingConnector Corner: Leveraging Snowflake Integration for Smarter Decision Making
Connector Corner: Leveraging Snowflake Integration for Smarter Decision Making
DianaGray10
 
Opencast Summit 2024 — Opencast @ University of Münster
Opencast Summit 2024 — Opencast @ University of MünsterOpencast Summit 2024 — Opencast @ University of Münster
Opencast Summit 2024 — Opencast @ University of Münster
Matthias Neugebauer
 

Recently uploaded (20)

The Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF GuideThe Role of IoT in Australian Mobile App Development - PDF Guide
The Role of IoT in Australian Mobile App Development - PDF Guide
 
(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
 
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-InTrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
TrustArc Webinar - 2024 Data Privacy Trends: A Mid-Year Check-In
 
(CISOPlatform Summit & SACON 2024) Orientation by CISO Platform_ Using CISO P...
(CISOPlatform Summit & SACON 2024) Orientation by CISO Platform_ Using CISO P...(CISOPlatform Summit & SACON 2024) Orientation by CISO Platform_ Using CISO P...
(CISOPlatform Summit & SACON 2024) Orientation by CISO Platform_ Using CISO P...
 
Introduction-to-the-IAM-Platform-Implementation-Plan.pptx
Introduction-to-the-IAM-Platform-Implementation-Plan.pptxIntroduction-to-the-IAM-Platform-Implementation-Plan.pptx
Introduction-to-the-IAM-Platform-Implementation-Plan.pptx
 
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
 
WhatsApp Spy Online Trackers and Monitoring Apps
WhatsApp Spy Online Trackers and Monitoring AppsWhatsApp Spy Online Trackers and Monitoring Apps
WhatsApp Spy Online Trackers and Monitoring Apps
 
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes..."Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
 
Vertex AI Agent Builder - GDG Alicante - Julio 2024
Vertex AI Agent Builder - GDG Alicante - Julio 2024Vertex AI Agent Builder - GDG Alicante - Julio 2024
Vertex AI Agent Builder - GDG Alicante - Julio 2024
 
Computer HARDWARE presenattion by CWD students class 10
Computer HARDWARE presenattion by CWD students class 10Computer HARDWARE presenattion by CWD students class 10
Computer HARDWARE presenattion by CWD students class 10
 
Acumatica vs. Sage Intacct _Construction_July (1).pptx
Acumatica vs. Sage Intacct _Construction_July (1).pptxAcumatica vs. Sage Intacct _Construction_July (1).pptx
Acumatica vs. Sage Intacct _Construction_July (1).pptx
 
Tailored CRM Software Development for Enhanced Customer Insights
Tailored CRM Software Development for Enhanced Customer InsightsTailored CRM Software Development for Enhanced Customer Insights
Tailored CRM Software Development for Enhanced Customer Insights
 
Feature sql server terbaru performance.pptx
Feature sql server terbaru performance.pptxFeature sql server terbaru performance.pptx
Feature sql server terbaru performance.pptx
 
Data Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining DataData Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining Data
 
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptxUse Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
 
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdfAcumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
 
(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf
(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf
(CISOPlatform Summit & SACON 2024) Gen AI & Deepfake In Overall Security.pdf
 
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
 
Connector Corner: Leveraging Snowflake Integration for Smarter Decision Making
Connector Corner: Leveraging Snowflake Integration for Smarter Decision MakingConnector Corner: Leveraging Snowflake Integration for Smarter Decision Making
Connector Corner: Leveraging Snowflake Integration for Smarter Decision Making
 
Opencast Summit 2024 — Opencast @ University of Münster
Opencast Summit 2024 — Opencast @ University of MünsterOpencast Summit 2024 — Opencast @ University of Münster
Opencast Summit 2024 — Opencast @ University of Münster
 

F# for startups v2

  • 1. F# for Startups Joel Grus @joelgrus Chief Scientist,
  • 2. Hello! • About me: – Chief Scientist at VoloMetrix – Previously at Decide, Bing, Farecast – Started using F# a little over a year ago, am an enthusiast/addict but not an expert – Also write a lot of Python, a fair amount of JavaScript, and a tiny amount of Clojure
  • 3. VoloMetrix “Social Enterprise Intelligence” • Analyze email and calendar data to learn – Who’s connected to whom, and – Where is people’s time going • In order to help them do their jobs better! • http://www.volometrix.com • We’re hiring 
  • 4. What is F#? F# is a succinct, expressive, and efficient functional and object- oriented language for Microsoft .NET that helps you write simple code to solve complex problems. http://research.microsoft.com/en-us/projects/fsharp/
  • 5. My F# Journey • Once upon a time the VoloMetrix application back-end was written entirely in C# • One day I used Ruby (ick!) to prototype very “functional” (and slow) analytics platform • Feel was very F#-y, so started learning and porting • Can develop in F# a lot faster than in C# • Can develop in F# a lot happier than in C# • Today application is a mix of F# and C# projects – Analytics mostly written in F# – Plumbing mostly written in C#
  • 6. Some nice things about F# • Conciseness – Whitespace formatting – Type inference • Convenience – First-class functions – Interactive shell • Correctness – No NULLs (in the normal course of things) – Immutable values • Concurrency – I don’t typically use this, so I’m not going to talk about it! • Completeness – Access to .NET libraries + Visual Studio – Can mutate/iterate when necessary I stole this list from http://fsharpforfunandprofit.com/
  • 7. Functional Programming • Is fun! • No single definition, but some combo of – First-class functions – Immutable variables – No side-effects – Lazy evaluation
  • 8. F# Basics • Type inference • Functions • Combinators • Tuples Goal is not to teach you F# tonight, but to prime your brains so that my examples sort of make sense
  • 9. Type Inference • F# is strictly typed, but usually you don’t have to tell it the types It figures them out like magic! • If you need to specify types, they go after val f : x:int -> int val g : x:float -> float val h : x:string -> string
  • 10. Functions • Functions are just objects • Anonymous functions are easy too val applyTwice : f:('a -> 'a) -> x:'a -> 'a val square : x:int -> int val fourthPower : (int -> int)
  • 11. Combinators • |> pipes values into functions • Easy to build elaborate data-processing pipelines • (Which are difficult to debug) Take the array [1,2,3] Send it through an “even filter” Send that to a length function
  • 12. Tuples • Easy way of creating compound types • Available (but wordier + less common) in C# – var pair = new Tuple<int,string>(1,”1”)
  • 13. Let’s Do Some Examples Punchline will always be some variation of “Hey, look how clean and safe and simple my code is and how fast I wrote it!” Every one of these things is nice in a start-up
  • 14. Contrived Example – Discriminated Unions • Imagine we had no bool type • Could define one in C# using an enum: Definition is simple enough You’d hope we’d never get here This can’t end well
  • 15. Contrived Example – Discriminated Unions • In F# would do the following: • Punchline: F# version is cleaner and safer
  • 16. Types for Business Logic • Want to represent “meetings” • A meeting has – Start Date – End Date – Subject – Invitees • Each invitee is a Person, and a Response • A Person can be have a Name or be Anonymous • A Response can be “Accept” or “Decline”
  • 18. Types for Business Logic Given a meeting, how many Invitees accepted? How many Invitees were anonymous? val NumAccepts : m:Meeting -> int
  • 19. Discriminated Unions for Business Logic Given a meeting, how many Invitees accepted? How many Invitees were anonymous? What can we factor out? val CountInvitees : predicate:(Invitee -> bool) -> m:Meeting -> int
  • 20. Discriminated Unions for Business Logic Given a meeting, how many Invitees accepted? How many Invitees were anonymous? val NumAccepts2 : m:Meeting -> int val NumAccepts3 : m:Meeting -> int Use currying!
  • 21. Discriminated Unions for Business Logic • Punchline: – Types make business logic simple to implement – First-class functions make abstraction and refactoring quick and easy
  • 22. Contrived Example – ValueOrDefault • Want to get a value out of a dictionary, or a default if the key’s not there
  • 23. Contrived Example - ValueOrDefault • What if we want it generic?
  • 24. Contrived Example - ValueOrDefault • Same code in F# Don’t have to specify types to use generic! val ValueOrDefault : dict:Dictionary<'a,'b> -> key:'a -> defaultValue:'b -> 'b Punchline: Takes less code than C#, is more readable (for me)
  • 25. Fun Example – JSON Type Provider • Want to get tweets in a lightweight way • Sounds like a job for Python!
  • 26. Fun Example – JSON Type Provider Or for F#!
  • 27. Fun Example – JSON Type Provider • Punchline – Easy to bang out really quick prototypes – Get flexibility of a scripting language like Python but with type safety – .NET integration means easy to build your prototypes into full-fledged applications
  • 28. Useful Example – SQL Type Provider This was the most generic database schema I could think of!
  • 29. Useful Example – SQL Type Provider • Punchline: Get to work with typed database objects for free, great for complex analytics (or external libraries) with no SQL equivalent
  • 30. F# is not Perfect • Life is dull without NullReferenceException • Tooling is not on par with C# • Hard to organize projects, file order matters • Everyone knows C#, no one knows F# • P(zealot | knows F#) is very high! • Your code will be so unexpectedly good that people will mistake you for some sort of guru and then invite you to give talks that are way outside of your comfort zone!
  • 31. Resources • http://www.tryfsharp.org/ • http://fsharp.org • http://fsharpforfunandprofit.com/ • http://en.wikibooks.org/wiki/F_Sharp_Programming • Lots of F# people on Twitter • There are some good books out there: Expert F# and F# Programming are two that I like • Ask me, I know a few things

Editor's Notes

  1. currying
  2. Sequence expressions
  3. Anonymous Functions, Pattern Matching, Type Inference
  4. Static v dynamic typing
  5. Explain what the type provider does
  6. Explain what the type provider does
  7. More about sequence expressions, group by, IQueryable