SlideShare a Scribd company logo
Eriawan Kusumawardhono
   F# is starting from a research project of
    Microsoft, created by Don Syme
   F# is a functional programming language
    that runs on top of .NET
   F# is now part of VS 2010 built in
    programming language
   Also part of OCAML programming language
    family
   There are many definitions about this, and
    there’s no simple standard definition
   According to Erik Meijer and Brian Beckman
    of Microsoft, Functional Programming is
    programming with mathematical function,
    where function is a first class citizen of a
    program
   A simple operation that returns a value, that
    can have a parameter or more than one
    parameters
f(x) = x+1
y=x+1
x=x+1
x++
F#                                 OOP (C#, VB, C++…)

    Immutable by default             Mutable by default
    Function is the same as          Function is treated as a
     data in a program, and can        method that must reside in
     be written as a standalone        a body of a class
     function                         ‘Noisy’ syntax
    Succinct syntax                  Type inference is only
    Type inference is available       available since C# 3.0 and
     from the start                    VB 9.0, not in C++ and
                                       others
Comparison of F# to others such as C#, VB, C++
   Immutable by default       Mutable by default

    let y = x + 1               x = x +1

   Mutable is explicit        Immutable is explicit.
                                For example, in C#:
    let mutable x = x + 1        readonly x = 0


                               In VB:
                                 ReadOnly x As Integer
   In F#, it can be              In C# and VB, it must
    standalone and simple          be enclosed in a
                                   class/module

    let f x = x +2                 class SimpleFunc
                                   {
                                       public static Int32
                                   f(Int32 x)
   This is why it is called           {
                                           return x + 2;
    “succinct”                         }
                                   }

                                  This is “noisy”
   Already have at the first release
   It is also a strong type language
   Including built in support of Generic
   The type inference is not just local type
    inference, but it then can be inferred based
    on the use of the parameters!
Int32
let avalue =10               String
let aName = ‘Hello’
let savingInterest = 0.2           Double
   Type inference on functions when it’s used
                     let f x = sqr x + 1
                                            Infers integer
                         .. return type     from a whole
                          becomes int       number…
let sqr x = x * x

                                             Infers double
                                            from a double
                                                literal..
                    let f x = sqr x + 1.0
Less noise syntax but it’s still strongly typed
   Always begin with keyword “let”


      let avalue = 10
      let aName = ‘Hello’
      let savingInterest = 0.2
   When there’s a need for explicit type system:


     let x:int = 0
     let piConstant:float = 3.141
     let Name:String = ‘Eriawan’
   Always begin with let keyword

     let f x = x + 1
     let sqr y = y * y
     let force x = x * gravity
   Parameters are written in a nice separation
    “juxtaposition” syntax: a space

          let sqr x = x * x
                               Function parameter

          let add a b = a + b
The code in F#
   Multiple lines of code is using indentation:


       let rec fib x =
           if x < 2 then 1
           else fib (x–1) + fib (x-2)
   Comment is the same with VB and C#
       // some code
       let x = x + 2

       // XML doc comment:

       /// <summary>A square function<summary>
       /// <param name=‚x‛>the value</param>
       let f x = x * x
The object oriented and imperative are here in F#
let f x = x *x
let g(x) = x* x
fun x -> x * x
   Mutable is easy, by adding keyword
    “mutable”
   Next operation of assignment must use “<-”
    to differentiate mutability.
              let mutable y = 10
              y <- y + 1
   Creating enum is also easy:


                   type Suit =
                       | Heart
                       | Diamond
                       | Spade
                       | Club
type Vector2D(dx:float, dy:float) =
    // The pre-computed length of the vector
    let length = sqrt(dx*dx + dy*dy)
    /// The displacement along the X-axis
    member v.DX = dx
    /// The displacement along the Y-axis
    member v.DY = dy
    /// The length of the vector
    member v.Length = length
    // Re-scale the vector by a constant
    member v.Scale(k) = Vector2D(k*dx, k*dy)
   It’s easy! Just create type but with abstract
    keyword as modifier for all functions and
    other members:

          type IPeekPoke =
              abstract Peek: unit -> int
              abstract Poke: int -> unit
