Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Hipster Oriented Programming

905 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Hipster Oriented Programming

  1. 1. hipster oriented programming
  2. 2. 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
  3. 3. Is it really functional programming if you don't give a talk about it? - @alejandrocrosa
  4. 4. This talk is not about functional programming.
  5. 5. orientation
  6. 6. 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 }
  7. 7. 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
  8. 8. Functional Reactive Stream of events being processed.
  9. 9. 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))
  10. 10. Object Oriented Put your family of objects in a room and let them talk.
  11. 11. Protocol Oriented You have a lot of equatable, comparable, parseable, archiveable, transmittable, displayable objects.
  12. 12. Spaghetti Oriented JSON parsing.
  13. 13. 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
  14. 14. They all mix pretty well. - pretty big secret
  15. 15. bridging the worlds
  16. 16. Monads. http://fuckingmonads.com
  17. 17. Signals. jensravens.de/series/functional-reactive-programming-in-swift/
  18. 18. Boxing and Optionals.
  19. 19. Throwing Errors.
  20. 20. Mapping Arrays and Collections.
  21. 21. Type Safety.
  22. 22. These are just concepts.
  23. 23. These are just concepts. They won’t hurt you, they won’t take away your job.
  24. 24. It’s more out there than just object oriented programming.
  25. 25. object oriented programming has a lot of hidden gems you might not be aware of yet.
  26. 26. What’s .next()?
  27. 27. Functors, Applicatives and Monads in Pictures. http://adit.io/posts/2013-04-17- functors,_applicatives,_and_monads_in_pictures.html
  28. 28. The Introduction to RP you’ve been missing. https://gist.github.com/staltz/868e7e9bc2a7b8c1f754
  29. 29. Imperative Programming In Swift (Graham Lee) sicpers.info/2015/07/imperative-programming-in-swift/ Protocol-Oriented Programming in Objective-C sicpers.info/2015/06/protocol-oriented-programming-in- objective-c/ Mutable objects in immutable objects in object-oriented programming in functional programming in Swift sicpers.info/2015/06/mutable-objects-in-immutable- objects-in-object-oriented-programming-in-functional- programming-in-swift/
  30. 30. Thank you. @JensRavens jensravens.de (and be nice to the next monad you meet)

×