SlideShare ist ein Scribd-Unternehmen logo
1 von 30
F# for Startups
Joel Grus
@joelgrus
Chief Scientist,
Hello!
• About me:
– Chief Scientist at VoloMetrix
http://www.volometrix.com
We’re hiring 
– Previously at Decide, Bing, Farecast
– Started using F# a little over a year ago, am an
enthusiast/addict but not an expert
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
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
– Immutable variables
– No side-effects
– First-class functions
– 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
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
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!
15
F# ( Bot) F# is a simple, succinct, efficient functional programming language for
.NET...
Igor Brejc RT @dsyme: If you're into open/cross-platform .NET, F# or C# but mainly use
windows, please read this testing/dev technique http://t.co/poTiUcSsXe
F# ( Bot) F# lets users concentrate on the problems they are solving rather than
getting lost in programming details.
Onorio Catenacci RT @cdrnet: Blog: Test your #csharp/#fsharp code on mono 3.0.10/debian
using #vagrant without leaving Windows: http://t.co/CtGnVn06Cd
…
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, modify my code to find
them!
• There are some good books out there: Expert F# and
F# Programming are two that I like
• Ask me, I know a few things

Weitere ähnliche Inhalte

Was ist angesagt?

Executable specifications for xtext
Executable specifications for xtextExecutable specifications for xtext
Executable specifications for xtext
meysholdt
 
Week10style
Week10styleWeek10style
Week10style
hccit
 
Exception handling.41
Exception handling.41Exception handling.41
Exception handling.41
myrajendra
 

Was ist angesagt? (20)

Kevin Whinnery: Write Better JavaScript
Kevin Whinnery: Write Better JavaScriptKevin Whinnery: Write Better JavaScript
Kevin Whinnery: Write Better JavaScript
 
PHP Annotations: They exist! - JetBrains Webinar
 PHP Annotations: They exist! - JetBrains Webinar PHP Annotations: They exist! - JetBrains Webinar
PHP Annotations: They exist! - JetBrains Webinar
 
Pigaios: A Tool for Diffing Source Codes against Binaries (Hacktivity 2018)
Pigaios: A Tool for Diffing Source Codes against Binaries (Hacktivity 2018)Pigaios: A Tool for Diffing Source Codes against Binaries (Hacktivity 2018)
Pigaios: A Tool for Diffing Source Codes against Binaries (Hacktivity 2018)
 
Training python (new Updated)
Training python (new Updated)Training python (new Updated)
Training python (new Updated)
 
Executable specifications for xtext
Executable specifications for xtextExecutable specifications for xtext
Executable specifications for xtext
 
MongoDB.local Berlin: How to add your favorite language to MongoDB Compass
MongoDB.local Berlin: How to add your favorite language to MongoDB CompassMongoDB.local Berlin: How to add your favorite language to MongoDB Compass
MongoDB.local Berlin: How to add your favorite language to MongoDB Compass
 
C# 8 e além
C# 8 e alémC# 8 e além
C# 8 e além
 
JetBrains MPS
JetBrains MPSJetBrains MPS
JetBrains MPS
 
Js tips & tricks
Js tips & tricksJs tips & tricks
Js tips & tricks
 
Using ANTLR on real example - convert "string combined" queries into paramete...
Using ANTLR on real example - convert "string combined" queries into paramete...Using ANTLR on real example - convert "string combined" queries into paramete...
Using ANTLR on real example - convert "string combined" queries into paramete...
 
Presentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStackPresentation of Python, Django, DockerStack
Presentation of Python, Django, DockerStack
 
Why I Love Python
Why I Love PythonWhy I Love Python
Why I Love Python
 
Week10style
Week10styleWeek10style
Week10style
 
Programming with Python: Week 1
Programming with Python: Week 1Programming with Python: Week 1
Programming with Python: Week 1
 
