I’ll start my conclusion so you guys know not going to surprise you complexity is bad functions are simple that’s that’s what we like and that’s what this is all about so get that all the way who is this guy who is in front of speaking right now my name is Colin Lee I that’s me twitter handle 30 years programming like today is my birthday so if you if i tell you that i started 1060 you can do a little bit of math but okay so yeah i’m working at hot new startup in town vid coo we make this awesome product called flip great you should check it out if you’re in education we do wonderful things and we’re hiring of course everyone’s ire Inc welcome to a convention so this guy I shouldn’t pick on him he’s actually one of the founders of Haskell but I look at the slides behind him and this is what happens often times when you see a functional programming language lecture is your eyes just start to glaze over at all the symbols on the screen and the scary scary words and so we’re not going to be like that today oh here we go let’s all get up 30 seconds just want everybody’s brains to be awake because I know but personally I just got my caffeine 30 seconds left all stretch this is good this is getting the blood flowing it’s actually good all right all right right we should do it epic yeah we should totally do this a big coup every day we’re gonna take a little stretch just get you guys going all right all right we’re all stretched out ready to rock okay so my first contention we got long word of the day is that simple is not equal to easy I know we’re all speak English in the English language you know there’s all these connotations between simple and easy like they’re the same thing the easy button simple they’re all but think of it this way there are two ways there’s an easy way and a simple way to get day off from work you can tell everybody that would be the simple way or you can just not come that would be the easy way now which one will leave you with a job at the end right the simple way right right am i right ok I’m going to talk about simple today I’m not talking about easy you want easy you’re not going to have a very easy job unfortunately so we’re talking simple hate a lot of people they go to college they get a lot of like six CS lectures computer science they’re there professor tells them about functional programming some language like Oh camel or Haskell or scheme or list and they just hate it because it’s not what they’re familiar with the started programming Navy and JavaScript or maybe they started in you know I know any easy language but not have school or lisp or scheme or something crazy a lot of us end up walking away from those lectures just hating dealing I took a ml compiler course at the U of M and I had to write it in ml for ml and by the end I hated ml anyone had that’s it situation though they just walked out of a functional language lecture and they couldn’t stand it anymore no yeah got a few nods around the room ok from the cs degree people think is hate tends to create ignorance because if you hate something you don’t learn anything about it so you tends to reinforce itself because that ignorance and causes you to fear it in fear causes you to hate it and so the more that you dislike going through that lecture with the scary symbols in the background the more that you learn less about it and don’t know what you why you need to learn and why it’s cool or what’s worth while to learn from it and that’s I’m going to tell you today there are really cool things you should be learning and just because it’s in heavy heavy talk with scary words and symbols doesn’t mean it can’t be learned and done and applied more easily more simply so we don’t need a holy war we shouldn’t the spread revolutionary ideas now in programming there have been many generations of these crazy ideas I know I’ve been at it for 30 years I can say I started on basic I don’t know how many people here are still making corporate basic code anybody anybody any hands basic know about pearl pearl got any pearl programmers we got a few it’s two hands in the back of the room so we got these generations where languages died naturally natural deaths because new ideas come up and these new ideas are

