F# Eye for the C# Guy

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

2 comments

Comments 1 - 2 of 2 previous next Post a comment

  • + haveaword Tanveer Iqbal 2 years ago
    Interesting perfect show thanks for sharing
  • + guest86a3cd guest86a3cd 2 years ago
    Console.WriteLine(a()) would be more correct... (for slide 44, not slide 1)
Post a comment
Embed Video
Edit your comment Cancel

Notes on slide 1

What’s this F# thing anyway?

4 Favorites

F# Eye for the C# Guy - Presentation 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!
    • No Shared State
    Purely functional…
    • Why learn F#?
    • Do More With Less
      • “ If I was using F# I’d be done by now”
    Why learn F#?
    • 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#?
    • 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#?
    • Moore’s Law Keeps Going!
    Why learn F#?
    • But computers are not getting faster
    Why learn F#?
    • Data Grows Quickly
    • But # of Dimensions Grows much faster!
    • And semi-structured data outgrowing structured
    • Entropy Increasing
    • Complexity is through the roof!
    • “ Software gets slower faster than hardware gets faster”
    • --Wirth’s Law
  11.  
    • Some stuff is now cheap!
      • Ram
      • Disk
      • Cores
    • Some stuff remains expensive!
      • Time
      • Concurrency
      • Locking
    Computer Economics is Changing
    • Some stuff is now cheap!
      • Ram
      • Disk
      • Cores
    • Some stuff remains expensive!
      • Time
      • Concurrency
      • Locking
    Computer Economics is Changing
    • Some stuff is now cheap!
      • Ram
      • Disk
      • Cores
    • Some stuff remains expensive!
      • Time
      • Concurrency
      • Locking
    Computer Economics is Changing
    • Some stuff is now cheap!
      • Ram
      • Disk
      • Cores
    • Some stuff remains expensive!
      • Real Time
      • Concurrency
      • Locking
    Computer Economics is Changing
  12. This tips the balance toward higher abstractions
  13. 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
  14. Think About Game Programming
  15. Game Programming Involves…
    • 3D Animation
    • Rendering
    • Shading
    • Simulation (e.g. physics)
    • Collision Detection
    • AI Opponents
  16. Genealogy of F # …
    • Theorem proving and ISWIM
  17. Genealogy of F # …
    • Theorem proving and ISWIM begat:
      • ML “Meta Language”
  18. Genealogy of F # …
    • Theorem proving and ISWIM begat:
      • ML “Meta Language”, which begat:
        • CAML
  19. Genealogy of F # …
    • Theorem proving and ISWIM begat:
      • ML “Meta Language”, which begat:
        • CAML, which in turn begat
          • OCaml
    Oh!
  20. 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!
  21. WTF # ?
    • First official functional language on .net
  22. WTF # ?
    • First official functional language on .net
    • Deep support thanks to Generics
  23. WTF # ?
    • First official functional language on .net
    • Deep support thanks to Generics
    • Assimilated by dev-div
  24. WTF # ?
    • First official functional language on .net
    • Deep support thanks to Generics
    • Assimilated by dev-div
    • Will ship in VS.next
  25. Code!
    • Finally!
  26. Code!
    • //F#
    • let a = 2
  27. Code!
    • //F#
    • let a = 2
    The ‘let’ keyword represents a binding between a value and an expression tree.
  28. Code!
    • //F#
    • let a = 2
    The ‘let’ blah blah blahblah blah blahblah blahblah blah blah blah blah blah blah.
  29. Code!
    • //F#
    • let a = 2
    //C# int a = 2 ≠
  30. Code!
    • //F#
    • let a = 2
    //C# //a function! static int a() { return 2; } More like
  31. 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); } } }
  32. More Code!
    • //F#
    • #light
    • open System
    • let a = 2
    • Console.WriteLine a
    More Noise Than Signal!
  33. More Code!
    • //F#
    • #light
    • open System
    • let a = 2
    • Console.WriteLine a
    Looks Weakly typed? Maybe Dynamic?
  34. F#?
  35. F#
  36. F# Yet Expressive
  37. F# Yet Versatile
  38. More Code!
    • //F#
    • #light
    • open System
    • let a = 2
    • Console.WriteLine a
    Type Inference
    • let a = 2
    • let a = 3
    • error: FS0037: Duplicate definition of value 'a'
    Immutable by default
    • let square x = x * x
    • > val square : int -> int
    • square 5
    • > val it : int = 25
    simple function…
    • let square x = x * x
    • > val square : int -> int
    • square 5
    • > val it : int = 25
    simple function… Parameter
    • let square x = x * x
    • > val square : int -> int
    • square 5
    • > val it : int = 25
    simple function… “ Signature”
    • let square x = x * x
    • > val square : int -> int
    • square 5
    • > val it : int = 25
    simple function… Types are “inferred”
  39. Discriminated union types
    • type NullableInt =
    • | Value of int
    • | Nothing of unit
  40. Discriminated union types
    • type NullableInt =
    • | Value of int
    • | Nothing of unit
    Wish C#/“O-O” had this.
  41. 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
  42. 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…
  43. 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?
  44. Another great tool is “pattern matching”
  45. Another great tool is “pattern matching” “ Switch/Case” statements on steroids
  46. Another great tool is “pattern matching” “ Switch/Case” statements on steroids “ method overloads” on crack
  47. Discriminated unions example
    • type Weapon =
    • | Knife
    • | Gun
    • | Bomb
  48. 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
  49. 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
  50. 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)
  51. 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)
  52. Useful libraries Neat manual Awesome Samples
  53.  
  54.  
  55. “ Empty” source file… 5 pages of help!
  56. Make sure F# Interactive is running!
  57. F# Interactive:
    • It’s the bomb!
  58. F# Interactive:
  59.  
    • msdn.microsoft.com/fsharp/
  60. 8 Ways to Learn
    • http://cs.hubfs.net
    • Codeplex Fsharp Samples
    • Books
    • ML
  61. 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

+ gueste3f83dgueste3f83d, 2 years ago

custom

4749 views, 4 favs, 19 embeds more stats

F# Eye for the C# Guy by Leon Bambrick

More info about this document

© All Rights Reserved

Go to text version

  • Total Views 4749
    • 2496 on SlideShare
    • 2253 from embeds
  • Comments 2
  • Favorites 4
  • Downloads 46
Most viewed embeds
  • 2181 views on http://www.hanselman.com
  • 39 views on http://www.axisebusiness.com
  • 7 views on http://www.agglom.com
  • 5 views on http://esd-matisa.blogspot.com
  • 4 views on http://www.adnanmasood.com

more

All embeds
  • 2181 views on http://www.hanselman.com
  • 39 views on http://www.axisebusiness.com
  • 7 views on http://www.agglom.com
  • 5 views on http://esd-matisa.blogspot.com
  • 4 views on http://www.adnanmasood.com
  • 3 views on http://voraanjana.blogspot.com
  • 2 views on http://www.slideshare.net
  • 1 views on http://www.worldoflinks.net
  • 1 views on http://www.hanrss.com
  • 1 views on https://nhmailsrv01.needhost.dk
  • 1 views on http://ayende.com
  • 1 views on http://www.xianguo.com
  • 1 views on http://feeds.feedburner.com
  • 1 views on http://209.85.135.104
  • 1 views on file://
  • 1 views on http://msdn.microsoft.com
  • 1 views on http://davesbox.com
  • 1 views on http://blogs.msdn.com
  • 1 views on http://adnanmasood.com

less

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

Cancel
File a copyright complaint
Having problems? Go to our helpdesk?

Categories

Tags