Unit of measure in F# only!
[<Measure>]
type kg

[<Measure>]
type m

[<Measure>]
type s

let gravityOnEarth = 9.81<m/s^2>
let heightOfMyOfficeWindow = 3.5<m>
let speedOfImpact =
    sqrt (2.0 * gravityOnEarth + heightOfMyOfficeWindow)
Created by Eriawan Kusumawardhono, courtesy of RX Communica

More Related Content

What's hot (20)

PPT
Lec 42.43 - virtual.functions
Princess Sam
 
PDF
C++ Chapter I
Sorn Chanratha
 
DOCX
Virtual function
harman kaur
 
PDF
yield and return (poor English ver)
bleis tift
 
PDF
C++ Chapter III
Sorn Chanratha
 
PDF
Lecturer23 pointersin c.ppt
eShikshak
 
PDF
Kotlin Delegates: Reduce the boilerplate
Dmytro Zaitsev
 
DOCX
Bc0037
hayerpa
 
PPTX
Pointers in C
Vijayananda Ratnam Ch
 
PPT
5 - OOP - Smalltalk in a Nutshell (c)
The World of Smalltalk
 
PDF
Interpreter Case Study - Design Patterns
CodeOps Technologies LLP
 
PDF
C# Summer course - Lecture 3
mohamedsamyali
 
PPTX
Dynamic Memory Allocation in C
Vijayananda Ratnam Ch
 
PPTX
Lecture 7, c++(complete reference,herbet sheidt)chapter-17.
Abu Saleh
 
PPTX
Interpreter Design Pattern
sreymoch
 
PPTX
Java Foundations: Basic Syntax, Conditions, Loops
Svetlin Nakov
 
PPTX
Java essence part 1
HanRu Yeh
 
PDF
Back to the Future with TypeScript
Aleš Najmann
 
PPTX
Rust Intro
Arthur Gavkaluk
 
PDF
2013 lecture-02-syntax shortnewcut
Pharo
 
Lec 42.43 - virtual.functions
Princess Sam
 
C++ Chapter I
Sorn Chanratha
 
Virtual function
harman kaur
 
yield and return (poor English ver)
bleis tift
 
C++ Chapter III
Sorn Chanratha
 
Lecturer23 pointersin c.ppt
eShikshak
 
Kotlin Delegates: Reduce the boilerplate
Dmytro Zaitsev
 
Bc0037
hayerpa
 
Pointers in C
Vijayananda Ratnam Ch
 
5 - OOP - Smalltalk in a Nutshell (c)
The World of Smalltalk
 
Interpreter Case Study - Design Patterns
CodeOps Technologies LLP
 
C# Summer course - Lecture 3
mohamedsamyali
 
Dynamic Memory Allocation in C
Vijayananda Ratnam Ch
 
Lecture 7, c++(complete reference,herbet sheidt)chapter-17.
Abu Saleh
 
Interpreter Design Pattern
sreymoch
 
Java Foundations: Basic Syntax, Conditions, Loops
Svetlin Nakov
 
Java essence part 1
HanRu Yeh
 
Back to the Future with TypeScript
Aleš Najmann
 
Rust Intro
Arthur Gavkaluk
 
2013 lecture-02-syntax shortnewcut
Pharo
 

Viewers also liked (11)

PPTX
Introduction in Image Processing Matlab Toolbox
Shahriar Yazdipour
 
PDF
What Makes Great Infographics
SlideShare
 
PDF
10 Ways to Win at SlideShare SEO & Presentation Optimization
Oneupweb
 
PDF
Masters of SlideShare
Kapost
 
PDF
STOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
Empowered Presentations
 
PDF
How To Get More From SlideShare - Super-Simple Tips For Content Marketing
Content Marketing Institute
 
PDF
You Suck At PowerPoint!
Jesse Desjardins - @jessedee
 
