0
FUNCTIONAL ARCHITECTURE       Phillip Trelford          Trayport
About MeFamily Values     Retail   Halo 3                  Trade
Programming LanguagesAssemblers       C with Classes   Functional• 6502           • C++            • JavaScript• Z80      ...
Video Game Decades1980s/1990s                  2000s/2010s      Scripts                      Scripts                      ...
Coroutine ZombiesPseudo Coderandom_pause 10while not dead  wait_until_in_range 50.0  home_in_on_target 10
Coroutine ZombiesPseudo Code                  F#random_pause 10              yield! random_pause 10while not dead         ...
SpeedRuntime                     DevelopmentSuper Nintendo              DSL• Interprets byte code      • Close to domain• ...
FP Sweet Spots          DomainComputation        Concurrency
Thoughtworks Tech Radar 2012F#                              Languages“F# is excellent at concisely  expressing business an...
TypesF#                                    UML Class Diagramtype Object(name) = member this.Name = nametype Action = | Cal...
FunctionsImply : Instrument[] -> Order[] -> Order[]
Computation
Concurrencyasync { do! control.MouseLeftButtonDown     |> Async.AwaitEvent}
Joule Trading screen
Thoughtworks Tech Radar 2012“Developers trying to achieve explicit business logic within an application may opt to express...
ApplicationsErlang for Fault Tolerant Messaging• Messaging in Chat, Gaming, Messaging, NoSQL• Facebook, MMOG, RabbitMQ, Am...
Classesreference.Member(argument, …)Member(reference, argument, …)
Dot Driven Development
ButtonsMethods         63Properties      63Events          35Constructors    1Total Members   162
XBLA: Path to Go – F# AI
Q&A• Twitter: @ptrelford• Email: phil at trelford.com• Blog: http://trelford.com/blog
Upcoming SlideShare
Loading in...5
×

Functional Architecture - goto copenhagen 2012

2,648

Published on

Functional Architecture presentation on the Software Architecture track at goto conference in Copenhagen 2012.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,648
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
8
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • I work as a hands-on Software Architect AND Developer at Trayport.I work with the project team on the code on a day-to-day basis.
  • Wrote first commercial game when I was 13, nearly 30 years ago which makes me just over 27 ;)Characterized by functional concepts.Video games: state machines & DSLs, transformation, math, proceduralE-Commerce: immutable messages & commands (audit trail – no deletion)Machine Learning: computationTrading: immutable messages, computation, concurrency
  • C is assemblerC++ was initially called C with ClassesJava/C# = C with Classes + GC
  • 1980s/1990s Games written in C interpreters & custom DSLs with coroutines, engines written in Assembler including C2000s/2010s Games written in Lua & custom DSLs, engines written in C & C++
  • See: http://en.wikipedia.org/wiki/Coroutine#Common_usesCode sample:http://fssnip.net/ca
  • See: http://en.wikipedia.org/wiki/Coroutine#Common_usesCode sample:http://fssnip.net/ca
  • Runtime: 80/20 rule – performance of most code is not importantDevelopment: time to market is importantPsygnosis offered to pay: 25,000GBP to convert a video game in 6 months 75,000GBP to convert a video game in 3 months
  • Lightweight types with correct defaultsImmutabilityCompositionSeparation of concernsLightweight functions with correct defaultsIdempotentTestableType signatures
  • Map: (‘T -> ‘U) -> ‘T -> ‘U
  • Samples:Units in CellzLunar Landurz
  • Putting it all together: http://www.trayport.com/en/joule/video
  • Intellisense via the dot gives discoverabilityMakes it easy to explore an APIWorld bank sample
  • Transcript of "Functional Architecture - goto copenhagen 2012"

    1. 1. FUNCTIONAL ARCHITECTURE Phillip Trelford Trayport
    2. 2. About MeFamily Values Retail Halo 3 Trade
    3. 3. Programming LanguagesAssemblers C with Classes Functional• 6502 • C++ • JavaScript• Z80 • Java • F#• 680x0 • C# • Lua• 80x86• 65c816• SH-2• R3000•C
    4. 4. Video Game Decades1980s/1990s 2000s/2010s Scripts Scripts C with Assemblers Classes
    5. 5. Coroutine ZombiesPseudo Coderandom_pause 10while not dead wait_until_in_range 50.0 home_in_on_target 10
    6. 6. Coroutine ZombiesPseudo Code F#random_pause 10 yield! random_pause 10while not dead while true do wait_until_in_range 50.0 yield! wait_range 50 home_in_on_target 10 yield! home_in 10
    7. 7. SpeedRuntime DevelopmentSuper Nintendo DSL• Interprets byte code • Close to domain• On 3.58MHz CPU • Easy to port• At 60FPS • Zero compile time
    8. 8. FP Sweet Spots DomainComputation Concurrency
    9. 9. Thoughtworks Tech Radar 2012F# Languages“F# is excellent at concisely expressing business and domain logic.”
    10. 10. TypesF# UML Class Diagramtype Object(name) = member this.Name = nametype Action = | Call of Object * string *Object | Async of Object * string *Object
    11. 11. FunctionsImply : Instrument[] -> Order[] -> Order[]
    12. 12. Computation
    13. 13. Concurrencyasync { do! control.MouseLeftButtonDown |> Async.AwaitEvent}
    14. 14. Joule Trading screen
    15. 15. 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#.”
    16. 16. ApplicationsErlang 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
    17. 17. Classesreference.Member(argument, …)Member(reference, argument, …)
    18. 18. Dot Driven Development
    19. 19. ButtonsMethods 63Properties 63Events 35Constructors 1Total Members 162
    20. 20. XBLA: Path to Go – F# AI
    21. 21. Q&A• Twitter: @ptrelford• Email: phil at trelford.com• Blog: http://trelford.com/blog
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×