Survey on Script-based languages to write a Chatbot
Survey on Script-based languages to write a ChatbotSurvey on Script-based languages to write a Chatbot
Survey on Script-based languages to write a Chatbot
 
GDG Helwan Introduction to python
GDG Helwan Introduction to pythonGDG Helwan Introduction to python
GDG Helwan Introduction to python
 
Beginning Python Programming
Beginning Python ProgrammingBeginning Python Programming
Beginning Python Programming
 
Go for Rubyists. August 2018. RUG-B Meetup
Go for Rubyists. August 2018. RUG-B MeetupGo for Rubyists. August 2018. RUG-B Meetup
Go for Rubyists. August 2018. RUG-B Meetup
 
ANTLR4 and its testing
ANTLR4 and its testingANTLR4 and its testing
ANTLR4 and its testing
 
Exception handling.41
Exception handling.41Exception handling.41
Exception handling.41
 

Andere mochten auch

Andere mochten auch (10)

Tools for reading papers
Tools for reading papersTools for reading papers
Tools for reading papers
 
Functional linear data structures in f#
Functional linear data structures in f#Functional linear data structures in f#
Functional linear data structures in f#
 
T shirts, feminism, parenting, and data science
T shirts, feminism, parenting, and data scienceT shirts, feminism, parenting, and data science
T shirts, feminism, parenting, and data science
 
Alex Korbonits, "AUC at what costs?" Seattle DAML June 2016
Alex Korbonits, "AUC at what costs?" Seattle DAML June 2016Alex Korbonits, "AUC at what costs?" Seattle DAML June 2016
Alex Korbonits, "AUC at what costs?" Seattle DAML June 2016
 
The Road to Data Science - Joel Grus, June 2015
The Road to Data Science - Joel Grus, June 2015The Road to Data Science - Joel Grus, June 2015
The Road to Data Science - Joel Grus, June 2015
 
Swift vs. Language X
Swift vs. Language XSwift vs. Language X
Swift vs. Language X
 
Karin Strauss - DNA Storage, July 2016
Karin Strauss - DNA Storage, July 2016Karin Strauss - DNA Storage, July 2016
Karin Strauss - DNA Storage, July 2016
 
Numbers game
Numbers gameNumbers game
Numbers game
 
Secrets of Fire Truck Society - Slides for Ignite Strata 2013
Secrets of Fire Truck Society - Slides for Ignite Strata 2013Secrets of Fire Truck Society - Slides for Ignite Strata 2013
Secrets of Fire Truck Society - Slides for Ignite Strata 2013
 
Actor Clustering with Docker Containers and Akka.Net in F#
Actor Clustering with Docker Containers and Akka.Net in F#Actor Clustering with Docker Containers and Akka.Net in F#
Actor Clustering with Docker Containers and Akka.Net in F#
 

Ähnlich wie F# for startups

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
 
Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®
Hannes Lowette
 

Ähnlich wie F# for startups (20)

Static-Analysis-in-Industry.pptx
Static-Analysis-in-Industry.pptxStatic-Analysis-in-Industry.pptx
Static-Analysis-in-Industry.pptx
 
C# .NET - Um overview da linguagem
C# .NET - Um overview da linguagem C# .NET - Um overview da linguagem
C# .NET - Um overview da linguagem
 
The Final Frontier
The Final FrontierThe Final Frontier
The Final Frontier
 
Introduction to Python for Security Professionals
Introduction to Python for Security ProfessionalsIntroduction to Python for Security Professionals
Introduction to Python for Security Professionals
 
CPP02 - The Structure of a Program
CPP02 - The Structure of a ProgramCPP02 - The Structure of a Program
CPP02 - The Structure of a Program
 
Hack in the Box GSEC 2016 - Reverse Engineering Swift Applications
Hack in the Box GSEC 2016 - Reverse Engineering Swift ApplicationsHack in the Box GSEC 2016 - Reverse Engineering Swift Applications
Hack in the Box GSEC 2016 - Reverse Engineering Swift Applications
 
