Your SlideShare is downloading. ×
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
F# Eye for the C# Guy
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

F# Eye for the C# Guy

10,637

Published on

F# Eye for the C# Guy by Leon Bambrick

F# Eye for the C# Guy by Leon Bambrick

Published in: Technology, Health & Medicine
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
10,637
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
87
Comments
0
Likes
6
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • What’s this F# thing anyway?
  • Transcript

    • 1. F# Eye for the C# guy Leon Bambrick, secretGeek.net
    • 2. F#... Do not be afraid.
    • 3. hello
    • 4. I’m F #
    • 5.  
    • 6. functional
    • 7. Purely functional…
      • Avoid
      • Side-
      • Effects!
    • 8. Purely functional…
      • Avoid
      • Mutation!
    • 9. Purely functional…
      • No Variables!
      • Only Functions!
    • 10. Purely functional…
      • Same input ->
      • Same output!
    • 11.
      • No Shared State
      Purely functional…
    • 12.
      • Why learn F#?
    • 13.
      • Do More With Less
        • “ If I was using F# I’d be done by now”
      Why learn F#?
    • 14.
      • Do More With Less
        • “ If I was using F# I’d be done by now”
      • See where C# and VB.net are headed
      Why learn F#?
    • 15.
      • Do More With Less
        • “ If I was using F# I’d be done by now”
      • See where C# and VB.net are headed
      • “ Learn one new language every year” (or two)
      Why learn F#?
    • 16.
      • Moore’s Law Keeps Going!
      Why learn F#?
    • 17.
      • But computers are not getting faster
      Why learn F#?
    • 18.
      • Data Grows Quickly
      • But # of Dimensions Grows much faster!
      • And semi-structured data outgrowing structured
      • Entropy Increasing
      • Complexity is through the roof!
    • 19.
      • “ Software gets slower faster than hardware gets faster”
      • --Wirth’s Law
    • 20.  
    • 21.
      • Some stuff is now cheap!
        • Ram
        • Disk
        • Cores
      • Some stuff remains expensive!
        • Time
        • Concurrency
        • Locking
      Computer Economics is Changing
    • 22.
      • Some stuff is now cheap!
        • Ram
        • Disk
        • Cores
      • Some stuff remains expensive!
        • Time
        • Concurrency
        • Locking
      Computer Economics is Changing
    • 23.
      • Some stuff is now cheap!
        • Ram
        • Disk
        • Cores
      • Some stuff remains expensive!
        • Time
        • Concurrency
        • Locking
      Computer Economics is Changing
    • 24.
      • Some stuff is now cheap!
        • Ram
        • Disk
        • Cores
      • Some stuff remains expensive!
        • Real Time
        • Concurrency
        • Locking
      Computer Economics is Changing
    • 25. This tips the balance toward higher abstractions
    • 26. Some Applications of F#
      • “ Computationally intensive” work
      • Map/Reduce over internets
      • Financial Analysis
      • Advertising Analysis
      • SQL Data Mining
      • XNA Games Development
      • Web tools, Compile F# to Javascript
    • 27. Think About Game Programming
    • 28. Game Programming Involves…
      • 3D Animation
      • Rendering
      • Shading
      • Simulation (e.g. physics)
      • Collision Detection
      • AI Opponents
    • 29. Genealogy of F # …
      • Theorem proving and ISWIM
    • 30. Genealogy of F # …
      • Theorem proving and ISWIM begat:
        • ML “Meta Language”
    • 31. Genealogy of F # …
      • Theorem proving and ISWIM begat:
        • ML “Meta Language”, which begat:
          • CAML
    • 32. Genealogy of F # …
      • Theorem proving and ISWIM begat:
        • ML “Meta Language”, which begat:
          • CAML, which in turn begat
            • OCaml
      Oh!
    • 33. Genealogy of F # …
      • Theorem proving and ISWIM begat:
        • ML “Meta Language”, which begat:
          • CAML, which in turn begat
            • OCaml, which in turn begat
              • F#
      • ... a sort of OCaml.net
      • (plus more)
      Oh!
    • 34. WTF # ?
      • First official functional language on .net
    • 35. WTF # ?
      • First official functional language on .net
      • Deep support thanks to Generics
    • 36. WTF # ?
      • First official functional language on .net
      • Deep support thanks to Generics
      • Assimilated by dev-div
    • 37. WTF # ?
      • First official functional language on .net
      • Deep support thanks to Generics
      • Assimilated by dev-div
      • Will ship in VS.next
    • 38. Code!
      • Finally!
    • 39. Code!
      • //F#
      • let a = 2
    • 40. Code!
      • //F#
      • let a = 2
      The ‘let’ keyword represents a binding between a value and an expression tree.
    • 41. Code!
      • //F#
      • let a = 2
      The ‘let’ blah blah blahblah blah blahblah blahblah blah blah blah blah blah blah.
    • 42. Code!
      • //F#
      • let a = 2
      //C# int a = 2 ≠
    • 43. Code!
      • //F#
      • let a = 2
      //C# //a function! static int a() { return 2; } More like
    • 44. More Code!
      • //F#
      • #light
      • open System
      • let a = 2
      • Console.WriteLine a
      //C# using System; namespace ConsoleApplication1 { class Program { static int a() { return 2; } static void Main( string [] args) { Console .WriteLine(a); } } }
    • 45. More Code!
      • //F#
      • #light
      • open System
      • let a = 2
      • Console.WriteLine a
      More Noise Than Signal!
    • 46. More Code!
      • //F#
      • #light
      • open System
      • let a = 2
      • Console.WriteLine a
      Looks Weakly typed? Maybe Dynamic?
    • 47. F#?
    • 48. F#
    • 49. F# Yet Expressive
    • 50. F# Yet Versatile
    • 51. More Code!
      • //F#
      • #light
      • open System
      • let a = 2
      • Console.WriteLine a
      Type Inference
    • 52.
      • let a = 2
      • let a = 3
      • error: FS0037: Duplicate definition of value 'a'
      Immutable by default
    • 53.
      • let square x = x * x
      • > val square : int -> int
      • square 5
      • > val it : int = 25
      simple function…
    • 54.
      • let square x = x * x
      • > val square : int -> int
      • square 5
      • > val it : int = 25
      simple function… Parameter
    • 55.
      • let square x = x * x
      • > val square : int -> int
      • square 5
      • > val it : int = 25
      simple function… “ Signature”
    • 56.
      • let square x = x * x
      • > val square : int -> int
      • square 5
      • > val it : int = 25
      simple function… Types are “inferred”
    • 57. Discriminated union types
      • type NullableInt =
      • | Value of int
      • | Nothing of unit
    • 58. Discriminated union types
      • type NullableInt =
      • | Value of int
      • | Nothing of unit
      Wish C#/“O-O” had this.
    • 59. Discriminated union types
      • type NullableInt =
      • | Value of int
      • | Nothing of unit
      “ O-O” has discriminated union envy When the only tool you have is a hammer Everything looks like a nail
    • 60. Discriminated union types
      • type NullableInt =
      • | Value of int
      • | Nothing of unit
      “ O-O” has discriminated union envy When the only tool you have is a hammer Everything looks like a nail e.g. “Inheritance” ends up being used in places where it’s not a perfect fit…
    • 61. Discriminated union types
      • type NullableInt =
      • | Value of int
      • | Nothing of unit
      “ O-O” has discriminated union envy When the only tool you have is a hammer Everything looks like a nail e.g. “Inheritance” ends up being used in places where it’s not a perfect fit… ‘ Discriminated union types’ -- a better fit for some problems?
    • 62. Another great tool is “pattern matching”
    • 63. Another great tool is “pattern matching” “ Switch/Case” statements on steroids
    • 64. Another great tool is “pattern matching” “ Switch/Case” statements on steroids “ method overloads” on crack
    • 65. Discriminated unions example
      • type Weapon =
      • | Knife
      • | Gun
      • | Bomb
    • 66. Pattern Matching
      • type Weapon =
      • | Knife
      • | Gun
      • | Bomb
      //block any weapon! let block w = match w with | Knife | Gun -> disarm w | _ -> difuse w block Gun block Knife block Bomb
    • 67. Pattern Matching
      • type Weapon =
      • | Knife
      • | Gun
      • | Bomb
      //block any weapon let block w = match w with | Knife | Gun -> disarm w | _ -> difuse w block Gun block Knife block Bomb
    • 68. Lazy is a virtue
      • let lazy_square x =
      • lazy ( print_endline “thinking...“
      • x * x )
      • let lazy_square_ten = lazy_square 10
      • //first time: “thinking…”
      • Lazy.force (lazy_square_ten)
      • //second time: no thinking, just result
      • Lazy.force (lazy_square_ten)
    • 69. Lazy is a virtue
      • let lazy_square x =
      • lazy ( print_endline “thinking...“
      • x * x )
      • let lazy_square_ten = lazy_square 10
      • //first time: “thinking…”
      • Lazy.force (lazy_square_ten)
      • //second time: no thinking, just result
      • Lazy.force (lazy_square_ten)
    • 70. Useful libraries Neat manual Awesome Samples
    • 71.  
    • 72.  
    • 73. “ Empty” source file… 5 pages of help!
    • 74. Make sure F# Interactive is running!
    • 75. F# Interactive:
      • It’s the bomb!
    • 76. F# Interactive:
    • 77.  
    • 78.
      • msdn.microsoft.com/fsharp/
    • 79. 8 Ways to Learn
      • http://cs.hubfs.net
      • Codeplex Fsharp Samples
      • Books
      • ML
    • 80. Acknowledgements
      • Cartman
      • Einstein
      • Dilbert
      • Alan Turing
      • Alonzo Church
      • Godzilla
      • Gears of war
      • John Hughes, Why Functional Programming Matters, http://www.math.chalmers.se/~rjmh/Papers/whyfp.html
      • Robert Pickering, Foundations of F#, http://www.apress.com/book/view/1590597575
      • Slava Akhmechet, Functional Programming For The Rest of Us, http://www.defmacro.org/ramblings/fp.html
      • Steve Yegge, Execution In the Kingdom of Nouns, http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html
      • P. J. Landin, The Next 700 Programming Languages http://www.cs.utah.edu/~wilson/compilers/old/papers/p157-landin.pdf
      • Tim Sweeney, The Next Mainstream Programming Language , http://www.st.cs.uni-sb.de/edu/seminare/2005/advanced-fp/docs/sweeny.pdf
      • Tomas Petricek, F# Web Tools, Ajax Made Simple , http://www.codeplex.com/fswebtools
      • Don Syme, http://blogs.msdn.com/dsyme

    ×