superior it’s not that pearls a terrible language you can get all the same stuff done in it but that new ideas appear and I’m going to talk about some of these so if you want to see a talk and functional programming in great depth one of my good buddies from vid KU name Brydon Matty is going to be talking right after lunch so I’m not going to go a super super deep use any heavy terminology I’m going to try to it’s more persuasive talk if you’re looking to learn more about our X Java you definitely need to see the last talk of the day with dan lew he loves this stuff knows it inside and out his co-workers didn’t have to have holy war with him over because they all love functional languages and so he got to learn so much RX java he will melt your brain with it and you got to go see that talk if you really want to see arcs java in great depth i’m just going to use short words for this talk i am i’m here as Harvey Milk once said I’ll do my best straight Harvey Milk I am here to recruit you I’m here to recruit you to learn new programming principle something that’s actually going to revolutionize the way you write code and it’s not even that great of a change it’s not as big as oo object-oriented programming was back in the 90s but it’s important because of all the changes we’re seeing and I’ll explain a little more functions what are functions you probably all learned about functions and we see void functions that’s not what you’re talking about when we’re talking about functional programming so I mean something with input output and no side effects in between essentially most of the time you’re doing functions you’re talking about you know having a functional flow from one function to the next something that doesn’t do anything unpredictable in between so that you can very easily understand the flow so what’s this reactive term and everybody throws it around nobody understands it it’s become there’s a reactive manifesto now if you actually read the reactive manifesto it reads like business speak it tells you everything it does and nothing about that underlying technology I mean you know if you if you go off the reactor manifesto Microsoft Excel is reactive but here’s what I’m talking about when I say reactive reactive program output is a function of input and it happens in real time so you look at that spreadsheet the effect is reactive effectively it’s doing a reactive thing it just happens to have code behind the behind it where the output is not is going through too many permutations and it could be simpler than it is that’s what I’m talking about when I say reactive output is a function function in the functional sense of input so a reactive programming is functional programming I know you guys who are scared of functional you’ll learn why it’s really cool and why they’ve made it easy for normal people like you and me who started out on languages with looping and variables and all these simple simple ideas and your professor is right if you touch you functional there’s a lot of cool things to learn so what is our X self let’s talk about a few things so here’s the first thing you guys are probably noticed this your PC’s at home when I was a kid you couldn’t get more than one core or one cpu it was unheard of you would have to be like a major Eber serious hacker to have more than one processor in your computer today we’re going men and up and to the right and we’re going to be up in the hundreds pretty soon on regular pcs on your desktop and as a programmer that’s a little bit scary because if anybody here has ever dealt with threading and threads that gets intimidating very bad gets really really scary you know because now you have to manage those threads you have to manage the state and state is something that can get lost very easily again Brian Matias talk will go into that in even more detail I’m just kind of doing an overview here another problem look at the cloud I mean again open to the right this is actually an exponential scale which makes us a little bit deceiving looks like it’s linear growth but it’s actually exponential here what’s going on is that you know we’re at a point now where there’s so many network API calls going on at a program that it gets very difficult to manage it all and we need new concepts to make it easier to manage all the threads all the network calls and bringing it all back together into one unified user interface so threading code locking it’s a big scary nightmare you can deadlock pretty easily you can you need to actually know that your threads are working in concert with each other air is go crazy you have an error and a thread in the middle of a bunch of callbacks and trying to trying to handle

that error also very scary we need a way to move the errors to one place where we can handle them all and not ghosts you know mental trying to write a program deadlocking related to locking but the idea that we don’t necessarily know we have to handle every case where something might not come back and how to handle it life cycle let’s say we’re dealing with mobile now mobile phones are constantly interrupted let’s say you got a phone call in the middle of your app is it going to be able to handle when you get off that call still having your state the way you want it ready to go for your your app still so there’s really psycho problems now you have to retry operations over and over again because you may not have network you know because we’re at a big conference and the Wi-Fi is over and you know I’ll be surprised if I get to the end of the talk no kidding but yes retry caching someone a famous said recently that offline first is the new mobile first the idea that if you’re in a coffee shop and you’re you know if you’re on your phone you’re usually waiting for something and if you’re waiting for something you don’t want to have to wait while you wait right now what no one wants that it’s like you know here you go to play your mobile game while you’re you’re you know it’s just taking a quick quick break from work you don’t want to sit there for a minute you know waiting for your thing to load up sharing of state I mean I kids keep going down this list call back hell’s where you get like several layers deep of callbacks and if you talk to a lot of JavaScript programmers I’ve heard them and suggest that the solution to call back hell is you just name the functions you name the callbacks and then now what you have instead of having your code scrolling to the right and now you have this nonlinear jumping thing going on where you don’t know where the codes coming from you know where it’s going to we call that spaghetti code and negative testing because nobody actually tests every possible error state for their app in every possible sense and all of these things get easier when we write our code differently with the different technology so anytime you have needless state it causes accidental complexity it makes your program more complex more complex more ways to fail and yeah by changing functions together in a functional programming sense you don’t have to worry about callback hell you don’t have to worry that you could be jumping all over the program because it’s all one chain so the old ways complex and complex as we say at the beginning is bad ray ozzie he’s the was i believe the CTO of microsoft at some point he was also found a lettuce notes ran i believe the microsoft outlook division he wrote this memo that inspired a whole bunch of people at microsoft saying the complexity kills sucks lefoux developers we got to do something different and this guy named Eric Meyer came along and answer his call for something different that would solve the complexity problem so again Michael my conclusion complexity is bad but functions are simple we like functions the Gang of Four who knows the Gang of Four anyone this is not the Gang of Four but I love the idea that maybe after they finished writing the design patterns book that they shot up a car and torched it and just went for a walk and said glad I’m done with that seminal work and it’s a good image anyway no the Ganga for wrote the design patterns book and the design patterns book was 1994 it revolutionized a lot of ideas what object oriented programming included all kinds of patterns we know and love today or not like the you know I could just go crazy on them factory pattern observer pattern iterator pattern you name it there’s dozens in that book and many of them are you know like used constantly and some of those patterns if you add them together they come up with this really neat idea that I’m going to tell you it about in a little bit here but at the time they didn’t actually come up with the reactive idea they just kind of danced around the edges so if you take the observer pattern and you combine it with the iterator pattern it’s okay if you don’t know these it’s something we can all pick up later if you combine these two together and you add ideas from functional programming you end up with the new reactive extensions ideas so this guy this is Jeff Atwood he writes a very popular blog you may know coding horror anybody recoating or got a lot of readers it’s a good blog too actually he likes to say that design patterns are a symptom that your language is broken and I’m going to make a wild statement here i’m going to say every programming language any one of you uses is broken including the ones i’m going to advocate today because they