Rootcon X - Reverse Engineering Swift Applications
Rootcon X - Reverse Engineering Swift ApplicationsRootcon X - Reverse Engineering Swift Applications
Rootcon X - Reverse Engineering Swift Applications
 
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 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.....
 
C++ Basics
C++ BasicsC++ Basics
C++ Basics
 
Metaprogramming Go
Metaprogramming GoMetaprogramming Go
Metaprogramming Go
 
Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®
 
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#
 
Class_X_PYTHON_J.pdf
Class_X_PYTHON_J.pdfClass_X_PYTHON_J.pdf
Class_X_PYTHON_J.pdf
 
Why Plone Will Die
Why Plone Will DieWhy Plone Will Die
Why Plone Will Die
 
Understanding Typing. Understanding Ruby.
Understanding Typing. Understanding Ruby.Understanding Typing. Understanding Ruby.
Understanding Typing. Understanding Ruby.
 
Getting started-php unit
Getting started-php unitGetting started-php unit
Getting started-php unit
 
Austin Python Learners Meetup - Everything you need to know about programming...
Austin Python Learners Meetup - Everything you need to know about programming...Austin Python Learners Meetup - Everything you need to know about programming...
Austin Python Learners Meetup - Everything you need to know about programming...
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

F# for startups

  • 1. F# for Startups Joel Grus @joelgrus Chief Scientist,
  • 2. Hello! • About me: – Chief Scientist at VoloMetrix http://www.volometrix.com We’re hiring  – Previously at Decide, Bing, Farecast – Started using F# a little over a year ago, am an enthusiast/addict but not an expert
  • 3. 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/
  • 4. 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
  • 5. 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/
  • 6. Functional Programming • Is fun! • No single definition, but some combo of – Immutable variables – No side-effects – First-class functions – Lazy evaluation
  • 7. 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
  • 8. 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
  • 9. 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)
  • 10. Combinators • |> pipes values into functions Take the array [1,2,3] Send it through an “even filter” Send that to a length function
  • 11. Tuples • Easy way of creating compound types
  • 12. 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
  • 13. 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
  • 14. Contrived Example – Discriminated Unions • In F# would do the following: • Punchline: F# version is cleaner and safer
  • 15. 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”
  • 17. Types for Business Logic Given a meeting, how many Invitees accepted? How many Invitees were anonymous? val NumAccepts : m:Meeting -> int
  • 18. 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
  • 19. 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!
  • 20. Discriminated Unions for Business Logic • Punchline: – Types make business logic simple to implement – First-class functions make abstraction and refactoring quick and easy
  • 21. Contrived Example – ValueOrDefault • Want to get a value out of a dictionary, or a default if the key’s not there
  • 22. Contrived Example - ValueOrDefault • What if we want it generic?
  • 23. 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)
  • 24. Fun Example – JSON Type Provider • Want to get tweets in a lightweight way • Sounds like a job for Python! 15 F# ( Bot) F# is a simple, succinct, efficient functional programming language for .NET... Igor Brejc RT @dsyme: If you're into open/cross-platform .NET, F# or C# but mainly use windows, please read this testing/dev technique http://t.co/poTiUcSsXe F# ( Bot) F# lets users concentrate on the problems they are solving rather than getting lost in programming details. Onorio Catenacci RT @cdrnet: Blog: Test your #csharp/#fsharp code on mono 3.0.10/debian using #vagrant without leaving Windows: http://t.co/CtGnVn06Cd …
  • 25. Fun Example – JSON Type Provider Or for F#!
  • 26. 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
  • 27. Useful Example – SQL Type Provider This was the most generic database schema I could think of!
  • 28. 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
  • 29. 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!
  • 30. 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, modify my code to find them! • There are some good books out there: Expert F# and F# Programming are two that I like • Ask me, I know a few things

Hinweis der Redaktion

  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