SlideShare a Scribd company logo
Functional programming and F#Sanko.net meeting 8.6.2011
AgendaFunctional programming from c# perspective, Linq principlesFunctional programming in generalF# and C# interoperabilityF# examples: ’basic’ stuffF# vs. C#
AgendaFunctional programming from c# perspective, Linq principlesFunctional programming in generalF# and C# interoperabilityF# examples: ’basic’ stuffF# vs. C# Eh?There’s a bug in the Agenda!!!Wrong order and names missing!
This happens, when you Powerpoint without test harness! Lets kick the PowerPoint and.... Correct the agenda using....
F#?This happens, when you Powerpoint without test harness! Lets kick the PowerPoint and.... Correct the agenda using....
F#?This happens, when you Powerpoint without test harness! Lets kick the PowerPoint and.... Correct the agenda using....Java guy? Great!
Demo.... Source available @ github: https://github.com/ramik/Demo/blob/master/FunctionalTutorial/CSharpExamples/PresisDemo/SlideDemo.fsAnd if you don’t have internet access, snapshotted source just for youmodule SlideDemoopen System;type PresentationKeeper(name: string, employer : string) =         member lollis.name = name        member fuulis.employer = employer        override this.ToString() = name + ", " + employerlet Rami = PresentationKeeper("Rami Karjalainen", "Reaktor")let Tuomas = PresentationKeeper("Tuomas Hietanen", "Basware")let topics = [ (2, "Functional programming from c# perspective, Linq principles", Tuomas);               (1, "Functional programming in general", Rami);               (3, "F# examples: ’basic’ stuff", Rami);               (4, "F# and C# interoperability", Rami);               (5, "F# vs. C#", Tuomas) ]let formatTopic topic keeper = String.Format ("{0} ({1})", topic, keeper.ToString())let pimpTheList = topics |> Seq.sortBy (fun (prio,_,_) -> prio)                          |> Seq.map (fun (_, a, b) -> a,b)                         |> Seq.map (fun x -> (formatTopic (fst x) (snd x)))let printPimped x = x |> Seq.iter (fun c -> printfn "%s" c)
Why F#?
Why F#?Well, simply because its fun!
Why F#?Well, simply because its fun!(fun is reserved keyword, for      expression)!
F# has / is:SuccintClosuresFunctionalGenericsDiscrimated unions.net official language (v4  )Pattern matchingTail recursion optimization  TuplesImmutable by defaultasynchronous workflowsVery expressiveInteroperableType inferenceClassesInfinite lists etc. (laziness) Strongly typedHybrid (oo, imperative)Lambda expressions (anon func)REPL (interactive)OCaml
F# has / is:But for now, lets focus on this!Functional
Well, what is functional programming?Immutable constructs
Functions as first class ”citizens”
Recursion
No mutable state Many other concepts apply, but these are ones to focus in this presentation
Immutability:Object cannot be changed after creationIn C#, mark fields as readonlyNo mutable state  no local variables
Functions as first class citizens:Functions can be passed as normal parameters CompositionHigher order functionsTakes a function as paramand/orReturns a function as outputFunctions as first class citizens:Functions can be passed as normal parameters CompositionHigher order functionsTakes a function as paramand/orReturns a function as outputTuomas will cover the deeps of the function theory later in the session
Recursion:In functional programming, no iteration or ”looping”Recursion is very important concept
Recursion:In functional programming, no iteration or ”looping”Recursion is very important conceptRecursion is very important, as without it ....
Recursion:In functional programming, no iteration or ”looping”Recursion is very important conceptRecursion is very important, as without it ....

More Related Content

What's hot (20)

PPTX
Creating Domain Specific Languages in F#
Tomas Petricek
 
PPTX
What is Python? An overview of Python for science.
Nicholas Pringle
 
PPT
F# Intro for Scala Developers
fsug
 
PPTX
Introduction to C Programming
Aniket Patne
 
PPT
C language introduction
musrath mohammad
 
PPTX
C programming
Rohan Gajre
 
PDF
Python Programming - I. Introduction
Ranel Padon
 
PPTX
Dmitry mozorov on code quotations code as-data for f#
Skills Matter
 
PPTX
Python Basics
Pooja B S
 
PPTX
FSharp eye for the Haskell guy - London 2015
Phillip Trelford
 
