SlideShare a Scribd company logo
1 of 61
Download to read offline
Jon Harrop, Flying Frog Consultancy
 Jon Harrop
 Started programming in 1981
BASIC, Pascal, 6502, ARM, C, C++
 At British Petroleum in 1995
UFI
 Physics and Chemistry at Cambridge
Fortran, SML, OCaml, Mathematica, F#
 Co-founded Flying Frog in 2005
◦ Sell books, software and consultancy services
◦ Over 1,100 clients in industry using OCaml & F#
 One of the world’s largest insurance
companies.
 One of the world’s largest insurance
companies.
 Actually, almost everyone else too…
1. An ordinary delivery process
2. Streamlining the delivery process
3. Technical aspects of the solution
 Automate repetition
◦ Traders in a pit
◦ Actuaries with calculators
 Use computers!
 Much better performance
◦ Latency
◦ Throughput
 More sophisticated algorithms
1. Business idea!
1. Business idea!
2. Model idea: MS Excel.
1. Business idea!
2. Model idea: MS Excel.
3. Build idea: C++/Java/C#.
1. Business idea!
2. Model idea: MS Excel.
3. Build idea: C++/Java/C#.
4. Test idea: NUnit (feedback to 2)
1. Business idea!
2. Model idea: MS Excel.
3. Build idea: C++/Java/C#.
4. Test idea: NUnit (feedback to 2)
5. Deploy production code.
Room for improvement?
Room for improvement in:
 Classic waterfall approach.
◦ Iterations are an absolute killer.
 Delivery speed and cost.
◦ This is a long journey.
So what does an iteration look like?
 First iteration highlights issues.
◦ Civilized discussion.
 First iteration highlights issues.
◦ Civilized discussion.
 Second iteration, more issues.
◦ Stressful disagreements.
 First iteration highlights issues.
◦ Civilized discussion.
 Second iteration, more issues.
◦ Stressful disagreements.
 Later iterations.
◦ Wild fighting.
Big problems:
 Accuracy.
◦ Excel/Word are too free-form.
 Complexity.
◦ Models are complicated, lots of dispatch.
 Latency.
◦ Complected testing.
Old process:
 See the forest for the trees.
◦ Don’t just rewrite code in language du jour!!!
◦ Common mistake when adopting new technologies.
 Overhaul the delivery process…
A new process:
Observations
Observations
 Separate people/jobs
◦ One person uses Tool to turn ideas into products.
◦ Another person maintains Tool.
 Separate tests
◦ Tests for the model.
◦ Unit test for the Tool.
Advantages
Advantages:
 Business people ship products themselves!
 Less contention
◦ Faster iterations
◦ Quicker time-to-market
◦ Cheaper delivery
◦ Happier employees
 Scalable delivery process
◦ Add more tool users
◦ Add more tool developers
Challenges:
 Designing bespoke Tool
◦ Hard to gather requirements:“Define the language
you dream in?”
 Training
◦ Users
◦ Developers
 Plumbing
 Deployment
Build a new tool for business users that:
 Has a great user experience.
◦ Graphical application.
◦ Interoperates with Excel.
 Creates precise specifications.
◦ Catch errors as early as possible.
 Mirrors the production environment.
◦ Code reuse.
 Integrates testing.
 Is tuned to their needs.
DSLs have a rich history but GUIs are notably
absent…
DSL Patterns by Martin Fowler
No need to ship a DSL that looks worse than
this:
No need to ship a DSL that looks worse than
this:
1974
Started with a working demo
 Developed in one week!
 Slick looking
 Easy to use
 Bespoke language
 Integrated testing
 Their own worked examples included
 Demo runs on their machines (WPF)
Final solution:
 Development effort
◦ 3 months to design
◦ 3 months to build
 Code size
◦ 10kLOC of F#
 Performance
◦ 20,000 msg/s
◦ Under 35ms door-to-door latency
A different 3 month project:
 114µs latency.
 200,000 tps.
 With fault tolerance!
 Async message passing over Infiniband
 Low-latency allocationless F# code
 Training
◦ On-the-fly
◦ 30 people
◦ 5 teams
 Emergency