can only get better and these design patterns are really working around the edges of a problem ultimately if you can internalize them into your language in the best way possible you’re going to have a better language yeah I as a as a Java programmer i love this one this one viral in the java community you know i had a problem so i thought to use java design patterns now i have a problem factory although if you work for a corporate job you know the big corporate java job it would probably be an abstract problem factory factory maybe one more but that’s the problem when you overdo a design patterns we love design patterns we wish they were embedded in the language in a way that they were more useful so he says boilerplate as a form of complexity and we can get around that by changing our languages this is eric meyer he’s my favorite pot-smoking hippie he lives he lives another the netherlands he worked from microsoft netherlands in a I think Amsterdam and he’s the guy who came up with this crazy idea called reactive extensions this would be I think 2007 I don’t think they released it until two thousand nine or so so this isn’t that old really the technologies that he created he created RX net and he suggested what’s the difference between an array and events now what do you think about your program anything in your program can be an event your click handlers every click can be an event your variables every variable change can be an event variable not changing could be an event if you you know attach something to it to say happen check at a certain time every single thing your program can be thought of as an array of events and that’s kind of the idea that I’m getting it is think about your program in this deep hippie enlightenment everything in your program is a stream everything is a flow of events happening over time entire programming languages have been written with this idea that it’s not about variables it’s about events and how you handle them so what do you guys think 2015 functional programming is it going to happen is it the thing well let’s see what people are saying about it let’s talk about react extensions which is one form of functional programming Netflix these are one of the the big shot guys who really took off with a bang on reactive programming they say we’re a big believer in RX it spreads deeper in our code the more we use it they love it they wrote many of the libraries and they use it throughout their company Netflix does a few you know things there they have a few customers and a little bit of traffic yeah Microsoft that’s where it all started as Microsoft say if a sink spaghetti code where disease Rx is the Cure kind of witty prescription github the github guys they loved it a ton when they made their windows app so they actually wrote their own library for the Mac team so I mean these guys are bought in wholesale and what about languages we got Java JavaScript c-sharp other forms of C sharp Scala’s closure C++ Ruby Python groovy jruby Kotlin cocotte our trust and a bunch of others and everything but the dotnet it was in the last two years that’s what I call an explosion so I mean we not only that but now there’s these ideas from reactive programming have gone into the core of languages like the language committees have adopted these ideas and brought them in and made them cord art so a dart programmers here no one okay it’s actually a good language take my word for it it’s a good language but it’s broken so is it the year I hope so I think it’s getting there let’s take a look at streams so Java 8 they actually internalize this idea of the iterator pattern into the language in a way i can take this array of numbers i don’t have to loop over it i can get all the data stream it filter it get only numbers where the number is greater than 4 map it so every number multiplied times 10 at the end this is going to output only numbers greater than 4 x 10 so it’s very simple very easy to use the only problem is it’s a synchronous API it doesn’t do a lot of good for most people because you know you can do this in a heartbeat it’s not that interesting ultimately but it does something gets rid of loops and it does functional style java in a synchronous manner so javi it streams it allows you to punk shins to the whole array or collection RX java so this

