Download - 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
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 }
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
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))
Protocol Oriented
You have a lot of equatable, comparable, parseable, archiveable, transmittable, displayable objects.
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
Signals.jensravens.de/series/functional-reactive-programming-in-swift/
Functors, Applicatives and Monads in Pictures.
http://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
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/