F# eye for the C# guy - NorDev Norwich

  • 596 views
Uploaded on

Introduction to the F# language for curious C# developers

Introduction to the F# language for curious C# developers

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
596
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
0
Comments
0
Likes
4

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
  • MonoDevelop,Emacs & VIM

Transcript

  • 1. F# Eye 4 the C# GuyPhillip Trelford@ptrelfordhttp://trelford.com/blog
  • 2. Visual F#
  • 3. The F in F# is for FUN!
  • 4. Halo 3 with F# Skills
  • 5. XBLA: Path to Go – F# AI
  • 6. Facebook: Monopoly
  • 7. F#• Statically Typed• Functional• Object Orientated• Open Source• .Net language• In Visual Studio& Xamarin Studio
  • 8. F# for Profit• Time to Market• Efficiency• Correctness• Complexity
  • 9. Time to marketspeed development by 50 percent or more,European IBorder of magnitude increase in productivity,GameSys
  • 10. Efficiencyprocesses that used to require hours now take just minutes,Grange Insuranceperformance is 10× better than the C++ that it replaces,Aviva
  • 11. Correctnessleads to virtually bug-free code,Fixed IncomeI am still waiting for the first bug to come in,E-On
  • 12. Complexityeverything becomes simple and clear when expressed in F#,Byron Cook
  • 13. DEMOS
  • 14. Light Syntax: POCOsF#type Person(name:string,age:int) =/// Full namemember person.Name = name/// Age in yearsmember person.Age = ageC#public class Person{public Person(string name, int age){_name = name;_age = age;}private readonly string _name;private readonly int _age;/// <summary>/// Full name/// </summary>public string Name{get { return _name; }}/// <summary>/// Age in years/// </summary>public int Age{get { return _age; }}}
  • 15. Light Syntax: DIF#type VerySimpleStockTraderImpl(analysisService:IStockAnalysisService,brokerageService:IOnlineBrokerageService) =interface IAutomatedStockTrader withmember this.ExecuteTrades() =() // ...C#public class VerySimpleStockTraderImpl: IAutomatedStockTrader{private readonlyIStockAnalysisService analysisService;private readonlyIOnlineBrokerageService brokerageService;public VerySimpleStockTraderImpl(IStockAnalysisService analysisService,IOnlineBrokerageService brokerageService){this.analysisService = analysisService;this.brokerageService = brokerageService;}public void ExecuteTrades(){// ...}}
  • 16. Unit TestingF# NUnitmodule MathTest =open NUnit.Frameworklet [<Test>] ``2 + 2 should equal 4``() =Assert.AreEqual(2 + 2, 4)C# NUnitusing NUnit.Framework;[TestFixture]public class MathTest{[Test]public voidTwoPlusTwoShouldEqualFour(){Assert.AreEqual(2 + 2, 4);}}
  • 17. MockingF# Foqlet [<Test>] ``order sends mail if unfilled``() =// setup datalet order = Order("TALISKER", 51)let mailer = mock()order.SetMailer(mailer)// exerciseorder.Fill(mock())// verifyverify <@ mailer.Send(any()) @> onceC# Moqpublic void OrderSendsMailIfUnfilled(){// setup datavar order = new Order("TALISKER", 51);var mailer = new Mock<MailService>();order.SetMailer(mailer.Object);// exerciseorder.Fill(Mock.Of<Warehouse>());// verifymailer.Verify(mock =>mock.Send(It.IsAny<string>()),Times.Once());}
  • 18. Tickspec: Debugging
  • 19. FunScriptTypeScript Type Provider
  • 20. Try F#:http://tryfsharp.org
  • 21. RESOURCES
  • 22. F# Books
  • 23. F#UNCTIONAL LONDONERS• 550 Members• Founded 2010• Meets every 2 weeks
  • 24. Meet the F#ersTwitter #fsharp@rickasaurus@tomaspetricek@jonharrop
  • 25. Show me the money!
  • 26. Questions?Twitter:@ptrelfordBlog:http://trelford.com/blogFoundation:http://fsharp.org