SlideShare una empresa de Scribd logo
1 de 32
Turning to the Functional side(Using C# and F#) Phil Trelford http://trelford.com/blog@ptrelford Tomas Petricek http://tomasp.net/blog@tomaspetricek
About Us Tomas  Author of F# book for C# programmers Worked with the F# team at Microsoft First blogged about F# in May 2006 Phil  Software Developer and Architect Worked on first F# applications at Microsoft Co-organizer of London F# User Group
Tutorial Goals Introduce Functional Concepts with F# and C# Non-goals Provide in-depth understanding Mass conversion to functional programming cult Sell books
Jargon Buster OO = Object Orientated FP = Functional Programming Lambda = Anonymous Function DSL = Domain Specific Language
Thoughtworks Technology Radar 2011
Languages circa 2010
Languages go multi-paradigm
F# is a mix of
What is F#? F# is multi-paradigm language, that is: Functional Declarative Object Orientated Imperative .Net language with VS integration
Running F# Visual Studio 2010 Visual Studio Shell + F#  MonoDevelop on Linux and Mac F# Compiler + Emacs etc. In your browser
FP hits mainstream Visual Studio gets F# C# gets LINQ, lambdas, etc C++ gets lambdas JVM gets Clojure & Scala
Writing queries with LINQ Query syntax supported in C# 3.0 Functional programming concepts Declaratively describes “what” not “how” Written as single expression varq= frompindb.Products wherep.UnitPrice>75.0M selectString.Format("{0} - ${1}",  p.ProductName, p.UnitPrice);
Graphical User Interface Frameworks XUL (Mozilla), Glade (Gtk), XAML (.NET) Functional programming concepts Compose button with ellipse inside Specify behavior declaratively <Buttonx:Name="greenBtn" Background="Black">   <EllipseWidth="75"Height="75" Fill="LightGreen" /> </Button> <DoubleAnimationStoryboard.TargetName="greenBtn" Storyboard.TargetProperty="(Canvas.Left)"     From="0.0"To="100.0"Duration="0:0:5" />
Specifying financial contracts in F# Functional programming concepts Declaratively describes “what” not “how” Written as single expression Composed from small number of primitives letmarch day = DateTime(2011, 3, day) letitTrades =   (sell (tradeAt(march15) "GOOG"500)) $   (between (march10) (march19) (trade"MSFT"1000)) lettradeAtdatewhatamount = between datedate (trade whatamount)
Code Samples 1: // Declare a local value (inferred type is string) 2: letworld="world" 3:  4: // Using '%s' format specifier to include string parameter 5: printfn"Hello %s!"world  
Functional data structures A way of thinking about problems Model data using composition of primitives Tuple    Combine two values of different types Discriminated Union    Represents one of several options List    Zero or more values of the same type
Tuples: Containers for a few different things
Discriminated Unions: Exclusive alternatives
Representing event schedule Object-oriented way Easy to add new cases Hard to add new functions Functional way Easy to add new functions Hard to add new cases Good thing about F# and Scala– you can use both!
List: Heads and Tails
Map Reduce MapReduce is a patented software framework introduced by Google to support distributed computing on large data sets on clusters of computers. Functional design scales extremely well!
Domain Modelling Retail Domain -> Testing
Checkout application workflow Think of a simple while loop Implement… Mutable field to keep the state and event handlers? Asynchronous while loop in F#
Asynchronous and concurrent programming Asynchronous GUI in Checkout example Single-threaded thanks to Async.StartImmediate Easy way to encode control flow Parallel programming Workflows are non-blocking computations Run workflows in parallel with Async.Parallel Concurrent programming Compose application from (thousands of) agents Agents communicate using messages
Wild Card Filler Silverlight mini-samples
Summary FP is already in the mainstream FP languages are ready Start small, go big Language Orientated Programming Exploratory and Scripting Asynchronous & Concurrency Technical Computing Testing
Summary Don’t underestimate  the power of the  functional side
Meet the F#ers
F# Books
On the horizon Next Meet: In the brain of  Rob Pickering on March 16th
Q & A http://Fsharp.net http://fssnip.net http://tomasp.net/blog http://trelford.com/blog

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Effective Data Analysis with Deedle
Effective Data Analysis with DeedleEffective Data Analysis with Deedle
Effective Data Analysis with Deedle
 
Dmitry mozorov on code quotations code as-data for f#
Dmitry mozorov on code quotations code as-data for f#Dmitry mozorov on code quotations code as-data for f#
Dmitry mozorov on code quotations code as-data for f#
 
F# for functional enthusiasts
F# for functional enthusiastsF# for functional enthusiasts
F# for functional enthusiasts
 
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 ...
 
Data analysis with R and Julia
Data analysis with R and JuliaData analysis with R and Julia
Data analysis with R and Julia
 
F# in MonoDevelop
F# in MonoDevelopF# in MonoDevelop
F# in MonoDevelop
 
C vs c++
C vs c++C vs c++
C vs c++
 
Have you met Julia?
Have you met Julia?Have you met Julia?
Have you met Julia?
 
F# Type Providers in Depth
F# Type Providers in DepthF# Type Providers in Depth
F# Type Providers in Depth
 
Lecture 2 lisp-Overview
Lecture 2 lisp-OverviewLecture 2 lisp-Overview
Lecture 2 lisp-Overview
 
basics of c++
basics of c++basics of c++
basics of c++
 
Introduction to Rstudio
Introduction to RstudioIntroduction to Rstudio
Introduction to Rstudio
 
Create Your Own Language
Create Your Own LanguageCreate Your Own Language
Create Your Own Language
 
Swift vs. Language X
Swift vs. Language XSwift vs. Language X
Swift vs. Language X
 
LIL Presentation
LIL PresentationLIL Presentation
LIL Presentation
 
C & C++ Training in Ambala ! BATRA COMPUTER CENTRE
C & C++ Training in Ambala ! BATRA COMPUTER CENTREC & C++ Training in Ambala ! BATRA COMPUTER CENTRE
C & C++ Training in Ambala ! BATRA COMPUTER CENTRE
 
R language
R languageR language
R language
 
Fun with java 8
Fun with java 8Fun with java 8
Fun with java 8
 
C++ questions and answers
C++ questions and answersC++ questions and answers
C++ questions and answers
 
R language
R languageR language
R language
 

Destacado

Queries in general purpose languages
Queries in general purpose languagesQueries in general purpose languages
Queries in general purpose languages
Tomas Petricek
 

Destacado (8)

Presentation Earth Saver Canvas Bags
Presentation Earth Saver Canvas BagsPresentation Earth Saver Canvas Bags
Presentation Earth Saver Canvas Bags
 
Tics
TicsTics
Tics
 
Docase notation for Haskell
Docase notation for HaskellDocase notation for Haskell
Docase notation for Haskell
 
Doing data science with F#
Doing data science with F#Doing data science with F#
Doing data science with F#
 
Queries in general purpose languages
Queries in general purpose languagesQueries in general purpose languages
Queries in general purpose languages
 
F# on the Server-Side
F# on the Server-SideF# on the Server-Side
F# on the Server-Side
 
Academia
AcademiaAcademia
Academia
 
Social Media in Small Business is Anything But Small
Social Media in Small Business is Anything But SmallSocial Media in Small Business is Anything But Small
Social Media in Small Business is Anything But Small
 

Similar a F# Tutorial @ QCon

Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010
Satish Verma
 
Exploring SharePoint with F#
Exploring SharePoint with F#Exploring SharePoint with F#
Exploring SharePoint with F#
Talbott Crowell
 
Procedural Programming Of Programming Languages
Procedural Programming Of Programming LanguagesProcedural Programming Of Programming Languages
Procedural Programming Of Programming Languages
Tammy Moncrief
 

Similar a F# Tutorial @ QCon (20)

Bay NET Aug 19 2009 presentation ppt
Bay  NET Aug 19 2009 presentation pptBay  NET Aug 19 2009 presentation ppt
Bay NET Aug 19 2009 presentation ppt
 
Introduction to F#
Introduction to F#Introduction to F#
Introduction to F#
 
Practical F#
Practical F#Practical F#
Practical F#
 
Progressive f# tutorials nyc don syme on keynote f# in the open source world
Progressive f# tutorials nyc don syme on keynote f# in the open source worldProgressive f# tutorials nyc don syme on keynote f# in the open source world
Progressive f# tutorials nyc don syme on keynote f# in the open source world
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010
 
F# 101
F# 101F# 101
F# 101
 
Exploring SharePoint with F#
Exploring SharePoint with F#Exploring SharePoint with F#
Exploring SharePoint with F#
 
Programing paradigm &amp; implementation
Programing paradigm &amp; implementationPrograming paradigm &amp; implementation
Programing paradigm &amp; implementation
 
F# and the DLR
F# and the DLRF# and the DLR
F# and the DLR
 
Sudipta_Mukherjee_Resume-Nov_2022.pdf
Sudipta_Mukherjee_Resume-Nov_2022.pdfSudipta_Mukherjee_Resume-Nov_2022.pdf
Sudipta_Mukherjee_Resume-Nov_2022.pdf
 
Algorithm and Programming
Algorithm and ProgrammingAlgorithm and Programming
Algorithm and Programming
 
Envisioning the Future of Language Workbenches
Envisioning the Future of Language WorkbenchesEnvisioning the Future of Language Workbenches
Envisioning the Future of Language Workbenches
 
Build your own Language - Why and How?
Build your own Language - Why and How?Build your own Language - Why and How?
Build your own Language - Why and How?
 
Key Features Of The Pseudo Code
Key Features Of The Pseudo CodeKey Features Of The Pseudo Code
Key Features Of The Pseudo Code
 
Procedural Programming Of Programming Languages
Procedural Programming Of Programming LanguagesProcedural Programming Of Programming Languages
Procedural Programming Of Programming Languages
 
CLTL Software and Web Services
CLTL Software and Web Services CLTL Software and Web Services
CLTL Software and Web Services
 
1504.00693
1504.006931504.00693
1504.00693
 
OOP Comparative Study
OOP Comparative StudyOOP Comparative Study
OOP Comparative Study
 
Introduction To Computer Programming
Introduction To Computer ProgrammingIntroduction To Computer Programming
Introduction To Computer Programming
 
OBJECT ORIENTED PROGRAMMING.docx
OBJECT ORIENTED PROGRAMMING.docxOBJECT ORIENTED PROGRAMMING.docx
OBJECT ORIENTED PROGRAMMING.docx
 

Más de Tomas Petricek

Más de Tomas Petricek (9)

Coeffects: A Calculus of Context-Dependent Computation
Coeffects: A Calculus of Context-Dependent ComputationCoeffects: A Calculus of Context-Dependent Computation
Coeffects: A Calculus of Context-Dependent Computation
 
Domain Specific Languages: The Functional Way
Domain Specific Languages: The Functional WayDomain Specific Languages: The Functional Way
Domain Specific Languages: The Functional Way
 
F# Data: Making structured data first class citizens
F# Data: Making structured data first class citizensF# Data: Making structured data first class citizens
F# Data: Making structured data first class citizens
 
Doing data science with F# (BuildStuff)
Doing data science with F# (BuildStuff)Doing data science with F# (BuildStuff)
Doing data science with F# (BuildStuff)
 
How F# Learned to Stop Worrying and Love the Data
How F# Learned to Stop Worrying and Love the DataHow F# Learned to Stop Worrying and Love the Data
How F# Learned to Stop Worrying and Love the Data
 
Information-rich programming in F# (ML Workshop 2012)
Information-rich programming in F# (ML Workshop 2012)Information-rich programming in F# (ML Workshop 2012)
Information-rich programming in F# (ML Workshop 2012)
 
Asynchronous programming in F# (QCon 2012)
Asynchronous programming in F# (QCon 2012)Asynchronous programming in F# (QCon 2012)
Asynchronous programming in F# (QCon 2012)
 
Teaching F#
Teaching F#Teaching F#
Teaching F#
 
Concurrent programming with Agents
Concurrent programming with AgentsConcurrent programming with Agents
Concurrent programming with Agents
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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...
 
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
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
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...
 
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
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

F# Tutorial @ QCon

  • 1. Turning to the Functional side(Using C# and F#) Phil Trelford http://trelford.com/blog@ptrelford Tomas Petricek http://tomasp.net/blog@tomaspetricek
  • 2. About Us Tomas Author of F# book for C# programmers Worked with the F# team at Microsoft First blogged about F# in May 2006 Phil Software Developer and Architect Worked on first F# applications at Microsoft Co-organizer of London F# User Group
  • 3. Tutorial Goals Introduce Functional Concepts with F# and C# Non-goals Provide in-depth understanding Mass conversion to functional programming cult Sell books
  • 4. Jargon Buster OO = Object Orientated FP = Functional Programming Lambda = Anonymous Function DSL = Domain Specific Language
  • 8. F# is a mix of
  • 9. What is F#? F# is multi-paradigm language, that is: Functional Declarative Object Orientated Imperative .Net language with VS integration
  • 10. Running F# Visual Studio 2010 Visual Studio Shell + F# MonoDevelop on Linux and Mac F# Compiler + Emacs etc. In your browser
  • 11. FP hits mainstream Visual Studio gets F# C# gets LINQ, lambdas, etc C++ gets lambdas JVM gets Clojure & Scala
  • 12. Writing queries with LINQ Query syntax supported in C# 3.0 Functional programming concepts Declaratively describes “what” not “how” Written as single expression varq= frompindb.Products wherep.UnitPrice>75.0M selectString.Format("{0} - ${1}", p.ProductName, p.UnitPrice);
  • 13. Graphical User Interface Frameworks XUL (Mozilla), Glade (Gtk), XAML (.NET) Functional programming concepts Compose button with ellipse inside Specify behavior declaratively <Buttonx:Name="greenBtn" Background="Black"> <EllipseWidth="75"Height="75" Fill="LightGreen" /> </Button> <DoubleAnimationStoryboard.TargetName="greenBtn" Storyboard.TargetProperty="(Canvas.Left)" From="0.0"To="100.0"Duration="0:0:5" />
  • 14. Specifying financial contracts in F# Functional programming concepts Declaratively describes “what” not “how” Written as single expression Composed from small number of primitives letmarch day = DateTime(2011, 3, day) letitTrades = (sell (tradeAt(march15) "GOOG"500)) $ (between (march10) (march19) (trade"MSFT"1000)) lettradeAtdatewhatamount = between datedate (trade whatamount)
  • 15. Code Samples 1: // Declare a local value (inferred type is string) 2: letworld="world" 3: 4: // Using '%s' format specifier to include string parameter 5: printfn"Hello %s!"world  
  • 16.
  • 17. Functional data structures A way of thinking about problems Model data using composition of primitives Tuple Combine two values of different types Discriminated Union Represents one of several options List Zero or more values of the same type
  • 18. Tuples: Containers for a few different things
  • 20. Representing event schedule Object-oriented way Easy to add new cases Hard to add new functions Functional way Easy to add new functions Hard to add new cases Good thing about F# and Scala– you can use both!
  • 22. Map Reduce MapReduce is a patented software framework introduced by Google to support distributed computing on large data sets on clusters of computers. Functional design scales extremely well!
  • 23. Domain Modelling Retail Domain -> Testing
  • 24. Checkout application workflow Think of a simple while loop Implement… Mutable field to keep the state and event handlers? Asynchronous while loop in F#
  • 25. Asynchronous and concurrent programming Asynchronous GUI in Checkout example Single-threaded thanks to Async.StartImmediate Easy way to encode control flow Parallel programming Workflows are non-blocking computations Run workflows in parallel with Async.Parallel Concurrent programming Compose application from (thousands of) agents Agents communicate using messages
  • 26. Wild Card Filler Silverlight mini-samples
  • 27. Summary FP is already in the mainstream FP languages are ready Start small, go big Language Orientated Programming Exploratory and Scripting Asynchronous & Concurrency Technical Computing Testing
  • 28. Summary Don’t underestimate the power of the functional side
  • 31. On the horizon Next Meet: In the brain of Rob Pickering on March 16th
  • 32. Q & A http://Fsharp.net http://fssnip.net http://tomasp.net/blog http://trelford.com/blog

Notas del editor

  1. Thoughtworkstechnlogy radar: http://www.thoughtworks.com/radar/Image source: http://www.thoughtworks.com/sites/www.thoughtworks.com/files/files/tw-radar-april-2010.pdfSee also: http://qconlondon.com/london-2010/file?path=/qcon-london-2010/slides/AmandaLaucher_and_JoshGraham_TheStateOfTheArtNET12MonthsOfThingsToLearn.pdf
  2. http://en.wikipedia.org/wiki/Dynamic_programming_language
  3. http://en.wikipedia.org/wiki/Comparison_of_programming_languagesDefinitions of FP, OO and Dynamic
  4. Python = light, C# = OO, OCaml = Functional
  5. http://tryfsharporg.cloudapp.net/http://trelford.com/MissileCommand.fsx