functional programming,
and does it matter?
Alexis Gallagher
@alexisgallagher
Questions
classes
methods
protocols
categories
functions
ARC
blocks
Cocoa values
& collections
Objective-C
Swift
classes
methods
protocols
extensions
functions
ARC
closures
Cocoa values
& collections
What's'a'bit$new'in'Swi,?
Objective-C
Swift + Swift
classes structs
methods namespaces
protocols access control
extensions operator
functions overloading
ARC ObjC interop
closures Swift values &
Cocoa values collections
& collections
What's'really&new'in'Swi,?
Objective-C
func%on
as#the#primary#unit#of#abstrac2on
mathematical functions computational functions
establish true relations do things
which remain true
t0 = 5 NSNumber * t0 = @5;
pos = f(t0);
f (t0 ) = 50 pos; //=> 100; (surprise!)
mathematical variables computational variables
are names are like names for places,
we give to values whose contents can change
t0 = 5 five = @6; // ?!
five = @7;
t0 = 6 [five setIntegerValue:8]; // ?! ?!
FP style boils down to
Restrictions to emulate the
predictability of mathematical
functions and variables
Erlang (1986)
Haskell (1988)
OCaml (1996)
Scala (2003)
F# (2005)
Clojure (2009)
generics Y Y N N Y N
enum types Y Y N N Y N
type inference Y Y N N Y N
FP != type systems
Where Swift/Cocoa fight FP
Support for immutable values, but
Cocoa is subclasserific.
Videos, notes, and exercises from the Coursera Programming
Languages course, a great intro to Scheme, SML, and Ruby.
<https://class.coursera.org/proglang-2012-001>
The talks by Rich Hickey (inventor of Clojure) are very rich: the Value
of Values, the Language of the System, etc..
ChrisEidhof, FlorianKugler, and WouterSwierstra
Maxwell Swadling
David Nolen.
Om. Functional approach to writing GUIs in the browser, using ClojureScript with Facebooks
React, leveraging CSP-style concurrency. Untyped FP.
<http://swannodette.github.io/2013/12/17/the-future-of-javascript-mvcs/>
@end
Is ObjC going away?
Is it easier now?
Objective-C
unified syntax for value types and references types, for methods,
functions, and closures,
type inference