Top Banner
hipster oriented programming
30

Hipster Oriented Programming

Aug 14, 2015

Download

Technology

Jens Ravens
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Hipster Oriented Programming

hipster oriented programming

Page 2: Hipster Oriented Programming

I hate monads already. Even if it’s the most useful, elegant thing - it’s all what’s wrong about hype based hipster-programming in one word.

- tweet after UIKonf

Page 3: Hipster Oriented Programming

Is it really functional programming if you don't give a talk about it?

- @alejandrocrosa

Page 4: Hipster Oriented Programming

This talk is not about functional programming.

Page 5: Hipster Oriented Programming

orientation

Page 6: Hipster Oriented Programming

Imperative

Do this 5 times!

func nullToNil(dict: [String: AnyObject])->[String: AnyObject]{ var cleaned = [String: AnyObject]() for (key, value) in dict { if !(value is NSNull) { cleaned[key] = value } } return cleaned }

Page 7: Hipster Oriented Programming

Functional

Same input, same output.

let l : List<Int> = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] let sum = l.reduce(curry(+), initial: 0) // 55

Page 8: Hipster Oriented Programming

Functional Reactive

Stream of events being processed.

Page 9: Hipster Oriented Programming

Functional Reactive

Stream of events being processed.

voiceSignal .filter { response in return response.intent == WitIntent.Eat } .bind(WitResponse.getSubject) .map{ subject in self.speak("I will search for recipies for \(subject).") return subject } .bind(RecipeSearch().search) .map { recipes in self.speak("Please select on of these recipies.") return recipes } .bind(RecipePickerViewController().selectRecipe(self)) .map { ingredients in self.speak("Do you have all the ingredients or should I order some online for you?") return ingredients } .bind(ShoppingList.selectIngredients(self)) .bind(Shopping.order) .bind(PayPalViewController().checkout(self))

Page 10: Hipster Oriented Programming

Object Oriented

Put your family of objects in a room and let them talk.

Page 11: Hipster Oriented Programming

Protocol Oriented

You have a lot of equatable, comparable, parseable, archiveable, transmittable, displayable objects.

Page 12: Hipster Oriented Programming

Spaghetti Oriented

JSON parsing.

Page 13: Hipster Oriented Programming

Question State How to recognise?

IP imperative

How? a lot of nested loops and assignments

OOP object oriented

How? (but encapsulated)

encapsulated state

seperation of concerns “unix principle”

POP protocol oriented

What? encapsulated objects implementing hundreds of protocols.

FP functional

What? no state. you have no idea what it’s doing, but it’s short and beautiful.

FRP functional reactive

When? over my dead lambda. you’re constantly binding

Page 14: Hipster Oriented Programming

They all mix pretty well.

- pretty big secret

Page 15: Hipster Oriented Programming

bridging the worlds

Page 16: Hipster Oriented Programming

Monads.http://fuckingmonads.com

Page 17: Hipster Oriented Programming

Signals.jensravens.de/series/functional-reactive-programming-in-swift/

Page 18: Hipster Oriented Programming

Boxing and Optionals.

Page 19: Hipster Oriented Programming

Throwing Errors.

Page 20: Hipster Oriented Programming

Mapping Arrays and Collections.

Page 21: Hipster Oriented Programming

Type Safety.

Page 22: Hipster Oriented Programming

These are just concepts.

Page 23: Hipster Oriented Programming

These are just concepts.They won’t hurt you, they won’t take away your job.

Page 24: Hipster Oriented Programming

It’s more out there than just object oriented programming.

Page 25: Hipster Oriented Programming

object oriented programming has a lot of hidden gems you might not be aware of yet.

Page 26: Hipster Oriented Programming

What’s .next()?

Page 27: Hipster Oriented Programming

Functors, Applicatives and Monads in Pictures.

http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html

Page 28: Hipster Oriented Programming

The Introduction to RP you’ve been missing.

https://gist.github.com/staltz/868e7e9bc2a7b8c1f754

Page 29: Hipster Oriented Programming

Imperative Programming In Swift (Graham Lee)

sicpers.info/2015/07/imperative-programming-in-swift/

Protocol-Oriented Programming in Objective-Csicpers.info/2015/06/protocol-oriented-programming-in-objective-c/

Mutable objects in immutable objects in object-oriented programming in functional programming in Swiftsicpers.info/2015/06/mutable-objects-in-immutable-objects-in-object-oriented-programming-in-functional-programming-in-swift/

Page 30: Hipster Oriented Programming

Thank you.

@JensRavensjensravens.de

(and be nice to the next monad you meet)