looks identical because i wanted to be very very similar you can see it’s the same idea basically RX java is the same ideas done asynchronously now not only can i do this where I’m outputting a bunch of numbers from an array not very exciting kind of boring actually it’s a sink streaming like I said not only that I can actually then take that number i can say well i just want to take let’s go out to the database see if it’s newer than the cash expiration we’ll go out to the network just grab a copy and then we’ll merge those two results and subscribe to them and in the minute that an event happens where we come back from the database or the network well I’ll put that result and this way we can automatically handle going to the network than the database and then you know output a result right all asynchronous all beautiful very simple there’s no state here I don’t I didn’t have to save any variables you notice that not a single variable outside of the callbacks that are basically they call these lambdas I had no long words but I I just broken my rule uh so our Java allows you to apply those functions to a stream of events which is really really cool ok let’s do something even more crazy and even more cool and again like hippie craziness let’s look at frp this is funk this is true functional programming this is not there’s no more loops there’s no more variables it’s all immutable and if you want to hear a lot about it Brian Matty will tell you about it after lunch a functional reactive programming goes beyond reactive extensions this will actually allow you to do some really in crazy incredible things for example you can time travel because it’s pure you can basically well because it has pure functions because as a mutable state you can act actually tell it every point in time through the past and into the future what it’s going to be because you know there are no side effects so you know exactly how to trap time travel within the language our ex tries to be both the best of both worlds obviously you can’t do certain things in our X you can do with frp and i’m going to show you one of those in just a little bit here so in frp times only a variable and we can change time we’re going to do that let’s look at a little talk here hopefully our Wi-Fi doesn’t cut out on us is anyone seen Brett Victor’s inventing on principle yeah got a few hands let’s see we’ll just watch a little bit for a refresher hopefully my sound works try not to blast people there we go so Brett Victor what he’s

showing us is really awesome and this was actually a mock-up he did in JavaScript Brett Victor’s a designer he’s a brilliant guy brilliant ideas and yet this wasn’t actually like showing something that really kind of worked yet in the sense he wanted it to it’s cool but someone actually had to come along and build that let’s see so one sec here click outside here we go so time travel is easy totally easy a breakfast or makes it looks easy but that’s just a mock-up let’s look at some real time travel here this is a language called Elm it’s a web programming language it’s called it’s a functional reactive programming language so it’s a very very dense format you’ll notice how tight that’s in text there is I notice a critic of elm actually was writing a blog post on it he had a code that was three hundred lines in j/s and and backbone.js cut it down to 200 with angular and rewrote his app in elma got it down to 50 lines very dense language kind of hard to read at times unfortunately but this is functional reactive programming and i’ll show you how something really really cool you can do with it see you just saw the braid character let’s take a look at mario so here’s mario i’m going to introduce a bug into this program I’ll do all right so restart him Mario is going to take a little jump whoa looks like if I do it right I can fly with Mario or double jump triple jump jump in indefinitely so let’s pause time so what we’ve seen so far is we’re just tracing his steps there’s actually a debug watch up there on the left you can see if I comment that out his his path goes away I’m doing this stuff live this is actually in the programming language right now and I can mess with his velocity right here this is changing gravity at the moment you’ll notice at gravity values where it’s like 1.5 and one point he seems to be able to double jump triple jump fly go nuts which you know as cool as it is he probably we want him have the the raccoon suit while he’s doing that we don’t want him to just jump randomly and fly all the time so for our game programming purposes we’re going to want to figure out what gravity what’s causing this to happen honestly so let’s go back in time just back it up a little bit here here we go so we can see at the peak of these jumps here’s his velocity on y is less than 1 you see it never actually hit zero here in the when he reaches the peak of his jump never quite touch 20 but if we change us to a something where it’s like point five or one point 0 we get a perfect zero at the peak and he suddenly his velocity jumps up to six because that’s happening here so we can very easily debug our program by traveling back in time and after I back up time I can easily then change the future so something really awesome so yeah I just changed the history I changed the future I’m totally awesome right all right all right now it’s your turn guys so complexity lexi is bad we all agree right flex d sucks and functions are simple so anyone have any questions because i want to actually like give you some time not just to ask the questions but say whatever you feel like i mean i want to talk about this recruiting for revolution right questions come on someone no I’ll pass the mic which function language do you guys using your company Oh in my company right now we’re using two functional languages well k Brian in a spare time runs closer to MN so he actually runs a meetup group for closure which is a lisp which is totally awesome in our company right now we’re using functional principles through reactive extensions i use RX java our iOS team uses reactive cocoa they’re wonderful libraries and you should definitely check them out because what allows you to do like i showed before is handle these stream of events without having to hang on to state and then gets rid of all that accidental complexity that makes your