◦ Valuable change came in late
◦ Estimated 9 months and £1m
◦ Completed in 24 hours
 Maintenance
◦ All done by client now
◦ After one week of F# training
◦ Ordinary developers
“Pattern matching is quite neat, as is the partial
application of functions”
“rapidly coming to appreciate the benefits
when it comes to refactoring code”
“Our plans are getting bigger each week as we
can see more and more flexibility, it’s great!”
Benefits
 Delivery speed
◦ From idea to production 100x faster
 Delivery costs
◦ Maybe 10,000x lower?!
 F# is good for programmatic GUIs
 Approach described in the F# Journal
 Custom Control union type
 Compiled to WPF Control
 Custom Editable Control
 Reuse for editable strings, unions etc.
 Compose into a UI tree
 Peek Value property to get the “rules”
Nice name!
Input
Variables
Patterns
Output
Variables
Expressions
Take a leaf out of Excel:
 Editable content:
 Display version:
Display version:
Editable content:
A bit like type checking…
type Control =
| Gap
| Label of string
| Title of string
| Dock of (Position * Control) list
| Ctrl of FrameworkElement
| …
let rec make : Control -> FrameworkElement = function
| Gap ->
let ctrl = new FrameworkElement()
ctrl.HorizontalAlignment <- HorizontalAlignment.Stretch
ctrl.VerticalAlignment <- VerticalAlignment.Stretch
ctrl
| Label s -> upcast Controls.Label(Content=s)
| Title s -> upcast Controls.TextBlock(Text=s, FontSize=24.0)
| Dock xs ->
let panel = Controls.DockPanel()
for p, ctrl in xs do
let ctrl = make ctrl
Controls.DockPanel.SetDock(ctrl, p.AsWPF)
panel.Children.Add ctrl |> ignore
upcast panel
| …
let ui =
Dock
[ Top, Title "Bespoke business rules engine"
Bottom,
Tabs
[ Label "Inputs",
Dock[ Top, Label "This version was…"
Bottom, Scroll inputs ]
Label "Rules",
Dock[ Top, Label "The following rules…"
Bottom, Scroll(Ctrl rulesView) ]]]
let StringValue(value: Value) =
let label = Controls.Label()
let textbox = Controls.TextBox()
let setContent = function
| VString text ->
label.Content <- text
textbox.Text <- text
| _ -> failwith "Invalid value"
let ctrl =
Editable<Value>(value, label, textbox, setContent)
textbox.TextChanged.Add(fun _ ->
ctrl.SetValue(Some textbox.Text
|> Option.map VString))
ctrl
let UnionValue(allCases, value: Value) =
let label = Controls.Label()
let combo = Controls.ComboBox()
let itemOf case = case, Controls.ComboBoxItem(Content=case)
let items = Map[for case in allCases -> itemOf case]
let setContent = function
| VCase case ->
label.Content <- case
combo.SelectedItem <- items.[case]
| value -> failwith "Invalid value"
let ctrl = Editable<Value>(value, label, combo, setContent)
combo.ItemsSource <- [ for KeyValue(_, ctrl) in items -> ctrl ]
for KeyValue(case, x) in items do
x.Selected.Add(fun _ -> ctrl.SetValue(Some(VCase case)))
ctrl
The expression language:
type Expr =
| EBool of bool
| ENumber of decimal
| EString of string
| EDate of System.DateTime
| ETuple of Expr list
| EVar of string
| …
The expression interpreter:
let rec eval vars expr =
match expr with
| EBool b -> VBool b
| ENumber x -> VNumber x
| EString s -> VString s
| EDate d -> VDate d
| ETuple fs -> VTuple(List.map (eval vars) fs)
| EVar v ->
match Map.tryFind v vars with
| None -> failwithf "Unknown variable '%s'" v
| Some x -> x
| …
Challenges
 Slow startup times
 Poor GUI performance (grid of numbers)
 Minor perf bugs
 Brittle .NET serialization
Startup times
Problems:
 64-bit NGEN bug
 Poor WPF Grid performance
Solutions:
 Use 32-bit client
 Custom WPF control…
Startup times
 Took two days to fix
 Startup times down from 15s to 0.1s