ODP
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Skills Matter
 
PPTX
Presentation on C++ programming
AditiTibile
 
PPT
F# and the DLR
Richard Minerich
 
PDF
C programming Ms. Pranoti Doke
Pranoti Doke
 
PPTX
Introduction to Python Part-1
Devashish Kumar
 
PDF
The GNOME way - What can we learn from and within the Open Documentation World
Radina Matic
 
PPTX
File handling With Solve Programs
Rohan Gajre
 
PPTX
# And ## operators in c
Dr. Prashant Vats
 
PDF
Python programming
Prof. Dr. K. Adisesha
 
PPTX
C++
Neha Gupta
 
Creating Domain Specific Languages in F#
Tomas Petricek
 
What is Python? An overview of Python for science.
Nicholas Pringle
 
F# Intro for Scala Developers
fsug
 
Introduction to C Programming
Aniket Patne
 
C language introduction
musrath mohammad
 
C programming
Rohan Gajre
 
Python Programming - I. Introduction
Ranel Padon
 
Dmitry mozorov on code quotations code as-data for f#
Skills Matter
 
Python Basics
Pooja B S
 
FSharp eye for the Haskell guy - London 2015
Phillip Trelford
 
Progressive f# tutorials nyc dmitry mozorov & jack pappas on code quotations ...
Skills Matter
 
Presentation on C++ programming
AditiTibile
 
F# and the DLR
Richard Minerich
 
C programming Ms. Pranoti Doke
Pranoti Doke
 
Introduction to Python Part-1
Devashish Kumar
 
The GNOME way - What can we learn from and within the Open Documentation World
Radina Matic
 
File handling With Solve Programs
Rohan Gajre
 
# And ## operators in c
Dr. Prashant Vats
 
Python programming
Prof. Dr. K. Adisesha
 

Similar to F# and functional programming (20)

PPT
Lập trình C
Viet NguyenHoang
 
PDF
Boo Manifesto
hu hans
 
PPTX
Functional Programming
Ryan Riley
 
PPTX
What the math geeks don't want you to know about F#
Kevin Hazzard
 
PDF
88 c programs 15184
Sumit Saini
 
PDF
88 c-programs
Minh Thắng Trần
 
ODP
F# 101
Chris Alcock
 
PPT
Bay NET Aug 19 2009 presentation ppt
Art Scott
 
PPTX
F# Tutorial @ QCon
Tomas Petricek
 
PDF
OOP and FP
Mario Fusco
 
PPTX
Exploring SharePoint with F#
Talbott Crowell
 
PDF
ProgFund_Lecture_4_Functions_and_Modules-1.pdf
lailoesakhan
 
PDF
Functional programming
OpenAgile Romania
 
PDF
Functional programming in C++
Alexandru Bolboaca
 
PDF
88 c-programs
Leandro Schenone
 
PPTX
Qcon2011 functions rockpresentation_f_sharp
Michael Stal
 
PPTX
Qcon2011 functions rockpresentation_f_sharp
Michael Stal
 
PDF
Functional programming is the most extreme programming
samthemonad
 
PPTX
Mastering Python lesson3b_for_loops
Ruth Marvin
 
PDF
[4DEV] Bartosz Sokół - Functional developer in object oriented world - how F#...
PROIDEA
 
Lập trình C
Viet NguyenHoang
 
Boo Manifesto
hu hans
 
Functional Programming
Ryan Riley
 
What the math geeks don't want you to know about F#
Kevin Hazzard
 
88 c programs 15184
Sumit Saini
 
88 c-programs
Minh Thắng Trần
 
F# 101
Chris Alcock
 
Bay NET Aug 19 2009 presentation ppt
Art Scott
 
F# Tutorial @ QCon
Tomas Petricek
 
OOP and FP
Mario Fusco
 
Exploring SharePoint with F#
Talbott Crowell
 
ProgFund_Lecture_4_Functions_and_Modules-1.pdf
lailoesakhan
 
Functional programming
OpenAgile Romania
 
Functional programming in C++
Alexandru Bolboaca
 
88 c-programs
Leandro Schenone
 
Qcon2011 functions rockpresentation_f_sharp
Michael Stal
 
Qcon2011 functions rockpresentation_f_sharp
Michael Stal
 
Functional programming is the most extreme programming
samthemonad
 
