F# Information RichProgrammingRodrigo VidalVisual F# MVP
What’s in this talk?•   Intro to F#•   Language features for solving real-world problems•   F# Type Provider demos•   Futu...
F# Tagline F# is a practical, functional-first language       that lets you write simple code         to solve complex pro...
Created By
Motivation        Ideas   Product     Research   Reality
#inceptionLambda     LISP   ML   Ocaml   HaskellCalculus                                 F#
F# 1.0      Functional + Objects + .NET F# 2.0     Functional + Objects + .NET +Async + Parallel + Interactive + Scripting
12                      C#, VB,             10                       Java                                           LINQ  ...
Immutability       “Values are immutable by default”
Side Effects  • Example: “The Butterfly Effect”• A side effect  •   Modifies some state  •   Has observable interaction wi...
Composing Functions                   f(x)f(x) = 3x+2g(y) = 4y-1     g(f(2)) = ?                          g(x)
Simplicity
abstract class Command {Simplicity                                 }                                               public ...
SimplicityFunctional data     let swap (x, y) = (y, x)    Tuple<U,T> Swap<T,U>(Tuple<T,U> t)F#                            ...
F# is declarative
F# 3.0Information Rich Programming
Two propositions
Proposition 1:We live in an information society
Proposition 2:Our languages are information sparse
A Big Problem
Challenges• Impedance mismatch with statically-typed languages• Need to manually integrate codegen tools with build  proce...
But…• Data sources often have rich schemas and associated  data definitions• Static types should make your experience bett...
Why this mattersProgramming the web
F# Type Providers:IntelliSense for data
Type provider   IDE                   CompilerIntelliSense for                     Type-Check     Compile using  Generated...
Demo summary• Can program against web-scale schematized data  • code gen would never work here!• Don’t have to wait for co...
Demo 3:Web service with multiple data sources
What’s next for F#?• Cloud, cloud cloud!• Make F# programming on Azure even easier• Can use F# computation expressions to ...
Computation in the Cloud
Cloud Numerics• Extensive library of numerical algorithms  • Ranges from basic math to advanced statistics to linear algeb...
F#3.0
Upcoming SlideShare
Loading in …5
×

F#3.0

467 views

Published on

Apresentação de F# 3.0

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
467
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • have linq, have create way to manipulate data, but how do you get the schema?
  • who here has used one of these apis?
  • show how cloud numerics solves a problem“how would you do numerical analysis on large quantities of data?”(be interactive)- connect to problems they are already working on- “show how sausage is made” : what were we thinking in design?- type providers are linq on steroids
  • F#3.0

    1. 1. F# Information RichProgrammingRodrigo VidalVisual F# MVP
    2. 2. What’s in this talk?• Intro to F#• Language features for solving real-world problems• F# Type Provider demos• Future directions
    3. 3. F# Tagline F# is a practical, functional-first language that lets you write simple code to solve complex problems
    4. 4. Created By
    5. 5. Motivation Ideas Product Research Reality
    6. 6. #inceptionLambda LISP ML Ocaml HaskellCalculus F#
    7. 7. F# 1.0 Functional + Objects + .NET F# 2.0 Functional + Objects + .NET +Async + Parallel + Interactive + Scripting
    8. 8. 12 C#, VB, 10 Java LINQ F# Nirvana 8Usefulness 6 C# Nirvana 4 Haskell LINQ 2 Haskell 0 0 2 4 6 8 10 12 Safety http://channel9.msdn.com/posts/Charles/Simon-Peyton-Jones-Towards-a-Programming-Language-Nirvana/
    9. 9. Immutability “Values are immutable by default”
    10. 10. Side Effects • Example: “The Butterfly Effect”• A side effect • Modifies some state • Has observable interaction with calling functions • Has observable interaction with the outside world • Example: a function or method with no return value
    11. 11. Composing Functions f(x)f(x) = 3x+2g(y) = 4y-1 g(f(2)) = ? g(x)
    12. 12. Simplicity
    13. 13. abstract class Command {Simplicity } public virtual void Execute(); C# abstract class RoverCommand : Command {Functions as values protected Rover Rover { get; private set; } public RoverCommand(MarsRover rover) { this.Rover = rover; } F# } class BrakeCommand : RoverCommand {type Command = Rover -> unit public BrakeCommand(Rover rover) : base(rover) { }let BrakeCommand = public override void Execute() { fun rover -> rover.Accelerate(-1.0) Rover.Accelerate(-1.0); } }let TurnLeftCommand = class TurnLeftCommand : RoverCommand { fun rover -> rover.Rotate(-5.0<degs>) public TurnLeftCommand(Rover rover) : base(rover) {} public override void Execute() { Rover.Rotate(-5.0); } }
    14. 14. SimplicityFunctional data let swap (x, y) = (y, x) Tuple<U,T> Swap<T,U>(Tuple<T,U> t)F# { C# return new Tuple<U,T>(t.Item2, t.Item1) } let rotations (x, y, z) = ReadOnlyCollection<Tuple<T,T,T>> Rotations<T> (Tuple<T,T,T> t) [ (x, y, z); { (z, x, y); new ReadOnlyCollection<int> (new Tuple<T,T,T>[] (y, z, x) ] { new Tuple<T,T,T>(t.Item1,t.Item2,t.Item3); new Tuple<T,T,T>(t.Item3,t.Item1,t.Item2); new Tuple<T,T,T>(t.Item2,t.Item3,t.Item1); }); } let reduce f (x, y, z) = int Reduce<T>(Func<T,int> f,Tuple<T,T,T> t) { f x + f y + f z return f(t.Item1) + f(t.Item2) + f (t.Item3); }
    15. 15. F# is declarative
    16. 16. F# 3.0Information Rich Programming
    17. 17. Two propositions
    18. 18. Proposition 1:We live in an information society
    19. 19. Proposition 2:Our languages are information sparse
    20. 20. A Big Problem
    21. 21. Challenges• Impedance mismatch with statically-typed languages• Need to manually integrate codegen tools with build process, source control, etc.• No elegant way to handle schema change• Loss of type information due to up-casts to Object, or even have to just parse strings
    22. 22. But…• Data sources often have rich schemas and associated data definitions• Static types should make your experience better, not worse!
    23. 23. Why this mattersProgramming the web
    24. 24. F# Type Providers:IntelliSense for data
    25. 25. Type provider IDE CompilerIntelliSense for Type-Check Compile using Generated Imported Types Type Provider Types
    26. 26. Demo summary• Can program against web-scale schematized data • code gen would never work here!• Don’t have to wait for codegen or code to compile• With typechecking! • Can detect schema change• With great Visual Studio tooling!
    27. 27. Demo 3:Web service with multiple data sources
    28. 28. What’s next for F#?• Cloud, cloud cloud!• Make F# programming on Azure even easier• Can use F# computation expressions to add new syntax in a library • for example, cloud { … } • F# async and query expressions are not built-in syntax—they use computation expressions
    29. 29. Computation in the Cloud
    30. 30. Cloud Numerics• Extensive library of numerical algorithms • Ranges from basic math to advanced statistics to linear algebra• Supports distributed arrays and computation• Can deploy to Azure when lots of compute resources are needed

    ×