GUI performance
Problem:
 The WPF Grid control is:
◦ very slow to start up
◦ very slow to scroll
Solution:
 Custom FastGrid control…
 Low-level rendering in F#
◦ Calls DrawGlyphs
GUI performance
 16x faster startup than vanilla WPF.
 Solution in the F# Journal.
 Still a lot of room for improvement…
Minor perf bugs
 sprintf “%A”
 Decimal slow (but ok)
Serialization
Problem:
 .NET serialization not great for F#.
 Bloated format (includes types).
 Brittle when loading (incompatible types).
Solution:
 Custom structural serialization library.
 Handles values of all F# types.
 Solution in the F# Journal.
Serialization
write true = "<bool>True</bool>"
write {anInt=2; aReal=3.4m} = "<record><
field><name>anInt</name><value><int>2</i
nt></value></field><field><name>aReal</n
ame><value><decimal>3.4</decimal></value
></field></record>"
Structurally-typed serialization handles:
 unit
 bool
 byte, int, float, decimal
 System.DateTime
 string
 Tuples, records, unions
 Lists, arrays, sets and maps
Any questions, please contact me:
Jon Harrop <jon@ffconsultancy.com>

More Related Content

Similar to Using F# to change the way we work

Object Oriented Programming I
Object Oriented Programming IObject Oriented Programming I
Object Oriented Programming Iraven_rainagi
 
MWLUG 2014: ATLUG Comes To You
MWLUG 2014: ATLUG Comes To YouMWLUG 2014: ATLUG Comes To You
MWLUG 2014: ATLUG Comes To YouPeter Presnell
 
Adtech scala-performance-tuning-150323223738-conversion-gate01
Adtech scala-performance-tuning-150323223738-conversion-gate01Adtech scala-performance-tuning-150323223738-conversion-gate01
Adtech scala-performance-tuning-150323223738-conversion-gate01Giridhar Addepalli
 
Adtech x Scala x Performance tuning
Adtech x Scala x Performance tuningAdtech x Scala x Performance tuning
Adtech x Scala x Performance tuningYosuke Mizutani
 
The Ring programming language version 1.10 book - Part 18 of 212
The Ring programming language version 1.10 book - Part 18 of 212The Ring programming language version 1.10 book - Part 18 of 212
The Ring programming language version 1.10 book - Part 18 of 212Mahmoud Samir Fayed
 
Gatling - Bordeaux JUG
Gatling - Bordeaux JUGGatling - Bordeaux JUG
Gatling - Bordeaux JUGslandelle
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agilityelliando dias
 
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"Fwdays
 
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.Chris Laning
 
Wayfair Storefront Performance Monitoring with InfluxEnterprise by Richard La...
Wayfair Storefront Performance Monitoring with InfluxEnterprise by Richard La...Wayfair Storefront Performance Monitoring with InfluxEnterprise by Richard La...
Wayfair Storefront Performance Monitoring with InfluxEnterprise by Richard La...InfluxData
 
Just In Time Scalability Agile Methods To Support Massive Growth Presentation
Just In Time Scalability  Agile Methods To Support Massive Growth PresentationJust In Time Scalability  Agile Methods To Support Massive Growth Presentation
Just In Time Scalability Agile Methods To Support Massive Growth PresentationEric Ries
 
Just In Time Scalability Agile Methods To Support Massive Growth Presentation
Just In Time Scalability  Agile Methods To Support Massive Growth PresentationJust In Time Scalability  Agile Methods To Support Massive Growth Presentation
Just In Time Scalability Agile Methods To Support Massive Growth PresentationTimothy Fitz
 
Introduction to programming - class 2
Introduction to programming - class 2Introduction to programming - class 2
Introduction to programming - class 2Paul Brebner
 
Евгений Руднев: "Programmers Approach to Error Handling"
Евгений Руднев: "Programmers Approach to Error Handling"Евгений Руднев: "Programmers Approach to Error Handling"
Евгений Руднев: "Programmers Approach to Error Handling"Anna Shymchenko
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tipsBill Buchan
 
Keeping code clean
Keeping code cleanKeeping code clean
Keeping code cleanBrett Child
 

