Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.
F# IN THE
ENTERPRISE
Phillip Trelford
@ptrelford
Developer South Coast
2013
F#UNCTIONAL LONDONERS
570 Members
Founded 2010
Meets every 2 weeks
JOULE TRADING SCREEN
TESTIMONIALS F# in the Enterprise
F# FOR PROFIT
Time to Market
Efficiency
Correctness
Complexity
* applied to Analytic components
TIME TO MARKET
speed development by 50 percent or more,
European IB
order of magnitude increase in productivity,
GameSys
EFFICIENCY
processes that used to require hours now take just minutes, Grange
Insurance
performance is 10× better than the...
CORRECTNESS
leads to virtually bug-free code,
Fixed Income
I am still waiting for the first bug to come in,
E-On
COMPLEXITY
everything becomes simple and clear when expressed in F#, Byron Cook
C# & F# BEST FRIENDS
FOREVER
Kaggle Testimonial
The fact that F# targets the CLR
was also critical - even though we
have a...
TEST & INTEGRATION F# in the Enterprise
DEFECT RATE
I am both a C# dev and an F# dev. I can
only offer subjective anecdotal evidence
based on my experience of del...
DEPENDENCY INJECTION
F#
type VerySimpleStockTraderImpl
(analysisService:IStockAnalysisService,
brokerageService:IOnlineBro...
NUNIT
F# NUnit
module MathTest
open NUnit.Framework
let [<Test>] ``2 + 2 should equal 4``() =
Assert.AreEqual(2 + 2, 4)
C#...
FSUNIT
[<Test>]
let ``2 + 2 should equal 4``() =
2 + 2 |> should equal 4
UNQUOTE
let [<Test>] ``2 + 2 = 4``() =
test <@ 2 + 2 = 4 @>
FSCHECK
.NET MOCKING LIBRARY
type ITime =
abstract GetHour : unit -> int
type ImageCalculator (time:ITime) =
member this.GetImageF...
F# OBJECT EXPRESSION
type ITime =
abstract GetHour : unit -> int
type ImageCalculator (time:ITime) =
member this.GetImageF...
HIGHER-ORDER FUNCTION
let imageCalculator getHour =
fun () ->
let hour = getHour()
if hour > 6 && hour < 21
then "sun.jpg"...
MOCKING
F# Foq
let ``order sends mail if unfilled``() =
// setup data
let order = Order("TALISKER", 51)
let mailer = mock(...
CONTINUOUS BUILD
DSLS F# in the Enterprise
TICKSPEC
TICKSPEC OXO EXAMPLE
CELLZ
type formula =
| Neg of formula
| Exp of formula * formula
| ArithmeticOp of
formula * arithmetic * formula
| Logica...
F# PROJECTS F# in the Enterprise
FILE ORDERING
MUTUAL RECURSION
type Folder(path:string) =
let files = Directory.GetFiles(path)
member folder.Files =
[|for file in files...
CYCLES
TickSpec (F#) SpecFlow (C#)
C#/F# INTEROP F# in the Enterprise
C#/F# INTEROP
Mostly it just works
Minor friction points
Equality
Explicit interfaces
Tuples & Union Types
Nulls
Tip: Read...
EQUALITY: POP QUIZ
C# F#
var a =
new Order(Side.Bid, 99.9M, 5);
var b =
new Order(Side.Bid, 99.9M, 5);
return a == b;
let ...
F# REFERENCE EQUALITY
let (==) a b = obj.ReferenceEquals(a,b)
C# ==
public static bool operator == (Order a, Order b)
{
return a.Equals(b);
}
public static bool operator != (Person a, ...
F# -> C# ==
static member op_Equality (a:Order,b:Order) =
a = b
static member op_Inequality (a:Order,b:Order) =
a <> b
OPERATORS F# in the Enterprise
OPERATORS
Brackets
List.reduce (+)
(List.map abs
[-9..+9])
Pipes
[-9..+9]
|> List.map abs
|> List.reduce (+)
SCALA: PIMP MY LIBRARY
F# GUIDELINES
http://fsharp.org/about/files/guidelines.pdf
CONCURRENCY F# in the Enterprise
IMMUTABILITY BY DEFAULT
Types
Tuples
Records
Discriminated Unions
Data structures
List
Map
Set
ASYNC WORKFLOWS
async {
do! control.MouseLeftButtonDown // First class events
|> Async.AwaitEvent
}
TYPE PROVIDERS F# in the Enterprise
TYPE PROVIDERS
WEB
B-MOVIE MADNESS
FUNSCRIPT
TRY F#:
HTTP://TRYFSHARP.ORG
LEARN ME AN F# FOR
GREAT GOOD
F# in the Enterprise
LEARNING F#
Hands on:
F# Koans
Katas/Project Euler
Reading:
F# for Fun and Profit
Podcasts:
.Net Rocks
F# BOOKS
SHOW ME THE MONEY!
QUESTIONS?
Twitter:
@ptrelford
Blog:
http://trelford.com/blog
Foundation:
http://fsharp.org
FSharp in the enterprise
Próxima SlideShare
Cargando en…5
×

FSharp in the enterprise

3.601 visualizaciones

Publicado el

FSharp talk at Developer South Coast meetup July 2013

Publicado en: Tecnología
  • DOWNLOAD FULL BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Responder 
    ¿Estás seguro?    No
    Tu mensaje aparecerá aquí
  • //DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... //DOWNLOAD PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... //DOWNLOAD EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... //DOWNLOAD doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... //DOWNLOAD PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... //DOWNLOAD EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... //DOWNLOAD doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Responder 
    ¿Estás seguro?    No
    Tu mensaje aparecerá aquí
  • //DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... //DOWNLOAD PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... //DOWNLOAD EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... //DOWNLOAD doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... //DOWNLOAD PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... //DOWNLOAD EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... //DOWNLOAD doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Responder 
    ¿Estás seguro?    No
    Tu mensaje aparecerá aquí

FSharp in the enterprise

  1. 1. F# IN THE ENTERPRISE Phillip Trelford @ptrelford Developer South Coast 2013
  2. 2. F#UNCTIONAL LONDONERS 570 Members Founded 2010 Meets every 2 weeks
  3. 3. JOULE TRADING SCREEN
  4. 4. TESTIMONIALS F# in the Enterprise
  5. 5. F# FOR PROFIT Time to Market Efficiency Correctness Complexity * applied to Analytic components
  6. 6. TIME TO MARKET speed development by 50 percent or more, European IB order of magnitude increase in productivity, GameSys
  7. 7. EFFICIENCY processes that used to require hours now take just minutes, Grange Insurance performance is 10× better than the C++ that it replaces, Aviva
  8. 8. CORRECTNESS leads to virtually bug-free code, Fixed Income I am still waiting for the first bug to come in, E-On
  9. 9. COMPLEXITY everything becomes simple and clear when expressed in F#, Byron Cook
  10. 10. C# & F# BEST FRIENDS FOREVER Kaggle Testimonial The fact that F# targets the CLR was also critical - even though 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.
  11. 11. TEST & INTEGRATION F# in the Enterprise
  12. 12. DEFECT RATE I am both a C# dev and an F# dev. I can only offer subjective anecdotal evidence based on my experience of delivering projects in both languages (I am too busy delivering software to do anything else). That said, the one stat in the summary that I find most compelling is the defect rate. I have now delivered three business critical projects written in F#. I am still waiting for the first bug to come in. Simon Cousins, Power Company
  13. 13. DEPENDENCY INJECTION F# type VerySimpleStockTraderImpl (analysisService:IStockAnalysisService, brokerageService:IOnlineBrokerageService) = interface IAutomatedStockTrader with member this.ExecuteTrades() = () // ... C# public class VerySimpleStockTraderImpl : IAutomatedStockTrader { private readonly IStockAnalysisService analysisService; private readonly IOnlineBrokerageService brokerageService; public VerySimpleStockTraderImpl( IStockAnalysisService analysisService, IOnlineBrokerageService brokerageService) { this.analysisService = analysisService; this.brokerageService = brokerageService; } public void ExecuteTrades() { // ... } }
  14. 14. NUNIT F# NUnit module MathTest open NUnit.Framework let [<Test>] ``2 + 2 should equal 4``() = Assert.AreEqual(2 + 2, 4) C# NUnit using NUnit.Framework; [TestFixture] public class MathTest { [Test] public void TwoPlusTwoShouldEqualFour() { Assert.AreEqual(2 + 2, 4); } }
  15. 15. FSUNIT [<Test>] let ``2 + 2 should equal 4``() = 2 + 2 |> should equal 4
  16. 16. UNQUOTE let [<Test>] ``2 + 2 = 4``() = test <@ 2 + 2 = 4 @>
  17. 17. FSCHECK
  18. 18. .NET MOCKING LIBRARY type ITime = abstract GetHour : unit -> int type ImageCalculator (time:ITime) = member this.GetImageForTimeOfDay() = let hour = time.GetHour() if hour > 6 && hour < 21 then "sun.jpg" else "moon.jpg" let [<Test>] `` at 01:00 the moon image should show `` () = let time = Mock().Setup(fun (x:ITime) -> x.GetHour()).Returns(1) let calculator = ImageCalculator(time.Create()) let image = calculator.GetImageForTimeOfDay() Assert.AreEqual("moon.jpg", image)
  19. 19. F# OBJECT EXPRESSION type ITime = abstract GetHour : unit -> int type ImageCalculator (time:ITime) = member this.GetImageForTimeOfDay() = let hour = time.GetHour() if hour > 6 && hour < 21 then "sun.jpg" else "moon.jpg“ let [<Test>] ``at 01:00 the moon image should show`` () = let time = { new ITime with member mock.GetHour() = 01 } let calculator = ImageCalculator(time) let image = calculator.GetImageForTimeOfDay() Assert.AreEqual("moon.jpg", image)
  20. 20. HIGHER-ORDER FUNCTION let imageCalculator getHour = fun () -> let hour = getHour() if hour > 6 && hour < 21 then "sun.jpg" else "moon.jpg" let [<Test>] ``at 01:00 the moon image should show`` () = let getHour () = 01 let getImageForHourOfDay = imageCalculator getHour let image = getImageForHourOfDay () Assert.AreEqual("moon.jpg", image)
  21. 21. MOCKING F# Foq 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 C# Moq 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()); }
  22. 22. CONTINUOUS BUILD
  23. 23. DSLS F# in the Enterprise
  24. 24. TICKSPEC
  25. 25. TICKSPEC OXO EXAMPLE
  26. 26. CELLZ 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 list
  27. 27. F# PROJECTS F# in the Enterprise
  28. 28. FILE ORDERING
  29. 29. MUTUAL RECURSION type Folder(path:string) = let files = Directory.GetFiles(path) member folder.Files = [|for file in files -> File(file,folder)|] and File(filename: string, folder: Folder) = member file.Name = filename member file.Folder = folder
  30. 30. CYCLES TickSpec (F#) SpecFlow (C#)
  31. 31. C#/F# INTEROP F# in the Enterprise
  32. 32. C#/F# INTEROP Mostly it just works Minor friction points Equality Explicit interfaces Tuples & Union Types Nulls Tip: Read the F# Component Design Guidelines
  33. 33. EQUALITY: POP QUIZ C# F# var a = new Order(Side.Bid, 99.9M, 5); var b = new Order(Side.Bid, 99.9M, 5); return a == b; let a = Order(Bid, 99.9M, 5) let b = Order(Bid, 99.9M, 5) a = b
  34. 34. F# REFERENCE EQUALITY let (==) a b = obj.ReferenceEquals(a,b)
  35. 35. C# == public static bool operator == (Order a, Order b) { return a.Equals(b); } public static bool operator != (Person a, Person b) { return !a.Equals(b); }
  36. 36. F# -> C# == static member op_Equality (a:Order,b:Order) = a = b static member op_Inequality (a:Order,b:Order) = a <> b
  37. 37. OPERATORS F# in the Enterprise
  38. 38. OPERATORS Brackets List.reduce (+) (List.map abs [-9..+9]) Pipes [-9..+9] |> List.map abs |> List.reduce (+)
  39. 39. SCALA: PIMP MY LIBRARY
  40. 40. F# GUIDELINES http://fsharp.org/about/files/guidelines.pdf
  41. 41. CONCURRENCY F# in the Enterprise
  42. 42. IMMUTABILITY BY DEFAULT Types Tuples Records Discriminated Unions Data structures List Map Set
  43. 43. ASYNC WORKFLOWS async { do! control.MouseLeftButtonDown // First class events |> Async.AwaitEvent }
  44. 44. TYPE PROVIDERS F# in the Enterprise
  45. 45. TYPE PROVIDERS
  46. 46. WEB
  47. 47. B-MOVIE MADNESS
  48. 48. FUNSCRIPT
  49. 49. TRY F#: HTTP://TRYFSHARP.ORG
  50. 50. LEARN ME AN F# FOR GREAT GOOD F# in the Enterprise
  51. 51. LEARNING F# Hands on: F# Koans Katas/Project Euler Reading: F# for Fun and Profit Podcasts: .Net Rocks
  52. 52. F# BOOKS
  53. 53. SHOW ME THE MONEY!
  54. 54. QUESTIONS? Twitter: @ptrelford Blog: http://trelford.com/blog Foundation: http://fsharp.org

×