• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
F# Eye For The C# Guy - Seattle 2013
 

F# Eye For The C# Guy - Seattle 2013

on

  • 1,400 views

 

Statistics

Views

Total Views
1,400
Views on SlideShare
1,220
Embed Views
180

Actions

Likes
0
Downloads
9
Comments
1

2 Embeds 180

https://twitter.com 178
https://si0.twimg.com 2

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

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • I Got The Full File, I Just Wanna Share to You Guyszz.. It's Working You Can The Download The Full File + Instructions Here : http://gg.gg/setupexe
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • MonoDevelop,Emacs & VIM

F# Eye For The C# Guy - Seattle 2013 F# Eye For The C# Guy - Seattle 2013 Presentation Transcript

  • F# Eye 4 the C# GuyPhillip Trelford@ptrelfordhttp://trelford.com/blog
  • Thoughtworks Tech RadarMarch 2012 - Languages
  • “F# is excellent at concisely expressing business and domain logic.”“Developers trying to achieve explicit business logic within an application may opt to express their domain in F# with the majority of plumbing code in C#.”Thoughtworks Tech RadarMarch 2012 - Quotes
  • Visual F#
  • The F in F# is for FUN!
  • Halo 3 with F# Skills
  • XBLA: Path to Go – F# AI
  • Facebook: Monopoly
  • • Statically Typed• Functional• Object Orientated• Open Source• .Net language• In Visual StudioF#
  • • Idempotent Functions• Higher Order Functions• Pattern MatchingFunctional Programming
  • Functions - Excel
  • F# Map/Reduce C# Map/Reducelet map f xs = seq { public static for x in xs do IEnumerable<R> Map<T, R> (this IEnumerable<T> xs, yield f x Func<T, R> f) } { foreach (var x in xs)let reduce f init items = yield return f(x); let mutable current = init } for item in items do public static R current <- f current item Reduce<T, R> current (this IEnumerable<T> xs, R init, Func<R, T, R> f) { var current = init; foreach (var x in xs) current = f(current, x); return current; }Higher Order Functions
  • F# C#match day with switch (day) {| 0 -> "Sunday" case 0: return "Sunday"; case 1: return "Monday";| 1 -> "Monday" case 2: return "Tuesday";| 2 -> "Tuesday" case 3: return "Wednesday";| 3 -> "Wednesday" case 4: return "Thursday";| 4 -> "Thursday" case 5: return "Friday";| 5 -> "Friday" case 6: return "Saturday"; default:| 6 -> "Saturday" throw new| _ –> ArgumentException("day"); invalidArg "Invalid day" }Pattern Matching
  • DEMOS
  • F# C#type Person(name:string,age:int) = public class Person { public Person(string name, int age) /// Full name { member person.Name = name _name = name; _age = age; /// Age in years } member person.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; } } }Light Syntax: POCOs
  • C# F#public class VerySimpleStockTraderImpl : IAutomatedStockTrader type VerySimpleStockTraderImpl{ (analysisService:IStockAnalysisService, private readonly IStockAnalysisService analysisService; private readonly IOnlineBrokerageService brokerageService; brokerageService:IOnlineBrokerageService) = member this.ExecuteTrades() = () // ... public VerySimpleStockTraderImpl( IStockAnalysisService analysisService, IOnlineBrokerageService brokerageService) { this.analysisService = analysisService; this.brokerageService = brokerageService; } public void ExecuteTrades() { // ... }}Light Syntax: DI
  • F# NUnit C# NUnitmodule MathTest = using NUnit.Framework;open NUnit.Framework [TestFixture] public class MathTest {let [<Test>] ``2 + 2 should equal 4``() = [Test] Assert.AreEqual(2 + 2, 4) public void TwoPlusTwoShouldEqualFour() { Assert.AreEqual(2 + 2, 4); } }Unit Testing
  • BDD
  • Units of Measure
  • type formula = | Neg of formula | Exp of formula * formula | ArithmeticOp of formula * arithmetic * formula | LogicalOp of formula * logical * formula | Num of UnitValue | Ref of int * int | Range of int * int * int * int | Fun of string * formula listUnits in Cells
  • F# 3.0Type Providers
  • SUMMARY
  • F# Books
  • @rickasaurus @tomaspetricek @jonharropMeet the F#ersTwitter #fsharp
  • #chtd Quote from "future of .net" Have a look at F# for two days and you will find yourself two years ahead of your peer .net devs. #fsharp@jbandi
  • Links Connect• http://fsharp.org • @ptrelford• http://fssnip.net • phil@trelford.com• http://tryfsharp.org • http://trelford.com/blogQ&A