Mastering Python lesson3b_for_loops
Ruth Marvin
 
[4DEV] Bartosz Sokół - Functional developer in object oriented world - how F#...
PROIDEA
 
Ad

Recently uploaded (20)

PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
July Patch Tuesday
Ivanti
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
July Patch Tuesday
Ivanti
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Biography of Daniel Podor.pdf
Daniel Podor
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Ad

F# and functional programming

  • 1. Functional programming and F#Sanko.net meeting 8.6.2011
  • 2. AgendaFunctional programming from c# perspective, Linq principlesFunctional programming in generalF# and C# interoperabilityF# examples: ’basic’ stuffF# vs. C#
  • 3. AgendaFunctional programming from c# perspective, Linq principlesFunctional programming in generalF# and C# interoperabilityF# examples: ’basic’ stuffF# vs. C# Eh?There’s a bug in the Agenda!!!Wrong order and names missing!
  • 4. This happens, when you Powerpoint without test harness! Lets kick the PowerPoint and.... Correct the agenda using....
  • 5. F#?This happens, when you Powerpoint without test harness! Lets kick the PowerPoint and.... Correct the agenda using....
  • 6. F#?This happens, when you Powerpoint without test harness! Lets kick the PowerPoint and.... Correct the agenda using....Java guy? Great!
  • 7. Demo.... Source available @ github: https://github.com/ramik/Demo/blob/master/FunctionalTutorial/CSharpExamples/PresisDemo/SlideDemo.fsAnd if you don’t have internet access, snapshotted source just for youmodule SlideDemoopen System;type PresentationKeeper(name: string, employer : string) = member lollis.name = name member fuulis.employer = employer override this.ToString() = name + ", " + employerlet Rami = PresentationKeeper("Rami Karjalainen", "Reaktor")let Tuomas = PresentationKeeper("Tuomas Hietanen", "Basware")let topics = [ (2, "Functional programming from c# perspective, Linq principles", Tuomas); (1, "Functional programming in general", Rami); (3, "F# examples: ’basic’ stuff", Rami); (4, "F# and C# interoperability", Rami); (5, "F# vs. C#", Tuomas) ]let formatTopic topic keeper = String.Format ("{0} ({1})", topic, keeper.ToString())let pimpTheList = topics |> Seq.sortBy (fun (prio,_,_) -> prio) |> Seq.map (fun (_, a, b) -> a,b) |> Seq.map (fun x -> (formatTopic (fst x) (snd x)))let printPimped x = x |> Seq.iter (fun c -> printfn "%s" c)
  • 9. Why F#?Well, simply because its fun!
  • 10. Why F#?Well, simply because its fun!(fun is reserved keyword, for expression)!
  • 11. F# has / is:SuccintClosuresFunctionalGenericsDiscrimated unions.net official language (v4  )Pattern matchingTail recursion optimization TuplesImmutable by defaultasynchronous workflowsVery expressiveInteroperableType inferenceClassesInfinite lists etc. (laziness) Strongly typedHybrid (oo, imperative)Lambda expressions (anon func)REPL (interactive)OCaml
  • 12. F# has / is:But for now, lets focus on this!Functional
  • 13. Well, what is functional programming?Immutable constructs
  • 14. Functions as first class ”citizens”
  • 16. No mutable state Many other concepts apply, but these are ones to focus in this presentation
  • 17. Immutability:Object cannot be changed after creationIn C#, mark fields as readonlyNo mutable state  no local variables
  • 18. Functions as first class citizens:Functions can be passed as normal parameters CompositionHigher order functionsTakes a function as paramand/orReturns a function as outputFunctions as first class citizens:Functions can be passed as normal parameters CompositionHigher order functionsTakes a function as paramand/orReturns a function as outputTuomas will cover the deeps of the function theory later in the session
  • 19. Recursion:In functional programming, no iteration or ”looping”Recursion is very important concept
  • 20. Recursion:In functional programming, no iteration or ”looping”Recursion is very important conceptRecursion is very important, as without it ....
  • 21. Recursion:In functional programming, no iteration or ”looping”Recursion is very important conceptRecursion is very important, as without it ....
  • 22. Recursion:In functional programming, no iteration or ”looping”Recursion is very important conceptRecursion is very important, as without it ....Tail recursion or stack says bye!
  • 23. Time to switch to Visual Studio!(for good this time)