このページは https://speakerdeck.com/mchakravarty/functional-programming-in-a-stateful-world の内容を掲載しています。
Today, functional programming is mostly used in the development of server-side software and command line applications. This is changing with Swift, a language with strong support for functional programming that is pitched as the successor of Objective-C for desktop and mobile applications. Unsurprisingly, there are obstacles. Any attempt to use Swift’s support for functional programming to its full potential leads to architectural challenges, especially in the separation of stateful and purely functional computations. In desktop and especially in mobile applications, a superb user experience is a central aim of application design. This typically leads to a ubiquitous use of application frameworks, such as Cocoa, which tend to encourage a tangled web of stateful, mutually mutating objects — very much the anti-thesis of modern functional programming.
Established approaches to disentangling stateful from pure computations, while necessary, are not sufficient for desktop and mobile applications. A careful separation of the view layer (implementing the user interface) from the application logic (forming the computational heart of the application) requires us to rethink application architecture and depends on adopting an interaction paradigm focusing on the data flow between components rather than on object mutation.
This talk summarises my experience with building a desktop application including a complex user interface in Swift and Haskell. The talk will provide answers to the following questions. In which way is functional programming useful in desktop and mobile applications? What are the advantages of stateless, pure functions? What software architecture maximises the impact of functional programming in that context? How can we propagate changes from user interactions, file system & network events, and so on in a manner that keeps an application responsive, while facilitating stateless computations.
Although, the talk mostly revolves around Swift, no previous knowledge of Swift is required and the main ideas translate to writing desktop and mobile applications in other functional languages, such as Scala, F#, or Haskell.
This talk was presented at the YOW! Lambda Jam 2015 conference, in Brisbane http://lambdajam.yowconference.com.au as well as the Sydney CocoaHeads user group.