F# for BLOBA 
It isn’t just for Science and Financial 
Domains 
Boring Line Of Business Applications
Brandon D’Imperio 
imaginarydevelopment.blogspot.com 
@maslowjax
A Team of 3 Devs Beat a Team of 8 
A team that peaked at 3 developers (only one 
of which knew F#) finished in 1 year what a 
team that peaked at 8 developers couldn’t do in 
5.
But That’s Just One Company Rave 
● @TachyusCorp - From zero to shipping 
product in 12 weeks ( $28 million within 26 
months) 
● Princeton University - F# ... made it trivial ... 
( Graduate courses on Parallelism)
Define Win 
Implementation C# F# 
Braces 56,929 643 
Blanks 29,080 3,630 
Null Checks 3,011 15 
Comments 53,270 487 
Useful Code 163,276 16,667 
App Code 305,566 21,442 
Test Code 42,864 9,359 
Total Code 348,430 30,801
LoC is a Terrible Metric 
In most ways yes. 
C#, F# 
● Test Code Ratio 14%, 44% 
● Useful Code Ratio 53%, 78% 
o Almost half the c# code was noise 
● The C# was not finished and often failed to 
reach near-real-time
What Does This Mean to Me? 
● Could you find bugs more easily in 1/5th of 
the code? 1/10th? 
● OOP SOLID and Design patterns become a 
thing of the past 
o Design patterns are language bug reports - 
(paraphrased) - Peter Norvig 
o DI is not even relevant
A Code Break - What’s Wrong? (with both) 
C# 
public class Contact { 
public string FirstName {get;set;} 
public string MiddleInitial {get;set;} 
public string LastName {get;set;} 
public string EmailAddress {get;set;} 
// true if ownership of email address 
is confirmed 
public bool IsEmailVerified {get;set;} 
} 
F# 
type Contact = { 
FirstName: string 
MiddleInitial: string 
LastName: string 
EmailAddress: string 
// true if ownership of email address 
is confirmed 
IsEmailVerified: bool 
}
What’s Wrong? 
Which are optional? 
What are the constraints? (are all strings allowed to be 
unlimited length?) 
Which fields have a relationship? 
What is the domain logic?
Desired Features of BLOBA Development 
● Express requirements clearly
Desired Features of BLOBA Development 
● Express requirements clearly - Is the flow of 
the code clearer with less noise?
Desired Features of BLOBA Development 
● Express requirements clearly 
● Rapid development cycle 
o Built-in REPL 
o Far less boilerplate code 
o Production-ready code capability for non-f# devs in 
2-4 weeks
Desired Features of BLOBA Development 
● Express requirements clearly 
● Rapid development cycle 
● High quality deliverables 
o Why don’t we sub-type ints? (Primitive Obsession) 
o Is that int the Id of a user or the Id of something 
else?
Desired Features of BLOBA Development 
● Express requirements clearly 
● Rapid development cycle 
● High quality deliverables 
● Fun (Ruby anyone?)
Features not to be missed 
● No null 
● Extended strong typing 
● Enums (DU), Records (no more mapping 
code), Units of Measure, Strongly typed 
strings! 
o Type Providers 
o Design-time checking of string formats
Units of Measure 
[<Measure>] 
type MemberId 
[<Measure>] 
type m // meters 
[<Measure>] 
type mile 
let mPerMile: float<m/mile> = 1609.34<m/mile> 
let milesToMeters (mi:float<mile>) = mi * mPerMile
Features We’d Like to Forget 
● Inheritance 
● Mutability 
● Accidental Recursion 
● Cyclic Dependencies 
o In C# 
 Very do-able via Web References 
 Very do-able within an assembly
Features Worth Mentioning 
● Pattern matching 
● Composition over inheritance 
● typedefof<> and typeof<>
Methods 
C# 
public void Main(string[] args){ /* … */ } 
F# 
● let Main (args: string[]) = ... 
● let Main (args: string array) = … 
● let Main args = ...
Method calling options 
let HelloWorld a b c = … 
let HelloWorld (a,b,c) = … 
let HelloWorld (a,b) c = … // different 
// more concrete 
let ProcessName first m last = …
More stats 
● Compiler comparison 
o LoC 
 Roslyn C# - almost 500k lines of code 
 F# - 150k lines of code 
 over half the C# lines are non-useful 
o Cycles 
 899 mutually dependent classes vs ZERO
Warts 
● (args:string[]) [] means array here every other context in F# [ ] would be a 
list. 
● required fun! fun e -> e instead of C#’s e => e 
● printfn with [<Measure>] (fixed in next version most likely) 
● this. everywhere inside a type 
● no protected members 
● Property syntaxes ( immutable, mutable) (auto option) 
o member this.MyProp = foo //immutable 
o member this.MyProp with get() = … // mutable 
o member val MyProp = “” // auto immutable 
o member val MyProp = “” with get,set // auto mutable
Links 
● My blog 
o http://imaginarydevelopment.blogspot.com/ 
o Why am I so enthusiastic about F#? - 
http://imaginarydevelopment.blogspot.com/2014/06/why-am-i-so-enthusiastic-about-f.html 
● F# cheat sheet - http://dungpa.github.io/fsharp-cheatsheet/ 
● Domain Driven Design using the F# type system - 
https://www.slideshare.net/slideshow/embed_code/28992749 - Scott Wlaschin 
● Does the language you use make a difference (revisited) - 
http://simontcousins.azurewebsites.net/does-the-language-you-use-make-a-difference-revisited/ 
● What about inheritance? - http://codewonderings.blogspot.com/2012/09/what-about-inheritance. 
html 
● SOLID: the next step is Functional http://blog.ploeh.dk/2014/03/10/solid-the-next-step-is-functional/ 
- Mark Seemann

F# for BLOBA, by brandon d'imperio

  • 1.
    F# for BLOBA It isn’t just for Science and Financial Domains Boring Line Of Business Applications
  • 2.
  • 3.
    A Team of3 Devs Beat a Team of 8 A team that peaked at 3 developers (only one of which knew F#) finished in 1 year what a team that peaked at 8 developers couldn’t do in 5.
  • 4.
    But That’s JustOne Company Rave ● @TachyusCorp - From zero to shipping product in 12 weeks ( $28 million within 26 months) ● Princeton University - F# ... made it trivial ... ( Graduate courses on Parallelism)
  • 5.
    Define Win ImplementationC# F# Braces 56,929 643 Blanks 29,080 3,630 Null Checks 3,011 15 Comments 53,270 487 Useful Code 163,276 16,667 App Code 305,566 21,442 Test Code 42,864 9,359 Total Code 348,430 30,801
  • 6.
    LoC is aTerrible Metric In most ways yes. C#, F# ● Test Code Ratio 14%, 44% ● Useful Code Ratio 53%, 78% o Almost half the c# code was noise ● The C# was not finished and often failed to reach near-real-time
  • 7.
    What Does ThisMean to Me? ● Could you find bugs more easily in 1/5th of the code? 1/10th? ● OOP SOLID and Design patterns become a thing of the past o Design patterns are language bug reports - (paraphrased) - Peter Norvig o DI is not even relevant
  • 8.
    A Code Break- What’s Wrong? (with both) C# public class Contact { public string FirstName {get;set;} public string MiddleInitial {get;set;} public string LastName {get;set;} public string EmailAddress {get;set;} // true if ownership of email address is confirmed public bool IsEmailVerified {get;set;} } F# type Contact = { FirstName: string MiddleInitial: string LastName: string EmailAddress: string // true if ownership of email address is confirmed IsEmailVerified: bool }
  • 9.
    What’s Wrong? Whichare optional? What are the constraints? (are all strings allowed to be unlimited length?) Which fields have a relationship? What is the domain logic?
  • 10.
    Desired Features ofBLOBA Development ● Express requirements clearly
  • 11.
    Desired Features ofBLOBA Development ● Express requirements clearly - Is the flow of the code clearer with less noise?
  • 12.
    Desired Features ofBLOBA Development ● Express requirements clearly ● Rapid development cycle o Built-in REPL o Far less boilerplate code o Production-ready code capability for non-f# devs in 2-4 weeks
  • 13.
    Desired Features ofBLOBA Development ● Express requirements clearly ● Rapid development cycle ● High quality deliverables o Why don’t we sub-type ints? (Primitive Obsession) o Is that int the Id of a user or the Id of something else?
  • 14.
    Desired Features ofBLOBA Development ● Express requirements clearly ● Rapid development cycle ● High quality deliverables ● Fun (Ruby anyone?)
  • 15.
    Features not tobe missed ● No null ● Extended strong typing ● Enums (DU), Records (no more mapping code), Units of Measure, Strongly typed strings! o Type Providers o Design-time checking of string formats
  • 16.
    Units of Measure [<Measure>] type MemberId [<Measure>] type m // meters [<Measure>] type mile let mPerMile: float<m/mile> = 1609.34<m/mile> let milesToMeters (mi:float<mile>) = mi * mPerMile
  • 17.
    Features We’d Liketo Forget ● Inheritance ● Mutability ● Accidental Recursion ● Cyclic Dependencies o In C#  Very do-able via Web References  Very do-able within an assembly
  • 18.
    Features Worth Mentioning ● Pattern matching ● Composition over inheritance ● typedefof<> and typeof<>
  • 19.
    Methods C# publicvoid Main(string[] args){ /* … */ } F# ● let Main (args: string[]) = ... ● let Main (args: string array) = … ● let Main args = ...
  • 20.
    Method calling options let HelloWorld a b c = … let HelloWorld (a,b,c) = … let HelloWorld (a,b) c = … // different // more concrete let ProcessName first m last = …
  • 21.
    More stats ●Compiler comparison o LoC  Roslyn C# - almost 500k lines of code  F# - 150k lines of code  over half the C# lines are non-useful o Cycles  899 mutually dependent classes vs ZERO
  • 22.
    Warts ● (args:string[])[] means array here every other context in F# [ ] would be a list. ● required fun! fun e -> e instead of C#’s e => e ● printfn with [<Measure>] (fixed in next version most likely) ● this. everywhere inside a type ● no protected members ● Property syntaxes ( immutable, mutable) (auto option) o member this.MyProp = foo //immutable o member this.MyProp with get() = … // mutable o member val MyProp = “” // auto immutable o member val MyProp = “” with get,set // auto mutable
  • 23.
    Links ● Myblog o http://imaginarydevelopment.blogspot.com/ o Why am I so enthusiastic about F#? - http://imaginarydevelopment.blogspot.com/2014/06/why-am-i-so-enthusiastic-about-f.html ● F# cheat sheet - http://dungpa.github.io/fsharp-cheatsheet/ ● Domain Driven Design using the F# type system - https://www.slideshare.net/slideshow/embed_code/28992749 - Scott Wlaschin ● Does the language you use make a difference (revisited) - http://simontcousins.azurewebsites.net/does-the-language-you-use-make-a-difference-revisited/ ● What about inheritance? - http://codewonderings.blogspot.com/2012/09/what-about-inheritance. html ● SOLID: the next step is Functional http://blog.ploeh.dk/2014/03/10/solid-the-next-step-is-functional/ - Mark Seemann

Editor's Notes

  • #4 http://simontcousins.azurewebsites.net/does-the-language-you-use-make-a-difference-revisited/
  • #5 http://fsharp.org/testimonials/ https://twitter.com/talbott/status/456471919983095808
  • #8 http://gorodinski.com/blog/2013/09/18/oop-patterns-from-a-functional-perspective/ http://blog.ploeh.dk/2014/03/10/solid-the-next-step-is-functional/ http://en.wikipedia.org/wiki/Peter_Norvig
  • #10 https://www.slideshare.net/slideshow/embed_code/28992749
  • #13 REPL allows you to reference your current solution code and run it interactively
  • #14 REPL allows you to reference your current solution code and run it interactively
  • #15 REPL allows you to reference your current solution code and run it interactively
  • #17 http://msdn.microsoft.com/en-us/library/dd233243.aspx
  • #18 http://fsharpforfunandprofit.com/posts/cyclic-dependencies/
  • #22 http://fsharpforfunandprofit.com/posts/roslyn-vs-fsharp-compiler/