Similar to Using F# to change the way we work (20)

Object Oriented Programming I
Object Oriented Programming IObject Oriented Programming I
Object Oriented Programming I
 
MWLUG 2014: ATLUG Comes To You
MWLUG 2014: ATLUG Comes To YouMWLUG 2014: ATLUG Comes To You
MWLUG 2014: ATLUG Comes To You
 
Adtech scala-performance-tuning-150323223738-conversion-gate01
Adtech scala-performance-tuning-150323223738-conversion-gate01Adtech scala-performance-tuning-150323223738-conversion-gate01
Adtech scala-performance-tuning-150323223738-conversion-gate01
 
Adtech x Scala x Performance tuning
Adtech x Scala x Performance tuningAdtech x Scala x Performance tuning
Adtech x Scala x Performance tuning
 
The Ring programming language version 1.10 book - Part 18 of 212
The Ring programming language version 1.10 book - Part 18 of 212The Ring programming language version 1.10 book - Part 18 of 212
The Ring programming language version 1.10 book - Part 18 of 212
 
Gatling - Bordeaux JUG
Gatling - Bordeaux JUGGatling - Bordeaux JUG
Gatling - Bordeaux JUG
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
 
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Agile
AgileAgile
Agile
 
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
 
Wayfair Storefront Performance Monitoring with InfluxEnterprise by Richard La...
Wayfair Storefront Performance Monitoring with InfluxEnterprise by Richard La...Wayfair Storefront Performance Monitoring with InfluxEnterprise by Richard La...
Wayfair Storefront Performance Monitoring with InfluxEnterprise by Richard La...
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
 
Just In Time Scalability Agile Methods To Support Massive Growth Presentation
Just In Time Scalability  Agile Methods To Support Massive Growth PresentationJust In Time Scalability  Agile Methods To Support Massive Growth Presentation
Just In Time Scalability Agile Methods To Support Massive Growth Presentation
 
Just In Time Scalability Agile Methods To Support Massive Growth Presentation
Just In Time Scalability  Agile Methods To Support Massive Growth PresentationJust In Time Scalability  Agile Methods To Support Massive Growth Presentation
Just In Time Scalability Agile Methods To Support Massive Growth Presentation
 
Introduction to programming - class 2
Introduction to programming - class 2Introduction to programming - class 2
Introduction to programming - class 2
 
Vba Class Level 3
Vba Class Level 3Vba Class Level 3
Vba Class Level 3
 
Евгений Руднев: "Programmers Approach to Error Handling"
Евгений Руднев: "Programmers Approach to Error Handling"Евгений Руднев: "Programmers Approach to Error Handling"
Евгений Руднев: "Programmers Approach to Error Handling"
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tips
 
Keeping code clean
Keeping code cleanKeeping code clean
Keeping code clean
 

Recently uploaded

How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 

Recently uploaded (20)

How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 

