Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Future of Functional Programming on iOS

Ash Furrow
September 18, 2014

The Future of Functional Programming on iOS

This is a presentation I gave at NSSpain 2014: http://nsspain.com/2014/

Code used in the presentation: https://github.com/AshFurrow/NSSpain2014

The "Functional Programming in Swift" book is available at http://www.objc.io/books/

The new Artsy Swift app written in ReactiveCocoa is available at http://github.com/artsy/eidolon

The Carl Sagan wallpaper was downloaded from http://picc.it/c/wallpapers/pictures/album/wallpaper_28/id/50302/@carl_sagan_wallpaper_i_made

Ash Furrow

September 18, 2014
Tweet

More Decks by Ash Furrow

Other Decks in Technology

Transcript

  1. the$f&t&re$of
    Ash Furrow
    functional programming
    on$iOS

    View Slide

  2. Objective-C

    View Slide

  3. Objective-
    C

    View Slide

  4. Closures
    Functional patterns
    Concise syntax
    Native Collections
    Operator overloading
    Namespaces Tuples
    Clear mutability syntax
    Interactive playground Multiple return types
    Generics
    Protocols and extensions on structs
    Pattern matching
    Fast iteration
    Optional types
    Object orientation
    Type inference
    Read-Eval-Print-Loop (REPL)
    Compile to native code

    View Slide

  5. Closures
    Functional patterns
    Concise syntax
    Native Collections
    Operator overloading
    Namespaces Tuples
    Clear mutability syntax
    Interactive playground Multiple return types
    Generics
    Protocols and extensions on structs
    Pattern matching
    Fast iteration
    Optional types
    Object orientation
    Type inference
    Read-Eval-Print-Loop (REPL)
    Compile to native code

    View Slide

  6. Closures
    Functional patterns
    Concise syntax
    Native Collections
    Operator overloading
    Namespaces Tuples
    Clear mutability syntax
    Interactive playground Multiple return types
    Generics
    Protocols and extensions on structs
    Pattern matching
    Fast iteration
    Optional types
    Object orientation
    Type inference
    Read-Eval-Print-Loop (REPL)
    Compile to native code

    View Slide

  7. Objective-C

    View Slide

  8. Objective-
    C

    View Slide

  9. Objective-C

    View Slide

  10. View Slide

  11. It will not be we make apps for the WATCH 5
    and the other future iOS devices.
    It will be a group of developers very much like us.
    But with more of our strengths and fewer of our weaknesses.
    More confident, far-seeing,
    and capable of using functional paradigms.
    For all of our failings, despite our limitations and fallibilities,
    we developers are capable of greatness.
    —Carl Sagan

    View Slide

  12. 1. Imperative$prog5amming$is$old$and$busted$
    [email protected]$
    3.Ge?ing$starCed$with$f&nctional$prog5amming$in$Swiſt$is$superEeasy

    View Slide

  13. old
    and
    busted

    View Slide

  14. BNE ADD1
    BRA NONE1
    ADD1 INY ;increment our counter of 1's
    NONE1 LDAA TEMP ;reload accumulator A
    LSL MASK ;Shift the mask's 1 bit left
    BNE LOOP1 ;If we haven't finished our loop, branch
    LDAA #$01 ;load new mask into A
    STAA MASK ;store the reset mask into MASK
    TSX ;pull of return address and store in X
    PULA ;pull off A
    STAA TEMP ;store the value into temp
    TXS ;push return address back onto the stack
    LOOP2 LDAA TEMP ;Load A into TEMP
    ANDA MASK ;logical AND MASK with A
    BNE ADD2 ;add one if we need to
    BRA NONE2
    ADD2 INY ;increment our counter of 1's
    NONE2 LDAA TEMP
    LSL MASK ;shift our mask left by one
    BNE LOOP2 ;loop back until we've exhausted positions

    View Slide

  15. new
    hottness

    View Slide

  16. functional programming
    • It’s been around forever
    • But only in universities (ew)

    View Slide

  17. what is functional programming?
    • Treat computation as the result of functions
    • Avoid mutable state and data

    View Slide

  18. f&nctional$prog5amming$tells$the$computer
    instead$of
    what to do
    how to do it

    View Slide

  19. getting started
    is
    super-fácil*
    *ed:$Spanish

    View Slide

  20. code
    let’s

    View Slide

  21. github.com/ashfurrow/nsspain2014
    [~]

    View Slide

  22. resources
    • Books
    • GitHub
    • ReactiveCocoa
    • swiftz
    • Stack Overflow
    • Tweet me

    View Slide

  23. objc.io/books

    View Slide

  24. github.com/artsy/eidolon

    View Slide

  25. 1. Imperative$prog5amming$is$old$and$busted$
    [email protected]$
    3.Ge?ing$starCed$with$f&nctional$prog5amming$in$Swiſt$is$superEeasy

    View Slide

  26. so where now?
    • Swift promised functional patterns
    • Failed to deliver
    • Community is picking up the slack

    View Slide

  27. make
    better mistakes
    tomorrow

    View Slide

  28. gracias
    @ashfurrow

    View Slide