![Page 1: Functional Architecture - goto copenhagen 2012](https://reader036.vdocuments.net/reader036/viewer/2022062303/5549112ab4c9056b458be63a/html5/thumbnails/1.jpg)
FUNCTIONAL ARCHITECTUREPhillip Trelford
Trayport
![Page 2: Functional Architecture - goto copenhagen 2012](https://reader036.vdocuments.net/reader036/viewer/2022062303/5549112ab4c9056b458be63a/html5/thumbnails/2.jpg)
About Me
Family Values Retail Halo 3
Trade
![Page 3: Functional Architecture - goto copenhagen 2012](https://reader036.vdocuments.net/reader036/viewer/2022062303/5549112ab4c9056b458be63a/html5/thumbnails/3.jpg)
Programming Languages
Assemblers•6502•Z80•680x0•80x86•65c816•SH-2•R3000•C
C with Classes•C++•Java•C#
Functional•JavaScript•F#•Lua
![Page 4: Functional Architecture - goto copenhagen 2012](https://reader036.vdocuments.net/reader036/viewer/2022062303/5549112ab4c9056b458be63a/html5/thumbnails/4.jpg)
Video Game Decades
1980s/1990s
Assemblers
Scripts
2000s/2010s
C with Classes
Scripts
![Page 5: Functional Architecture - goto copenhagen 2012](https://reader036.vdocuments.net/reader036/viewer/2022062303/5549112ab4c9056b458be63a/html5/thumbnails/5.jpg)
Coroutine Zombies
Pseudo Code
random_pause 10while not dead wait_until_in_range 50.0 home_in_on_target 10
![Page 6: Functional Architecture - goto copenhagen 2012](https://reader036.vdocuments.net/reader036/viewer/2022062303/5549112ab4c9056b458be63a/html5/thumbnails/6.jpg)
Coroutine Zombies
Pseudo Code
random_pause 10while not dead wait_until_in_range 50.0 home_in_on_target 10
F#
yield! random_pause 10
while true do yield! wait_range 50 yield! home_in 10
![Page 7: Functional Architecture - goto copenhagen 2012](https://reader036.vdocuments.net/reader036/viewer/2022062303/5549112ab4c9056b458be63a/html5/thumbnails/7.jpg)
Speed
Runtime
Super Nintendo• Interprets byte code• On 3.58MHz CPU• At 60FPS
Development
DSL• Close to domain• Easy to port• Zero compile time
![Page 8: Functional Architecture - goto copenhagen 2012](https://reader036.vdocuments.net/reader036/viewer/2022062303/5549112ab4c9056b458be63a/html5/thumbnails/8.jpg)
FP Sweet Spots
Domain
ConcurrencyComputation
![Page 9: Functional Architecture - goto copenhagen 2012](https://reader036.vdocuments.net/reader036/viewer/2022062303/5549112ab4c9056b458be63a/html5/thumbnails/9.jpg)
Thoughtworks Tech Radar 2012
F#
“F# is excellent at concisely expressing business and domain logic.”
Languages
![Page 10: Functional Architecture - goto copenhagen 2012](https://reader036.vdocuments.net/reader036/viewer/2022062303/5549112ab4c9056b458be63a/html5/thumbnails/10.jpg)
Types
F#
type Object(name) = member this.Name = name
type Action = | Call of Object * string *Object | Async of Object * string *Object
UML Class Diagram
![Page 11: Functional Architecture - goto copenhagen 2012](https://reader036.vdocuments.net/reader036/viewer/2022062303/5549112ab4c9056b458be63a/html5/thumbnails/11.jpg)
Functions
Imply : Instrument[] -> Order[] -> Order[]
![Page 12: Functional Architecture - goto copenhagen 2012](https://reader036.vdocuments.net/reader036/viewer/2022062303/5549112ab4c9056b458be63a/html5/thumbnails/12.jpg)
Computation
![Page 13: Functional Architecture - goto copenhagen 2012](https://reader036.vdocuments.net/reader036/viewer/2022062303/5549112ab4c9056b458be63a/html5/thumbnails/13.jpg)
Concurrency
async { do! control.MouseLeftButtonDown |> Async.AwaitEvent }
![Page 14: Functional Architecture - goto copenhagen 2012](https://reader036.vdocuments.net/reader036/viewer/2022062303/5549112ab4c9056b458be63a/html5/thumbnails/14.jpg)
Joule Trading screen
![Page 15: Functional Architecture - goto copenhagen 2012](https://reader036.vdocuments.net/reader036/viewer/2022062303/5549112ab4c9056b458be63a/html5/thumbnails/15.jpg)
Thoughtworks Tech Radar 2012
“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#.”
![Page 16: Functional Architecture - goto copenhagen 2012](https://reader036.vdocuments.net/reader036/viewer/2022062303/5549112ab4c9056b458be63a/html5/thumbnails/16.jpg)
Applications
Erlang for Fault Tolerant Messaging• Messaging in Chat, Gaming, Messaging, NoSQL• Facebook, MMOG, RabbitMQ, Amazon, …
F#/Scala• Computation in Insurance, Finance, Gaming• Credit Suisse, Jane Street, TrueSkill, Path of Go, …
C#/Java/PHP/Python/Ruby…• CRUD in Line of Business Applications• Everything else
![Page 17: Functional Architecture - goto copenhagen 2012](https://reader036.vdocuments.net/reader036/viewer/2022062303/5549112ab4c9056b458be63a/html5/thumbnails/17.jpg)
Classes
reference.Member(argument, …)
Member(reference, argument, …)
![Page 18: Functional Architecture - goto copenhagen 2012](https://reader036.vdocuments.net/reader036/viewer/2022062303/5549112ab4c9056b458be63a/html5/thumbnails/18.jpg)
Dot Driven Development
![Page 19: Functional Architecture - goto copenhagen 2012](https://reader036.vdocuments.net/reader036/viewer/2022062303/5549112ab4c9056b458be63a/html5/thumbnails/19.jpg)
Buttons
Methods 63
Properties 63
Events 35
Constructors 1
Total Members 162
![Page 20: Functional Architecture - goto copenhagen 2012](https://reader036.vdocuments.net/reader036/viewer/2022062303/5549112ab4c9056b458be63a/html5/thumbnails/20.jpg)
XBLA: Path to Go – F# AI
![Page 21: Functional Architecture - goto copenhagen 2012](https://reader036.vdocuments.net/reader036/viewer/2022062303/5549112ab4c9056b458be63a/html5/thumbnails/21.jpg)
Q & A
• Twitter: @ptrelford• Email: phil at trelford.com• Blog: http://trelford.com/blog