Using F# to change the way we work

  • 1. Jon Harrop, Flying Frog Consultancy
  • 2.  Jon Harrop  Started programming in 1981 BASIC, Pascal, 6502, ARM, C, C++  At British Petroleum in 1995 UFI  Physics and Chemistry at Cambridge Fortran, SML, OCaml, Mathematica, F#  Co-founded Flying Frog in 2005 ◦ Sell books, software and consultancy services ◦ Over 1,100 clients in industry using OCaml & F#
  • 3.  One of the world’s largest insurance companies.
  • 4.  One of the world’s largest insurance companies.  Actually, almost everyone else too…
  • 5. 1. An ordinary delivery process 2. Streamlining the delivery process 3. Technical aspects of the solution
  • 6.  Automate repetition ◦ Traders in a pit ◦ Actuaries with calculators  Use computers!
  • 7.  Much better performance ◦ Latency ◦ Throughput  More sophisticated algorithms
  • 9. 1. Business idea! 2. Model idea: MS Excel.
  • 10. 1. Business idea! 2. Model idea: MS Excel. 3. Build idea: C++/Java/C#.
  • 11. 1. Business idea! 2. Model idea: MS Excel. 3. Build idea: C++/Java/C#. 4. Test idea: NUnit (feedback to 2)
  • 12. 1. Business idea! 2. Model idea: MS Excel. 3. Build idea: C++/Java/C#. 4. Test idea: NUnit (feedback to 2) 5. Deploy production code. Room for improvement?
  • 13. Room for improvement in:  Classic waterfall approach. ◦ Iterations are an absolute killer.  Delivery speed and cost. ◦ This is a long journey. So what does an iteration look like?
  • 14.  First iteration highlights issues. ◦ Civilized discussion.
  • 15.  First iteration highlights issues. ◦ Civilized discussion.  Second iteration, more issues. ◦ Stressful disagreements.
  • 16.  First iteration highlights issues. ◦ Civilized discussion.  Second iteration, more issues. ◦ Stressful disagreements.  Later iterations. ◦ Wild fighting.
  • 17. Big problems:  Accuracy. ◦ Excel/Word are too free-form.  Complexity. ◦ Models are complicated, lots of dispatch.  Latency. ◦ Complected testing.
  • 19.
  • 20.  See the forest for the trees. ◦ Don’t just rewrite code in language du jour!!! ◦ Common mistake when adopting new technologies.  Overhaul the delivery process…
  • 22. Observations  Separate people/jobs ◦ One person uses Tool to turn ideas into products. ◦ Another person maintains Tool.  Separate tests ◦ Tests for the model. ◦ Unit test for the Tool. Advantages
  • 23. Advantages:  Business people ship products themselves!  Less contention ◦ Faster iterations ◦ Quicker time-to-market ◦ Cheaper delivery ◦ Happier employees  Scalable delivery process ◦ Add more tool users ◦ Add more tool developers
  • 24. Challenges:  Designing bespoke Tool ◦ Hard to gather requirements:“Define the language you dream in?”  Training ◦ Users ◦ Developers  Plumbing  Deployment
  • 25. Build a new tool for business users that:  Has a great user experience. ◦ Graphical application. ◦ Interoperates with Excel.  Creates precise specifications. ◦ Catch errors as early as possible.  Mirrors the production environment. ◦ Code reuse.  Integrates testing.  Is tuned to their needs.
  • 26. DSLs have a rich history but GUIs are notably absent… DSL Patterns by Martin Fowler
  • 27. No need to ship a DSL that looks worse than this:
  • 28. No need to ship a DSL that looks worse than this: 1974
  • 29. Started with a working demo  Developed in one week!  Slick looking  Easy to use  Bespoke language  Integrated testing  Their own worked examples included  Demo runs on their machines (WPF)
  • 30. Final solution:  Development effort ◦ 3 months to design ◦ 3 months to build  Code size ◦ 10kLOC of F#  Performance ◦ 20,000 msg/s ◦ Under 35ms door-to-door latency
  • 31. A different 3 month project:  114µs latency.  200,000 tps.  With fault tolerance!  Async message passing over Infiniband  Low-latency allocationless F# code
  • 32.  Training ◦ On-the-fly ◦ 30 people ◦ 5 teams  Emergency ◦ Valuable change came in late ◦ Estimated 9 months and £1m ◦ Completed in 24 hours  Maintenance ◦ All done by client now ◦ After one week of F# training ◦ Ordinary developers
  • 33. “Pattern matching is quite neat, as is the partial application of functions” “rapidly coming to appreciate the benefits when it comes to refactoring code” “Our plans are getting bigger each week as we can see more and more flexibility, it’s great!”
  • 34. Benefits  Delivery speed ◦ From idea to production 100x faster  Delivery costs ◦ Maybe 10,000x lower?!
  • 35.  F# is good for programmatic GUIs  Approach described in the F# Journal  Custom Control union type  Compiled to WPF Control  Custom Editable Control  Reuse for editable strings, unions etc.  Compose into a UI tree  Peek Value property to get the “rules”
  • 36.
  • 42. Take a leaf out of Excel:  Editable content:  Display version:
  • 44. Editable content: A bit like type checking…
  • 45. type Control = | Gap | Label of string | Title of string | Dock of (Position * Control) list | Ctrl of FrameworkElement | …
  • 46. let rec make : Control -> FrameworkElement = function | Gap -> let ctrl = new FrameworkElement() ctrl.HorizontalAlignment <- HorizontalAlignment.Stretch ctrl.VerticalAlignment <- VerticalAlignment.Stretch ctrl | Label s -> upcast Controls.Label(Content=s) | Title s -> upcast Controls.TextBlock(Text=s, FontSize=24.0) | Dock xs -> let panel = Controls.DockPanel() for p, ctrl in xs do let ctrl = make ctrl Controls.DockPanel.SetDock(ctrl, p.AsWPF) panel.Children.Add ctrl |> ignore upcast panel | …
  • 47. let ui = Dock [ Top, Title "Bespoke business rules engine" Bottom, Tabs [ Label "Inputs", Dock[ Top, Label "This version was…" Bottom, Scroll inputs ] Label "Rules", Dock[ Top, Label "The following rules…" Bottom, Scroll(Ctrl rulesView) ]]]
  • 48. let StringValue(value: Value) = let label = Controls.Label() let textbox = Controls.TextBox() let setContent = function | VString text -> label.Content <- text textbox.Text <- text | _ -> failwith "Invalid value" let ctrl = Editable<Value>(value, label, textbox, setContent) textbox.TextChanged.Add(fun _ -> ctrl.SetValue(Some textbox.Text |> Option.map VString)) ctrl
  • 49. let UnionValue(allCases, value: Value) = let label = Controls.Label() let combo = Controls.ComboBox() let itemOf case = case, Controls.ComboBoxItem(Content=case) let items = Map[for case in allCases -> itemOf case] let setContent = function | VCase case -> label.Content <- case combo.SelectedItem <- items.[case] | value -> failwith "Invalid value" let ctrl = Editable<Value>(value, label, combo, setContent) combo.ItemsSource <- [ for KeyValue(_, ctrl) in items -> ctrl ] for KeyValue(case, x) in items do x.Selected.Add(fun _ -> ctrl.SetValue(Some(VCase case))) ctrl
  • 50. The expression language: type Expr = | EBool of bool | ENumber of decimal | EString of string | EDate of System.DateTime | ETuple of Expr list | EVar of string | …
  • 51. The expression interpreter: let rec eval vars expr = match expr with | EBool b -> VBool b | ENumber x -> VNumber x | EString s -> VString s | EDate d -> VDate d | ETuple fs -> VTuple(List.map (eval vars) fs) | EVar v -> match Map.tryFind v vars with | None -> failwithf "Unknown variable '%s'" v | Some x -> x | …
  • 52. Challenges  Slow startup times  Poor GUI performance (grid of numbers)  Minor perf bugs  Brittle .NET serialization
  • 53. Startup times Problems:  64-bit NGEN bug  Poor WPF Grid performance Solutions:  Use 32-bit client  Custom WPF control…
  • 54. Startup times  Took two days to fix  Startup times down from 15s to 0.1s
  • 55. GUI performance Problem:  The WPF Grid control is: ◦ very slow to start up ◦ very slow to scroll Solution:  Custom FastGrid control…  Low-level rendering in F# ◦ Calls DrawGlyphs
  • 56. GUI performance  16x faster startup than vanilla WPF.  Solution in the F# Journal.  Still a lot of room for improvement…
  • 57. Minor perf bugs  sprintf “%A”  Decimal slow (but ok)
  • 58. Serialization Problem:  .NET serialization not great for F#.  Bloated format (includes types).  Brittle when loading (incompatible types). Solution:  Custom structural serialization library.  Handles values of all F# types.  Solution in the F# Journal.
  • 59. Serialization write true = "<bool>True</bool>" write {anInt=2; aReal=3.4m} = "<record>< field><name>anInt</name><value><int>2</i nt></value></field><field><name>aReal</n ame><value><decimal>3.4</decimal></value ></field></record>"
  • 60. Structurally-typed serialization handles:  unit  bool  byte, int, float, decimal  System.DateTime  string  Tuples, records, unions  Lists, arrays, sets and maps
  • 61. Any questions, please contact me: Jon Harrop <jon@ffconsultancy.com>