• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
F# Eye for the C# guy - Øredev 2013
 

F# Eye for the C# guy - Øredev 2013

on

  • 3,233 views

Introduction to F# for C# developers presented at Øredev in Malmö, Sweden

Introduction to F# for C# developers presented at Øredev in Malmö, Sweden

Statistics

Views

Total Views
3,233
Views on SlideShare
998
Embed Views
2,235

Actions

Likes
2
Downloads
4
Comments
0

20 Embeds 2,235

http://trelford.com 1533
http://www.trelford.com 293
http://qchat 108
https://twitter.com 66
http://cloud.feedly.com 59
http://www.feedspot.com 56
http://feedreader.com 25
http://eventifier.co 18
http://digg.com 18
http://feedly.com 18
http://www.newsblur.com 16
http://eventifier.com 14
http://newsblur.com 2
http://www.inoreader.com 2
http://newsvi.be 2
https://www.google.co.uk 1
http://www.tuicool.com 1
http://silverreader.com 1
http://inoreader.com 1
http://ec2-54-243-189-159.compute-1.amazonaws.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • MonoDevelop,Emacs & VIM
  • http://fsharp.org/testimonials/#kaggle-1Don’t throw out the baby with the bath water

F# Eye for the C# guy - Øredev 2013 F# Eye for the C# guy - Øredev 2013 Presentation Transcript

  • Phil Trelford, @ptrelford #oredev, Malmö, Sweden 2013
  •  Statically Typed  Functional First  Object Orientated  Open Source  .Net language  In Visual Studio & Xamarin Studio
  • Kaggle The fact that F# targets the CLR was also critical we have a large existing code base in C#, getting started with F# was an easy decision because we knew we could use new modules right away.
  • The F# code is consistently shorter, easier to read, easier to refactor and contains far fewer bugs. …we’ve become more productive.
  • Phil Trelford, @ptrelford #oredev, Malmö, Sweden 2013
  • F# C# type Person(name:string,age:int) = /// Full name member person.Name = name /// Age in years member person.Age = age 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
  • F# type VerySimpleStockTrader (analysisService:IStockAnalysisService, brokerageService:IOnlineBrokerageService) = member this.ExecuteTrades() = C# public class VerySimpleStockTrader { private readonly IStockAnalysisService analysisService; private readonly IOnlineBrokerageService brokerageService; public VerySimpleStockTrader( IStockAnalysisService analysisService, IOnlineBrokerageService brokerageService) { this.analysisService = analysisService; this.brokerageService = brokerageService; } () // ... public void ExecuteTrades() { // ... } }
  • F# NUnit C# NUnit module MathTest = using NUnit.Framework; open NUnit.Framework [TestFixture] public class MathTest { [Test] public void TwoPlusTwoShouldEqualFour() { Assert.AreEqual(2 + 2, 4); } } let [<Test>] ``2 + 2 should equal 4``() = Assert.AreEqual(2 + 2, 4)
  • F# Foq C# Moq let ``order sends mail if unfilled``() = // setup data let order = Order("TALISKER", 51) let mailer = mock() order.SetMailer(mailer) // exercise order.Fill(mock()) // verify verify <@ mailer.Send(any()) @> once public void OrderSendsMailIfUnfilled() { // setup data var order = new Order("TALISKER", 51); var mailer = new Mock<MailService>(); order.SetMailer(mailer.Object); // exercise order.Fill(Mock.Of<Warehouse>()); // verify mailer.Verify(mock => mock.Send(It.IsAny<string>()), Times.Once()); }
  • open FSharp.Data type Simple = JsonProvider<""" { "name":"John", "age":94 } """> let simple = Simple.Parse(""" { "name":"Tomas", "age":4 } """) Simple.Age
  • Phil Trelford, @ptrelford #oredev, Malmö, Sweden 2013
  • //--------------------------------------------------------------// About Let // // The let keyword is one of the most fundamental parts of F#. // You'll use it in almost every line of F# code you write, so // let's get to know it well! (no pun intended) //--------------------------------------------------------------[<Koan(Sort = 2)>] module ``about let`` = [<Koan>] let LetBindsANameToAValue() = let x = 50 AssertEquality x __
  • Phil Trelford, @ptrelford #oredev, Malmö, Sweden 2013