PDF
2015 Upload Campaigns Calendar - SlideShare
SlideShare
 
PPTX
What to Upload to SlideShare
SlideShare
 
PDF
How to Make Awesome SlideShares: Tips & Tricks
SlideShare
 
PDF
Getting Started With SlideShare
SlideShare
 
Introduction in Image Processing Matlab Toolbox
Shahriar Yazdipour
 
What Makes Great Infographics
SlideShare
 
10 Ways to Win at SlideShare SEO & Presentation Optimization
Oneupweb
 
Masters of SlideShare
Kapost
 
STOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
Empowered Presentations
 
How To Get More From SlideShare - Super-Simple Tips For Content Marketing
Content Marketing Institute
 
You Suck At PowerPoint!
Jesse Desjardins - @jessedee
 
2015 Upload Campaigns Calendar - SlideShare
SlideShare
 
What to Upload to SlideShare
SlideShare
 
How to Make Awesome SlideShares: Tips & Tricks
SlideShare
 
Getting Started With SlideShare
SlideShare
 
Ad

Similar to F sharp _vs2010_beta2 (20)

PPTX
Functional programming with FSharp
Daniele Pozzobon
 
PPT
Testing for share
Rajeev Mehta
 
PPTX
Intro f# functional_programming
Mauro Ghiani
 
PPSX
C++ quik notes
argusacademy
 
PPTX
Introduction to python programming ( part-2 )
Ziyauddin Shaik
 
PPT
C# programming
umesh patil
 
PPTX
Introduction to FSharp
Valdis Iljuconoks
 
PDF
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Chris Adamson
 
PDF
Python idiomatico
PyCon Italia
 
PDF
Pydiomatic
rik0
 
PPTX
ForLoopandUserDefinedFunctions.pptx
AaliyanShaikh
 
PDF
Functions_21_22.pdf
paijitk
 
PDF
Learn a language : LISP
Devnology
 
PDF
Functionscs12 ppt.pdf
RiteshKumarPradhan1
 
PDF
Functions.pdf
kailashGusain3
 
PPTX
#OOP_D_ITS - 2nd - C++ Getting Started
Hadziq Fabroyir
 
PPT
C++ Language
Syed Zaid Irshad
 
PPT
C++totural file
halaisumit
 
PDF
WEEK 1 -- DAY 1_20240119_220354_0000.pdf
Rahulsahoo43
 
PPTX
namma_kalvi_12th_computer_science_chapter_1_ppt_220184.pptx
adityakumardas16
 
Functional programming with FSharp
Daniele Pozzobon
 
Testing for share
Rajeev Mehta
 
Intro f# functional_programming
Mauro Ghiani
 
C++ quik notes
argusacademy
 
Introduction to python programming ( part-2 )
Ziyauddin Shaik
 
C# programming
umesh patil
 
Introduction to FSharp
Valdis Iljuconoks
 
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Chris Adamson
 
Python idiomatico
PyCon Italia
 
Pydiomatic
rik0
 
ForLoopandUserDefinedFunctions.pptx
AaliyanShaikh
 
Functions_21_22.pdf
paijitk
 
Learn a language : LISP
Devnology
 
Functionscs12 ppt.pdf
RiteshKumarPradhan1
 
Functions.pdf
kailashGusain3
 
#OOP_D_ITS - 2nd - C++ Getting Started
Hadziq Fabroyir
 
C++ Language
Syed Zaid Irshad
 
C++totural file
halaisumit
 
WEEK 1 -- DAY 1_20240119_220354_0000.pdf
Rahulsahoo43
 
namma_kalvi_12th_computer_science_chapter_1_ppt_220184.pptx
adityakumardas16
 
Ad

Recently uploaded (20)

PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
July Patch Tuesday
Ivanti
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
July Patch Tuesday
Ivanti
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 