lives scary in so many ways so when you guys go out to recruit new developers do you run into a wall like on day one trying to get these guys up to speed with functional programming I’m gonna let someone answer that who had just joined and just started learning functional what do you think about it Nate under Collins great leadership in the last week I’ve managed to pick this up don’t be afraid of it it’s pretty awesome once you get it and obviously working together for 11 days and it’s a good it’s a good language so thanks Nate I didn’t pay him to say that I don’t write the checks who has other question no come on right there okay so with all the events and stuff are there a dish memory overhead here you know a memory overhead of events yes in element or language like that especially what they do is they basically that there are ideas of state and elm but you have to basically specify that you want state if you do want to keep it in addition you have to deal with things like one of the one of the biggest times you get memory overhead issues is when they had this thing called now I’m just drawing a blank back pressure back i said no long words and of course the questions make me do it back pressure is when you have maybe two or three events dreams you want to combine those streams together like in Ghostbusters or whatever combine the streams and what happens is one stream will produce much faster than the other ones which means you’re going to have to want it two things either you have to buffer and hang on to events for a while or you have to throw events away and often it’s a combination of both now if you’re hanging on to a lot of events if you have something over producing you can run into serious memory issues but I can say from experience that in terms of memory leaks you can leak memory much much much easier when you’re hanging on to state then when you’re hanging on to a couple events that happened you know a little minutes ago right okay pass this on here that question made me wonder so is there have you heard of anything like reactive reactive programming where you have more input than you can possibly process it once you just scale up you of prostitutes I also think it’s a really good marketing you might be able to get a lot out of that I haven’t actually heard of that idea but I could see where you’re going with it obviously if you’re throwing events away there might be a possibility where you’d be interested in hanging on to some but ultimately you know if you throw an event away it also means that you know they may not have been think of it this way maybe have analytics problem you storing data and throwing events away is actually throwing away revenue in that case yes you could attack the problem with more storage more and more threads more cpus but ultimately it’s not a hundred percent solvable because you know you’re going to hit a limit it’s on a wall at some point doing that kind of thing I’ll pass it up Mike again thank you um what would some advantages be of using the reactive frameworks instead of like adopting a similar pattern with say promises that’s a good question actually believe it or not when I talk about reactive a lot of times I like to frame and interns people understand promises and futures are all part of reactive you’re already using promises here well all this is is an array of promises that the whole language is based on taking an array of promises and tacking functions on the end to do whatever you want with them so what you’re doing is you’re not you’re not getting doing away with promises you’re making promises more powerful you’re actually just extending the pattern further beyond the you know simple promises so good question one in the back there is there what you would call a gold standard RX extension that if someone were to say be writing a new or extension for a different language what would you say is the api set to match that’s a really tough question i I know Netflix and Eric’s Java has been treated as the gold standard extension you know obviously RX net came up with the ideas in the first place and they have taken ideas back from eric’s java to RX net I wouldn’t say that makes it the best I think that it’s very much an evolving standard the fact that I would say was it like at least 15 or 20 languages started

doing this in the last two years means that it’s growing very very fast and there’s a lot of new ideas happening all at once you’ve got languages like bacon Jas so there’s competing standards for Java scripts reactive you can do our xjs or bacon jeaious and and decide if you want to go more frp or do you want to go just reactive you know on its own without the overkill functional reactive programming another question right here I’ll take this this might be the wrong granularity for this forum but given Java how are you handling the threading model with these you’re registering for streams and they go away when their quest does right I mean so how am i handling threading in the Java model java concurrency libraries are pretty awful honestly they do a good enough job to get the job done but fortunately using RX they have what they call schedulers I did actually show schedulers a little bit ago here I can back up to it I just lost signal good timing uh oh uh anyway so schedulers allow you to decide what executor runs the request you can hit I do a lot of Android programming with java and so oftentimes what you want to do is you want to run your network requests on a special thread for networking requests and then you want to run the subscription the result on the main thread because you can’t make you I updates here we go you can’t make you I updates on any thread on it android except the main thread so they make this very very easy in RX java and again if you want more detail on this piece go see dan lose talk to learn all about RX java if you look right here subscribe on tells you where all the background work gets done observe on tells you where the results are handled and you can set these to anything and you can actually say a scheduler it from and pass in an executor object which could be a thread pool or anything you want it to be so this this is beautiful in terms of concurrency models it makes your life a lot easier and I can say from experience another question I hope you guys all enjoyed it will give you some time back so you can enjoy networking and have a great conference all right you