hipster oriented programming

30
hipster oriented programming

Upload: jens-ravens

Post on 14-Aug-2015

169 views

Category:

Technology


0 download

TRANSCRIPT

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

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

- @alejandrocrosa

This talk is not about functional programming.

orientation

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.

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))

Object Oriented

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

Protocol Oriented

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

Spaghetti Oriented

JSON parsing.

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

They all mix pretty well.

- pretty big secret

bridging the worlds

Monads.http://fuckingmonads.com

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

Boxing and Optionals.

Throwing Errors.

Mapping Arrays and Collections.

Type Safety.

These are just concepts.

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

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

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

What’s .next()?

Functors, Applicatives and Monads in Pictures.

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

The Introduction to RP you’ve been missing.

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

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/

Thank you.

@JensRavensjensravens.de

(and be nice to the next monad you meet)