F sharp _vs2010_beta2

  • 2. F# is starting from a research project of Microsoft, created by Don Syme  F# is a functional programming language that runs on top of .NET  F# is now part of VS 2010 built in programming language  Also part of OCAML programming language family
  • 3. There are many definitions about this, and there’s no simple standard definition  According to Erik Meijer and Brian Beckman of Microsoft, Functional Programming is programming with mathematical function, where function is a first class citizen of a program
  • 4. A simple operation that returns a value, that can have a parameter or more than one parameters
  • 7. F# OOP (C#, VB, C++…)  Immutable by default  Mutable by default  Function is the same as  Function is treated as a data in a program, and can method that must reside in be written as a standalone a body of a class function  ‘Noisy’ syntax  Succinct syntax  Type inference is only  Type inference is available available since C# 3.0 and from the start VB 9.0, not in C++ and others
  • 8. Comparison of F# to others such as C#, VB, C++
  • 9. Immutable by default  Mutable by default let y = x + 1 x = x +1  Mutable is explicit  Immutable is explicit. For example, in C#: let mutable x = x + 1 readonly x = 0  In VB: ReadOnly x As Integer
  • 10. In F#, it can be  In C# and VB, it must standalone and simple be enclosed in a class/module let f x = x +2 class SimpleFunc { public static Int32 f(Int32 x)  This is why it is called { return x + 2; “succinct” } }  This is “noisy”
  • 11. Already have at the first release  It is also a strong type language  Including built in support of Generic  The type inference is not just local type inference, but it then can be inferred based on the use of the parameters!
  • 12. Int32 let avalue =10 String let aName = ‘Hello’ let savingInterest = 0.2 Double
  • 13. Type inference on functions when it’s used let f x = sqr x + 1 Infers integer .. return type from a whole becomes int number… let sqr x = x * x Infers double from a double literal.. let f x = sqr x + 1.0
  • 14. Less noise syntax but it’s still strongly typed
  • 15. Always begin with keyword “let” let avalue = 10 let aName = ‘Hello’ let savingInterest = 0.2
  • 16. When there’s a need for explicit type system: let x:int = 0 let piConstant:float = 3.141 let Name:String = ‘Eriawan’
  • 17. Always begin with let keyword let f x = x + 1 let sqr y = y * y let force x = x * gravity
  • 18. Parameters are written in a nice separation “juxtaposition” syntax: a space let sqr x = x * x Function parameter let add a b = a + b
  • 20. Multiple lines of code is using indentation: let rec fib x = if x < 2 then 1 else fib (x–1) + fib (x-2)
  • 21. Comment is the same with VB and C# // some code let x = x + 2 // XML doc comment: /// <summary>A square function<summary> /// <param name=‚x‛>the value</param> let f x = x * x
  • 22. The object oriented and imperative are here in F#
  • 23. let f x = x *x let g(x) = x* x fun x -> x * x
  • 24. Mutable is easy, by adding keyword “mutable”  Next operation of assignment must use “<-” to differentiate mutability. let mutable y = 10 y <- y + 1
  • 25. Creating enum is also easy: type Suit = | Heart | Diamond | Spade | Club
  • 26. type Vector2D(dx:float, dy:float) = // The pre-computed length of the vector let length = sqrt(dx*dx + dy*dy) /// The displacement along the X-axis member v.DX = dx /// The displacement along the Y-axis member v.DY = dy /// The length of the vector member v.Length = length // Re-scale the vector by a constant member v.Scale(k) = Vector2D(k*dx, k*dy)
  • 27. It’s easy! Just create type but with abstract keyword as modifier for all functions and other members: type IPeekPoke = abstract Peek: unit -> int abstract Poke: int -> unit
  • 28. Unit of measure in F# only!
  • 29. [<Measure>] type kg [<Measure>] type m [<Measure>] type s let gravityOnEarth = 9.81<m/s^2> let heightOfMyOfficeWindow = 3.5<m> let speedOfImpact = sqrt (2.0 * gravityOnEarth + heightOfMyOfficeWindow)
  • 30. Created by Eriawan Kusumawardhono, courtesy of RX Communica