LA SOLUTION au problème de frein parking automatique renault velsatis / scenic – Alarme défaillance

here the alarm with the flashing of this witness and blinking here at the joystick I remove the key parking brake failure there the calculator warns me that there is something wrong yet it’s tight there is no problem hello to all of you I am delighted to find you on my DIY chain I will come back for the third time on the issue of ash parking lot my velsatis but this time I’m going with a tool that will allow me to diagnose because the previous ones it did not go very well I dismounted half of the car and I did not find the fault so there in terms of accessibility it’s like “Ushuaia” he is there the device. this black box and that’s back in the heart of the problem and it’s even worse than that I had tried to solve the problem dismounting the car I had decided to follow the bundle of cables today we will take care of the brake automatic rear which still poses problems this is the third time that I take care of it and this time it’s the last in fact the connection of the rear brake with the calculator that is the front goes under the seat so I have to remove the seat and I even think that we will have to I go under the tank because the son go under the tank so here once we have raised this case we access this connection and we reach the top of the fuel tank but that’s not the problem I think here is the connection between the automatic brake booster and departure to the calculator so here when looking for a failure we are looking for something blatant damaged cable protection a cable envelope that is damaged by friction or other we are looking for severed cables we look for things that move that is. pins that move inside that are not well fixed or else corrosion that’s what we’re looking for in an electrical fault gold here we see no injury on the cable there is nothing obvious ideally it would be necessary check from start to finish and that’s impossible mission where it would be necessary to the calculator that should tell us if there is a fault on a circuit but I do not have any equipment who can look at the calculator so I’m annoyed because I think more and more that the parking brake has no problem but something is not working well on the information that goes back to the automaton so too bad it’s cold outside it’s 7 degrees I put a little bit of heating in the car it is very dark because there are a lot of clouds but I’m decided once and for all to solve this problem until now I had taken my old habits mechanic:we disassemble we disassemble and we’ll see after! but it does not work. it does not work! because with modern cars there is a lot of information circulating between the mechanical parts and there are small boxes what are called calculators and his calculators make the car live and decide to make it work or not in this case I think the calculator receives information who tell him that there is a problem and yet I have an alarm on the brake but the brake works very well I do not have any problem to start up hill I have no problem for the brake parking works the only thing is that the calculator sends impulses all the time when the car has been stationary for a while and it ends up emptying the battery we can hear it very well at the back of the car and that’s the calculator who has bad information and who sends systematically a tightening order while it’s already tight that’s the rattling noise we hear when the calculator does not work well he sends a good order without stopping to brake more while it is already braked and that’s what ends up draining the battery I even got to put a circuit breaker on the battery here for extended stops because I got to empty the battery nothing but the history of the parking brake if I solve the parking brake problem I will be able to remove it put it back correctly this device is also used on motorhomes for vehicles that do not work often it allows like that to protect the battery it’s been two years since I

galley with this problem but here I have a technical check that will happen and he must this alarm disappear especially since it does not correspond to anything brake again works so here I was obliged to take the computer to install software with an OBD2 probe and with that I think I will come to find my problem so my idea is simple I will diagnose before dismounting and I think that I should have started there so I recovered some software that is called maxiecu in we can select vehicle models me it is for vel satis but there is a whole bunch of renault models I can select the year mine is from 2004 Velsatis was produced from 2001 to 2006 I see here all the calculators the one that interests me is this one electric parking brake and to diagnose and well they need software you saw it here it’s maxiecu I contacted several companies two answered me there is a third who laughed at me who gave me an appointment and who never held it he did one of the two who answered me who told me that his software could not access because actually not all suitcases can access to all calculators just because each calculator to a communication protocol who is particular a protocol is a language and this protocol on the vel satis he is very particular and so suddenly it is not accessible on any suitcase finally it’s OBDauto who answered me and who told me that he could lend me a demo software or test I do not know too much what that means but they told me that with that I would be able to diagnose the calculator parking brake I thank them for helping me in this process that’s why that I speak to them today I can also talk about “doctorauto” who were really laughing at me he gave me a phone appointment never reminded me so I imagine that if you have a problem with the tools you buy from them well you can wait for to be recalled and sebastien from “OBDAuto” was super nice he sent me a suitcase that I received this morning and that I will test the parking brake calculator automatic with several parameters to consider he has this command here they call it a palette so that’s the parking brake clamping pallet the calculator it takes into account the clutch pedal so you can start up hill so there is information that comes of the clutch pedal it also takes into account the engine speed not the position of the pedal sensor but the engine speed all this to have the point of friction to start on a hill and the calculator it also takes into account the plate the car or the angle according to the angle of inclination he will ask that the brake be more or less tight the calculator is accessed with what is called an OBD plug, Next car the catch is at different places mine she is here under the ashtray or under the empty pocket following the car models it’s a little different this OBD2 socket is connected to my computer with a usb socket the software is started I told you just now who had the opportunity to access a whole bunch of calculators me I’m going only access the electric parking brake he pay attention to this kind of software because we can modify parameters I just want to retrieve information but we can also have access to this kind of parameter here the reference of the electronic unit we have the supplier here and information about the calculator itself here we have a menu I can read them the fault codes and the real-time settings of the car so for example the engine speed in minute turns so I’m going to save it and I will start the car here is the engine speed that’s the engine speed 900 rpm that’s what we can get on a calculator so that was the real time fake codes this is what interests me so I click on default code here I already have all the faults codes which are listed which are memorized so there is a present redundant contactor tight brake signal inconsistency already it starts well and that one he is present there are some here that are sporadic manual control absence of signal multiplexers system abs connection failure unidentified electrical fault standby ,,,, it’s sporadic defects

whoever is present is contactor redundant brake signal inconsistency and that’s what makes this alarm that I have on the automatic brake I’m sure remains to know now what is it means that red brake contactor tight and here I can erase the defects so I will erase the flaws that’s it I have more defects they disappeared so that means I erased them of the calculator it’s not going to say that the defects will not come back but that means that I erased them from memory so I’ll get the key back the key and see what happens here I have the alarm that is there so it means that the alarm is always present since there is a check which is done every time the car restarts so if I do that I do it in “live” refreshment, the alarm 5172 present type is back redundant contactor tight brakes signal inconsistencies that’s what makes the alarm it’s not a brake motor problem it’s nothing else than this signal inconsistency so he may have redundant contact who checks that the brake is tight we can see the benefit of having a diagnostic case because with that I’m going to search now what does this mean and once I found I will not disassemble at random I will not disassemble everything to find the fault I will only go there where there is the problem here is a signal inconsistency which goes back to the calculator I’ll finish for tonight because it’s cold in the car it is 7 degrees and we do not see much to film It’s dark Hello. so today is PIRE it is 2 degrees and the snow has arrived practically at the foot of the house I put some heating in the car to continue this diagnosis because I am in a hurry to find the solution so I inquired about this history of redundant contactor brakes tight, It seems like it’s coming from the palette, The palette I remind you it’s this little controller here that allows you to tighten or loosen the brake inside there are several sensors and its sensors we can control them simply by going to see here in this menu we have the position of the unlocking sensor lock sensor position and redundant locking sensor position so we can see here that on braking on the lock there is redundancy and our alarm she tells us what she tells us redundant contactor tight brake signal inconsistency and we find it here because when we look at course the lock and its two sensors there is one who is inactive and an asset when they should be at the same value we have the possibility with this software to monitor them so here unlocking here lock and we will watch what happens when you manipulate the palette I will first start shooting on that one lock when I shoot it goes to active when I release it goes back inactive and the other the second the redundant him he remains active so there is a problem when I pull on the palette Ahhh! there he walked! he walks sometimes and sometimes he does not walk it comes from this palette there I am active inactive I released and it did not come back and if I release like that. that’s it so that’s it the other at the top of unlocking when I press it locked here so I have more alarm I’m going to tighten here and there I do not have an alarm I managed to get them both I go back to the beginning I will update manual control signal inconsistency so I erase the defects I redo a reading and there I have more defects

necessarily because when I look here here it’s good it’s coherent if I arrange for it to be more coherent shaking the controller like that I am no longer coherent I will go see the flaws just now I had ps now I reread the flaws contactor giving back signal inconsistency I find him Why ? because here I am not coherent so that’s it and so it’s the palette now I’m going to dismount it so here I am taped in three minutes I found the fault that I sought during two years a crazy thing there I win a crazy time now I’m going to disassemble the palette I cross my fingers I hope it will work disassembly is quite simple enough to remove this little protection in front of and we have two small torx screws I will not unplug it as long as I have not cut the battery it’s easy to cut clock battery so that’s great I think I will leave him finally to remove it you have to pull this little clip this one and this one are redundant so I think they are a little bit glued they must be activated especially this one I take my testers I put it on test of continuity and normally when the stems touch each other that makes noise I have a contactor here and I have a contactor here that are operated with this palette so I find him on this side I have one here so it’s not easy but we can get there if I do that here is it I look at each other I think that having manipulated it it took off because everything at the time it did not work I will use a miracle product that removes moisture and that’s very good for electrical contacts especially try that it fits well in contactors then I’ll have to maneuver we look at this palette we do not see other defects except the fact maybe these sensors here they are attached to the circuit board and these are the feet of the sensors that make the fixation there is no other way of so fix them with time this car at 14 but it’s been 14 years since some contactors are completely supported but if there are any years tablet and good for letting go it can be difficult I think that’s what had to happen we’ll see right away if it worked we cross our fingers we go back to the palette

we put it back that’s it then ah well yes I did not connect the battery I go back there to read the faults the computer is connected we will try to manipulate the palette, I do not shake any defect I loose. nothing, I am looking here for defects there is no I’ll do like everything at the time I will go get the settings in real time i’m going save settings in real time what do I have here then both must give the same value give the same value i’m going to manipulate the brake to active / inactive active / inactive that’s where I have a frank answer both contactors must give the same value and this is what happens so ultimate verification, I take off the key I put the key. neutral I start the car tight parking brake it’s normal here I do not have an alarm, it does not blink, All is well, I had not seen this display for a long time because the brake alarm masked this information everything is OK!! if we look at the angular curve the most right is the instruction that is given to the tightening and the curve which is slightly more inclined it is the measure of the real value so we can clearly see that we are set which means that we come to pull enough on the brake! two years that I am waiting to solve this problem and I had to get help with a software like that to make it happen very simple way, with that In the space of half an hour the problem is solved when I think I dismounted the half to the car at least three times to get me wrong I was wrong but huge because I looked behind when in fact it was in front of my nose, I think we must not hesitate we must first pass the bag it’s primordial there are several solutions either you go to a dealer and you pay the price he asks you for read the codes and after you you do it either you equip yourself with software like this one I found it very well because it there is a grip very easy, I have never used software Well. I could easily adapt it is necessary to add of course a probe but be careful not all software are not equal. some software does not do not read the protocols of some calculators including calculators safety like that of the brake of parkin, So. ask before buy it I put you the link in the description to “OBDauto” which helped me for this video I saw also on forums that even by going at a dealership sometimes there is had problems interpreting the defaults so it’s not guaranteed to find the solution but we must first pass the suitcase because frankly we win a crazy talent, I lost a lot of time not to want to use it It’s over for the parking brake of the vel satis, I’ve been waiting for two years that. I hope you had a good moment before this video even though she is a bit long I’m sorry but I really involved you in all phases of the diagnosis because that I think if there was a message to to pass today is that on modern cars and well these tools are indispensable, I give you an appointment you in an upcoming video that will only maybe not mechanics auto because that on this chain we tinker all round

I’ll tell you very soon if you have liked this video and want to see the next ones think about subscribing and especially think about activating the notification because even if you subscribe youtube will not necessarily warn you from the release of my next video so think about activating the notification. think about share this video around you if you loved it and if you think that she can be useful to someone, see you soon in an upcoming episode and by then be curious be careful and tinker “The guy makes a video and he shows his despicable winner yeah so in fact I do not know how to do it passed a product a few years ago I think with silicone in it and the result is that it actually sticks the dust is stuck it’s a kind of I do not know what and I do not know how to get rid of this thing, if you have an idea if you have a miracle product. I’m a taker! I tried to scrape a few places and I damaged the plastic so it’s not necessarily a good solution and I do not know how to do it to get rid of it in a clean way after I could even cover with something but he must first remove this thing who sticks dust and it really does not clean I await your proposals in the comments thanks in advance

Haskell Amuse-Bouche

>> LENTCZNER: Thanks everyone for showing up for a crazy taste of Haskell I’m Mark [INDISTINCT] So, Haskell is scary, you’ve all heard it You’ve all heard the runs on Reddit, right? You know, it’s got no state, you know, who wants Lazynest? Lazynest is, it’s lazy, you know, and PHP has, you know, [INDISTINCT], screw that And after all, didn’t we just spend the last 20 years like making dynamic languages rule the world? I mean, we did, didn’t we? Right? And my ads–okay But Haskell is actually really scary cool It is functional, which turns out to be kind of scary and cool and it’s lazy and it has high order of functions and type in friends and it has monads Okay This is why I got hooked in the–in to Haskell I’ve actually been programming for more than half the time profession has even existed and so three years ago when I ran in to Haskell or sort of looked at Haskell again, I was shocked and really enjoyed that like, My god There was like something new to learn about programming I mean, something really new So that was fun It really does twist your mind, I mean, you know, Haskell is really–makes you really rethink a lot of stuff but the two things that I think it really got me is, look the language is beautiful, you write code and you just look at it, and you’re, like, Wow, those are like the nicest seven lines of code I’ve written in the last month Like they’re just gorgeous, you know, and so it’s really a beautiful code So, because of that reason, a lot of code to show you I have 50 more slides and every one of them I think has code on it So, we’re going to go really fast with you all Googlers so it will be no problem Mute we need a mute on some DC, hopefully some slide No? Mute I don’t know who it is All right The code is going to look like crazy-moon language, it’s just insane You know, it’s just totally different but not really but it is different, so just be brave, okay? Just be brave All right There is git repo, if you want to pull everything a little, of course, I edited the slides 15 minutes before we started So it’s not quite up to date, you can just Google for Haskell-Amuse-Bouche and the fist hit is this repo and I haven’t pushed yet to get the latest stuff so it’s a little bit out of date from the slides But it has not only the slides, it has all the source code I’m going to show you and Haskell files that you can load up in the repo and edit So, you can play along as well, If you want But I’m not going to give you too much time So, let’s start with something really, really familiar This is Bouche, not Haskell, right? And this stuff should look pretty familiar to anyone, there we go, a little bigger All right This is just standard pipelines on the shelf Okay, what do they all do? They all take input, they process it, they produce the output, as soon as they are able, that’s actually a feature of most Unix commands Most of those commands do not modify any state Actually, I chose ones which didn’t modify any state at all, right? But those are just small things you do, right? In short, those are functional, pure and lazy, right? So, you’re actually used to this stuff It’s actually not as crazy and weird as you think and, you know, the vast shell or the shell and the concept of the shell has been around for how many decades now and we still all use it, so it might have some value there Okay Let’s rewrite that in Haskell Hopefully that’s big enough for you to read So there are some gullible [INDISTINCT] on the first line which we’re going to ignore for this millisecond Because the next line, we’re going to talk about a lot and if you stick that in the file called run hask in a Part1.hs and run it; you give it this poem it’s input and surprise, it sorts the lines and gives you that poem as output Then master [INDISTINCT] or those who the reference Okay So, let’s look at the actual processing, all right, which is right on that first line It is not exactly rocket science We’re going to define a function called process which takes some t some text and it’s going to call some functions And the only difference from what you are used to is that functional arguments don’t go in parenthesis, we just used parenthesis for grouping So be brave, just look at the code Get the lines of t, it means take the string and turn it into an array of strings or a list of strings, technically a list

Sort that list and then unlines which is another library function which takes a list of strings, slams new lines into them and throws it all together All right So, the first line should be like dead clear, right? I don’t see anyone looking strange you can like, okay, everything is nodding yes, so good Okay. now, I know I had to take you back to high school and everyone hates that but in high school you hate algebra because, you know, you learn this, right? F of G of X can be written as this funky thing with a dot in the middle All right This is function composition F of G of X, all right, so you can see that While in Haskell, it turns out, that’s actually a programming language feature So in the same way, we can do that up here, we can fact it–we can sort of rewrite this, this way All right So, the function process of some text t is applied to that text t, the function lines composed with sort composed with unlines, all right So that data operator is exactly like it was in algebra All it just means is apply the thing on the left to the result of having applied the thing on the right, so unlines it then sort it, I mean, lines it then sort it then unlines it All right It reads kind of right to left which might seem kind of strange to you because bash things go in the other direction But look up here, right? I mean, it’s just getting rid of all these parenthesis Okay Now, here comes the real [INDISTINCT] We can actually do algebraic simplification or sort of the equivalent So, work with me here If process of–it takes some input, right? Process a function applied to some input t and all it is, is this composite function, these three things applied in sequence to t–in Haskell you should get rid of the t’s because we can say, Well, process–by the way, the tip marks are just valid characters for identifiers and I had to name them all three different things so they can go on the same file The process double tip mark is a function that is just the composition of these three functions Have I lost anyone yet? Good Onward Okay So we can code a bunch of other ones We can say sorting lines is unlines.sort lines, right? Compose those three We can reverse lines, we can take the first two lines because take two is a–no, it does what you think, right? So, anyone see a pattern? It’s a pattern, it’s algebra, we can factor it So, we can actually write a function called by lines which takes a function F and it’s equal to–we just write the same expression but stick our variable in the middle, right? So by lines of F is the same as having written unlines.f.lines So, now I can rewrite those three functions Sort lines write by line sort Reverse lines, by lines reverse First two lines, by lines take two Yes, yes, no, there you go, [INDISTINCT] that’s good All right Let’s write our own Okay I’m going to write a new function, sort of from scratch here it’s called indent This funny line at the top is a tight declaration, it says indent is a function that starts with a string, takes a string argument and turns it in to a string as a string result It’s kind of very functional style in notation, oddly enough All right Anyone noticed that this is the first type I have shown you anywhere? All the other code is completely 100% valid Haskell you’ll find it in the–in the files that are with the repo exactly as I wrote it here with no additional typing So, Haskell is a language that is really strongly typed and yet we didn’t have to type any types because Haskell is type [INDISTINCT] which means that when you type some–when you write on a code, the expression, Haskell figures out what type that must be when you write a type to a first order of approximation, 98% of time The type is for you, not for the compiler In fact, the compiler ignores what you write as a type, figures out what the type is on its own and then says, Did I get it right? Now, you might think that’s kind of crazy like aren’t–like, it shouldn’t be, but no The compiler it’s there because we write the types as communication between programmers and the communication of our intent and the compiler is actually checking us Checking to make sure we’re honest Okay So indent is a function from string to string, it’s really complicated, it takes an argument S, ended up pens at the double plus operator, a bunch of spaces to the front Great So, we should be able to follow our pattern All right By line sort by lines reverse and say by lines and dent, anyone want to guess? Boom, it doesn’t work And the worst problem is if you put this in the [INDISTINCT] you’ll see this horrible thing down there That is the Haskell compilers idea of poetry, it’s writing you a kind of a love poem but it’s from a compiler and so, as a consequence, we ignore it Do you agree with that?

This is just crazy moon poetry and you just have to deal with the fact that it’s there and most of the time you just figure what line number it is and go looking at them Okay What is the problem? The problem is, all our other functions sort and reverse took a list of lines and did something to them but we wrote something which takes a string Okay So, we’re going to use something called map Map to the rescue now, you probably all at this day and age program did a language that has a collections library and that collections library has either a four each or a map function, right? And usually map takes a functional argument, a function pointer or it depends on the language your working in and iterates through the collection applying the function and gathering up all the results and returning you a new collection This is nothing new Map exist and you–I’m certain everyone here has been exposed to a map function and just to make sure we are to realize what we’re talking about I gave you some examples, compare if we map reverse over this list of strings, right, it reverses each individual string versus mapping reverse to the list of strings which map reverses the list itself, got it? All right The same thing is like sorting some of you might at this point be scratching your nose and go, Wait, does reverse work on a list of strings or does reverse work on a string? The answer to that question is, yes it does both Okay So, to indent each line of our poem, right? I have to do something by lines but I better map, all right, by lines expects a function over a list So, I’m going to map indent over that list By lines map indent I could also factor that whole pattern out because we had a thing called by lines, have it each line, given a function–now, I’ve written this–now I’ve written a type Given a function from a string to a string, notice the parenthesis and the string return a new string So, let’s–let’s look at what’s going to happen, each line F is going to take this–it’s going to take a string, apply lines to it, give us a list of lines, map our function F over each individual line and then unlines the result back together into one big string to return So, each line is now useful utility function which does something–apply something to each individual line Yes? >> When you write maps space indent is that the same as indent.map? >> LENTCZNER: No, it is not So, the question was when you write maps space indent is that the same as indent.map? No, it is not We are passing indent as a function, as an argument to map >> Okay Map is a function >> LENTCZNER: Map is a function, right There’s no period or object There’s no receiver in this language It is not object oriented So, map is just a pure function at the top there but we’re going to–you’re getting close to a problem Anyway, close to [INDISTINCT] so indent line, we can do it this way or we can use this combinator of this thing we just build called each line–each line indent and then if you run them either you get indeed an indented poem, it’s very exciting But wait, where is the second argument to map? I told you back here, map takes a function and a list and returns a list In fact, at this point, looking at that top line should hopefully be kind of clear that that’s what that says It takes, right? It starts with it takes a function from A to B, a list of As and gives you a list of Bs but in this code up here, there is no second argument to map Where is it? All right Because it’s not there Because map of F–so look at map this way, we can say map takes a function from A to B and because [INDISTINCT] just trust me I can parenthesize the remainder So you can think of map as taking a function from A to B and turning it into a function from list of A to list of B, got that? If I just applied map to the first argument, I get back a new function it’s called [INDISTINCT] it’s [INDISTINCT] and I get back a new function, a function list of A to B, it turns, our indent which only works on a string to a version of indent which works on a list of strings We call this lifting or lifting up, map is kind of bringing our simple function up into the world of lists and that’s what’s going on All right And we’ll write some more code here, quickly I want to yell because we like yelling, right? So, this is another function from string to string and so, I’m going to yell and I’m going to map this function called to operate from the library listed uppercases characters And I map that over the string and I append a bunch of exclamations, and I’m going to

write yell each line and I’m going to use our each line function to apply this to each line of the poem And indeed what happens? I’ve yelled each line of the poem, not particularly exciting, it’s pretty much what we did before But what if I want to yell each word? Well, we’re very, very lucky, there’s actually like lines and unlines, the library has words and unwords So, we can define equivalently a function called each word that given a function will apply it to each word of the string So, right? We call words which breaks it up into a list of words We map F in this case, yell over that list of words and then we unwords to put it all back together And when we go off and do this, crap it all comes out on one line, right? Because it broke all the words apart all the words got slammed together with spaces and we lost all the lines So, what do we really want to do? We want to yell by words by lines Well, guess what? We can actually write yet another helper function Each word on each line, all right? Given a function F, this will apply to each word on each line by wrapping our function in each word and that we’re calling each word on our function and then calling each line on that And indeed, if I apply that, I get this, right? And I had managed to preserve the lines and do it every single word Notice that I have used the very functions we have defined ourselves as functions to more functions we’ve defined ourselves, right? So, what bus do we just get hit by This is the power of higher order of functions, all right? You can very quickly build yourself up a library for doing higher level manipulations of things and then re-use it very, very, very quickly Onward Okay So, we’ve talked a lot about functions, what about data? You got to have data in the program somewhere so, of course, we’re going to talk about structure data we might as well about list and so, one could use to define list like this This is actually a user defined type, this is not the built in list It’s just a list If you come from a certain persuasion, you might choose to call that mill and cons instead of end of list and link but let’s just read this When you have a piece of data of type of type–yes? >> You work [INDISTINCT] do you actually type what you’re [INDISTINCT] into a compiler? >> LENTCZNER: Either Good question So yes, I actually wrote the alphas because I just wanted to flex that Haskell was actually define in terms of unit code yohoo And so, you can–welcome to use Greek and variable names if you wish Actually, in fact, you’d probably not unlikely to see this, most people do in fact use Latin letters in this particular context So, that is actually a tight variable, tight variable So, this is–so, when you have a list of some type, either note the or sign there Either it’s just the end of the list, the empty list or it is a link of the list with some value of whatever the hell alpha ends up being and then recursively another datum of type list alpha, right? This is just a standard kind of recursive definition of the list Okay So, we can all play around with some obvious types, where we can define the value empty equals the end of the list Notice that we can kind of use these user defined options, we call them constructors–don’t think constructors like C++ or java Empty is end of list, one word is a link of the string apple and the end of the list, right? So that’s a one word list, two words is a link banana and then in parenthesis I create another link of cantaloupe of end of list, right? Kind of sort it should be sort straight forward, be brave, just go for it All right Pop quiz If we’ve given those three things I just typed, what do you think happens with the bottom with one of the first mysteries? So, anyone guess, what is mystery number one? It is a list of A pair It’s one thing, right? So, the first thing this is showing you is that, all right–remember, there is no modification of state in Haskell so when I declare the empty equal to end of list, I can use it just as well anywhere else You might think that’s annoying because like you can’t modify state but it’s actually really nice because things factor really well, like the guy who wrote mystery.1 is like, This is a single element list, I’m certain of it, you know Isn’t a change [INDISTINCT] you think? Mystery two, well, you can compose these things link the string peach and then what? And then some other list, right? Some other item has to be in a list [INDISTINCT] So, mystery two is a two word list, right? Peach apple Mystery three, anyone would guess what mystery three is? Who wants to be brave? >> Pineapples >> LENTCZNER: What? >> Lots pineapple >> LENTCZNER: A lots of pineapples Yes, it’s an infinite list of pineapples Haskell’s perfectly happy with this, completely happy Like you type it in, Haskell’s like, Sure, no problem

It works fine Anyone want guess what mystery four is? >> A tiger >> LENTCZNER: Yes, it’s a tiger, all right Because something that’s others that lists are all right We said it was a list of some type and all these other ones have been a list of string This first link has an integer but the second link has a string and if you looked at the definition you’ll notice that it had the same alpha in both places Yes? >> Okay [INDISTINCT] So, what is like, a context of mystery? >> LENTCZNER: What is the context of mystery? These are type of the top level >> So, I mean, at a point where mystery [INDISTINCT] >> LENTCZNER: Yes >> Okay >> LENTCZNER: Yes So, your names are all on top of the same It’s a mutually reclusive set of definitions Yes, so you can refer to yourself And the reason that this hasn’t go often to infinity at this moment is it’s lazy All right No one’s asked for what happens after the first link of the list so, we haven’t bothered to go look there and the fact that we will eventually go look one step further is fine Okay So, yes, number four isa type error Okay, let’s write some quick functions on list Good, I’m doing great on time All right Here are some examples of how you write functions Notice list back here has two different kinds a datum of type list can have one of two forms, it can be the end of the list that’s one form or it can be a link, that’s the other form So, strangely enough it is common that all our functions on list will have two clauses, yes? >> Going back to the type error >> LENTCZNER: Yes >> Well, [INDISTINCT] >> LENTCZNER: No Not of the type you are used to There are strange, weird, wonderful, odd things which you will be tempted to use in your first weeks of Haskell, you know, that let’s you do this, I really, really need a help, you know, a heterogeneous type And then when you’ve used Haskell for six months, you’re like, I’m so foolish I’ve never needed that heterogeneous type ever So–and this one you’ve got to be brave and like trust that this sounds crazy, that you can’t do this but in fact you really won’t actually need it There are other ways to achieve what you’re trying to achieve which are actually more powerful and more importantly safer Okay So, some functions Because list has two forms, a datum of type list has two forms, almost all functions on it will have two clauses, notice I have two equations for drop one So, we can read this pretty straight forward Drop one takes a list of some type and I don’t know what type it is and returns me a list of the same type If it has the form link first rest [INDISTINCT] pattern match variables they’re just variables for what we’ll be matching in those positions, then it’s just the rest of the list having dropped the first link And what if drop one gets a list of type form end of list, what should I do? Well, I don’t know We’ve decided that dropping one element off an empty list it’s just an empty list That seems like a nice safe thing to do All right, we’ll write end of list And do you want to guess what happens if you leave off that second equation? It is probably like, Dude, you forgot one, your missing out, right? So, one aspect about Haskell is that it’s pretty easy to make sure that you’d caught all the cases, all right >> So, it catches that before you actually [INDISTINCT] use that >> LENTCZNER: It catches it at compile time >> [INDISTINCT] >> LENTCZNER: Yes, at compile time, it’s like, You missed one Like if you really want to miss one, go turn off this warning here but like we really don’t suggest you miss one Why would you–why would you not want to miss one? You don’t want to miss one because–all right If you have all the cases covered, then you’re certain the function always has a well-defined value In fact, this is kind of something subtle, it takes a while to get used to If you have all the cases covered then you’re certain your function never crashes and I mean, never in a much more serious sense than the never that you are used to I mean, it never crashes It can’t Like it has a well-defined value, right? If you covered all the cases and the compiler doesn’t complain, all right, then the only possible problem that the function could have–I mean, it might not implement what you’re trying to do, right? It might have a different function than your computer different result All right The only thing it can really do is go often to, you know, go off diverge, go off an infinite computation That’s the only real error that you could have left It’s just kind of fun Okay Here’s another function called Just One It’s a little weird, it takes a list, it returns a list, if the list is just a link then we return a list of just that the first item, right? And what do we do if there’s nothing in the list? We just want to return, I don’t know it’s got to return something or get that compiler warning which yells at me So, I’ll have it return an empty list Okay It seems kind of weird but there’s a function definition Okay Pull back to reality Actually Haskellers, you know, lists are really common We don’t like to type so much and so, this is from the standard library I want to point out a little bit something amazing here

The syntax of the square brackets is actually built into the language but the type list isn’t This is actually defined in a library file who’s source code on your installation, you can actually go find and look and inspect In fact, you can copy them to your own modules and create your own version Which is kind of astonishing, right? I mean, it’s actually built in the language There’s nothing magical about how this works So, here’s everything I just wrote but it’s written with this new notation; notice end of list is written at this funny empty square, you know, double square brackets and link is written by an infix operator called Colin, right? So, Colin puts an item the A onto–and this is kind of a funny list of A. Don’t worry about it too much The syntax of list looks pretty much like what you’d expect, in fact, it’s so much like what you expect, what I wrote is Haskellers don’t even type that much And I flip back the words real quickly between these two, wait–stop that There you go The only real deference is on these lines, people like to write lists this way because they don’t like to write the silly Colin, look at the Colin, right? The string apple Colin linked on to the empty list They don’t like to write that, they like to write apple, you know, inside the square brackets it’s purely syntactic sugar that’s all And these are all the same functions and so much for that Okay Two more standard things and then we’ll get to some code, more code, okay A string is just a list of characters, really Here it is And then there’s this funny other type, a datum of type maybe It has two clauses too just like a list had two clauses but it’s even simpler than list; maybe is either a datum of type maybes, some type–it’s either nothing or just a single value Seems kind of crazy a little minor thing, right? This is how you use it, like maybe if this function takes–pick message gets maybe an integer, right? It has to have two clauses because there’s two forms, right? So, we pick message, if it’s just an N then I’m going to construct this string Pick a number like N, you know, show us how you turn a value into a string, you know, display it And then pick message if the value was nothing, I’m going to say a different message So, that’s how you use it, just pattern matching just like we did with lists So, we have this awkward function called just one, right? Remember I said like, what if the list is empty, what should I do? Like what should I return? It’s really awkward because I want the first thing on the list but just one gives me the first thing on the list but damn it, it’s inside another freaking list, right? It’s kind of annoying, right? So, you might be tempted to write the bad function at the bottom, in which case, you would be bad because look at it, it says, if the list is, here’s some cool notation stuff We like to–we don’t like to type a lot as Haskellers, right? If a list consist of a value A and the under bar is, whatever, I don’t care It’s a variable that matches but doesn’t–no one uses it Then it’s just A, just the first thing on the list but if it’s the empty list, well, I can’t like what A would I return? I mean, if A is integer, should I return zero? I don’t know, maybe zero is a useful value I mean, what are you going to return? Well it turns out it’s like nothing you can return in this case and so you write error and error is this magical built-in function which, like, kills your program and crushes it with a message Actually, it does if you end up trying to use it but–so you don’t want to use an error, it’s a bad thing So that’s a very bad thing to have happened So this one, like, shuts the compiler up but you end up using an error into your program So, here’s a better way So, let’s use maybe because the answer is this function maybe has an answer, maybe it doesn’t All right? And so, this is a much more clean way to right this all right? The first one on the list is maybe of something We have had just or nothing Okay Keep your eye on the code very carefully Here’s a real function that finds the first character after a star So, given a string maybe it’s going to return the character maybe [INDISTINCT] Notice we’re getting rid of nulls, there’s no, like, no nulls in this language all right? Find after star Well, if I have a list of a character and another character and then the rest of the list then if that character equals the star, let’s return just D because we found it, we have a character after a star else, let’s just recurs find after star We’ll put D in front of the rest of the list and call it on that list Let’s have another clause, if all else fails–under bar, this is a catch hall, catches everything, then nothing, there is nothing after a star Got it? Anyone confused on how that code works? No Yes?

>> So, you have mentioned matching semantics are likely to [INDISTINCT] >> LENTCZNER: Yes So the question is, “Are the pattern matching semantics in order?” And the answer is yes They write–they trust in the order that you write them None of this funny reordering or any of that stuff it’s, like, exact–just read it in order, that’s how they test it Makes it easy >> Well, how about just [INDISTINCT] >> LENTCZNER: So, just is right back here There’s this type called maybe, it’s a data of type might So, maybe it has two forms If you have a datum of maybe an integer, either you have nothing or you have just an integer So, there’s two forms Just like the list had two forms A [INDISTINCT] and a cons or end of list and a link So, there’s two forms So we can return either kind–all right, here we could return two things Now, in this case you might be asking–I’m not sure this question you’re asking is just acting like a function in this case; it’s acting like a constructive or building a value of type maybe So, this function is going to return a datum that has either two forms: just a character or it’s going to be nothing >> I think that [INDISTINCT] that when you define a type and give a list of constructors and >> LENTCZNER: No >> …constructors all have the same name as the type >> LENTCZNER: Yes >> …has [INDISTINCT] and give it new names for each form >> LENTCZNER: Yes Right Every form has to have a unique name, right? And that’s how we distinquish them and tell them apart All right And in essence, you don’t–in other language the constructive constructors, you know, you have–constructors are just different ways of building up, you know, an instance of that class but, you know, then you just have an instance that class then are all the same This is sort of the other way around right? When you build up and instance of maybe by using the nothing constructor, it is different in structure than the version that has just the value It actually has a different internal structure >> So, [INDISTINCT] >> LENTCZNER: No, no This is user define It’s not–it actually it’s in the library, it’s standard but this is just built out of a language >> Okay The point when you [INDISTINCT] >> LENTCZNER: Because you always need a tag–there’s tags in the front that identify Think of it as a discriminated union This is like a union of different struck and you need to have a tag in the front so you can tell which one you’ve got And you use that tag both when you build it and you use that tag when you tear it apart When do we tear it apart? Pick message here is tearing it apart, it is looking at the union and saying, “Huh, is this value of maybe have a just tag on it? Oh, then of course it’s got a value A that follows the just tag.” Right? And the bottom one says, “Oh, does this value of maybe have just a nothing tag on it?” Well, of course it doesn’t have anything else with nothing; all it’s got is nothing Nada Okay So, here’s the version that does string just find after star And let me change it to find after char, I’m going to make it more generic, I’m going to give it a argument It takes another argument, a character of [INDISTINCT] M to match And so all I did is instead of saying C double equals–all right, so I gave an extra argument M, you can see it up here, there it is All right, you can see that it does now compares against M instead of against the fix character star, I changed the tag signature, takes a character and a string and returns maybe a character so it finds after this character I had to add another thing here for nothing but–otherwise, the code is basically the same Oh, and when I recalled recursively, I had a pass M again Okay I’m going to make this once more generic So, this function, I made it a little more generic by checking for any character Let’s make this a template and make it work for any type not just strings Ready? One, two, three, go Anyone noticed the only thing that changed? Okay The name of the function, find after elem instead of find after char The only thing that changed here is the type declaration That’s it Now, I did add this very funny weird piece of cryptic nonsense, be brave, you know, trust me it’s good All it says is that A is a type that knows how to do equality, that’s all that’s saying But instead of going from char to string, remember string is just a list of char to maybe char, I just made this generic Go from some type A and a list of As and maybe A. Notice that the code is the same The actual body of the code is identical Yes? >> So, is the type line necessary? >> LENTCZNER: Boy, you’re like the, you know, like [INDISTINCT] man from the question Yes, so Mark, what is the deal here, like what–like what is the type line? The answer is, when we wrote this, the compiler compile the bottom code and went, “Wow, this is a nice cool generic function It finds any element after any other elements in a given list Oh man, he wrote this restrictive types signature, oh well, whatever fine, I’ll only let him

use it in context of chars and strings.” When I wrote this, the compiler did the same thing It read–looked at the exact same code, came to the same exact conclusion and said, “Ha, his type-line is right That’s exactly right That’s the type of that code This code is–this code will work if and only if A is a type that understands equality.” It figured that out because I used the variable here And it figured out that indeed there better be a list because I used the list constructor here And it figured out that the result better be .maybe because I used Just and Nothing It figured all that automatically That’s all it takes to make your code generic It is really common when writing Haskell to suddenly realize that the thing you just wrote for some particular case is actually complete generic and you just fix the type line and go on >> So you then–when you define string as an array of char, you also >> LENTCZNER: List of char >> Sorry You also manually specify the Maybe and the Just and the Nothing types in terms of that >> LENTCZNER: No, no, no >> [INDISTINCT] >> LENTCZNER: You don’t have to achieve or write that That’s all inferred Maybe was written–so when we were at maybe, right so this is just like, well Okay, so what happened like, there’s Maybe int and Maybe char, but I just wrote this thing called Maybe A. No, that A didn’t mean, oh yeah, when you get around to it, like, type a version with replacing A, that really is a type variable So you write that line, and Maybe is now defined for every type: past, present, and future And it’s already [INDISTINCT] Okay, onward Now, Maybe, actually, is really important Maybe is so important that Maybe is actually the thing that blew my mind This silly little teeny tiny itsy bitsy type, this was like the first thing that, like, [INDISTINCT] my first two weeks back in [INDISTINCT] I was like, “Oh, okay.” This is thing is really useful, okay? These functions–I just wrote there type signatures And you don’t have to really pay too much attention to them because just look at the names, these are all functions you’ve used in libraries all the time “Find the index of an element.” “Look up something on app,” right? “Shoot this prefix from this string,” you know “Get the port out of URI.” Anyone every written that one? Okay, these are all functions which may not have an answer And in almost every language and in every library I have ever seen, gee whiz, we write conventions like, “If the element is not in the list, return -1.” Anyone ever been bitten by that? Ever? Right? That is a sucky design All right, that’s just bad Look how easy it is when you have Maybe, you–because you can declare precisely and so here is the first aha that types in Haskell Types in C and C++, as we know, are for the compiler to make sure it lays it out in memory correctly I mean at least initially Types in Haskell are for you to communicate with other programmers what you mean in a really deep sense In a sense I think that is deeper than others All right, so these are all examples of functions where Maybe is far better than returning Null Did Null mean it wasn’t there? Did Null mean it was an error? I mean what is that Null? Like, I don’t know what that Null means Is the empty string an error? Or did stripping the prefix from the string return me the empty string because it was only the prefix or did–you all see the errors here, right? Okay So let’s look how you use this So it turns out this other fun stuff about Maybe because once you have something of this concept into the language or that you’ve been building language, you can now start building better utilities for using it, all right? So for example, all right Here’s a function called addaweek.day, it comes from a library, right? So we add day 7 to some day object and we get, you know, one week later And imagine I’ve got some list of interesting dates and we’re going to use our first one function which given a list returns Maybe 1, right, because if the list is empty, then you get nothing So I want to find, all right, one week later from that interesting date, I can’t apply addaweek to an interesting date Everyone see why I can’t apply it directly, right? Addaweek takes a day, but interestingdate has a maybe a day, right, because it might be a nothing So how do you do that? Now in most other languages, what we would probably do at this point in our code is we would write an If statement, right? If date equals null then do this, else right Okay, and we would probably propagate that null further up the line, if date equals null, return null Else, add seven to the date, okay? Here, we use fmap What is fmap? Well, you know what map is, right? Map is like a function, like, for example, addaweek And map would apply it to a list of days, adding a week to every single one If map, let’s just take a function of days and apply it to a maybe day

And fmap says, “Well, if we just have a day then we’ll apply it to the inner value and return just that And if we have a nothing, we’ll just return a nothing We’ll propagate the nothing Fmap does exactly what we want So, furthermore, if you want to think about this like–I’m sorry, have I lost anyone? How fmap–what fmap does? Fmap takes a function from A to A–actually from A to B, but [INDISTINCT] on that In this case, it takes the addaweek function which goes from day to day, and allows us to apply that function inside–to the value inside a Maybe If there’s a Just in there, we’ll apply it If there isn’t then not Of course, we think of–yeah? >> [INDISTINCT] >> LENTCZNER: Well, it’s in the library But it is user-defined, yes >> [INDISTINCT] >> LENTCZNER: Ah, how does this–how does it know how to apply the real value or not So here’s an even bigger sort of–here’s a Simon for a true head explosion, how that is done is not built into the language either That’s in the library as well So you can go and find how fmap is implemented And you’re like, “Oh my God, it can do that That’s cool.” A little outside the talk, but >> [INDISTINCT] >> LENTCZNER: That is true, right >> [INDISTINCT] >> LENTCZNER: Yes, there is writing code for that Although–yes So–all right, so fmap, in the same way that I said, you could think of map as taking a function from A to B and turning it into a function from list of A to list of B, we’re going to give fmap, at least in this context, as taking a function from A to B–or in this case, day to day–and turning it into a function from Maybe Day to Maybe Day Fmap is lifting your function up into this other environment Okay, and so you can do a week later Now, the cool thing about this stuff is that all the stuff is in the library And you can build things which end up being really powerful Here’s an operator It’s got a funny spelling, greater than vertical barl, less than–greater than the vertical barl, less than, whatever You can define your own operators out of symbols and Haskell Amuse-Bouche, people sometimes do This function don’t pay too much attention to it It does exactly what you think it does It is short-circuit evaluation on–based on maybe It runs the first function, favorite show, which returns maybe a string if the person has a favorite show, or it returns show with name, right? And it does show with [INDISTINCT] so it takes–by four it takes two maybes and if the first one is just a value, it returns that If it’s nothing, then it returns to the second one It’s short-circuit choice The cool thing about this is, this is not–right–now, we all work in languages with a short-circuit choice, but they’re generally built in and you cannot build user operators to do the same thing, or user functions that do same thing Must you’re working in common less when you’ve got some–or scheme and you’ve got some great macro system, right But, you know, most of us are stuck with, you know, C++ Where you can’t really do this, it turns out you can make your own functions do this kind of stuff all the time because it is lazy And so, the reality is that, any of these operations can be extremely complexed to compute, but because the Or operator will never, you know, if your operator never selects that option, and never returns it, the computation never actually gets done So, that’s kind of fun Here’s another common thing we often do, all right So this would’ve been a series of ifs have we–have to write this was no, as the key value as the value indicating that there was no answer [INDISTINCT] so this is much more concise, all right Okay Here’s another thing we do, so here’s a set of functions that, like, get headered, it takes a string and a message and maybe gets a string because there might not be a header And parse state gets a string and maybe returns to a day because maybe it isn’t parseable And mailbox for a day, it takes a date and maybe we have a mailbox and the user’s file system for that date or something, you know, who knows what that function does but they’re all valued to maybe And so what I wanted to do is, I want to pass the values along stopping at any point in the sequence in which I get nothing So get header for a day, that answer is nothing, we’re done we return a nothing Otherwise, I need to sort of unwrap the just value and pass it to the next function, parse state which if it succeeds in parsing that header as a date, then I want to unwrap that maybe to just get the date value out and pass that to mailbox, all right So we would normally write this as a giant cascade of ifs, a nested ifs all the way at the bottom And the else [INDISTINCT] to the whole–either we’d return from the inner part or worse, if we had to continue to use the value we’d have to set some value It’s the default value at the top or no, and do the [INDISTINCT] you know, it would be some horrible nested thing And so, we have this kind of injection operator, it’s pronounced “bind”

Which is does that Now, I won’t give quite too in there but it’s get a little bit to the question about like, how does it know how to do F map So, it turns out that these functions, these things, these operators are actually part of type classes which I’m not going to explain too much But, are wonderfully useful and the answers is that they’re highly generic so it turns out we can use F map actually over lists We can use that alternative thing with lists, we can use it with–we can use bind with things that are monads These things are highly generic and get used for lots and lots of it’s [INDISTINCT] places Okay Do we have time for just one more? Yes, we have 11 minutes so, go Now, the thing I really love about Haskell, one of things I really love It’s a strongly type language, that types really help you encode what you mean to say to your fellow programmers, the types the compiler will really catch your ass when forget at light, oops, you didn’t cover the empty case, you know, it’s really nice But here’s the thing I like most about the types in Haskell, you don’t actually type them very much Okay Here is a wrong lengthing code function, I will not through how it works, you can work that out It’s a fun little puzzle Well, it’s not really a puzzle, just a fun little piece of code The only type declarations are on the very first line, it says if A is a type that knows how to do equality, then given a list of A, I will return a list of pairs of A and an integer right, this is standard wrong lengthing code Okay And blah, blah, blah And now I’ve got–I’m aware lets me introduce like local functions, these are just local functions that I’m only using inside this other function that’s where the ware clause is I’ve got local variables, I’ve got this crazy function called next group which seems to take one, two, three arguments, I think You know, it’s got tests, it’s got all the stuff in here The only types I wrote were up at this top line And yet, right The type of every single thing on the rest of this function has been completely inferred by the compiler, checked, verified And I get all that protections for all those things even though I didn’t bother to ever write their types All right This is like the–so this is just like [INDISTINCT] it was like, wait a minute, it’s all the benefits of type checking or even more benefits of type checking but I write it like I used to write python or I didn’t write types anywhere, like, oh, that’s nice I don’t have to write all those things Now, C++, x11, 0x11, whatever it’s called these days has auto, the auto type which is somewhat like this, although I don’t believe it’s quite as powerful or quite as hubicueous And, you know, there are languages that we use that sometimes have types or not, or let you–have things un-typed This is great This is types that you don’t type-checking but you don’t ever type them Now, let’s compare that to C++, are you ready? That’s fun There are a lot of types here, and what bothers me most is the programmer is There are a lot of types that are repeated a lot Okay So first of, I have to tell, see something that this is generic, okay, whatever Now, I have to decide list of a pair of Ts and Ns, okay that’s a lot more wordy than the way you write then in Haskell but I had to write that on Haskell And it takes as an argument a list of Ts, I had to write that in Haskell too, we’ll ignore the constany Then I have this local variable and crap, I had to duplicate the freaking type again and I had to do that And then, here’s the one I really love I have an etorator but I like that I have to type, type to tell the compiler that the next thing I type is a type Right? I mean, this is really bloody awesome Now, it’s true, C+–the new C++ will you write auto there in and will figure it out Yey, C++ learned something from Haskell or other type inferencing systems But, there’s a lot of type stuff you have to write here and it’s pain, and it’s knarly, and it’s in the middle of all the damn code and it annoys me By the way, just another minor little point, the type systems has lots–it can lets people do crazy wonderful things If you’ve never encountered a quick check library, I don’t know if Haskell was the first quick check library but I think–and who knows But it’s certainly–here’s a bunch of properties about that run length encoding function I just simply read them as functions from a given input and to bullion and I expect these all to be true Like, I expected the length of the list equals the sum of the second elements of the run lengthing coded lists Oops that’s mine–sorry, that line is really long, right And run length code the list, I take the second elements of all the sum and I summed them and I expect that to be the length of the original list That’s kind of, you know, a run length encoding invariant And these are all various invariants that I just I wrote Okay I would like to actually test this, so I could got to my unit and test, frame, or can write, you know, several hundred, you know, unit tests so I could write–well, I probably write maybe a dozen tests unit, you know, tests cases for this by hand But in Haskell, because of the type system I can use the thing called quick check and I can ask quick check just to check this function and quick check will derive from the type

of the function, the possible set of inputs, like it could go there Then generate test cases and it’s relatively smart by generating test cases that actually matter, like, you know, like, oh it’s a list I better try empty list that’s got to be really important I better try a list of just one item, you know, it gets all the good corner cases And it generates cases so this actually allowed me to run 300 test cases on my run length encoding function You can actually, really, honest to god, like, pull this in, type it and run it This is the entire–sorry, that plus this, plus the loading the module quick check is all it takes to be able to run this There was no actual additional scaffold thing I’ve left out Okay So, that’s actually really sort of fun Okay So a few other things to point out about the Haskell ecosystem, we’ve gone to the language a lot but the ecology of Haskell is actually tremendously nice to work with GHC, the Glasgow Haskell–the glorious Glasgow Haskell Compiler is the–probably premier standard and the most common used compiler now It has a command line ripple called GHCI the interactive version which is just a delight to use It’s really trivial load all where all these code up in there and reload your code and you can ask if things like, I wrote this code and I didn’t write a type signature, can you tell me what the compiler thinks, the type of this code is? That’s actually really common for Haskell programmers to do I don’t want to figure out what it is, you just tell me Cabal and Hackage, Cabal is a packaging and building subsystem and Hackage is a very large package repository of now about 3000 packages Cabal is the nicest package manager I personally have ever used It’s the only one I know that knows how to install things locally just for you by default You know, it can do system installs or personal installs and it does all the recursive dependency analysis and download and configure and reinstall those things and it’s just enjoy to use Hatek is the inline documentation system which I worked on so, recently so it–but it’s nice and it looks cool Hugo is astonishing Do I have three seconds to show you Hugo? I do Okay Oops, that’s what I want to do All right Hugo again, the power of types, Hugo is a search engine for code that you’ve never seen the–just–let’s say I have a function, I need to go from maybe some value and the list of values and I want to end up with the list of values Is there a function that does that? Oh, yeah there is So, you can actually–or you can see like, what’s a better example? Like, I’ve got a–I’ve got a string I’m looking for something that’s like a, I don’t know You know, what manipulates two string, you know You can actually search by type signature and find all sorts of wonderful functions that you need It’s astonishing how quickly it is to find what you need And the search is not just what’s–the search is like all the packages and stuff, so Hugo is very wonderful and great It is worth noting that–I think it’s a very recently hash Haskell and freenode was the largest room, I see it has typically 6700 people on it It’s a very friendly community and it’s a really great place to get your questions answered anytime of day or night, just kind of fun Want to learn more? Go Haskell internally, we’ll get you a bunch of stuff including some of these links as well Haskell is actually used here at Goggle and if you select secret corners find out more there What else? Learn new Has–these are some great online tutorials and stuff and, we’re done, thanks I have two minutes for questions >> What does it look like when you write something [INDISTINCT] >> LENTCZNER: So, yes What does it look like when you write big table or some big giant server, and is it this pretty? The answer is, yeah Lots of it are, so one of the nice things about Haskell is it’s very easy to cleanly separate that parts of your code, it’s really good and [INDISTINCT] is modularity and reuses very, very high and so often is really easy to take the parts of your code that knarly in dealing with the, you know, with the network stack in dealing with, you know, the vagaries of–well, like [INDISTINCT] back in web servers and Haskell that do standard stuff talking on my sequel And it’s very, very easy to sort of incapsulate because you could do always nice [INDISTINCT] functions that deal with the IO stuff or deal with the database stuff You can stick that on the scion and have like your logic be nice–and your logic and your business logic, if you want to call that back in stuff really clearly separated out It’s also the case that, because of the high orderness and laziness often in libraries, we have to–because we don’t want the user to actually execute user code if it’s not

necessary, we all have to bubble control back out to the user Users of libraries are generally have to do the control operations Highlable control operations and Haskell you can–you can bury all that back down in your library so, the short answer is, yeah it’s a lot nicer In my experience writing the exact same server in, well big server library in C++, python and Haskell, the Haskell code was literally one-third the size I can give you pointers that code’s open source if you want to actually see the comparison of Haskell that’s one-third of the C++ size It’s about half the size of the python Did I say Haskell? That’s like, python Yes, there’s a question over here? >> Actually, I want to know which office has all the [INDISTINCT] >> LENTCZNER: Yeah, who’s the big office is that? >> Big or [INDISTINCT] >> LENTCZNER: Oh cool, wow Hi New Yorkers Great Anything else? >> [INDISTINCT] >> LENTCZNER: I can answer that question offline >> [INDISTINCT] build system, is the build system supported? >> LENTCZNER: Yes, it’s in the, yeah Yeah, out build systems had stuff in it Blaze has support for Haskell >> What kind of [INDISTINCT] >> LENTCZNER: Well, I don’t like to write client web front end code because I can’t get the damn Haskell to run in time The processor on the front end I would in an instant You know, in my mind Haskell has, of the last couple years finally traversed into the realm of like, yup It’s a good general purpose programming language enough functionality is to almost any kind of stuff that you need I don’t know, I’m too much of a sand to answer that question My answer is I do everything in Haskell if can All right I can stick around and we’re officially over and we can stop the recording, thank you And I’ll stick around if anyone wants to talk or go over or find a

"Toyota Gas Pedals: Is the Public At Risk?" Panel 2 Part 1

our second panel I would like to introduce our second panel testifying on this panel and mr. Keogh Toyota president CEO of Toyota Motor Corporation and mr. Inaba president and CEO of Toyota Motors North America gentlemen it is the committee’s long-standing policy that all witnesses are sworn in please stand and raise your right hand as I administer the oath do you solemnly swear to tell the truth the whole truth and nothing but the truth if so answer in the affirmative let the record reflect that the witnesses answered in the affirmative let me begin by first welcoming you and I really appreciate the fact that you have come to testify and that mr. Toyota that you actually volunteered to come and to testify that to want you to know we’re very impressed with that that shows your commitment and of course to safety as well and we want to appreciate the fact that you volunteer to come mr Nava we welcome you here as well and we’ve had conversations with you you know over the past few weeks and months so at this time we would ask you to testify actually we will give you additional time we generally give five minutes but you know being he is all the way from Japan we give him more time so mr. Toyoda yes you may begin is microphone thank you chairman towns I’m Akio Toyoda of total Motor Corporation at first like to state that I love cars as much as anyone and I love Toyota as much as anyone I’m here with my Toyota family of dealers from team members and friends I take that most pleasure in offering vehicle that our customers love and I know that Toyota’s 200,000 team members dealers and suppliers across America feel the same way however in the past few months our customers have started to feel uncertain about the safety of turtle vehicle and I take full responsibility for that today I will actually explain to the American people as well as our customers in the US and around the world how seriously Toyota takes the quality reax mr. mr. Toyota just pull the mic just a little closer to you thank you today I would like to explain to the American people as well as our customers in the US and around the world how seriously Toyota takes the quality and safety of each vehicle I would like to express my appreciation to chairman towns and ranking member Issa as well as the members of the House Oversight and Government Reform Committee for giving me this opportunity to express my thoughts today I would like to focus my comments on three topics Toyota’s basic philosophy regarding quality control the cause of the recalls and how we will manage quality control going for first I want to discuss the philosophy of total quality control I myself as well as Toyota I am not perfect at times we do find defects but in such situations we always stop strive to understand the problem and make changes to improve father in the name of the company its long-standing tradition and

pride we never run away from our problems or pretend we don’t notice them by making continuous improvements we aim to continue offering even better products for society that is the core barrel we have kept closes to our hearts since the founding days of the company at Toyota we believe the key to making quality product is to develop quality people each employee thinks about what he or she should do continuously making improvements and by doing so makes even better cars we have been actively engaged in developing people who share and can execute on this core value it has been over 50 years since we began selling in this great country and over 25 years since we started production here and in the process we have been able to share this core value with the 200 thousand people at Toyota operation dealers and suppliers in this country that is what I am most proud of second I would like to discuss what caused the recall issues we are facing now Toyota has for the past few years being expanding its business rapidly quite frankly I fear the pace of which we have grown may have been too quick I would like to point out here that Toyota’s priority has traditionally been the following first safety second quality third volume these priorities became confused and we are not able to stop think and make improvements as much as we are able to before and a basic stance to listen to customers voice to make better products has weakened somewhat we pursued growth over the speed at which we are able to develop our people and our organization and we should sincerely be mindful of that I will get that this has resulted in the safety issue described in the recalls we faced today and I am deeply sorry for any accident that Toyota drivers have experienced especially I would like to extend my condolences to the members of Saylor family for the accident in San Diego I would like to send my prayers again and I will do everything in my power to ensure that such a tragedy never happen again since last June when I look to office I have personally placed the highest priority on improving quality over quantity and I have shared that direction with our stakeholders as you well know I am the grandson of the founder and all the Toyota vehicles bear my name for me when the cars are damaged it is although I am as well I more than anyone wish for Toyotas cars to be safe and for our customers to feel safe when they use our vehicles under my leadership I would like to reaffirm a value of safety and quality the highest on our list of priorities which we have held to firmly from the time we are founded I will also strive to devise a system in which we can surely execute what we value sir I would like to discuss how we plan to manage quality control as we go for up to now any decision on conducting Rico’s have been made by the customer quality engineer division at automotive cooperation in Japan this division confirms whether there are technical problems and makes decisions on the necessity of Rico however reflecting on the issues today what we lacked was the customer perspective to make improvements on this we’ll make the following changes to the Rico decision-making process when Rico

decisions are made a step will be added in the process to ensure that management will make responsible decision from the perspective of customer safety first to do that we’ll devise a system in which customers boys around the world will reach our management in a timely manner and also a system in which each region will be able to make a decision as necessary father will form a quality advisory group compose a respected outside expert from North America and around the world to ensure that we do not make misguided decision finally we’ll invest heavily in quality in the u.s. through the establishment of an automobile center of quality excellence the introduction of new position product safety executive and the sharing or more information and responsibilities Windom within the company for product quality decisions including the effects and recalls even more importantly I will ensure the members of the management team actually drives a car and that they check for themselves where the problem lies as well as its severity I myself am a training test driver as a professional I am able to check a problem in a car and can understand how severe the safety concern is in a car I drove the vehicle in the accelerator pedal Rico as well as a Prius comparing the vehicles before and after the remedy is various environmental settings I believe that only by examining the problems on-site can make decisions from the customer perspectives one cannot rely on reports or data in the meeting room through the measures I have just discussed and with whatever results we obtain from the investigation we are conducting in cooperation with Nita I intend to further improve on the quality of Toyota vehicles and fulfill a principle of putting the customer first my name is on every car you have my personal commitment that Toyota will work vigorously and unceasingly to restore the trust of our customers thank you thank you very much mr. Toyoda mr Inaba general towns ranking member is eisah members of the committee thank you for inviting me to testify today my name is Yoshi Manabe and I’m the president and CEO of Toyota Motor North America and chairman and CEO of Toyota Motor Sales USA as you heard today from Toyota president Akio Toyoda and as the Subcommittee on Oversight and investigation heard yesterday from Jim Lance president of chief operating officer of the autumn of the cells USA Toyota is taking decisive steps to restore the trust of the tens of millions of Americans who purchase and drive our vehicles our hundred seventy two team members and leaders across North America are making extraordinary efforts to complete our current recalls as quickly and conveniently as possible we have rigorously tested our solutions and are confident that with these repairs Toyota vehicle will main among the surface on the road today we also going further by installing advanced brake override systems in all over new North American vehicles before the end of 2010 and in an expanded range of existing models as a customer confidence measure and taking comprehensive steps to ensure strict quality control and increase responsiveness to our customers and regulators in the future as you have heard Mr Toyota is leading a top-to-bottom review of our global quality control press processes and will seek input from independent safety

experts to ensure that our processes meet or exceed industry standards as head of third as North American operation I’ll be closely involved in this review working with a new chief quality officer for North America I also will take responsibility for ensuring that we improve our dialogue with US safety regulators and that we take prompt action on any issue we are to ensure the safety of American drivers in inviting me to testify today the committee asked me to address several issues with regard to our recent recalls let me summarize my answers here our recent Rico’s address five separate issues that we have identified with certain Toyota vehicles in total some 5.3 million vehicles across 14 models are affected by the by one or more of these recalls in United States the biggest rico’s are for solutions our engineer have developed with regard to two specific mechanical causes of unintended acceleration one involves all whether or innapropriate accessory floor mats that when loose or improperly fitted can entrap the accelerator pedal the other concerns axle pedals that can over time grow sticky with wear in rare instances the solutions we have developed for both these issues are effective and durable with respect to possible accelerator pedal entrapment by the floor mat Toyota recently designed a vehicle based change that directly address addresses the problem and announced the solution to the public in November 2009 as part of the safety campaign announced on September 29th 2009 owners of affected vehicles can in the meantime drive safely by ensuring that they use only properly secured appropriate floor mats with respect to Street as seeking accelerator pedal tirta announced a safety recall in the United States in January to address this issue the sticking condition does not occur suddenly and if it does the vehicle can be controlled with firm and steady application of the brakes we are confident that vehicles whose drivers are not experience any issues with their accelerator pedal are safe to drive and Toyota dealers are rapidly completing the repairs on our customers vehicles in both these cases tirta thoroughly and carefully evaluated the technical aspect of these issues however we now understand that we must think more for a customer first perspective rather than a technical perspective in investigating complaints and that we must communicate faster better and more effectively with our customers and our regulators a recent smaller voluntary recalls of certain 2010 prius and lexus HS hybrids for software update to a braking system certain 2000 camry cars to inspect the power steering hose and certain 2010 tacoma trucks to inspect the front drive shaft all illustrate this new approach chairman towns ranking member Issa and members of the committee i assure you that nothing matters more to toyota than the safety and reliability of the vehicles our customers drive we are committed not only to fixing vehicles on the road and ensuring they are safe but to making our new vehicles better and even more reliable through our redoubled focus on putting our customers first thank you thank you very much and let me thank both of you for your testimony let me begin by saying have you told Nitsa everything you know about sudden acceleration problems have you tone it it is to me in both I know what does

Medicaid ever I know Yoho embassy assess it that I did to you who need if I was to according to my understanding all my clothes according to my understanding yeah we fully share the information we have with the authorities our Washington office has been always in touch with Nitza and we are fully cooperating with Nitza in any information they require as Toyota disclosed all information about other potential safety defects with your vehicles to the regulators have you done that so no good tiding in dota 2 co2 economist de cicada most masterly yo holla harshly today tariqa was too much i do not know the specifics however as i mentioned earlier i do understand that all the information we have are shared with authorities let me ask this question today Attorney General Andrew Cuomo of New York announced an agreement with Toyota and this agreement provides that if a customer might be afraid to drive his or her car subject to a recall the dealer will pick up their cars fix them and return them to the customers now the customer will then be reimbursed for any taxi or rental car expenses that they might incur will you commit to doing this for customers nationwide I repeat if you want me to repeat it I won’t be the language being translated chairman let me address that questions because I know local here be delighted yes I heard number of instances that when this recall news came out I think number of customers who were very afraid and our leaders are fully behind it and leaders took care of a customers very well in many instances did ask when to pick up their cars and then also gave them a turtle rent-a-car for for the time that they’re not able to do and this RICO process is really going on I think there is a good understanding now on the part of the customers that the cars are being fixed well and they are confident about that I guess my question is are you just doing this in New York or is this something that you’re gonna do no this is they have won all of all over the world I mean the nation nationwide yes okay so I just want to make certain you know we have that understanding because I understand it’s going on in New York and the last and the last question I have for you is that mr. Toyoda you have offered a brake override feature for some recalled vehicles why haven’t you offer that feature for all toyota vehicles I know chato said to me research data document I know you’re kissing kisaku no gain to neva and okhta get there and you’re to audit about using your mod tournament allow me to explain the situation a little bit you pull my factors contributing to the unexpected acceleration I believe can be roughly classified into four categories so to that very dense rotor no ego Neru are this moisture to you hurried skycutter toka I know it’s kind of much lighter by you you’re not talkin about mini Ramos samba maybe I had a clue Monaco saw you on a Monday it’s so stay you’re too many booty no cause ornament I know now you got your to the art oh honey

DeCoster Yuma’s first problem with electronic throttle system secondly the way in which a car is used or misuse of the car and thirdly the structural aspect of the vehicle and fourthly the structural aspect of the parts used in the vehicle so these I understand are four four major factors contributing to an expected acceleration so dissonance is dr. Marashi Lomo scotia demo yogurt Oh nan deo pio Quixote she’s rude abandoned IT no concept they said chaos story muscle the mattis Arriba pyon-kichi Sharon you chose a demo meet certain atossa demo chromatic asado ah miss Carter or MSA no day vacation Oh Mon devanne I told you Clooney toxeus taurima’s and of that the electronic throttle control system is designed based upon the concept of safety first and therefore whenever there is any abnormality or anomaly there in that system the fuel supply to the system is cut off and even under a very vigorous testing conducted internally or by Nitza no problem and malfunction was identified and therefore I’m absolutely confident that there is no problem with the design of the e.t.c system Saturday I know me – no no no or do you they custom akamai maangchi Yokosuka lobster doors ricotta you can walk Motel ug so juice is master surrani and Jo Kazuto many hmm sorry master vos load suka suka Tony Kimi master um however placing emphasis upon the fact that customers do have concern as to the possibility of unexpected acceleration which may result from the remaining three reasons in order to offer extra measure of competence as a chairman has just mentioned we decided to add brake override system yeah miss again a yes or no I think that’s I’m trying to get to yes and no because I mean know that I know judo code a Symbian uh-oh hang la comarca he said to me about the keema Sangha okay extra money unleashed an optimal tammini he’s okay me congratulate all uses your state made master the Senate’s happiest are torn of Karuma okok Samaha and she still notated a cool a kuma any boso chakra at the unique IO story much I yield to congressman i sir but I’m trying to find out that a yes or no let me address in a different perspective we are just for the record we are putting break overs right system on all the models for North America coming after dying by the end of this year and now probably your question is retro actively what about the existing models we have already announced yeah let’s have our own and then yes 300 and then is those are already included in as an additional measure when we recalls and now we have recently announced Tacoma which has a very high complaint late and then added to a Venza and Sequoia this covers probably about my recollection is correct 72% of the recall population and any older one technically it is not possible and therefore we think we have covered but we do not you know stop it there we carefully monitor the situation by the next year with this new model with POS coming in with this retroactive actions I think we will quite sure will be quite sure that it will be very much lower than the industry average I was most narrow I yield to the gentleman from California Thank You mr. chairman and the Chairman has proven that he can ask a question so complex as to even be difficult for people of your great knowledge and it doesn’t surprise me let me ask in a different way the same question so that we all on the dais have clarity and and mr. Nava I will put this one to you in order isn’t it true in order to use a break or events break override system like this your cars depend on electronic systems they depend on microprocessors and they depend on

engine control modules that could actually simultaneously reduce fuel when sensing through the data bus that the brake has been pushed isn’t that correct you are much better if you could Tuffy done I am i I think I’ve I believe so so I think for all of us here who are concerned of course about failsafe and acceleration caused by electronics I think I’m asking you isn’t it fair to say that although electronics could at times be a problem and you have your people have not eliminated that the solution is in fact electronics in this case and that’s what’s going to give the higher level of safety well I can only say that this is an added measure of to a customer confidence and of course it I do not mean to say is solve all the problems yes Helen I understand that in the earlier testimony there were some discrepancies perhaps between how secretary LaHood would explain certain technical occurrences and how you would is that correct that you would like to be able to correct the record on some areas of secretary LaHood’s testimony I’m not quite understand what specific comments are you referring to I guess I would welcome that if you would like to we would offer you the opportunity to submit for the record any technical Corrections in what secretary LaHood’s questions and answers were during the earlier testimony well we’ll be glad to sort of full record thank thank you and then I would ask that we put up the unattended acceleration exhibit that I showed earlier and I put this up for both of you because in your current advertisement on TV you said something which I thought was extremely profound in a high goal you said that good companies fix their mistakes and great companies learned from them in the case of the unattended acceleration in 2007 there was a problem in the United States for which the floor mats were changed there was a problem in Japan with a different model but similar in floor pedal in which the Toyota pedal itself was shortened and now in the case of all these models there is an electronic upgrade additionally to prevent an accident like we had in 2009 would that be the outcome today the outcome of the recall including the electronics upgrade to advanced brake override is that the type of learn from your mistake that we can expect in the future on any problem that develops Nakano you say Nantucket or Disney and a shuttle rocket cannon Masuka no panting any Java so Emond I gotta talking you at this name I know since in a tie today not on dicto you coat oh god I’m s I do not know this situation you referred to about 2007 but generally speaking whenever a problem occurs Toyota addresses those problems in the most sincere manner and attitude um yes please I came to know this Japan’s problem to be shameful only in a previous hearing you mention if that was a very first time that I ever heard and therefore let me look into that if it is correct or not but at the same time I think we’re the company that we learn great lessons from me from this instance and we try to do more so I think this is you know we are committed that we try to remain as great company not at just good company so I think we have a full commitment over present and then he has just said and we have many many measures already taking place I don’t want to go no I appreciate that and I have a copy of documents that you have provided to us concerning the the Toyota blade which is the Japanese only vehicle and we’ll deliver that to you for your further update my second and only other question secretary LaHood talked about wanting to but not necessarily having the transparency of worldwide sales and problems will you agree mr. Toyota to be the company that leads by providing the

u.s. Nitsa with full transparency of your worldwide observations and help set a model for all the major companies here in the US I know so no I know Cosmo enticed Eva I know yesterday I – – I know isn’t the code or week or month like I could see no it mastaba toboni just take can see it’s us take our cheek you know hora in in steel cut to unique and a tamale master so you’re in ecology must stop oh so now you’re a chick you know Oh Jo hole you re a time reading every time I know oh hi say well Emma so tonight’s very much the global quality coming in Chi you know what I co-chaired a yacht okay she died ko saing has no Sanjana keynote EST remis sake mother need a coconut America Movil a catchy keynote I say tonight a co human daily so Menkaure so stay open e curriculum they could tell you tell you what about diamonds to that question I clearly say yes in the past case is a recall or problem solution in making decisions we based our decision on two issues the technical our consideration and also whether or not the regulations and statutes of different parts of the world are complied with and in that sense going forward we intend to exchange and share information more timely throughout the world and we are now setting up the system for that purpose and for that specific purpose we are going to establish the Special Committee on global quality which I personally will be heading and the very first meeting of that will be held on March the 30th and for that purpose we are now setting up the structure where the United States and other parts of the world will be represented in the meeting of that special committee of Global Committee for global quality and we are now introducing this system so that we really face up to this problem openly and transparently thank you and thank you as chairman for your indulgence I recognize the gentleman from Pennsylvania mr. Kanjorski thank you very much mr. chairman gentlemen welcome the United States I have to compliment you mr. Toyoda for deciding to come here and testify actually it’s quite a unique experience in terms you’ll be able to brag about the fact that you withstood the interrogation of a congressional committee and that’s a a Badge of Courage in the United States but if you’d heard any of the examiners questions of the secretary and I think now yourselves we’re a little disturbed by some things that I am too a long very sympathetic to the fact that we want to encourage international business we want to certainly open our markets to your manufacturing from Japan or your ownership of manufacturing facilities in the United States but I thought I heard this morning the secretary say that you had a problem in Japan that was detected in oh seven and then subsequently the same problem was detected in Europe but there was no communication of that problem or the prospect of that problem being contained an American manufacturer automobiles or your products being sold in the American market if that impression that I have is true that’s very troubling to me III would like you as best you can and I understand the difference in language to explain whether or not you’re giving the American automobile purchaser your customer and the American market the same level of attention that you give to the Japanese market or the European market and if you didn’t in the past what are you going to do to make sure that difference doesn’t occur in the future we can’t afford to have a lie a leg of a year two years of finding out something that is defective in an automobile I suspect the stock price is reflecting

that to you that that can be very costly I hope it doesn’t destroy a great deal of the equity of your company and I hope you can move on and move beyond this question but I want I want to hear in my own mind that there hasn’t been this difference between the home market and the American market the home market in the European market the home market and European market and the ignoring of the American market the American customers if I may I know America Naumann are at the Innova Dakshina totila second okay Dominique I know hon tony honest ii sabisu una Jacinto they overnighted Yahoo knee amok taurima’s Sarah a congressman was taking a Tory a mama day no car no speed Oh God – oh so no Oceano CH oh no speed oniy two Toads Takata a Toyota Corolla EST remis so stay – you got a second ain’t you got any it’s a journey not acara Yabba fq Chacho whoa or Kaku a cheeky no Tonto Oh motorboating Yuri Yuri a cheeky no Jahoda Innova heidi hace una carta Jeanie Tracy taurima’s sorry my mistake a con Chi no hints term on tiny economist Eva Domino grant oka yes oh no oh cool Cuisinart my no okok so Monica whoa Yuri timely knee hon Shivani story onna yet I say whoa Oh tonight we must we provide the same services with the same degree of care to the customers not only in the United States but customers world over however as congressman has just pointed out our speed of expansion outpaced our development and training of people working for us and right now I’m fully aware of that in July last year I became president and since then I appointed executive vice president’s responsible for each regions of the world and by doing so we established a system where information of different regions can come into the head office can be captured in a more timely manner and on top of that with specifically about this quality issue that we are faced with at the moment we respect the concerns of the customers or customers voices before they are expressed in the terms of in terms of a complaints we are going to capture those so that information be conveyed to the head office in a timely manner and we are putting in place a system to enable us to do that let me address if I may specific issues of defect information sharing which was also ranking members Issa I says they no question I think we should have done a better job in sharing those cross regional defective information what have you determined it was the cause that you did what it was it is culture is a psychology is it something that happened in the communications breakdown just seems absolutely when you go into a certain database you can find it but it is not I must say I don’t know very well but positively shared now going forward what we are going to do is one of the things I’d like to so report to you that we are making now one American we call product safety executive is a part of recall decision-making as part of the global committee headed by one Japanese one American and maybe later added from other regions like Europe and China and then in that all the information are shared there so that we can evaluate and know what’s going on and other part of the world in more transparent way so this is the change that we are making you know now let me ask you just a side question for me does Japan have a torch system similar to the United States where a suit can be brought for damages

by these injuries and loss of life I believe we do we have a little bit of a content sometime going on in the United States we call it tort reform totally and and it’s an argument that my friends on the other side very often used in the medical argument feel that if you had tort reform and you just allow some people to die or get severely injured without recovery that would correct things I think you’re making the best argument in the world I’ve ever heard of why we should have the present tort system and I hope you recognize what kind of payment for your the injuries and the damages suffered by innocent American citizens who like myself have have grown up in an atmosphere that we had a great deal of faith in something that was stamped made in Japan that it was of the highest reliability and you you injured that thought process in the American public and you will be called upon under our system to pay compensation for that I now yield to the gentleman from Indiana on that note let me just preface my remarks by saying we really need tort reform we should just forgive these companies and let them kill our forever mind we just have a difference of opinion first of all let me thank you both for being here I think it’s very very good that you came it shows real concern on the part of Toyota and I also want to compliment Toyota dealers around the country I went to a couple of Toyota dealers this last week to take a look at what’s going on and their working day and night to correct these mistakes and so to your Toyota dealers I want to say thank you for working so hard to correct these problems now after having said that first of all I have a case here that took place in 1997 I don’t want to go into all the details on it but a woman was injured in an automobile accident involving a Toyota she lost both legs and I would like for you to review that and if you wouldn’t mind giving me a response would you do that for me yes I’ll have my staff give this to you so that we can talk about that the second thing I want to do is I don’t understand this look I went to the Toyota dealer and this this is the floor pedal mechanism that’s used in Japan and in some cars here in America this is one that’s manufactured by CTS here in the United States and it is yes and they have done a good job on this this pedal here has been involved in the accident cybo leave that have caused the fatalities this one here there’s been sticking and they’ve been putting a shim in there little metal piece in to correct that and my question is why the difference these are going in the same model car and why do why do they have different specifications because this one here has caused the problems that’s created some deaths and this one here’s had some sticking problems which have been created or corrected but it’s different and so when you’re manufacturing the same car why is it that they don’t meet the same exact specification it seems to me that would be easier to correct than having one that’s made one way and one that’s made another way I know Karuma but it’s near journey LaMontagne Carson Monty no booing Cara Narita taurima’s the Sunoco mono say Kayla serious octo Kohaku stay yeah teratomas boracay Tamara teratomas as a congressman already knows a core consists of some 20,000 to 30,000 parts and I would like you to understand 20,000 to 30,000 parts and I would like you to first of all know know that we work together with the suppliers in designing those parts mr. Abedini Abdullah if I might if I might interrupt I understand that you work with the suppliers but the designs are different this one here has a different mechanism in the bottom than this one and I’m just wondering why if it’s the same model car there is a difference yes Cara Mohini Ottawa SiriusXM nah it’s a Coast a toyota gazoo shown in suit oh you ho ho toh OH Toyota no naka no engineer da si kissing – you know ho ho ho Thomas a con queso no Peter in economist IVA areo Hotah mecir 1600 SE cayó Watterson Omaha sean is Ruto yokatta Joe Torre’s are steeped Erasmus timoni

Nahant American e co SUNY at I salute you tuna serious action Nisha burrito Yoko today if Tata no se que se que Sarita a paella detect up to you when you got a great director – – some parts are designed by our suppliers with Toyota approving that and in other cases a turtle’s own engineers design those parts so there are two approaches used in the case of this specific pedal the suppliers designed the pedal and Toyota proved that and in both cases we were able to identify two excellent suppliers whose parts were worthy of us to use in the United States in Japan and therefore those two parts designed by our suppliers were used in this pedal Cerrito thermosolar serious accent Romani aho staccato you know can- avoidance so amid Eva study no serious action Dakini Heihachi under Danica una Jackie no Hadassah behemoth kotero rockin omega2 yabba fukusa hatsue Adrian AMA donut holiday oka narrator koto mo or acai Tamara tight you could – and on top of that it is a philosophy to grow together with our suppliers and in that sense rather than placing order with one single suppliers we a source the same parts from multiple suppliers that is to say when there are suppliers that can supply parts that perform the same function we do that and this is another point I would appreciate your understanding no if I might real quickly just say I understand the winners of a problem of this magnitude where people have been killed because of a part and there’s another part that didn’t result in fatalities but there was a sticking it seems to me it would be easier to correct the problem if there was more consistency in the two parts okay thank you very much and gentleman’s time is expired I now recognize the gentleman from Maryland congressman Cummings thank you very much mr Chairman I want to thank both of you for being with us this afternoon and to mr Toyoda I have read your testimony and I’ve listened to it and I can appreciate you saying and meaning that you’re sorry the problem is that it’s one thing to say you’re sorry it’s another thing when it seems as if time after time there are announcements that problems are being addressed and over and over again they seem like they’re not being addressed 2007 fatal crash involving a camera because allegedly of formats a person was killed and we can’t get away from these facts September 2007 you then 55,000 call cars are recalled and I know this was before your presidency August 2009 California fatal crash four people were killed Seiler family September 2009 4.2 million cars recalled and we could go on and on and then just yesterday mr. James Lenz the third said something that was very interesting in basically what he said was that even with the sticky pedal and floor mat problem that there may be this may not account for all of the problems so and he implied that maybe this were some electric funny problems taking place the question becomes at what point do and I know also you want to regain the trust of your customer base but that trust is hard to establish a reassembling when they see over and over again these kinds of situations and they say well why should we believe that things are going to get

better and I know that they have been members on this dais to have said they’ve had some good things too Toyota’s done but I’ve got people in my district who by the way are saying they call and they have to wait to get their cars repaired but at the same time they got to take they have to take the children to the babysitter they’ve got to go and do their marketing yeah I mean this is just practical things that are happening so I’m just asking you how do you say to your customers the people who take their hard-earned dollars in a tough economic time and spend them on a Toyota vehicle how do you say to them that we can trust you now when and I say this most respectfully when it seems as if there is no end to the series of promises and then promises that seem to come short of reaching the goal of safety no more tonight you must know I sincerely regret that some people actually encountered accidents in Toyota vehicles there are no cicada most of us together more I know Dan sister Nova Scotia demo is over at Oh nan deo pio pio taste and then die – no concept the mother said chaos taurima’s as I mentioned earlier with respect to the electronic throttle control system the system itself has been designed based upon the philosophy of safety first and therefore whenever any abnormality or anomaly is detected fuel supply is instantly cut off discussion Nevada again g2g cocktail rocket because I must know that what is the mall or today Guinea in any way a demo Oh sigh against Rianna Gigi no moto you don’t sigh against testable okinawa de texto you must leave mama day – an idea technicality among diver was i’ma send this Cara secured Oh Cara the instrument denied you honey Mosquera Terranova I know you don’t not testable organ chicken but today yatta agains I know to follow Monday night you got almost another code Imus that notwithstanding accidents actually happened and therefore I instructed that every effort be made thoroughly to reproduce and duplicate the accidents and up until yesterday those big duplication tests have been repeated and conducted however no malfunction or problems were identified based upon the tests conducted internally within Toyota and therefore based upon such thorough examination and testing conducted within Toyota I have been saying that I have no question with respect to the integrity of our ATC system the Congo Tokioka Tomo akio aksana Vera s daija process Detrick mostella event today today coda oh it ain’t them SSST hoc in matazano Qatar Doha don’t enjoy Hokkaido stricto yo katoa security Guinea estimate transparency Oh Eureka komiteh the keone kaity state you could not do much and therefore in cooperation with the authorities concerned we already announced that we are going to thoroughly examine and investigate the outcome and data recorded in event data recorder and the findings will be made public and disclosed in a prompt and timely manner and changes will be made in a very transparent manner so that that be assured going forward Thank You mr. chairman thank you very much and now you five minutes to the gentleman from Florida mr. mica first of all mr chairman I’d like to request unanimous consent to include in the record the specific information on the administration’s proposed 2011 budget requests which cut National Highway Transportation Safety Administration’s vehicle research program and also

further reduce the amount for vehicle safety research in the budget I didn’t have this further if that could be inserted also in the budget I mean in the the budget information in the record appropriate to my previous questioning of the secretary without objection I will review it and then no and we will but I reserve the right to reject well this again okay and I’ll proceed this is indeed a very embarrassing day for the United States National Highway Safety transportation administration it’s equally a very embarrassing day for Toyota to have the son of the founder of Toyota here as a chief officer to come before the United States Congress I’m embarrassed for you sir I’m embarrassed for my dealers that I’ve talked to I’m embarrassed for thousands of people hardworking Americans who work in I guess over ten plants across the United States I thought actually I thought we were doing pretty good because that Toyota was taking quite a hit and I’ll put in the record later on your safety record and some of the things you’ve done positively information that that I got until I was shaving the other day and heard the news of the of the memo that was a that was prepared by a gentleman who I didn’t even know his name bring over a copy of the July 6 Inaba memo I hadn’t read this actually the details of it and today mr. Inaba this is one of the most embarrassing documents I’ve ever seen you’re in your preparation of this you embarrassed all the people I represent those hard-working people across this country this is absolutely appalling sir that you would identify and I know you were on the job only a few days but key safety issues and identify as one of them on page 14 of the document you prepared and you identified the the problem of of the the safety issue and with with regard to this these these pedals then on page 16 wins for Toyota safety group how could you possibly put in writing this and list as wins for Toyota it’s particularly under the defects entry and negotiated equipment called recall on Camry ESS a saved a hundred million with no defect foul I think you’ve done a great injustice sir in in this eye I don’t know if it was it’s not a rookie mistake obviously you’ve been with the company but to prepare this document to undermine the good working people and the reputation Toya has an outstanding reputation and actually has had a great safety record but this decree discredits everyone how would you respond sir yes sir first of all let me get the facts straight this is the only few days after my arrival to the company and then had you been with Toyota before yes I long 40 years in total sir but this is after two years of officers away from Toyota I also first became the president of Toyota Motor North America and then I visited one of the few days to Washington office I had no idea what the company was and that’s why our staff wanted to give me a a orientation material I’m stunned to find your name on the front page address to me I did not know that till today okay and the point is that you know I was in the middle of orient or in station tour yes I mean I mean I didn’t made it very clear my name is on it it is presented to me not me made it but that’s all I was aware of this this is present again this is information you had in your

company prepared if if in the future any company prepared a document like this and presented it to anyone in the company to me it would be to me it would be one of the most interest things you could do to anyone’s reputation I know it says on the side confidential and all of that but do you realize the people that have been let down me the the people in my district who go to work every day in those two Toyota operations that the sales and already reputation has been severely damaged by by what’s been done here I honestly with my honesty I do not recall the meeting in any depth but at the same time now I see that I think I must say to you that it is so inconsistent with a guiding principle of Toyota and my feeding is and therefore it’s it’s just to me it’s unbelievable yes finally met you the same way O’Day you’re in charge of the company and have that response that’s a responsibility can you assure the committee that this is not the approach this will not be the approach of Toyota now or in the future because now I’m getting more familiar I’m a prisoner of that company I am going to rectify that if there’s a horn of it the gentleman’s time is expired and now let me just make announcement before we yet move any further there’s a vote on the floor and it’s actually on three votes and we plan to continue and of course the gentlewoman from Washington DC will assume the chair so but I also want to let these number fraud I know that his time has long expired yes sir no sorry I know what you know how could story masane this garage to comment on this guy I know Al Attar ashishot yoga challenge talk to you soon on IO war presentations through to you know uh Goku Goku no contribution among SUNY a O’Connor a tell to you who need a moment ah yes oh no Serena not coming here Ted a key event I know oh so no Oman Oh God so you rocket Illuminati overnight you who need a panda on Davos I must have a almost Aramis I do not know about that specific document you referred to and I do not know the comment however generally speaking when a new person takes office as president it is customarily done in any division to make presentations on various contents of substances going on in the company however generally speaking the substance and contents of such documents does not affect the entire company in a way to cause drifting of the company itself the gentleman from Ohio mr. percentage has five minutes you can or you can if you only have a few minutes left I’m at I’m calling on people who are left well I’m gonna go to mr. Connolly then since it goes on this side we are mr. Connolly you have five minutes thank you madam chairman mr. Toyoda welcome to the committee when did it first come to your attention there was a problem with acceleration of your vehicles anymore I was appointed president in July and there is a major difference between the

sort of information I had received prior to assuming the position of president and the information I get to receive after becoming president and therefore there may be some difference between the information that company may have had as a company and the information I personally had as president however I will clearly state whatever I know and even in those cases where I do not know or I do not have any knowledge of I will look into the matter and supply the report to you disco you go sumo Natasha master ah Hakuna Matata it you so responding specifically to your question of when I would say at some time at or the end of last year toward the end of 2009 that is correct okay were you aware the fact that there had been complaints by consumers long prior to that time – 30 mas this is not only not of my knee so is your whole heist after you talk or shows you key right now I’m a world that how ever did I have that sort of information before I became president I didn’t have that sort of information with the same degree of accuracy that I do now but you had some awareness we just heard from secretary LaHood prior to your testimony and he talked about the fact that nitsa sent a team to Tokyo to meet with the top leadership of Toyota to bring to their attention as forcefully as they could the fact that there was a problem and that it needed to be attended to that meeting was prior to your testimony just now that you only learned about this problem in December of last year were you not aware of the fact that Nitza had sent a team to Tokyo headquarters Konoe Kenny can’t see my still are rubbish combos Oh God he’s currently below no I don’t wanna that needs a no homo you katoa don’t mess it up so Don I yield so no GP neat I saw what I saw – no on that specific point that was a matter handled by the division in charge of quality assurance and certain person in that division I understand received the visit from Nitza representatives and had discussion with them I know that however I do not know the specific content of the discussion nor the timing of that meeting well there seems to be some discrepancy again we’re trying to get at what did we know and when did we know it to sort of gauge the companies the quality of the company’s response to the serious problem on behalf of its customers and obviously we have an interest as American congressmen and women to protect our constituents who are your customers and we know that the company certainly was made aware by US officials through nitsa who flew to Tokyo for this express purpose and you’re telling us in your testimony you didn’t know about it you were aware of that trip and that meeting but you weren’t aware of the fact that there was a serious acceleration problem with your vehicles until just a few months ago December of 2009 is that correct because if it is correct given your position in the company and your family’s association with a company that would constitute extraordinary compartmentalization and nonito meeting

laptop so now you need to go study myself I personally know that there was a meeting with mr. representatives but I do not know the content of that meeting okay I’m just gonna ask one more question and that’s of mr. Inaba I’m looking at this confidential document that was made available to the committee yes my colleague was just referring to and and on one of the pages it has a you know just a series of tics like this and the bottom tick in your briefing I understand what you said it says secured safety rulemaking favorable to Toyota what and I’m gonna run out of time but could you at least ask answer what was your understanding of what that meant as I said I don’t recall meeting in any depth and I had no idea about this Riko processor back then therefore I have very little knowledge about it and funny enough that I only recall quiet cars in that whole list of that you know of course now I made aware of this you know that was you know a restriction of that but I don’t recall I am an chairman I know my time is up but I document is dated July 6 of 2009 gentleman’s time has expired mr. Davis thank you madam chair and I’d like to thank you and also a ranking member I so members of committee for the allowing me to from my position on the Ways and Means Committee on this oversight hearing on Toyota’s recalls I had the honor of representing Toyota’s North American headquarters in Erlanger Kentucky and wanted to voice some perspective from from our region a Toyota directly employs more than a hundred and seventy two thousand in plants and dealerships in the United States and it’s Toyota has an integral part in our economy in Kentucky and investment in the United States of America they maintained operations at a world-class level of quality in the Commonwealth for nearly 25 years the Georgetown facility now manufactures engines in addition to automobiles all part of a 5.4 billion dollar investment in our state Toyota has been an exceptional corporate citizen in Kentucky they’ve given more than 37 million dollars to local charitable groups with missions ranging from education to social services and not only his Toyota’s supported local charitable needs but Toyota has also been one of the Commonwealth’s strongest job creators Toyota North American headquarters in Erlanger Kentucky in the Hebron spart Center supplies distributors across the continent from my hometown of Hebron Kentucky in all more than eight thousand Kentuckians work directly for Toyota and almost 1,500 are in Kentucky’s fourth congressional district additionally ninety Toyota’s suppliers are located in Kentucky creating more than 10,000 additional jobs Toyota’s decades-long reputation for quality safety and service is based on their high standards of quality and innovation and based on their corporate ethic of discipline honor and humility they’ve had a positive and transformational effect on virtually every aspect of American manufacturing and I could speak to this as one of the few manufacturing professionals who serves in the Congress Toyota is as Congress conducts these hearings related to Toyota’s recalled we need to keep in mind Toyota’s willingness to do something unusual in American business politics in the Congress and has to actually take responsibility and ownership for the problem and continue their long-standing commitment to quality and more importantly for the well-being of their customers careless words and unfounded allegations by those who may have other agendas can do irreparable harm to job creation in Kentucky and in the United States at a time when quality jobs are in short supply and unemployed in Kentucky in the Ohio Valley remains above 10% the jobs created by Toyota are more important than ever echoing the concerns voiced by Kentucky governor steve Beshear and other governors across the United States and a recent letter to Congress I urge the members of this committee and my other colleagues to be thorough in their investigations of these issues and to arrive at conclusions based on evidence that is uncovered rather than circumstantial speculation or sensationalism let’s focus on the facts rather than giving way to the temptation to engage in political theater Congress must exercise appropriate oversight in determining if National Highway Transportation Security Administration or Safety Administration is able to effectively identify and comprehensively investigate automobile safety facing issues facing Americans and moreover America needs clear and consistent automotive safety standards apply to all manufacturers in this country not simply one to ensure the safety of the entire American public appreciate your willingness to come and participate in this today and the contribution of your business to our country’s economic strength and wealth

and with that madam chair I thank you and yield back thank you for your comment the gentleman’s time

CppCon 2018: Adi Shavit “C++ Cryptozoology – A Compendium of Cryptic Characters :: #2”

– I’m happy to be here Thank you for joining me I hope you’re brave enough We’re gonna take a fun trip into the crypt of C++ We’re gonna see some extremely esoteric pieces of information When I give this stuff, I generally like to guarantee that most people, that everybody’s gonna learn something With this crowd, I’d settle for a large subset So, by day, I’m computer vision and AI researcher and developer By night, I give a guided tour into the dungeons of C++ So, I hope you’re brave enough to join me Otherwise, you’re free to seek out some of the other talks here C++ has some extremely colorful terminology, which I’ve been collecting over the last couple of years Although some of these are extremely rare, and very strange, I think there’s a lesson to be learned for most of them This is free participation, so feel free to shout out comments Most of you know more than I do about some of these things, because they’re so esoteric I think you know they’re more or less sorted from A to Z So, we’ll start with A Right, so abominable function types An abominable function type is a type produced by writing a function followed by a cv-ref qualifier So, we have a nice example here using abominable, the abominable is just the name void Void to const volatile ref ref So, this looks like a function declaration, but in fact it looks like a function type, but it’s not a reference It’s not const and it’s not volatile There is in fact no way to accept a function in valid C++ So, how come we have these, this type of declaration? I know some people are actually actively trying to get rid of this strange part of the type system So, I’ll show you how this is actually used Abominable function types are used to forward the clear method prototypes Let’s say I’m the very enterprising rectangle developer, and I have this fabulous truck, but it really pains me to duplicate the signatures of these six methods, right, top, left, bottom, right, width, and height So, what I’m gonna do I’m gonna be extremely clever, and I’m going to code the int property is going to be an abominable function It’s a function that takes no arguments It’s turns an integer, and is of course constant And, we’re done So, and then we just define this function, the method declaration, of these six methods Of course, the implementation will be the implementation So, I’m just showing you how to use it, but don’t say I told you to Don’t use it If you see somebody do that, in code, you kick their butt, right So, this should not pass code If you have any questions, feel free to barge in Right, so COWs Copy on Write This was very, very popular, and it’s still very popular actually for resource management in various operating system components like virtual memory, file systems, databases Basically, you have an object, copies of objects, which share the internal state until one of the copies is, somebody tries to modify it Then a copy is made So, in 1999, I found this quote for somebody called HS in the C Users Journal, 1999 It said, “To my knowledge, all of the most popular “implementations of basic string on Windows “and other platforms is COW.” So, we see COWs, just like in Switzerland, used to be very popular However, unlike Switzerland, they’re now forbidden by the C++ standard The reason is that string needs to give, whenever you need, for example, to get an iterator, pointer, or reference like a bracket operator, you need, a COW would invalidate the iterator So, they were actually forbidden But, it’s good to know, and it is still a popular idiom in knocking the standard and not for string, but it is, you might come across it in various other cases It’s also related, like many COW products, it’s related to flies and the fly weight Yeah, it has a currency Okay, Duck Typing I’m sure most of you have come across this term It talks about application of the Duck Test The Duck Test is a form of abductive reasoning I have to rewrite that term Basically, it says if it looks like a duck, swims like a duck, and quacks like a duck, then it probably is a duck It originates classically from dynamically typed languages

where languages like JavaScript, or probably older languages as well, would determine the type of the class and the object only at run time, when actually at the point of trying to use, or access a member or the method Of course C++ is tactically typed, and therefore it doesn’t require a run time Duck Typing However, templates, at least until C++ 20, are statically, they are static Duck Typing inside templates So, whenever we get some kind of template parameter T, a type that we don’t know when we’re actually writing the template The only time inside the compilation where we’re checking the type of T is the extension point This is one of the reasons for getting a horrible template message One of the main motivations for concept, or I won’t say main, one of the motivations for concept is exactly to allow us to have template errors happen at the point of specification instead of point of usage So, we’re trying to get rid of ducks, Duck Typing inside C++ Now, I was trying to, so you know how they say that C++ is two incomplete languages It has, or more like two languages, or maybe five internal, two incomplete languages You know, the name programmer might say sure C++ is implemented in well, C++ right Yeah, well, apparently, like some broomsticks, C++ is quite magical A few months ago, I tweeted this rather naive tweet How many examples can you name of magical C++? It took a couple of minutes, and then the tweet storm that ensued that included like half of the C++ CPPCon speakers, past and present speakers, including many who are sitting here, with showing me what a can of worms I’ve opened So, I’d like to, some of you are quoted here The others just for lack of space, cause there were quite a few others Just to name a few, initialization lists, std::launder, most of atomic, even vector and complex types, most of type traits, typing for address, and built in functions, and of course, main itself is quite magical This is, but wait, there’s more because the compiler now generates for us So, we have integer sequences We have range forward loops We have landers We have space ship operator Yeah, maybe I should’ve put this under P for Pandora’s Box (audience laughs) Okay, so I really love this one Maximal Munch This beast actually raises its ugly head in many other languages This is a common parsing idiom Well, the standard says when the lexical analyzer takes as many characters as possible to form a valid token Otherwise, the next processing token is the longest sequence of characters that is constitute a preprocessing token, even if that would cause further lexical analysis to fail What does that mean? It means that if we have this expression like X++Y, which could be parsed as X plus positive Y, it is actually parsed as a post incrementing X, and then just the Y with no operator, which fits In fact, this is the culprit for most, if any of you remember that C++ used to have, used to require when we had two template types inside the angled bracket, we used to have to keep the space there Otherwise it would try looking for the output, like the right shift operator So, that’s one of the fixes that went in, and there are actually many other different examples where Maximal Munch creates very, very vexing parses Yeah, like there was a Stack Overflow question why doesn’t A+++++B work? I think Shafik, which I did see, yes, there he is I think he gave a very nice answer for that Okay, right, okay, so this is like very, very esoteric I’m wondering who’s seen this before Owlie eyes, anyone, anyone? Okay, okay, I came across this when I actually needed it So, that’s how come I know it I came across this So, in old versions of Microsoft Visual C, it used something like while zero, with a constant expression, you would get a warning, warning C4127,

conditional expression is constant One of the recommended solutions was to use the com operator and another zero, just to make the condition false, and then you won’t get that warning We don’t like warnings The mine usage was actually when you define MACROs, or needed some scope, and people used to recommend using Owlie Eyes So, apparently from Visual Studio 2015, they actually removed this warning for a constant like zero So, it actually, you won’t actually get it, although if I write while 42, we still get the warning So, the intent behind the warning is clear, but I guess somebody decided that while zero is frequently used enough and it makes sense for not worrying about it So, who’s seen it before, yeah? Couple of people So, this is a hoot (audience laughs) Sorry, I had to, it said here in my notes I can’t think Okay, Phantom Types You know, like many, many good super heroes, Phantom Types make types stronger Basically, we can have a template class that takes a template parameter, a type parameter, that is not actually used inside the template body Now, it might seem strange, and why would you wanna do that except for hey, I know how to use templates It is actually used a very common medium, used as a type for different type differentiations between otherwise identical types So, I have an example, and it’s actually taken from Ben’s talk last year at CPPCon So, let’s say we have formed data as a template, taking type named T, and T is our phantom type As you can see, it doesn’t actually appear anywhere inside the template So, we have these explicit instruction from a string and a string member, but T is actually, is unreferenced anywhere However, whenever I instantiate form data with any other tact type T, I’m getting totally separate types Therefore, in the example, we can have function get form data that returns the form data of honest, unsanitized, and then we can go and sanitize the data However, we can never mix up unsanitized and sanitized strings because these are totally different types Whenever we make this confusion, the compile is actually more than one So, instead of some kind of run time error, or maybe newer code, we’re going to get compile time error So, they’re actually very helpful and very good to know, but I do recommend watching Ben’s talk Right, so this, this next item comes from, there was a blog post recently from Jonathan Boccara about Poisoning Functions Nobody likes poisons, but apparently these ones do have some ability Both GCC and clang have a a custom pragma where you can poison an identifier So, that means whenever this identifier appears in your code, you get a compilation error There are some possible uses for doing that like identifying, using deprecated features, or preventing function usage by using the, for example, using these identifiers only before the pragma appears in the header file, and then anything, including this file, is forbidden from using So, that’s up to you It’s not standard It’s not portable Because it works on the identifier alone, but it doesn’t respect things like overload and namespace options So, if it sounds interesting, go check it out Check out the blog post Oh, yeah, that’s poison ivy with Batman He’s inside the poison ivy Right, so, again Twitter is an endless source of interesting information I’m sure Jeff can explain better than I can what this does, right So, some Atomic compare and exchange operations might fail when we have unions which have padding bits that don’t participate in the representing that value So, what does that mean? Basically, I took the quote directly out of the C++ 20 Standard, the Draft, where this code is not not guaranteed to ever succeed So, we have a union, let me make this clear This is a copy and paste from the International ISO Standard (audience laughs) I didn’t make up these names So, we have a union called pony, and it has these two beautiful members, celestia, which is a double, initialize to zero, and luna is short I guess she’s a little bit smaller, which has, because it’s a unit, and there’s several padding bits

Whenever we can initialize this, and Atomic, based on instruct, sorry, based on its union type Whenever we try to call compare exchange strong, this function might never succeed because there are several padding bits which don’t participate in the value representation So, if you have any questions, Jeff is sitting right there Sorry And, Michael Spencer is also signed on the proposal This is one of my favorites In case you didn’t know, there are many, many ways to die in C++ It’s actually extremely important to know, especially if you’re trying to write or bust programs You need to understand all the failure or paths that your program might take Additionally, if you’re writing libraries, or all kinds of shared libraries, or binary modules, things like DLLs, and the boundary module, the module boundaries are failure points which you need to understand how things percolate from Many of these paths have some defaults, and some of them might be user defined So, some of the terminators that we have in C++, this is an extremely small subset We have std:: exit, std::abort, std::terminate, signal, and raise, and these are only the C++ standard version There are C versions and several more By the way, they’re not directly related to std::destroy That’s another function A couple years ago, I had to understand what my program is doing So, I started reading the Standard, as we all do I guess, before we go to sleep, right I started plotting out how many ways our program can die I’m not really expecting you to read all the labels I’ll just say that the orange line, that’s normal program termination So, the flaming pest The rest are a representation of all the different functions and what not, I take that back, some of the ways that are more common for leaving the program In fact, after being here at CPPCon, there is one path that I need to add here, although I’m not sure I’ll have to, somebody will have to come up to me and explain, and that’s contract violation So, that doesn’t appear here today Pool requests are welcome Yes – [Man] Is a forward loop that determinant? Cause there’s nothing there Right on 10 of the fork, going up It goes up and around (unintelligible speech in audience) – No, they cross, yeah, it’s the cross I know, yes Yeah, you do, that’s right So, this graph, this only represents C++ 17 or 14 Okay, so 14 (audience laughs) Okay, you know, pool requests are welcome This is a graph This is available on GitHub Anyone can see it there and make changes Right, so now we come to a very, very dark place, The Void (audience laughs) Is there someone there, or maybe not? As I said a very, very lonely place, and it comes from C It’s an incomplete type that cannot actually be instantiated Incompleteness means the void needs special, it’s not actually, although it cannot be instantiated, it’s not the Empty Type It’s actually more like the Unit Type, or I would say a Unit Type because it’s a type that can have only one value Because it can have only one value, then well, we don’t need to specify that value if it’s the same code because we know the value So, if we know a function that returns just one value, basically it’s as if it doesn’t have a return type There’s a proposal to make regular Void, to make Void a regular type so we can actually instantiate Void object, and give it a lot of regular type semantics Because at the moment, incompleteness means that you need special treatments for templates and generic code, I think the very ironic thing is that they are many, many more Unit Types in C++ You expect that okay, how many Unit Types do you need? But, in fact, we already have null ptr and null opt, which are used in different places There are proposals for monostate and none, which are going to the Standard – [Man] Monostate’s already in there – Or, yeah, okay, so I’ll need to look at that reference

Actually, if you want to make an Empty Type, I’m sure you guys will find maybe a different solution, or way to actually instantiate it, but is a type that cannot, I think, be instantiated In functional programming, an absurd function is a function that takes an instant of Void Type, and we took whatever because we can’t actually call this a function because there’s no way to generate the Void So, that’s the Empty Type, but Void, C++ Void is actually a Unit Type That’s an interesting place, and I’m actually looking forward to seeing the regular type proposal goes soon Okay, so (unintelligible speech in audience) You can instantiate the void? (chatter in audience) Okay, okay so talk to me later I need to fix that Actually, most of this, some parts of this stuff is based on a blog post I wrote last Halloween, and most of it is actually based on a blog post I will write on next Halloween So, but Void is new, so I’ll talk to you later, and then we’ll fix it for the blog post So, Voldemort Types These guys, they come from D, I think from Walter Pride He originally named this term Basically, it’s a type that cannot be named outside of the scope it’s declared in However, code outside the scope can still use this type So, I have an example It’s kind of, sounds convoluted, but it’s actually really simple We have a lambda, and we declare some type of Voldemort inside this lambda, and we simply return an instance at this step Now, code outside this lambda must use the auto keyword because there’s no way to name this because it’s not in any scope that’s accessible for me So, we can use auto, but we can use deco type with this unnameable object to actually create another object of this type (audience laughs) (chatter in audience) You can use using, but using is, you’re still giving your name to something that’s unnameable So, you can use using on the deco type So, these are really cool Now, Zombies, okay What happens to an object in scope after it is move-from? This is kind of a loaded question, and I’m sure everyone here has an opinion because we’re getting some kind of empty shell of an object The Standard has one convention about how to do things Some other libraries might have something else So, the Standard says that at least the container should be invalid, but ad specifies the state Or, you could call members that don’t mutate, or don’t require any preconditions There was a long discussion a few years ago about destructive move, and what to do with these objects Again, I think some people here are much more educated about this than I am It’s a very interesting thing to consider if you’re actually adding move semantics to your type So you have to think what happens to your object before it goes out of scope, after it’s being moved from, if the move is not under, for example, under return statements They’re actually totally unrelated to std::decay, which I think is kind of surprising, or maybe not I don’t know, zombies, do they decay or not? Not sure (unintelligible speech in audience) Yeah, I hope Okay, there we go (audience laughs) So, in fact, as Jeff commented, if you’re really, really looking for zombies, all you have to do is go to the Standard because, again, the International ISO C++ Standard, section 20.5.4.3.1, actually has something called zombie names If you go to the index, there are two very clever entries One of them is brains, and they’re names that want to eat your The other one is living dead, name of This is like the Standard’s Crypt This is where standardized and deprecated names go to die, or get buried They’re zombies because they’re not really gone because many of us actually still have to deal with legacy code bases So, if you’re unfortunate enough to have to do with auto ptr, binary function, bind first, random shuffle, and a few other functions, this is only a partial list, then this

is where you’re going to find these functions in the Standard You know, Bjorne said once that there are only two kinds of languages, the ones people complain about and the one nobody uses I think we all love C++, and it’s good to shine a light on some of it So, thank you (audience applauds) However, I do have four minutes and 20 seconds If you want a few more bonus slides or questions (audience yells) I knew it Yes – [Man] So the Void in aggregate, you can still initialize it four, 20 – Yeah, I think that that’s what they mentioned I’ll add that to the, yeah, when I actually get to writing the blog post Okay, Unicorns So, there was a proposal, the Unified Call Syntax proposal, which wanted to allow, when we have the function called f(x,y), if f couldn’t be found, it’s going to try to look for x.f(y) The inverse is not, I’m just gonna run quickly cause I wanted to get to some of the other ones The opposite transformation from a method of a free function, it was not proposed The motivation was things like begin or swap, which today require two different implementations One is like vector.begin, and one is the global.begin If we have that, we can only have one implementation, and it was very controversial Many feared that it might break some legacy code So, at the moment, as far as I know, it’s still stuck, and it’s not in C++ However, yeah, so Jeff wrote this nice little, I just simply had to put this one up I’m just gonna let you read it for a couple of seconds This is valid code, and it does actually run You can see it on Godbolt, right, yeah (chatter in audience) Yeah, okay, so this is an implementation of unicorns So, Demons, yeah We all know and love the notorious, infamous Nasal Demon of Undefined Behavior We all love undefined behavior This is what most of C++, Twitter, and Shafik talk about all day, right, night and day Basically, it renders your entire program meaningless if there is even one undefined behavior situation in your code I think the most annoying thing is that the compiler actively assumes that UB never happens, never, ever happens So, that means that when the compiler gets to a point in your code where you have undefined behavior, it says no, no way There’s no possibility this can happen Then it tries to think up ways of under what conditions this isn’t undefined behavior, and then it will transform your code under this warped logic That’s how you get extremely strange things A couple of years ago, somebody posted a program on Reddit, and then it made it to Twitter for this five line program Let’s just go through it quickly We’re defining a function pointer called function It doesn’t take any arguments, returns an integer, and we define a function pointer of this type as static one on the global name space This is going to get default initialized to zero, right This is all good and well We’re defining and new function called Erase All, which erases your hard drive Okay, this is called Erase All And, another function called Never Called, which assigns Erase All to this global function pointer Our program hasn’t even started yet So, no harm done Then, what does main do? It calls Do But remember, we actually never called Never Called, so Erase All wasn’t ever set to Do, and all we did is call Do However, Do was default initialized to now, and you’re referencing or calling a default initialized function is undefined behavior Chaos ensued You don’t need to know a lot of assembly to understand that just see, at least that particular version with that set of lines actually erases the hard drive So, I think that a lot of people had a lot of fun with that, and some didn’t (audience laughs) Right, so Flying Saucers Oh, I have 10 seconds Spaceship Operator, I’ll skip that I think most of you know this one I think it’s awesome that the default is totally ordered number wise in comparison No need to write any operator Basically just define it equals default, and it’s awesome Shadowing, all of you know since you were five Transparent Objects, too difficult to explain in three seconds That’s the end, right, thank you (audience applauds)

2015 09 28 Jose Dizon, Paniolo Power

and what we’re doing their energy initiative diagonal what we’re doing on the energy side I keep it informal people lose I want to ask question can interrupt up yourself I can do this fifty thousand foot level I think I’ve got the pipe feet take it back up two hundred thousand feet ain’t y’all busy we’ll make it fun and easy okay so before I start Ron said that the I used to work for the electric utility I spent 22 years without in various leadership positions i was head of generation planning I hid all the power plants on Oahu for actually headed corporate communications with a corporation came over here general manager 4001 half series integration actually went to work for Pearl Harbor get that for about 18 months after four months I said I I gotta be something else 18 months cave and I said I’d be insulted other folks were asking what i did i said okay i’ll be back and then that’s when I met dutch hybrid collapse yes I went back to the big galaxy kidding best decision I ever made is coming to pick up the worst decision ever made leaving that big either so glad up here I talk about my back a little bit because I am going to talk but utility a little bit not yes I used to work there but the people you know the guys the deckplates have the most admiration for those guys during Hurricane the leadership and the direction of the company its slowest reaction solution so a little bit about Parker ranch we were trying 1847 monthly one of the oldest companies and the big app over 160 years I think of close to nine sixty years formed by a gentleman named Tom Parker who married great for the granddaughter of King Kamehameha the first interesting story he was I thinking China working his way back to Oregon when he passed through the first time he waited two years to get my ship to get back to a bigger and they had that barrel cao cao cao’s about over that they got and the kingdom to do with it because Springfree his job was to like kind of get him back together he started off with two acres got to 10 the rank eventually went about 11,000 acres right now during 6th generation Richard smart decided this before he passed away to throw the branch of trust so you model in something he modeled it after Queen Emma so it’s a the beneficiaries are health care education and community this case it’s a North white community hospital HP a punker schools and the Richard smartphone is part of what really validation this goes out flow rate scholarships the kids and under big oven and most of relations are going through Hawaii and so our mission is to maintain an improving the quality of life in my main area of led by providing vegetable support president beneficiaries through seven management improve investor from trust assets and we’ve been a cow-calf operation for a long time and that’s really where the lead of our but yeah what we’re answer what always going to be arranged but we decided to also split up into other areas one is what we call Lisa culture drastic I’m going to release the local Eve program over here we don’t want to call it grasp it because there may be times i doing a garage with my Hector some on the cow over or alfalfa farm or something he is oh so it’s locally grown feet and we have about 2,000 dead 2013 in the program right now for puppy or think about 1,500 into a slaughter by the end of the year think about two million pounds of even to the local market a lot of its going to the local slaughterhouse over here together be but some of it is also going to see y hasta on Oahu and it’s being market included chef zone under the final count company brand that’s for nothing two restaurants we’re doing that right now you know maybe hope you woke up you big enough to get my purse I

and tell a little story about animal power as we the only banking stuff now so that’s Khyber a couple years ago yes looking at our cow operations margins the Mauna Kea side of the ranch that’s where a lot of our water pumping roads are those margins were being wiped out by the high energy costs so you want to do something about it he hired a team from booze own booz allen hamilton and siemens oh so look it to look into it you know can all talk about it but I wanted to show this or right here it is graphic because poker ranked by mangled khattala isn’t it a red circle at spot besides of Hawaii acting in the dark blue is the wind resource we have up there in its class seven wing teaches you about investing you can get in so you can imagine Minister enough wind resource through there we’ve had it measured to provide share with not just a ranch in or Paula my mammoth actually in Thai private so that chassis ok ok let’s try to unlock the other renewable potential of this wind resource of this roof of the resources we have the energy resources to reduce the electric car everyone and look like well why we wanted to do that but we have wind resources and the one thing you want to talk about a little bit is filled volatility so this is graph of fuel prices these are he could help her feel classic over the last nine years the data we went south code word 2014 from the seabed website so i didn’t have any observable taxes with that but what it shows is that volatility original tilly over three year period was forty percent 3917 but the overall both to live within time various eighty-four percent what does that mean yeah we’re just going to ask you what you define mom ability use context okay sheriff Sosa volatility releases the swinging the oil prices and require a house computer it’s the standard deviation of returns which is the log of the differences okay they are pretty technical the technical folks that’s how it’s done so well what it means is when the utility makes investments in power factor safe awesome by our power plants that’s what it’s been over three years the shareholders basic video put their money in and expect to get a return but the fuel price and the changes in Google+ gets passed on to customers so when I say that fuel prices and volatility of feminist wealth it’s because you can put like you know your money in the bag heaven Grove for the interest but in this case one month to build to be two hundred dollars and X months it could be 180 4020 just moves around so you can’t like you know those people on fixed income especially you better have a little more money than you would only have case your classes farewell my pillow forts and paper bills so because you can’t you can’t just like you best that money or take any savings and put in the back to grow from that’s how your your wealth is effective where you yeah mr. Walton but the shareholders of Cena obviously shareholders that are here see general shareholders my time shielded that’s important because the cost curves of the google energy between solar have got that storage have gone down so those costs are gone down and they have zero bullets granted they move because cloud cover because of wind changes but that’s not price cover that bet fluctuation can be doubling the stories it’s also has your request and if you take price volatility who have caffeine Resource Bank on from planning you’re going to see that fossil fuel assets falsified assets cannot compete with the brutal essence even with the oil and what do you think we’ve got to be computed estimating it’s better word while at about forty five dollars about renewable energy oh and I say like they’re so we need to take well to lead into account the energy planning process because it’s not regularly done that way and again do that you can see that and store that more you look good boss

so we work with a team with Siemens and lose out on them put together a plan to help us at the ranch say okay how do we fix our ranging situation how to reduce costs for the ranch and they put together plan they look at our resources that we get wind of storage hundred feet does anyone know home storage matter who pays sometimes I just an engineer so you should let’s get away around yeah so uh I have a gun oh so silly oh but they look at potential resources on the ranch hey you can do I have lmg on there because elk a massive dictators what’s nice about it is if used it really is a bridge and when you get this term but if you really want to lower costs right now natural gas for my by understanding swimming if you do data study and you know it L&G price that email per kilowatt hour we had one of our partners to Deadspin solution quite when I making some it’s a nice educators it’s not permanent right right it’s a bridge yeah and and I’ll show you later on some plans that we have but you’re just resources that we were looking at and if you own one thing that we noticed was this is kind of interstate house that concludes out who’s out Hamilton particularly came up with it is probably for an energy transformation you have to spend about building building nothing’s 1.2 billion now I have here that lower rates and when you take into account the multiplier effect become generously the secondary tertiary effects of people everyone having extra money to spend into the cottage that’s 11 and a half times it’s about 1.4 billion dollars going those are big numbers recipe okay is it for me utility guy billion dollars is roughly on 200 million bell rings they’ll grow beyond that moonstruck two hundred million dollars of you spend a billion dollars right now okay what is well placed or what is how much does the utility spinning well being about 250 million and if you take into account the other independent power producers they made powered by powerful it’s about you know since utility basically generates about half like this date forty-seven percent so the remaining generation that they buy power from including the renewable it divide powerful men at oil costs principe garden and so figure so its marketing officer is five hundred million dollars or half a billion dollars in oil related costs per year for you that’s it goes away deciding the seven and if you’re placing to put a million dollars and clean you’re saving money you spend a billion dollars and you would say that’s good counterintuitive each other nothing that it’s impossible hey guys think see it and there’s about 200 million dollars net book value of existing awesome food unit strategy to be written off so you can make an argument that in their planning going so the shareholders repair that processes we’ve been bearing the volatility Prospero this time so we can sell those things Ella one who wants to 70 year old boiler okay so what year was spending a billion dollars actually reduces race then we get that too seems down to that’s a week so you know so we started thinking like utility it’s like a hybrid to see well I really do this in the right way and did actually came up with our first plan towards redo microgrid for go to cross over as a ranch we wanted to reduce our

cost of water pumping operations to increase our margins of cattle ranching do we said well students were involved in the community so let’s see will be something for my man also good cop and that’s how this region how we can save everybody there about money utility came back after we talked to one sit well you take away the northern part of ye then everyone else has defecated for the remaining infrastructure that these guys are paying for any more and so it’s a good so we lose you wait and everyone else loses and we said there’s like six hundred million dollars with benefit he got two hundred million dollars with old units for getting two hundred million dollars and you guys will be home and will still save water please plus the secondary economic they went how does that work so instead of working with utility in trying to get this microwave or looking at my pay grade we’re looking at resource planning we decided we go to be bigger transformational change but only happen with a commission of the legislators that’s not too happy that’s a good class play and we came up with a study we published a study of the regional microwave sir can we back up this did that cost we’re talking about when you’re done all the transmission lines they have already in place is that part of the equation yes actually there’s two ways we looking at one where we with legal the power we would basically used facility three distinct fence we should be sufficient wires hanging important and yoga that’s the big cost of the other one was we’ll just build it over yeah oh well yeah and by building a line we still owe you know so they kind of told you how inefficient system appearance but of course tsunamis not going to build good so young so but it was the point right happens me one point and we could publish the study you know I think this is on our website if you want excuse me but stopped about the microgrid so the nice thing about you guys know what am I commute is so Micah did basically is a smaller grade within the bigger on the cream so this case it was Waimea and what kahala but you can also form a series of mine could really okay series of my foots uncommon why can’t you do that so you would do that because for example even the storms that we had tsunami would please he could divide the evidence different groups perhaps the Waimea much power my people being that generator examples we have a lot of the wind resources there in elevation for storage so these older people natural gas-fired engines of needed the Kona Coast to me about the grid maybe in the Makua if you helo put up etc and what’s nice is if and the utility they could either Bowl the entire by the group is at themselves so they can own the wire for the transmission backbone and these the different life degrees and during a storm each might agree could separate from the other he don’t like it’s like that for example you know the other way we could still stay in service or maybe you know what may I like to be in that generated electricity to maybe most of the my critics but you know new resiliency or stalking the people cut sep reserved attention so is it costs more to do this we don’t think so we think you can do it clean but again just increases resiliency for the ill but not like the mainland work maybe I’d like to get your only cost more but given the strong prices are high well mainland has two major grids the name all these independent utilities some which are we messed around so much monkey that basically serves a geographic area that basically the same as quickly as matter fact they’re all interconnected those are saying didn’t help each other out yeah so the whole the whole national utilities we just don’t have that really hard to borrow some power compete from

big yeah so we wanted to demonstrate the value that my grid PUC but then we said well why my custom money we’re saving could we could potentially save all this way or what may why don’t we use something for the warhead so we did another study and I’ll show that shortly what we looked at the entire as a utility with the transformational standard and we were able to five percent sooner and lower cost point into that I’ll talk a little bit about gonna be stewards they said I would and you guys know about battery energy storage so they have utility steel storage which is a gay one perspective you divert tesla powerwall bigger units boarded the megawatt range they’re good for management of the grid in the seconds to minutes time period they move very fast so it provides a regulation will need and ramping that you need when so I’ll storage hopper can do the same thing on the short side but they also work on the longer minutes to hours duration and what they also provided is a rotational inertia for grid management how batteries do that do they call it the dedication so it’s it’s about the same but it’s not but what’s nice about I’m storage hydro or any long duration storage is when wind is being curtailed you can use that energy that would have been curtailed or back off to run a campana uphill and then in the evening time but that want to go and it would reduce the use of people unified utility total fire broken on so you’re making best use of existing google energy resources and served by false equivalence how do you agree pumps or two terms or conditions kilowatts I don’t need it because pumps are solely unless you’ve got a reservoir dump dude it’s much lower than the reservoir keep popping into pretty low yeah so nice thing about Parker anxious you know accepted 2500 foot level event elevation up to 9,000 feet so you got a 65 7,000 foot elevation difference we looked at 49 different places on the ranch it puts a pump storage but you hit the length ratios on whether there’s a number of places I don’t know match to basically firm up so you know the Apple on lower the lift basically really matters less give excess energy and doesn’t matter how much he used to talk about the hill because you’ve got excess pretty funny house of costume million dollars to run one light bulb and I’ll guests gasping and I will show that it’s it’s very very sensible we have report on that hydro efficiency right now that’s a first d I’ve seen that claim I went to how much weeks for killer yeah I don’t know the exact number when I was at utility I was here between 2007 2011 2011 as I didn’t say sir my home is it will be using them to generate electricity what they needed water and it really bothered it was that from you that’s thinking kind of small so I said you know if I were doing automatic Alec station why don’t I water from one field open up the station used electricity

produced and in the water i got i can use for irrigation in my men and I do it to prom thing instead is worth this electricity and o pretty-pretty sets your unstable what we think is comes to watch tiger given the water the ranch will change the face of every cruise leaves it who are finishing for pasture lands want to talk about farming you grow crops if there’s a lot of potential there’s potential for hot a lot of high elevation water up in our area source then some say it’s a tremendous resource so yeah so again i’m looking at energy but i also look at all which is the ability and culture did you work it is is compatible so you’re going to do that’s okay so okay so here’s some storage in a nutshell so it will lower reservoir that all this we want to back off you lose too much energy of the grid use that water up the hill and then evening you let that want to go now that’s traditional pumps going you see that California out of the way we want to do it is you could ahead to penstocks to ice to pops so you’re pumping water up the hill when you pick wind Energy’s being backed off and if you put your constantly trickle flowing water down here management and the great movies so you’re doing hoping the same time actually that’s really what we think is the next level next stage development yes if you use the win you know of course to get the water back out know that so all the numbers bertling hood also say win fifteen percent of 15 says 20 says whatever it is to get down few guys that you have any idea what where you might be per kilowatt hour power we have any idea what we might be but oh well let’s look at the resources separately ya think when I mammalia to get down to about two and a half three sets into an hour probably hello here probably eat pump storage it really depends so we’re gonna put out a request for information on palm storage on everyone is always the baby like crazy you see we fill the reservoir so okay so distant parts to it when is best due to the greatest in the late afternoons solar to test the time so the periods where there’s a lot of weight or a lot of solar to leave this can’t take that power into the back Wow believes that power water and then with all that what I was up to the top of the hill and you hit the date the evening people poaching right now they’re starting with the diesels instead of starting up those units just let the water down I’m going to generate electricity by just having water flow field generated alternative color remains electricity and now its just oh you’re making like these through google resources and you’re not starting

ezel dinner so there’s examples of bloomer westbourne upper reserved or house and help hero Spanish colony near islands is actually one hundred percent renewable they used to be good to this picture at least it has diesel generators because there’s a lot of power the town now diesel generators are just fat they have two other boards one up one down they have I think they also have two lines to test sets of pipes they’ve got the window so they can do it and so they cannot eat ility fans are their fans are too slow think their focus too much on the ship older it’s accidental hero do you know what the numbers are of what it’s producing and what it’s costing to produce or for these guys yeah I had the numbers I don’t have them I don’t have a mom but I can give to you okay let me sub is gonna be targeting right yeah they just that they go we’re generating but i will show you what we’ve come up with caustic said how much water is to discover it on the big island having five thousand foot elevation so you could pump it from 5,000 feet up to maybe 6,000 and then got 6,000 be ahead you can recover if you looked in developers it OMG 10 we we’ve looked at home several from 1000 foot bed to about five thousand foot hit I think you get the head is too large too soon who’s the cannibal me just that pie yeah the stage so there is a that is to grow our pies Cooper dance 4.1 Pete there you go my water 2 pumps are careful to the biggest can’t seem to let go of me just the pasta player generators too often sentra because we think that over here I mean think about it we have the highest rates I Pacific the lowest thing comes mostly gone through the counties and so the nice for transformational change to meet you hey we have the vision of potential exact day he been saying the same thing and up so we think i will show you some clans that we could accelerate the installation make celery retirement existing fossil fuel units in created value saying that even said the same thing doesn’t show you a graph of hell coast I arpita’s premise submitted 2013 got rejected by the Commission but i just wanted to show you a couple things this plan had a lot of renewable energy resources and data people at the bottom right you know there were 89 megawatts in 15 your plan why did the Commission rejected because there were no time rates of mosca units there was no fuel switch there was no display some customer value and so if you look at just added generation to the system it results in added incremental costs and so their costs and representation going on and that’s what I’m showing this reference if you look at their cop supply included plan so after the Commission rejected their I resource plan I said okay you got four months to come up with so they submit this lady they’ve added battery’s completely fuel switch allocated 2222 2018 what’s the

ISO containers that contain your eyes which has the scale for volume to reduce the cost of the head to your Bibble resource could even go out to win and they actually started to retirees and so they had 49 megawatts of economies not as much renewables and the utility called this a transformation this is transformational and all I say but what’s the interstate is with this new power supply equipment plane they’re saying that costs will be going down right about twenty-seven percent over two years and so if you lay on top of that the old iron econ’s member they have any retirements or feel switch so the cosmos go on you can see that tremendous value was generated just by listening heading back I was calming so we did that and we said well can we get better so we started with help coast of pounds of life in this plan he says is that 25 make wanted you go ballistic why realistic really there’s no tam thanh against at this point in time to prove the resource and the state wasn’t involved chemical analysis etc so the time it takes to develop the resource meant to do something really good like 25 so what if you were to replace that we pump storage hydro wind so 20 megawatts pump storage and 75 a lot of weight and in addition what salute requirements let’s accelerate those memories whether they have happening to them all okay get rid of one right we can get rid of that volatility and so what’s going to happen so if you look at the bottom right you’re retiring same number of units to suitors you’re adding a lot more renewables some of it firm and what does that do your cost well receptor became remember 2018 coughs go down to the ability because lmg came in containers in 2022 it went out again because the ship you putting a lot of potential gas then the sled benefits so by exerting retirements accelerating mg you can add little value and so we drop by Steve further faster because to benefit the customers right and we wanted it faster round eight so you could be excited too doesn’t sound the best interest of the customer we do that customer value drive shareholder done so I we t you can add more value and it turns out when you accelerate storage but uh this thing about Mt tility should be focusing on LG totally down on rebase assets which utility we’re saying we hear that if you want to do L&T what the gas company hit the gas company actually has already said that lmg for electricity would really be a bridge that they’re good folks on transportation so hey ramp up your city but it was the electric utility that’s a perception it though they had to buy so I’m you look at the clamps degree helko Pemberley comparable incur the ruination percentage of the health effects on ego say we have one hundred percent of Allah energy and uh really it’s the way formula is calculated for mothers in via

google voice and his life and he might have heard any critters talk about it or some folks are at but pepper advisors say it’s a greater number sir well we can really just did a pure engineering math percentage you know what it’s ninety percent rps real new things about just do it the way the laws so I said earlier that we think that the way you should look at this is customer value should drive shareholder value not the other way around you don’t build infrastructure and put it the rate base you think of what the customer needs first off you do that and that should hold you like that gave up of the list I like that they would let them stopped in what are some of the things that you could be doing to improve customer value I put number number three is my volatility one you know that if you’re able to discount all costs resources that he saw secure with in-store boston conservatory just just having a fraction so that we’ve been working on so we do let agreed that no computing Commission our long-term plan you’re working through the Commission we’re good rather get the Commission to he’s playing there but in the near term what can we do so come on this program with the utility called a community-based program you guys I’m Dennis No ok so it’s a lot that was passed by legislators this year signed by the governor and those that don’t have rooftop solar and like Richards like small business owners office space with delinquents or that reduce our costs now they buy you a solar developer can put solar somewhere else and you would subscribe to that program so now everybody that’s the good news the bad news is those that have that’s that energy so you guys are getting your credit full retail rates for these guys so those folks have put in palms so you’re but at least now thank you look get maybe two tajuk young Parker actually you would subscribe to that bugger by putting money down to buy panels and solar or wind and the utility will take compute the output of that plan figured out which is yours okay so

we’re working on that we were trying personally to have this thing down so we project in place before 2016 so those of you Phil but given how long tasty projects go back possible that very soon everything going how they should call it distributed power or funny what happen all about reef system solar panels and all this this will be wasted investment or if you think it’s such a long time it is worthless I think there’s two components I think there’s for those that have customer choice that have the ability to choose for those that’s where for those that so we think though but I think for camellia Google what we want to do anyway is just let folks know that if you can’t 40d baking up into Jim’s program you guys are gems google jams I don’t know so we’re all wait for that this seems like prices for those compliments are going down so fast yeah that’s true people are saying so therefore what we were told when I was a consultant so after a utility harbor and I got bored and consulting side I represented a company did fly will project that meeting to 10 feet over a walk and storage cloud potential taking the jitter short term energy huge big motors on the ground what’s amazing is I think in July so I but of the things are changing so fast it is do your water for estimating if I you know a traditional storage because because of the type of water you’re not going to the ocean right let’s play it’s all the country so but bra outside we pay it back we’re paying back there’s a round numbers I hoping about forty cents drill without electricity if they cut the generation cost to nearly nothing we’re still playing about twenty cents for grid now and they are rural counties in America we’re paying eleven cents less than that she always says a lot of the question is why is our grid so expensive that one question Matt back when we did this study just a really great

utility cool since the national average of electricity ensue cane almost injury suffered earlier southern Indiana counties we don’t a local generation for sending the power down from Great Lakes your pain 11 cents got it trees a bit of 150 miles young lass so why is our so much is anybody know yeah you know from utilities speaking just the cost of shipping things over here why but then ultimately don’t look at the design of the system to how it grew up right and so I think you know plantations I don’t know looks like our transmission lines are relatively low voltage 69 thousand volts vs 4 45 50 thousand gray and so then the question becomes what if we would do you know cooperative eat yeah but we got twice no madness of all the others should be higher let’s remember to do that and whether HS structured right now cost of new stuff I think that was thinking for we like that higher actually they’re converting the street lights to LED and I’ll say to two hundred thousand dollars a year but you’re still there 20 LED rings yeah I don’t know ik optimum for LEDs you talk about the twelve cents gonna prove whatever transfer cutter diversity yeah and the apt remember people forget the devil’s advocate they forget bit we have a cost of all the people that maintain these lines and their high tech people think it came from and so Bob Costas never been totally and so the event it’s good paying job they deserve to be paid and so that’s one thing yes you’ve talked a lot about LG being a transitional fuel behind er stood there was a problem in bringing the gas to the island there’s really only so obviously we’re an advocate for all

do that so we go sign a couple collaborations we’re working with Google X it’s a windmill that flies and it’s using ninety percent less mass than traditional way to win turban which is a tower of this so this thing is just looks like apartment everything they’ve been testing different versions of testing the full full potential prototype version now it’s going to be 600 KW energy flying on the tether and making big circles 711 30 feet high the winds there the stairways yeah the wings about 90 close to 90 feet it’s kind of exciting but the two are separate companies so we’re over here we don’t work with so we spoke to a lot of there is no project yet so what’s the vices and this is for lambs so you haven’t adult the projects were really we must put 150 megawatt project which we think you’re something and then why yes we’re going to finish the space will see that so some tea sites it’s been a lot of money to fix rates have you guess one thing I want to go any questions of you that figure twenty-seven percent reduction electricity rate sounds useful but not overwhelming is that what your heart beating like 25 to 30 production come down to about what don’t you mention an industry that’s a

good one you put rough idea with pretty natural sword with battery so including all the capital cost I think it’s it’s more expensive batteries of the killer could you have to replace that made very optimistic estimates of the cost of operating batteries like assuming you battery lasts 30 30 years the time of you straight weeks until V is also not publicizing the big help that’s where you pay lower cost than higher rated so maybe from an economic perspective it may not be a good thing but you know for someone to take control in the future so I tell folks some hobbies member incense know me now get ready for that rainy day probably expensive but you know what happens you i’ll be ready right before i go i look at the story FFF band used to be s’okay transformation should that make your first house sir what do we what do we I know it I knew it he told me what their cost is what are we paying we being fossil fuel cost % they mark it up from what they buy it because they buy it really achieved it depends okay first of all for any power that utility purchases from a third party there is no market for boston’s passed on now if the independent power producer is the wind or a group of energy that it’s probably would cost contracts the utility day so they cover the cost of one so they could be generating electricity pulses to expand so we pay 45 so they get a triple mark up no yeah there are our process like 45 see what their face 15 seasons what even 26 well that’s just the wholesale generation yeah you gotta stop delivering them energy at the twelve cents for that that’s included in all those taxes you ever see all the whole town getting the bottom of this like in California house in California we paid for me taking down a San Onofre and then when they put it up again we paid for the pretty young they took it down everything so we have three charges from San Onofre taking me down pointing up taking it down which i think is ridiculous but where is it utility come in a lot of millions the building’s they make where do they put their foot in and try to reduce the cost as for commissions come in what that’s where the Commission’s come in and easy there that causes the public interest me they have milk oh la la open or PowerPoint that never got built this so that’s the race he uses who is on the puc the chair is Randy awase is the

recently just a revolution he you see it actually needs to be exploding joke the PUC was wholly owned subsidiary of being built yet and now it actually answers to a different part of the legislature and it’s becoming more consumer authenticity this Commission has been very progressive and really shut down to the proof plans that the until we have plenty big fight the Commission has invited many many times over the collision is for transformations and the utilities and the utility I mean the Commission Oxley looking for the utility look at what’s going on Ashley with the New York Commission is pretty much the same thing same thing so our Commission Oh point because the Commission opened up the Pops play with and AH theater last year has a big part of this because Sarah we would actually in the merger documents we didn’t go with a park-wide full of plant operators going two days a week it are made in the murder docket and in the end when we wide awake by a solid a planet with an orthodontist that’s only way to know like discuss this company’s coming for the future so you merge the resource plan offers for each of the merger eat up mission tonight at which is fine but in the end he said well our resource plan or plans that we’re developing will work whether it’s a bit of a great utility whether its co-op whether it’s totally what is your inside feel why I wilco is some reluctant to change is that are they feeling pushback from their shareholders to hold on the oil way of doing things work probably just don’t have in light or all time it’s the latter i mean really i mean when i was here the destruction was there any new applause you this costco but the utility was just does not not a bunch of smart people i think there were a few of us that really want to change for asking treat the disruption like between a score all your energy into it branchburg party place resolve these plans oh its plans I am doing something right now that you mention in public just play action teeth to some of the plans but the other one is that community want something Newton we’re trying to make it happen so we’re trying to make land to build we want to say an agriculture but you’re

still going to be a ranch right we could get a lot of do a lot of land that example with mothers there’s make well land available

Daniel Garcia – Transforming High School Computer Science: The Beauty and Joy of Computing (BJC)

so I’m still open I’m a professor teaching in the computer science department here at UBC and it is my delight he is a teacher professor at the University of California Berkeley in the ecs department I had to go get a cookie because I know from previous meetings with Dan that I would be at least you’re cooking maybe one of the Nanaimo bars to actually keep up with him in translators the first time Daniel I hung out I was going to say taught me dance dance revolution but really I didn’t I didn’t necessarily get that far I was better than it was when I started but I was just watching it all up danznewz i have dance dance garcia I didn’t know that make sense chance against Garcia I’ve he’s done an amazing number of things as a teacher but also in service of computing education at Berkeley in California in his community and in the world particularly involved in CSE the ACM sigcomm computer science education and so I think without further ado I’m going to hand it over to Dan and eat my cookie watch that’s great thank you Steve good to see you all it’s wonderful to be here make sure the microphone is good for people it back I guess tapping out right here I’m captain right here it’s supposed to go to it so that’s good alright well we roll with that um so I said Steve say I’m Dan Garcia I’m going to talk about our initiative to transform high school computer science through our course we developed called the beauty and joy of computing so jump right in that medicine behind motivational slides talking about why we need this high school computing this is the number of in 2012 high school ap stands for advanced place when the college board has these courses that you take in high school and you can use them for college credit or placement and this is a number of students who are taking these courses in history in english in science and there in the upper near the Million numbers range and here’s all the way down at the bottom end of the curve you always want look at the right part of the curve it’s a top right or top very small in this case is very small this computer science and even worse is of that box you say well of that box maybe if there’s distributed to look like the people in the country or the world that’s okay but they’re not fifty percent of this tiny box or girls eight percent or african-american Hispanics and we have on the order of you know thirty percent twenty percent thirty percent Hispanics and ten percent african-american not at all forty percent and so eight percent is much less than that and fifty percent of women so actually we’re not doing so well in terms of getting this to the students who could really use it really could make a difference for them so computing as literacy a 21st century but a pcs is only available in five percent of the schools and so really the challenge is how do we get a great computer science everywhere and it isn’t just an intro to java because a Teague AP computer science a is an intro to job it isn’t about a course it isn’t going to that is going to teach how to program certainly the goal isn’t to make everybody a programmer it is to kind of bring perspective of what can you do with computer science give you the power that not just consume things on your mobile device but actually don’t how to build those kind of a thing so it’s giving them empowering students and broadening participation in computing so let’s do you think I love starting sentences less lest you think that I’m the only one in this initiative there’s a whole family of folks who are helping us with this this is the beauty enjoyed computing family Brian Harvey Tiffany Barnes of kind of the P is on the project luc and Colleen are amazing grad students that helped us build this course and these are unbelievably strong high school teachers we’ve worked with throughout the entire process to make sure that as the course developed the University moves to high school it’s still relevant connected and can be done in a high school setting so how do you make a change in the entire country we’re talking about the US at this point but it really the world but how do you make a change in the entire country if only a small fraction or actually to actually have an engaging puter science course well we decided rather than try to fix AP Computer Science a the strawberry sit has so little participation under-represented groups wouldn’t it be amazing if you’ve ended a new course let’s spend a new great course broad you can learn about the things you do the social implications of computing as well as I how to program as well so it’s not about just reading about what computing can do and not do it is both learning about what computing can do and what you can do with it and actually learning how to do it yourself and feeling really empowered with that so the single source of national leverage the US every state gets to make their own decision and if you know a little bit more the details of that whatever texas says it takes is one of our biggest states the Texas Board of Education things get adopted there they also go to top it by many other states so if you convince Texas you can get that but it still it’s about 50 different fights you have to fight at that level and even farther than that sometimes they even pass it on the federalism passes it down to its on the district level so you can recommit the state but they say well it’s not up to us when the district makes the final choice so that’s crazy to have to go to each one of these districts and try to

make that convincing argument why you need CS why you should have a teacher and I teach this course so the way you get it into all the places at once the National leverage point is the College Board the college board offers these courses and if you get it to be a college board course then all the schools will saying we got to make this happen of a sudden just nationally it takes it takes effect so it’s really delightful the goal of this new course called computer science principles replacing the old one computer science a doesn’t really tell you what a means a is a versus a be so it didn’t tell you what that is this is principal saying it’s the fundamentals of that is seven big ideas we’ll talk about that in the next slide or two it is really thinking about what computer science can do for you and what you can do it’s connected to the student as well as creativity it’s engaging accessible inspiring rigorous it’s awesome a lot of computational thinking I’m hearing there’s a new we would have most of the money we talked about the new computational thinking course you’re thinking you’re building it’s delightful to be in on the ground floor that to be able to have some new sense of what should we be doing for the rest of the campus not just our major the rest of the campus this is this with that space for us so what is CS principal CS principles comes from the College Board they hired an amazing group of educators I wasn’t part of that so I can tell them they did great work I can’t but I’m composting amazing group of folks who put together seven big ideas and these are both the university folks had high school folks who thought leaders who said we want to take some leadership to actually build this course so the seven big ideas are summarized in this slide deck with the key idea that kind of the name for the big idea in bold so computer is a creative activity how many folks teach that in their course APCs a I don’t think the word creativity spoken once all right if the drinking game like it says it drink all the glasses are still full nobody’s drinking when because they’re not hearing creativity in the CSA course abstraction we know about the power of reduces information in detail to focus on the relevant deep concepts data and information facilitate the creation of knowledge algorithms a lot of these are coming from the standard courses well programming is important programs are how you embed the algorithms the internet provides model computing this used to be systems but systems is too big as you mean embedded systems big small that’s about the internet let’s change a focus of that and commuting as global impacts this last one big idea 7 is the one that really resonates with me let’s talk about what you can do with it and what it means what’s the digital divide and how does that affect what people are building and what they can build in their space of thats really pretty powerful how can be transformative by the way there’s a website CS principles org if you want to know more about this there are six computational thinking practices there are two pillars one is the kind of big ideas the things the facts seem to learn about it and then what the things that you do at the nouns and the verbs this is what you do the practices what you do in your class so these are the things you do in your class you connect computing to other disciplines and two other things and that are transformative by transformed by computing you develop you build artifacts you develop things so you’re not just learning about them you’re also building yourself you’re doing abstracting you’re analyzing problems or artifacts so it gives you an artifact you want to Poquette and probably say what is it what situations is not working doesn’t work all the time could you build it yourself and doesn’t can use it as its scale the things you’d always you’ve been doing with your students as well communicating and collaborating this is great collaboration is part of the required things a lot of people taking AP CSA and they never once work in a team this is crazy this says no this is a core supposed to live in high school before the apcs a so it kind of like 11th graders which are about 16 year olds and you’re required to collaborate love it that’s how we do it in the industry and so we all do it at the university level let’s make it happen now at the high school levels we love that we all think this is great dynamic dynamic 67 Big Ideas 6ct practices we love it how do you assess it well in the old days you had and this is this is the old school way of doing you have a written exam at the end of the year which has multiple choice and you have some free response questions like write a logarithm do some stuff here it’s a hybrid in which you have these two authentic performance tasks that you do over the course of the year one is called the create performance stats which is coding but here’s once he’s is great about it unlike unlike a field of our of cs education which says let’s find the niftiest programs that we can make people all do so let’s find a tic tac toe or a hangman or a breakout or something that’s really our sound or something visual or graphical that’s nifty and really great but you make everyone do it so that’s easy why do you do that because now it can measure you all by the same stick and your project you all have the same spec but what are you not doing you’re probably not engaging everybody that probably some people that’s not really interesting oh I don’t like graphics I don’t there so you’re not gonna gauge everybody this says every single person picks their own project huh what the thing you do no that’s awesome okay that means everybody gets to find what’s passionate to them do you care about outreach to group so find a project where you find a local group a community group and you may be right an app for them or something that’s perfect I love it how about you

like graphics want to make a game love it too I want to do a simulation of traffic I love it yes to everything are you kidding me we love it in fact there was a small this is like give me some inside baseball there was a small time where we said let’s give them a list of things they can choose from and immediately all of us says no then this list means you’re gonna start picking from that once I put a list you’ll be check them from the list because no one’s say or other Knowles are the others always on the list no no list you pick whatever you want to do how would the thing okay explore performance task you go find an innovation a computing innovation in the world okay that has a societal impact and you research him you go read about it you go to you interview people you go to the web you go to library you find out all you can about it and you answer some prompts what are the positive benefits of this what are some possible negative benefits of this thing how does they use data and transform in a consumer what are some privacy concerns okay so you’re looking outside of innovation your research it and then you write about it delightful okay you also get to make this amazing thing called and called a you’re making some multimedia that is going to support that so you want to be able to some things you can’t describe so you might actually make this a competition Allart of fact that will go along with your research so this kind of a multimedia movie or sound file that will go along with the submission you have which is the answer to props those two things are 20 hours of class time and you’re great at the end of the year is some percentage of that it’s actually forty percent of combined those guys and sixty percent of a two hour exam so it’s kind of nice that it’s not all about a paper pencil exam at the end of the year if you’re a bad exam taker you can get forty percent of an a of a rock star a before you even walk into your exam is that great so it’s not all about your ability to perform on a paper or pencil test at the end of the year so what drives what did that outstanding dynamic group of 40 educators create they didn’t create a course framework that said by the way on our 37 of our five of day 37 you have to do this activity no that’s not how it works in the College Board when they come up with a curriculum framework a framework a general skeleton framework that you have tits like a skeleton you have to hang the meat on that bones in some sense so they’re firmly tells you in general what to do so of the big ideas you have these four subcategories what is big ideas at seven of them within that you have kind of a chapter heading of a thesis okay the subheading might be the enduring understandings which is the students will understand in grand terms okay so it’s a way to kind of break a big idea into smaller pieces then you have these things called learning objectives which our students will do such a verb it’s like what you will be doing in the class if you read all the blue guys that’s like what you’re going to be doing and then the red guys at the end o is essential knowledge statements which say students must know these facts okay so here’s an example set EU which is big idea seven which is global impact okay EU which is the next level down says computing enhances communication interaction and cognition it’s kind of a category you will understand that what will they do student will to explain how it affects it okay and here’s some facts okay so email SMS and chat have foster new ways to communicate and collaborate just one example kind of how it breaks down okay there are more than 300 e KS and you say dinner I want to make a class that is compliant with a pcs principles well you better make in class and you show me where in your class somewhere you handle all of these guys is a check box there’s a pointer from every minute to something in there it doesn’t mean you can do you can do things outside of it but you’ve it at least comply with every single guy you better knock all those things off and your punch list okay by the way I love interactive lecture so any question any stage I know I kind of going and going going feel free to just throw a hand up and stop me will do that so I should have said that the beginning I’m sorry about that so the cs10k project yes go please need ask i’m so glad i did that watch what’s your name tomorrow tomorrow thank you go the exclusion which is here’s the thing you don’t have to yes there are they’re few and far between but they really are there for example there’s some complexity theory and so in the complexity of to understand that some algorithms are reasonable time and some are not reasonable time okay that’s the kind of soft squishy way they have these categories and below it it says knowledge what P and NP is not what nothing not here so some of the language a you say oh I must have must mean I need to teach this but you don’t because of the line below it so whenever there’s a case where you think people maybe run run away and think that they do all this up they don’t buy you kind of limit out what they have to do so that it is there maybe there’s ten of them in the whole dr. out of 300 so got that money but I love it we then we have that tube we added that let that order the last steps i’ll post me up more question i love this is go keep we got make it interactive w tomorrow and machine and antoine go please santwon yes go back going yeah yeah so for instance interesting okay sure

sure should I get it um well I mean okay so you have to have a standard so we have 12 hours and you would work one of the things we learned is that in the early version of that you weren’t allowed to even talk to your teacher about whether the scope of what you want to do is reasonable or not but we’ve changed it so now you can so now it’s nice that’s what you the University you know people propose projects and we say is too hard too easy so if you wanted to do something you find whatever is passionate somehow in the class I taught about sorting you want to like look at more of them and analyze and visualize them whatever you want to do with that you’d say Dan is that’s feel okay you would even half is our requirement that we have an interaction but if you want to do that I say that’s great now if you say Dan I want to do this at its a 50 our project I say well you can still do a 50 but do 12 hours knock it out submit it and then keep working later one of the things that people do in the class is the exam happens with about a month left in the high school year so you have like a month afterwards to do any and all amazing things that are above and beyond the cs principles course because the exam has to kind of be a place where you’re not doing the exam for people in this summer seems to kind of matter have it right at the end the last day and high schools are all all around though on the map in terms of their calendar so that’s a perfect opportunity for you to do 12 hours of your project here and then you know 38 more hours after the exam happened that makes sense so there’s still a possibility for you in the course to do it given where the exam is hope that answers your question terms would be able to have a larger space of that all right so it’s great to come up with a great course and many people who put a lot of effort is that thought that we were done okay thank you very much goodnight pls tip your waitstaff no you got to do a lot more work to follow it up which is you gotta do the teachers doing it I mean the people realize this is a big problem this is a big lift and so what they realize is we got to have this out in every high school in the country there are twenty-five twenty-six thousand high schools in the United States computer science isn’t about two thousand of them so we got to get it into 24 more thousand high schools okay so really this project to get 10,000 teachers in 10,000 high schools all prepared engaged delivering an amazing course it’s almost falling short by a factor of two or three this should have been the 26,000 k project but they decided just 10,000 had a nice number about okay so so I still think that they takes a solo show show we are at the point where about 2,000 we think we have about two thousand teachers running he just course next year okay this guy why does it say 2016 just around the corner from us because the course goes live fall 2016 spring of 2017 exam happens may of 2017 so we’re coming up to I’m give this talk a lot and we’re coming up to the point where it’s actually the last year we’re like I can see the clock on the wall it’s we’re months away from the launch of this course it is so exciting to have to that we can’t wait to see what happens how many students sign up for the exam take it and Rockstar it’s amazing what I didn’t tell you what Stephen tell you there’s a seven-person Development Committee and that developing committee as you’d imagine makes the exam you know they edit the specs for the performance task and they actually make the questions I’m on that committee so I I’ve been looking at all the questions that we’re going to deliver a great exam I can’t wait to see how many will take it how well they do is I’m really just I mean it’s going to be more me more than anybody really want the other people take it and love you will succeed obviously ok so this cs10k effort but but brick going buick there were more there there was National Science Foundation funding to fund initiatives like my own who have a course that adheres to this CS principles requirements of the curriculum framework and want to go out to our country and share that course with them so there are many people like me who have competing products competing courses trying to get the eyeballs of high school teachers across the country so my next slide is saying I’m part of the bjc beauty and joy of computing is my logo big smile bjcc how we do the okay so we try to bring fun bringing engagement but also bring really rigorous CS to the space other people taking different angles other people have distinguished himself by saying I’m going to own the mobile computing space and app inventor is a wonderful tool to be able to make apps on phones with graphical drag-and-drop languages that’s one space another space might be I’m going to connect computer science plus X computer science and law computer science and history computer science and biology and owned the cs plus x space angle to this so our space is the following what differentiates us is we wanted to bring some of the most wonderful and most powerful ideas in computing to students we have a very programming heavy take we’re going to talk about i’ll show you some demos what

we do so we teach things that aren’t even taught in apcs a not even taught in some schools cs1 class for majors recursion is often taught us maybe the second class for majors we teach it at like the class behind that the class minus 2 in high school before you’ve left high school so recursion functions as data and I know this is a this is a group that has scheme as part of the cs1 so you know that the power of functions data from the scheme space we also talk about concurrency distributed computing we use a graphical language many people are evolving to using graphical language because you don’t have the syntax issues and all that and our particular take on global impact is we balance optimism with pessimism like our angle of it is that that technology is neither fundamentally good or fundamentally bad we have an overall optimism the technology will make our lives better but this but each particular technology has issues that may be wonderful ma issues that may be need to be brought up privacy issues or other issues like that okay so this is blown to bits blown to bits is an outstanding book it is a Creative Commons license book so that you can get it for free if you want to one of the things about our courses it’s completely free not a single I’m not doing this to try to make any money am I trying to sell a book all of our stuff is free all of our materials online our videos are materials every single thing is completely free we even use clickers in class I see your iclicker in front we give up we bought we got a grant to buy the clickers we give the clickers away to the students and we collect them at the end of the year so there’s not even a cost for the clickers for the suit you take our course z I ask this dude how much you paying for your biology courses well the book is 250 the labs of 50 like you’re talking about hundreds of dollars for every other course how much made for your CS 10 is our CS 10 in berkeley class it’s wonderful so that’s really nice blown to bits helps thud after that that is available free it’s a PDF so we started with scratch literally the Scratch programming language was the first language you looked at as we looked at the space of who has graphical languages that we want to use as our fundamental starting point but scratch had some issues we like to be like to scratch on to Alice with the App Inventor to all these things and scratch was the best guy we loved scratch we loved how easy young kids could be really engaged and do this in four years they’ve been doing that but the catch was scratch didn’t have functions at the time scratch 1.4 if you looked at scratches repository of student work you’d have these beautiful fractals now look at the dragon fractal and the sierpinski carbon and you look at the code and it was copies one calls copies to happys to cry mean like it was like I can’t because because I had no functions you couldn’t call that you know this was an end and the ending of them so is ugly let’s try to run on six well there’s only five copies so I can’t run in love with workers level six right it was a little bit embarrassing so yen’s Mon egg has gone on and Bella they’ve since added functions they’ve advert they had a command function so you could sort of fractals and so we’re kind of happy with that which and we think by the way we were the ones that people to push the scratch folks we’re all the same family we go to the scratch conference they come to ours where we’re all friends they had had they had made their code open source so Jen’s moaning had taken it was a developer there and he added these things so he added functions he had a generic lists even today in scratch you can’t make a list of return it here’s a list ret right now making on the fly and giving it to you like if I want to make you give me a function that’s going to make a list from one to n I hand you in you give me a list box it has 12 n elements in it they can’t do that now you cannot do that because you can’t return a list let’s their global things that live over the wall and lists are over there you can’t just have lispy first class where you can pass them back and forth we also added lambda so functions can now be did I can take a function make it a thing and pass it into a function I can return it from a function I can put in a list of functions powerful stuff okay we recoded it in JavaScript so now it’s in the browser a lot of high school teachers are telling us they can’t install any software so that was trouble so you have it in the browser experience and most people now have in the browser programming environments as well so here’s an example so I asked people you know who are programming languages fans all right great your particular language doesn’t have four doesn’t have the forum has while has repeat doesn’t have four in it so you want to be able to build the for loop and then use it seamlessly as if it had come prepackaged with the system can use in your language and I look around and almost nobody can say yes that yes they can build a control structure that behaves as if it were primitive control structure so here’s us building the for loop for I equals start equals 1 to end action action takes a thing you do in the inside the curly brackets set i equals start repeat until I is greater than end run the action action is the function of the data that’s the things that you’re going to do inside that loop that’s the stuff that’s inside the curly brackets change i buy one this is what it looks like when you start using it looks like as if it came built with the language for i equals 1 to 10 for Cagle 325 say I and K and this is running it seamlessly so it’s really powerful the people who are in the sub category programs go like that that’s really cool well it’s mostly like I was so boring who’s gonna care about a for loop but doesn’t engage the kids either but for a small slice of many audiences that toss them so it’s

awesome I hats awesome we call this the snap language so if you’ve heard of snap this is where it comes from it’s a beautiful little good logo which looks like the top of the block that snaps together with a little lamb to icon connected there by the way this is the gobo icon this is a kind of our icon for snap also and this is the gobo icon from scratch which we took he had kind of a bart simpson spiky head and we took one of his spikes and kind of made it a lambda see how we kind of see we did that to do that so we do learned all right okay so i want to ask you why you teach functions right we teach functions because of abstraction the power of abstraction i give you three blocks of code and those of you who have seen your student work that have three blocks like this the hair in the back of your neck goes up because like why do you have three copies of exactly the same thing with a small difference right here’s a topping code pen down p for move 25 turn 90 what does it do draws a square of size 25 pen down repeat for move 100 turn 90 what does it do try the square size 100 same thing 395 you say hey student we have a idea called functions the reason we use functions because you shouldn’t have those three copies you now combine them into draw a square of side length pen down repeatedly you take this you drag it onto that and now you have one generic draw a square block and I call it like that okay so that’s that’s it’s how we teach function teach when we introduce functions which we don’t do first day we do like the second week or something okay now look at this okay here is a block which is the draw square guy okay here is a draw dashed line cluster of code here is a draw wiggly line and I say how do you generalize that smarty pants and if you don’t have functions as data in your language you don’t what you do how do you do this in the languages that functions the data what you do is well I have a couple of parameters for the line you know okay how many dashes do you want how Wiggly do you want to you feel like parameterize the line and I say what if you write that and you bake it and you hand it to somebody and then I said you know I have a new idea for our line for like a squirrely squirrely squirrely guy that makes it pretty hard in the corner and Flutie Flutie you know you get letters back in your in middle school and Polly will draw an eye with the heart that’s somebody you could be a creative with your lines right so here is another way to draw a line that you never thought of before does your thing does your solution handle that they go actually no it doesn’t right right so why try two primaries all the cases just take in the line drawer and put it there and call it done look at this line draw our function 100 square repeat for run the line drawer whatever line drawing you happen to use that day today is the wiggly line and guess what wiggly line picture isn’t that beautiful so those of you who aren’t teaching functions that data tell me how you answer a student who has these three pieces of code and wants to generalize it in the same way you did a second ago slide ago I generalize the squares was the size of square now I want to do what do i do that day which it happens to wiggle a line or something else maybe I’m looking for how about this let’s write some code that figures out the smallest element of the list that’s made more data structure here okay list of things smalls emili´s you’ve got a piece of code smalls elementalist okay the next day you wake up and you know I need the biggest elementalist so you write that code you start to scratch your head and say wait that looks almost the same the next day i want the element that’s closer to six there’s a three copies of the code with like one line change which is a comparator so what do you do you come back to dance like you say hey wait I should pass the comparator and now and now it’s like fine closest to this this is like the best function and your same algorithm now can handle anything it’s the power functions as data that we use throughout this code is a big idea early on the cut in the course the students use this they don’t know how to build this yet but they’re using it they’re using some powerful ideas and only later do we teach them how to build it themselves okay and I have another slide deck if i have time which i can go to talk about that let me talk about recursion give you a demo it’s my favorite demo of the course so so so let me just show you how this is going to work okay so okay get out here live demo so you know what the love demo potential is here all right I’ve learned when I go to the snap i go to presentation mode data fills the whole screen okay good here’s my code i can even make this bigger you can even go over here and make the size of this bigger let me go zoom blocks and i say three and i say this and now it’s only little bit bigger okay so here’s how this works this guy up here is setup code it says clear the screen lift your pen go to our certain place put the pen down point up zero means up and call the V routine and I say what’s the V routine you might ask let’s edit that this is the V routine okay so let’s work this together as a pen hey Vee says remember I’m here point it up this is like my guy and my pens at the tip of my arrow and I say turn left 20 degrees okay now I’m like pointing this way okay move out 20 steps and the

pen by the way is is down so I move out I make a line Zoop 20 steps run item any of functions wait what I know over their shapes look what there that is a list you’ve seen list before we’ve together in class seen lists it’s like a it looks like this here’s you know here’s a here’s a list of a B and C looks like this and you see an A and being a seat that’s you’ve seen that before so now you see this and I’ve never ever showed you that functions can be data we just kind of use it and I say what’s that a list of and you all say it’s a list of three blocks which it is they happen to have a great board around them which is a way to kind of funkified them and lambda phi them but fine three blocks that’s not hard in other languages i say python show me a list of three functions i say a list of plus minus and add or something or mouth plus Madison Square and what I get I say show me what that is and I say for call the food what is foo it’ll go like left angle if you haven’t even left angle bracket pound signs some internal code is and show you what it is no there’s a square hexen star right it’s easy to read okay all right run item any of it so item any says go to this list pick any of them and now run it okay so square and all that means is wiggle around it’s like the pen thing but it’s like to move into square like we’re gonna repeat for move and it’s gonna do this okay it doesn’t do any pen thing cuz your pen is already down it’s just moves hey now move- 25-25 steps so i go back turn to the right 40 which is kind of symmetric so i’m now we’re here pointing this way and i do the same thing again i go out i pick an endo it says star so stars like this little star shape and I come back and I get that let’s try it okay so i go to full screen mode I’ve shown UV I’ve shown you this I’m gonna go here and go here and boy okay so there’s my here’s my shapes just to remind you and I’m gonna run this ready click this click this green guy and go oh look it went left and got a square and a star look okay that’s a look I did I didn’t that’s pretty good it’s like I should go to Vegas okay here we go going up two hexes oh that’s kind of fun but pedantic what’s the point in what if I hit up arrow no oh no you didn’t oh yes i did i just added me itself i need to have like an echo vvv itself it’s effing time to the list of things I could choose so now in class no class draw a picture of what you think will happen okay so everybody pauses and thinks about it and we got make him draw the picture okay and if you ask them what they often say is like what a little pig v it’d be like a double V it’ll be like a square and star of this that got that and that could be it let’s try it this is my favorite part ready and I set up a go pretty go Oh what happened there well it happened not to pick me both of those cases so sometimes it doesn’t pick a purple guy that’s fine try to get look at that that’s kind of neat it went left picked a V and then that meant it was going to slit again and pick two guys and those who tell you those guys weren’t v’s okay so only pick one v out of those three let’s keep going boring boring boring and what happens at that moment the whole class goes oh especially big draws for a long time and that’s a moment that you just pause and you realize computer science is awesome and recursion is awesome and there’s a reason this course is called the beauty enjoyed computing which is not only are the pictures beautiful but the code that generate them and the ideas are beautiful okay and the joy comes from appreciating that stuff so what happened here you just picked a lot of these okay so now you ask yourself might it never stopped might you just continue to pick purple v’s yeah what’s a chance of that it won’t okay you can do some problems you can alisis it won’t ever happen that’ll go forever but you can have a go for a long time I don’t need so this is beautiful and this is wonderful and then you this also side steps and is a really elegant way of handling the base case no you’re saying if I’m in the base case then don’t recurse otherwise recurse this is probabilistically handles it right yours going to sometimes not pick a purple guy and you just stop just beautifully don’t even talk about it but this is how we introduce recursion for the first time and the power of it and why we love it so that’s my that’s my video I love that demo Yoink alright so we’re on time we’re doing great we’re doing great that’s my video okay um you can make a mobile app and I talked about am I going to do I’m even going to do this I’m having such a good time now I’m gonna do this demo which is I can make a mobile app the app inventor team they have like a 30 minute tutorial about how to make a game called whack Amole you’ve seen the whack-a-mole game and they’re arcades we have to get little rubber hammer and you kind of whack the moles that pop up from the gopher holes okay let’s do it together and show you what

happens in the first five minutes of the course okay so five minutes of the course we gather this we’re going to stop this we’re going to make a new project if you keep doing this effect I’d you let get too close to the men you could be trouble give you trouble okay there a new thing replace with new okay so here’s my guy cancel that all right so I have done this in the past where I have 90 seconds and I make the whack Amole demo ok and then and I can usually make the demo in 60 seconds and then share it on my phone which I don’t have turned on to be connected the wireless thing in the other 30 ok so let’s try it maybe I can wait till the six and i’ll see if i can do it here we go ok hey ready and go alright so i want to do something forever because i want to have this thing always loop so i’m gonna grab that forever block and if i what am i doing I’m gonna be forever doing what I’m going to find and a move and be moving this what am i doing I’m moving to a suburban space I’m not moving there i’m actually going to so I’d had the wrong this is gonna be I’ve already messed up my damn ok here we go let’s go back and I type go go to x and y forever go to x and y and i also want probably do a find of weight so i’m going to wait like one second between that all right so am i going to i’m going to a random spot why I’m is it raining because I want to move randomly around the screen so I’m gonna go random here and put this guy right there and he’s gonna be from minus 2 40 minus 2 32 maybe 230 and this guy is also a duplicate of that site crap here duplicate that dragged him here and this is like minus 1 70 but our team is what is 172 17 t ok so what is going to move there any but right right boo Hoover enemy / now we gotta finish you guys have the score here when you gets clicked ok so what happens when it gets clicked when I am clicked when I am clicked then what do i do well I want to change a score so let’s make a new score let’s call it score okay i want to start from the beginning so when i’m fresh i reset and i’m going to reset the score so there’s variables and reset the score so set the score 2-0 set the score 2-0 and then when I’m clicked I also want to go to a new spot because I don’t want to just do that so what I’m clicked I got a new spot there and I think I’m pretty close I now so I need to increase this by one change score by one and I think I’m done okay this is this is that this is what they spend 30 minutes doing that I have now finished okay now why you often do is you kind of can add it you can add some Flair let’s add some Flair just for some Flair of some costumes I can make a fun costume of a big cat ok there’s my cat alright i’m supposed to click on my cat and make it work ok so let’s try this right here we go here we go let’s go and go ready try ok it’s moving moving click it yeah i get a point I didn’t get int I would see click did I get a point did I get a point is my code back working at one I got one see it up to now I need to make a smiler adjustment this is draggable it’s thinking that I’m trying to drag it live ok now tried it there oh that was that was live go back away go back away they’re okay come on get it nobody get it I get it no tell you gotta admit just meant to just up to two as a good game ok it works ok let’s stop let’s see how do I get this game into my mobile device well I do this I say save ok and I can save to the cloud cloud is our kudiyan or saved to the cloud kind of standard thing so I’m gonna save it as you bc a mole you bc whack whack ok you bc wacky okay i’m gonna say save it and now i’ve saved it and i also want to now open it as a shared projects i’m going to go change it to be a shared project so I’ve scripts the bottom half a million guys here ubc is down here ubc is it there waxy’s tau B and my love you Steph they put a space in there ubc whack ubc whack I don’t know where I say just not in that list you can help me a tape ubc wack did I not give me some love you SB not I don’t see it like the thing all right well I can try to save it again maybe I don’t know what happened to say ubc wack it’s saved their look like there’s UBC whack right to the cloud open it’s on the cloud and I’m gonna go here and find it here we go finding you bzy give me some love why isn’t it listed there that’s a fascinating thing I don’t know why that is do we know what did i do differently interesting let me save it as we’re gonna need to save it as something this is it may be a book I put a couple spaces about go public space to the beginning here spaces like that there now you’re in the front ubc bike safety okay now should be the first of the list if I open that give me that give me some BBC wackle of here we go and not listed there that’s good stuff okay what I have is I have another one I’ve saved before this guy I don’t know what’s happening with the same thing why it’s not listed there but I can open this this is the same project all of them differently is I’ve loaded at a picture but it says code is exactly the same this is the

same wack thing I did this kind of some stuff where I am I think this is actually the same i made it i change it so that however big the screen is it does something is like an HD version of this okay the same exact project I just changed him width here if I look here this is a URL okay that URL is this that URL you get copy I can now go to a page called tinyurl.com i can paste in this URL paste it like this i can go over here and type let’s see you b/c whack i just try that and see that URL is available sometimes it is it is so now let’s all of you who have a cell phone with wireless coverage or data plan go to tinyurl com / ubc wack again it’s not exactly what I did but it’s a version I don’t know why the save and load didn’t work today but that’s goes that here we go okay load that up and see if you can show me your phone it working on your phone and we have our students do this on the first five minutes of the class we have them we chop them tick I don’t know how things work yet but they’re following a pattern just like our code they kind of follow the pattern followed by development and then they have this workable runnable game at the end of that day which is pretty awesome so see if you can do Chinese roll calm / ubc whack with a wh see it gets it will take a while to load snap and it’s nice if you hold it kind of sideways in the longitudinal way so it’s horizontal but that is another way to get that working so i’ll keep going and you tell me if you get running while i keep going to my side so don’t delay too much and here’s an example by the way of this running on an ipad so one of the things hey you gotta run in his laptop and look he’s running it on into the play when you did it can you actually play it in playable game he’s playing the game he’s trying to boom okay love this love this so his example that ipad one of the problems i thought with the mobile computing space is that it only works on android devices so all of the photometer apple guy all the people who have apple devices you have no access there so what are you doing already on your emulator the whole time but this runs on any device it’s JavaScript you just work so it’s beautiful it’s kind of solves the problem of lock into a particular server okay so how is it going so that’s my course I think has a lot more details to that but how the course doing well I these are two students who took my course and walked out of the final and said dan I need to tell you how much is course meant to me and as I started to tell me I said do you mind if I record this is like a long times like four years ago I said sure you record me so I probably self one Apple just received desperate just had a iphone that had a movie camera so I making a movie my first little movie of a student and he’d say like Dan this course is amazing it changed my life and then seek next semester 16 other students I never told anybody about that 16 other students the next semester pulled Amish mike hotels and say Dan I gotta tell you bout this and I had a luckily this is a nearby classroom there was a neighboring classroom that was empty so one by one I was taking students over and they would just record us a testimonial and I wasn’t giving him credit for that it wasn’t telling me hey everybody if you like to tell me no I just quietly was taking the exams and they one by one we save dad I tell you something I say why are you okay no I tell how much this course was amazing I record all these guys saying that that’s now on our website so that’s great for students they’re really engaged this is the percentage of women in our courses for major a B and C our course one two and three and it Wiggles around you know 10 15 to up to 30 Wiggles around or maybe about 20 okay over oh this is longitudinally since 93 I believe this is the non majors course which was a scheme based course in which we taught recursion how to function at all scheme and no social vacations of computing no global impact no collaboration just you do my project end of the year all of the scheme and they were happy you know thirty-five percent women then we introduce bjc and we saw the highest number percentage of women ever including a semester twice now it’s happened which we eclipsed the fifty percent line of women so there are more women than men in this class and as a result the people want to join my class as lab assistants as readers and TAS we’re now more diverse and now i have half half tas women half half TAF have readers and every diverse all across the board and all roles students can have for me amazing so this is the course wouldn’t brian i taught it together so this is in high school so we handed to high school teachers as a nathan Maddux one of our early adopters from our local school Piedmont school he says BGC rocks the students love it this may be the best course I rented he says we have five times more girls than last year we smash our enrollment record we retain everybody girls they had like an intro course that used to have that was replaced by bjc the bjc replaced I mean and and they used to take that intro course but never go on to other courses in that school and now that everyone every single one at X pjs it goes on every single one at that high school goes on to the next course without any change in rules or anything we have received funding from the National Science Foundation funds activities and

research to go out and give PD professional development to high school teachers across the country how do you do that so we applied for a grant we got it so our model as petals around the flowers so we work with kind of a university anchor because universities have kind of free access to a meeting room so teachers can meet so it’s easy so it people we’re doing that and we engage another university we train we work with teachers face to face then they take a four-week online course and then we come back at the end so it’s going to 14 model 141 face-to-face for weeks online one week face to face and now our high school teachers run the PD so I’m kind of on the back coordinating and the high school teachers who really know how it works are the ones in front of the stage in front of the other high school teachers telling them how it works so it’s great we have now reached 240 teachers across the country including Puerto Rico and the first year of our grant we went to them we’d say hey does anybody want us to come bring our pd to you and small local CST a computer science teachers association chapters that had a lot of people and AJ said how about come to our chapter so we went to them but after that first year we lost the early adopters and it was more like to hear and 10 there and there so the next year we had to bring them to us just a small difference in model that but it we’ve done that heals is a program part of something about that which partners an engineer with the high school teacher who may not be experienced in CS and they teach the course together and teals offers two courses intro to AP intro and APCs a so intro is our course so we got the teals contract and that they taught our course with their engineer and that so that was great we brought in 44 more teachers that way and this is the teals program on the New York Times page we support our teachers with the Piazza group if you don’t know what Piazza you shoot it’s amazing and so we work with our teachers which is now more than 300 strong of people who are on our group please feel free to be drawn up your absolute this is how we talk about everything it does a new update to snap it goes here and there’s a update to the performance task it goes here everything is about that we need to say that not everybody going through our pd teaches the whole course it’s a lot less than half of that but many of them have it influenced them many of them use that and then you snap with these blown to bits that use some part of what we do they don’t all teach all of it but some of them teach exactly all of it and we offer monthly webinars to support them the future is to support our family we now have so many teachers that so much of my cycles is now making sure the people have gone through our pd are happy and supported and and connected so that’s a challenge for us to continue to grow and support the folks behind us so this is us in our local chapter we decided to go global we decided to take our course and put it on edx so we up we were the first computer science principles on any MOOC space EDX decided to come and give a grant for high school courses that would be given out the ghost scale so we got one of those early grants we had a limited beta of 12 teachers within a global launch of our MOOC which is to everybody it’s like many to one and a Spock and if Spock of your nose stands for a small private online course and the idea of a Spock is that a high school teacher can use the MOOC as like an e-book and they kind of use it the students in their local class are still a normal class but they’re using the MOOC to like log in and get the stuff Auto graded and all that stuff gives them a free dashboard they can see how the students are doing they can brand the course in a certain way and what’s nice about their Spock’s technology is it’s still one course from my point of view so there’s an error I make the fix once and it affects all the teachers who are grabbing it in the early days they actually had to make copies of it so that’s ridiculous i make its like the fractal thing right i have to change it all those different places now the spock technology allows me to make one fix and all the teachers see the fix so it’s like a layer of mylar in front of the actual core class the MOOC had 16,000 students but like any MOOC you have a lot the first day of just click the button and then fewer as they actually engage with the class but incredible enthusiasm of students who really want to learn this stuff it’s awesome here’s more details about the Spock which is that the student center for a class that the teacher gets to pick the parts they want the teacher can mute parts of it so if they I have like five units they can mute unit two and the students don’t see it doesn’t show up in their gradebook it’s kind of like customization of the e-book right you’re like you know just like you know do all the odd problems in the back of the book same idea with the MOOC with all the content they can boot stuff they don’t like it they could put their logo up there go Wildcats you’re going to go your logo mascot whatever teacher feels in control we launched this Labor Day and here’s a link to that I should say that recently we got a huge grant over 7 million dollars to take our course to New York City school system the largest school system in the country i think maybe in the world actually but the number of total students they have in total teachers and total high schools we are going to work with a hundred new york city teachers and work with a group called EDC who is a curriculum development group to look at our stuff and sit like saying yeah this is great but you’re making a huge conceptually peer or we needs more work on this material they’re basically making a refinement pass and they are amazing it’s like amazing group of developers who are working with us to having done that for many years for mathematics working with us with with CS this is the demographics of New York again almost seventy percent people of color so we’re really excited by getting to New York and showing some early success we made a little picture it’s like I Love New York BGC Love New York summary BGC has been transformational in many folks lives students lives my life

teachers lives we stand I didn’t mention this but I did say this a couple times we stand on the shoulders of giants okay it’s not just raw raw go me it’s raw other things that we wrap together in the bjc tin foil which is the cs principles framework that i didn’t develop is dynamite it’s really good seven big ideas 6ct practices that’s great and all these great courses are coming out of that so that’s awesome so I can point to that say that’s great without bragging scratch he’s great I didn’t build that either so that’s amazing if you haven’t seen scratch for your middle school kids or your grade school kids point them to that scratch is amazing and blown to bits again none of these things I wrote but they’re amazing and we brought those together and wrap some interesting exercise is called a bj see so that’s what we’ve done so year-long CSP MOOC if you want the URL for that we have we just recently had a summer PD 63 bringing our all-time total to actually over 250 and the future is so bright that you gotta wear shades so folks thank you very much this is bj see and it’s been a pleasure giving you a lecture wonderful so now I don’t know why yes please I have a question Tron part of your talk that really interests me it’s the enrollment by female by girls and I think I can speak for everyone here practically that that’s something everyone is striving to improve yeah what would you attribute specifically do you have anything specific that that is causing that increasing role not sure my girls sure do you feel like it’s snap or do you think it’s your curriculum or you think it’s your enthusiasm I think thank you for that question it’s wonderful and I’ve gotten I’ve got asked that question by reporters so I kind of have an answer which I haven’t baked it in my slides but if nothing comes up in question I had 10 answers so I’m 10 answers for you 10 things that we did that we think make a difference and I can’t tell you what the percentage of what those things are but I’ll tell you some of the times i can remember off the top my head number one branding this course is not like a programming course this course will teach your global impact this close will teach you about what you can do with computers this course will talk about the digital divide and other things so it’s about it’s a shifting it from programming only course which don’t succeed to being a course that lets you engage with computing at different levels that’s 12 the name of the course talks about beauty and joy like I’m drawn to that just even if I didn’t know I want to find what that’s about 3 because of the early success of you know even before this we had thirty eight percent women I really shook the trees and found strong students who would necessary put themselves out there to be lab assistants and readers and TAS I said you’d be great you’d be great how many diverse groups of students I said come on be part of my family really know what ever asked me but yes once you ask them they say yes to that and by doing that now I’ve got half of my tias at women and I didn’t have that the first year but I had that after doing that kind of shaking the trees some more so by encouraging more leadership roles harder in high school cuz you really have TAS and stuff but but but trying to like bring some of that there every single lab session is pair program so there’s never once where our students feel isolated and they feel like they’re dumb because they can’t get the particular challenge no you’re always with the partner and you’re always working together and you’re switching and I compare programming you’re always engaging together I think the curriculum is really fun as really powerful I mean these ideas are hard this isn’t like I mean this is like some of the heart we teach computability we teach Turing completeness we teach parallel programming this the race conditions we teach recursion higher functions there some stuff that’s like whoa this is from all across the four years of an undergraduate program into the non majors course are you kidding me and yet look at our results so it’s unbelievable how it can be done we really think that it can’t be done in terms of getting engaging all the students so having really rigorous stuff that’s hard but all fun and it’s fun because it’s hard right if it was just a trivial class we learned about loops and drawing pictures and do that it’s not as engaging as like wow my brain hurts that’s awesome I’m going to talk to my friends about that tell their friends ok we have encouraged so part of this came from CS principles which is that all the projects are of their own choice so giving students choice again so like the Nifty model which is you find a great thing and hope that works for but it never works for everybody so I put it X through nifty and say no it’s not about nifty it’s about independent choice for everything so that’s important it’s about having people tell their I so much to tell their friends so as much as I can I say look if you if this were engaging to you every time I made a video of somebody saying this at the end of it I said please tell everybody you know because I want more people like you to kind of bring that bring that enthusiasm there so as a lot of love I’ve given to the students in my support staff so that they really want to be part of my family and my team I take pictures of nut on the website I can show you pictures of all the folks who are just helping it’s unbelievable for a class of 240 students

I have a TAS eight readers who tease you know help teach lab a section and teach discussion I have eight readers who grade the homework and projects I had 70 lab assistants 70 for 240 students okay so this is like one for every three or four kids and that means when you’re in lab we have four hours of lab a week where you’re doing activities you’re doing long line activities it says write a block that does this what do you think that does run this way what are you never hear how about try this add this feature it’s asking you to do interesting things and whenever you’re stuck there’s a person two doors away two shares over who’s the person walking around and asking can I help you kind of help you like waiting around to see people like that so it’s not like this one ta and it’s under staff overstaffed my course like crazy I’ve changed the grading policy from being a b-minus centered course to being a B+ centered course because if you are from another discipline you’re in from chemistry and you want to try computer science you shouldn’t have your GPA at four point of stewed you show your GPA you’ll be competing with majors who need more background before this first course for majors you should be able to try a course be in the middle the curve and do well and not have to have your GPA be hit so by kind of pushing the GPA a little bit up we don’t care about it we care about your grade inflation but not on the non majors course come on care about it overall in your program but not one course you have a kind of graded high and the students if they do well they’re going to get a bay or be basically you don’t get to see in my course if you tried you’re getting to a or b and so we have students alike dan I barely got a bad project working you’re still gonna get to be in this course maybe b-minus but you still do well you won’t really get hit for that we have ah let’s see try to think there were like ten things that I said its graphical the language itself is graphical right so the fact that it’s kind of pretty like this V picture it’s almost pretty having the colors in this there’s no syntax we used to teach a scheme course right this scheme course that we taught I had probably a week or two that I lost over the whole course of the year of just how people understand parentheses I mean you guys teach scheme right it’s like there’s something about people can’t get that one left means the function call to left means this guy returns a fungi like it was just too much and I don’t have any of it here’s why and snap and this is from scratch to this is a block that’s called a command block it doesn’t return a value okay if i drag it over a reporter block it doesn’t highlight white because i can’t drop it cuz semantic that doesn’t make sense to drop something’s going to do something into a block the needs of value so i cant i drop in just sit on top it doesn’t actually fall into the hole this guy is a variable so this will fall into these holes so you have no tax errors in this language and scratch and App Inventor because it doesn’t submit that make sense to drop it so you can’t drop it so that block based programming I honestly since I taught 10 years of scheme and then five years of this I think this saves me one or two solid weeks of students just being frustrated with syntax and so I’m a huge fan of block programming for the intro space what are the things we do it I haven’t showed you I’ll show you this one this I love this demo students believe that if you’re programming in blocks you’re not programming so they say when do I start programming dan wait you wrote this this isn’t programming no no it was how’s it up well so they don’t ok so let me show you a great a great demo that we have here this comes built up the system ok go two examples and I go to codification okay check this guy up I have to click this again codification yank you like okay so Google on its interview cycle asks students to write the fizzbuzz a project you seem fizzbuzz it’s a drinking drinking water for the students in the freaking water game where you’re in a circle and you go around singing them number but larger than 1 2 3 cut off okay you keep going around and around around and then if your number is Rosa but by three you safe is visible by 5’s a buzz there’s about 15 you say fizzbuzz okay and Google asks people to write that algorithm in any language on there and they say that it’s unbelievable how people can’t even just do fizzbuzz okay so here’s fizzbuzz okay for i equals 1 to 100 if I mod 5 is 0 and I mod three dudes about both 5 and 3 8 15 safe is buzz otherwise if it’s was my three say Faisal s5 say buzz otherwise say I okay if I just click this watch my sprite he’s going to say 12 phys for buzz okay he’s from the fizz buzz game okay so I say you wrote this you’ve got this working mr. google interviewee but they said they needed in Python well we have a mapping because functions can be data I can drive this block of code into this gray border and now that’s the input to that and now I say set script to that boink script is now set to that block of code I scroll to the bottom and I say now do a mapping and all this is is for the internal if I know what JavaScript if looks like I know what Python it looks like so i click map to JavaScript and this is JavaScript so they say I want to learn JavaScript you did you learn it because you learn how to preside whadja which can be translated easily won 2-1 with

JavaScript so I go over here and I say export okay this my friends is the code that you were writing all along okay they do is encoded or corridor glazed the hour of code then they put your button should show the code that show the JavaScript okay so I copy this I here I go over here too is it view or is it window I forget divisions which is the history view developer k JavaScript console and I get the console and I click paste and ladies and gentleman fizzbuzz okay in JavaScript and I have this mapping for all these languages I have to up I just like before all these languages let me get out of this let me get out of this and go back to this window there okay close that so i can map to small talk or Python or see or 20 other language all that just get mapping of like this if block looks like this in C looks like this in Python it’s trivial but my point is the students get it start I show this and now they kind of get like wow I was learning computer science all along which is just a syntax translation between the other language you wanted to learn so that’s kind of a neat little example I can just show you in 10 0 the language is kind of fun so the fact is that this is more fun to program in than any other guys when you’re learning and you have any type of guy I can drag a block the bed of the benefit of blocks place is very simple one I don’t have to memorize anything for the functions like UNIX you memorize it commands no I just see them I try to find it and it’s even better I can I have a fine command so I go over here and say Apple command F and I say actions before I say move as mod that’s mod so there’s my mod block boom okay I type mo and then it just shows up I can drag it okay that’s cool then you say well Dan the other brother that’s one benefit the second benefit of having blocks playing with programs just programming is there’s no typos I talked about that before so and the third is I could think that I’m actually faster at control laughs grab the command that I am typing a long thing the fourth is there’s nothing just like command completion there’s nothing stopping from having really expressive functions that have spaces notice by the way that if I look at some of this code not every not every block has and this is just the general stuff here let me guess scape out of this and get out of here not every one of these have added in a while tempers giving me some trouble okay cuz I hid that they had they hid the program they hit the thing over here um notice has fib this as text the point is some of this code has the argument in the front you can write sentences rather than having you know python is long complicated name open for an argument argument argument no make a sentence out of what you want to do so it’s easier to sew blocks this language to let you do that very easily you can have spaces when you make a new block so all that stuff this s text this would be like as text open paren know this as text that kind of example so block Slammers have a couple of these benefits that for beginners is really powerful people have said Dan I can now as they get better by the end of the course they get frustrated because they it takes them longer to go click and drag then it could be if they wanted to type I say well then I’ll show you the fine thing were you much faster is what I’m faster than that then we added this this is the cool part right because I’m really really cool we just added this this is our recent project let me get out of this window thing let me say new and show you this guy here if I can get this right atmos if i can get this demo right there was a question of accessibility you know does this work for folks who who might need a screen reader we’re working on that part working on that but watch this i can click on this and shoes keyboard editing okay so watch me i’m going to click shift click I’m now in keyboard entry mode watch me ready let’s do it let’s do a squid draw square sure pen down PE down arrow enter okay what’s next i do i’ll probably repeat for right re no down arrow enter left arrow left arrow enter for escape right arrow now i’m inside this guy okay i’m typing i once you get good at this you are unbelievably fast okay so what about you i do now I’m probably do a move so mo ve bam hope I have to move homie from a bigger number than 10 so we enter 100 enter right arrow up down down down down right right right up left down there you remember how to get back to the slide get better as I do this and then does it probably turn their it serves it enter and then I turn or yep turn right by there how much is it enter 90 enter done ready click my square so there are people I have a friend who’s who isn’t has some visual issues and he’s unbelievably fast now like used to be hard to find it you also from other way I showed you you can change the size these blocks not all the elements of the UI changes your scale obviously it’s a web page I can like do apple plus I feel like get out of this mob I have to get out of keepo editing to be able do that but watch i do this i can go apple plus i maybe its view you can make view in zoom in right i can zoom make this bigger but i don’t like because it makes

a blurrier so you can make these blocks as a larger scale which is called zoom blocks to do that which is really nice you could also grab this and make this bigger if you need to kind of see that but not all the elements of the UIC these guys you out is still small so not everybody scales like that but we’re working to make it easier to kind of engage so the students who say Dan I want to switch to a text language to be able to do this faster they they once they have these keep our entry is better i also want to show you one more demo while we’re doing demos here and while no questions are pending let me just show you this one here which is and you can pedal you can do this this next one yourself i’m going to go to Chrome and make a new window and type um tinyurl you can feel free to tripped up on this right here / bjc jeopardy is the URL bjc jeopardy okay by the way one of the great things about having a URL is how you pass things over i’m making some code and coding in front of value right okay then i can save the RL you can load the URL and you’re all let machines laptops computers displays and now you all have my copy could I was working on then I go and add a feature and I say go grab that all you do is go back to the URL and it reloads what I had if I save mine it saves in the cloud then you reload so it’s a way to kind of keep students up in a workshop or in a class as you’re quoting with them it’s a great demo so bjc jeopardy slowed adem to see what happens so this will load snap will do this an enter presentation mode and do the other thing here okay this is one of my favorite projects because it talks it it uses the idea of open data and it channel’s the internet in that you’re using a block called the HTTP block I don’t know what’s happening with my cloud but the ATP block is a block where you can actually go to a website grab data and pull it back and then use it in in look in your type of sound I haven’t even tried it okay so i’m gonna click this button what is rock the boat okay and somehow my computer has a German accent I don’t know how it got that way and I would love it and it can help me take that off and but I don’t know I art it was fascinating is our men developers from Germany he might have borrowed my laptop at some point in the recent scratch conference and converted something in some setting I don’t know how to get it out so I still have a nice friendly German transcribe so this is what about this is it this is a normal Jeopardy question and i click i can just click on it to get the answer what is Michelangelo okay so how does this work how does this work this works by the following this is so cool ask jeopardy question but I do know that there’s another example simple example I sure the bottom TV news is named a gender forever nuna gender so it says what’s your name and I say Dan and it says ah expect I’m just changed something maybe I just change something out here but what let me show Jeopardy works jeopardy that worked this morning okay jeopardy calls this API this internet API that returns a json string so it looks like javascript object notation string well you don’t be parsing that this no list if I so that list if I something that takes this string which we just call the sentence and makes it a list of lists of lists of lists key value pairs then I have query which can take a key value pair and query this and find the if I give it a key get to the value from the key value pair so queries like I wrote it’s very easy okay so that’s the whole code so it goes to the API gets this J something in which one of these guys is the title one of these guys is the category one of these guys is the question pulls out all three of those it just says them that’s all it is this whole interactive thing is about five minutes of work if you’ve done this before so it’s so cool to have internet api’s open data for voting and for parking and for lights and four sensors and boys and temperatures and all these things that you could bring in and put in and wrap around a really beautiful experience for students who can then interact with some way this is great day my saw which was um there was sensors on parking spaces in front of one of the key spots in downtown Barcelona and you could just query it you require some API and say give me sensor number seven that would give you that parking spot with us a car there or not and so they then have a little loop that’s squaring it every 30 seconds or something and it shows cars when it frees up the virtual car will go and drive away and so there’s a picture of what the car status is even though they don’t know all they know is the sensor but like a little picture of cars driving and driving out as they’re comparing it and getting it there beautiful beautiful example of kind of wrapping an interactive thing with this in an API and connecting with that seamless with snap beautiful one last thing i want to show before i go to show you all the things you sure about codification how you can wrap that i showed you the internet api i showed you some of the graphics you can use the last thing to show you is this j/s function so again this is part of the demos under examples j/s functions up

back here examples jas functions ok Yanc this is in the web javascript runs below so they allowed a port where you can call a javascript function but wrap it in an interface that looks like it’s a block so let’s look at this over here on the bottom is speak hey my click on this see if that works for me today speak is the block for speak maybe my German think I tire okay stop that I’ll try label label this is like way to do our label we didn’t have a labeling in this okay how does label work label calls this JavaScript function now you don’t need to worry about this works because someone figured out how to call this interesting API to get is just write text on it okay with the parameter of size this code I don’t need to worry about it because all I see is a label block it’s as if we were primitive so you can go in and add interesting crazy blocks that call chrome api’s or other JavaScript API to do interesting things you wrap it in an interface that looks looks to everybody who uses it like it’s normal built in from the system so this big snap block is calling all the JavaScript hootie-hoo Danny who does all the work but I just see label I’m calling label and using it in a beautiful way so the other powers I’ve talked about codification I talked about the internet API but this last piece to internet with generac with javascript is a language feature that really can open the world for students who really want to go crazy and add some amazing things that weren’t built in to snap and too hard to build in the snap and for example it’s much faster to call a javascript drawing routine than it is to call snap so as in a simple example he does a here’s a seer Pinsky curve which poop and there’s a pretty picture which i think a little bit longer in snapped around but it’s really pretty to do that okay and I think there’s one I’ll just leave a cool demo which is I think it’s live tree I think it’s one that’s the one here let’s see if that works and I’m I say space that’s supposed to go space key that’s supposed to work let me just see run and that space key space key space keys work I might have I might have messed with it so this is a space key and this is our just a really fast thing and there’s that there’s a way to kind of make this there’s a way to change the private I did try this one last feature which is you can have input sliders and have you execute on slider change which means i can go in here and this tree sighs if I slide this notice I’m getting like live coding rather than running it and get the output I can grab it to this very this is also in Khan Academy app if you sing Khan Academy you can grab the JavaScript from change the parameters so I’m just showing you as I’m going and grabbing this number and changing the value being passed into this and now it’s live changing you these things I don’t know what this this may be the angle i know this guy that was is scheduled so is that just beautiful to kind of see how each of primers effects and output you don’t have these in other languages but the fact is because we came to javascript and make it fast we can kind of do other things and change some of this stuff this is just great for your fractals is just too great them of that so lots of things that we have in snap that are great benefits by the way you don’t have to buy the whole bjc package just free anyway it’s all out there but you can just do snap you can you decide to snap as language want to use and not use you know blown to bits and now use our curriculum but you think snap is fun or you can use some of our things and not use you know the book or something so all these things are pick and choose whatever you think is good so I was answering questions I wasn’t being asked to me because i want to show you more demos anyway I just having fun this is a good stuff back go yes ya mean thoughts on how early that’s a really good question that’s a really good question I love scratch so much that i would say every grade school kid in the world should be playing with scratch more than the maze thing i want to have an i’m a big constructivist so I want people to be building their own stuff not just follow the thing to do your maze mr. code.org but having you know now they also have some creative stuff at the end of the things but it’s all about you know open-ended for example the way scratch did their hour of code they said go make a greeting card right there’s no limit to what you can do with your creativity or pictures and sounds that’s my spirit also unless of the kind of wrote puzzle things so I think every kid should see scratch in grade school so by the time you’re in sixth grade before you go to middle school or fifth fifth grade you’re making projects and you’re saving you may not know really all of the cs map but you’re engaged and your interactive and you’re making sharing and all that stuff once you have scratch snap is like scratch it just it doesn’t have the same user demi they have 10 full-time staff or something a lot of you know just to manage the forum so make sure that kids are happy and not putting you know BAM and all that stuff so we don’t have that step but we have a great deal of programs we’ve done a lot of great things here so snap is just here’s functions you already we’re making functions and scratch here’s a

function equity undervalue a little bit there’s a little drop it’s the same the idea they look the same the same blocks and control construction now here’s some leak in the little idea now here’s a list that you can return a value from it a little bit more hits so you can kind of step really carefully and add more cognitively when the kids are ready add some of the details to that the real deeper question is that so many courses mine included assumes the kid has never programmed before right I even say in my first day of class all right who’s program before and there’s some hands and I asked him look what languages and I say thank you for telling me that you’re not supposed to be in this class and they go and I don’t kick them out I don’t make them embarrassed but I say please consider other classes which are better suited for people who have who have program before so by the time the second if their lecture comes around those people aren’t there anymore so I have a room of people who haven’t programmed and I can take you from Jump Street to all the stuff when I do but what if you have this in a high school class where kids might be feeding in from did for Middle School’s some middle schools may have no no programming then find you can do this some have done a lot of programming well what do you do differently so I think that’s a constant challenge for all of us to make sure you kind of can handle that impedance match where you have a large variance of kids with different experiences coming in we had that for our hour of code you know you’re an hour of code thing we have some activities we talked about that earlier today or where’s my earlier today person ever well we had the hour of code conversation we had and what do you do with 12 high schools that are coming in and this one has done snapped before and this group has time scratch but not snap but this group has not done anything so like what how do you make an activity or seller activities we were talking about before yeah all objects I couldn’t find it but all around right so that’s really a challenge I much of I entry question but it but it is a challenge I say early I say you can bring this stuff in early I said this is really meant for down the street never programming for juniors in high school 16 year olds I think if you’ve seen it earlier if you’ve seen scratch and you know that stuff this can be even earlier than that I don’t think the ideas of that crazy yeah yeah yeah ratio good what do we do love it love it no no it’s not one if I’ve chatted student it’s 125 teaching support person in student there’s one ta for 30 students and the lab assistants we brought this up early the lab assistants let me tell you it early the lab assistants are paid by credit so students get credit they just get general graduation credit they get one unit for every three hours they work so I have 70 people i could pay 2,000 people i have no limit to the credit i can give it’s the number i give and is no i’m sorry i don’t give them more you use the BR an allotment no no come on crazy so it’s a it’s a Stuart Regis University of Washington created this kind of undergraduates being involved and invested in the undergraduate education by teaching and being section leaders and that kind of thing that reflected and kind of bubble all around and hit everybody so you have to create a culture or students know that we like the course there’s a role for you all the a students you tell you all these two there’s an expectation if you get an A you’re going to give back it’s like the pay it forward model there’s expectation and a culture that you give back and you get credit and students all do them in all of my a students i would say eighty percent give back and come back for at least one semester and all of their lab assistants that are amazing you know those thieves other people in the room they bubble up to be readers in the bubble one’s the best readers become TAS when you get to be tae berkeley you get full tuition full tuition plus you get paid so you’re twisting covered and you get an hourly wage um it’s it’s a university thing and we somehow found the money for it but that is what works so there’s it’s not just that people doing it because they want that prize they want the gold ring but they all love it they’re giving back because i love the course of course meant something to them and you have to make the course meaningful so you bring a course that keep students love and are making videos about how much they love it and they want to give back and share that with other people and you talk about that the last week in class I’m just shaking and saying guys I really need you to the reason it worked because you had a four-to-one ratio I need you to come back so I can talk about the giving back thing and so I i push it really hard but there’s a culture of it which didn’t i didn’t have like create the culture that’s kind of already culture that and this is but other people mother may remember this is of course from mostly non majors so I’m telling the people who are the chemists and this and the bio people you need to come back to the computer science department and help the next even if you’re not a CS person you can and I have a fair number of my lab assistants a big percentage are not CS majors then his love this thing this somebody who worked away all the way up and she was a bio major she Jake in two or three classes she took it out the next course for major that was it but she still worked her way up to be a TA she was a TA for me even though she had only taken two or three more CS classes but she knew this stuff cold and there’s not a question and this stuff she couldn’t answer but more that she couldn’t but she was awesome she was where my best two days ever so you leave the space for students who are really want to give back to give back and you talk about that culture of giving back which really works great question today yes oh no it’s so much fun no this was

great oh yes indeed thank you right thing Holly for organizing everything Thank You Holly awesome all right wonderful yes I my schedule is my kids say I look about 25 women phones computers

From Synchronous to Asynchronous Postgres with Tornado

microblog from synchronous to asynchronous Postgres with tornado alright hello everybody my name is Mike Rowe blurred and we’re gonna be talking about writing asynchronous code in tornado mainly talk about Postgres database stuff related to that these slides are available online there’s a URL for that and the code that I’m gonna be talking about it’s also available on a public github see that so a little bit about me right now I am the director of Technology which at a start-up which basically means I’m one of the people founded to start up it really means but we make a product called EHR tutor that nursing instructors use for teaching them how to use not EHRs oh my god I don’t believe it no no we don’t teach nurses about object relationship mapping that’s what we’re going to be talking about here I can’t believe I didn’t catch that before yes um no no teaching about electronic health records not object relationship mapping oh but we use the object relationship mapping in the code so that’s all good I am the former senior software architect and on shift and there’s a bunch of people from on shift here so before that I worked at American green jersey from American Greens people here it’s like that just follows me around I can’t leave my previous companies ok so that’s enough about me because it’s not that interesting okay so for this talk I’m assuming that you at least know what asynchronous is hopefully you went to David’s talk this morning because it was really good and who taught you about asynchronous if you didn’t know what it was I’m also assuming that you know what tornado is and that you understand how to talk to a database software so this is meant to be kind of an advanced talk and that there are some assumptions I’m making so I won’t be going into a lot of details about the basics of this stuff but we are gonna go over is I am going to review a little bit of RM some I gave a talk two years ago about object relationship mapping and we’re going to briefly go over a little bit of that because it does play into the code that we’re gonna see a little bit later and then we’re basically gonna do is I’ve written four versions of the exact same code it does the exact same thing but it does it four different ways first it does it the old-fashioned synchronous way and then I wrote the same code that uses a library called Momoko which is the basic users straight tornado asynchronous stuff to do asynchronous i/o then I wrote the same code using the async i/o library and using a library called ail PG to do the same database stuff exact same stuff but using new async i/o in three four and then for the final one I wrote this exact same code using G event and all of these are running on tornado for the web application so we’re gonna talk I’m gonna kind of show you each one of those the difference is if anybody has any you know anybody see something that they’re like why would you do that just blurt it out that’s fine and then at the ending to wrap things up a little bit and that’s basically we’re gonna talk about so object relationship mapping if anybody was at my talk two years ago I’m very opinionated about object relationship mapping code especially when it comes to things like Django’s ORM and sequel object and some of the other ones i really don’t like them but you know and seek welcome means good it’s really super complex but the reason a lot of that complexity comes up is because sequel alchemy is built to talk to every single database in the world and it also provides stuff for handing handling the DDL handling you know building queries doing the pooling and it does all kinds of stuff like that you know that’s all great and a lot of people like that and if you like that there’s nothing along with that especially if you’re trying to build something quickly but when you start to try and build advanced stuff and you’re working on an ORM the ORM tends to really start to get in your way and it doesn’t need to because all Norum really is is about mapping database tables to objects and mapping the relationships between all the know RM is supposed to be and all the other stuff is really fluff on top of that so you can do this a lot simpler than using

these big libraries and the code that we’re gonna be looking at today which makes this a lot easier to talk about the asynchronous stuff because we don’t have all that all that overhead of using an ORM is going to make it a lot easier to see the asynchronous part of it so real quickly a little bit more about that so cyclo fiji to the library that we all use when talking to Postgres provides this wonderful ability to have adapters which will basically take a type in from coming out of Postgres and turn it into a class for you and the records coming out of wrote rows in the table are a type that can be adapted to a class so conveniently you can just go and say take this row and spit it out and it’ll as a single element and it will turn it into a class for you and that is the main thing that we’re using to accomplish the object mapping and then which one I actually didn’t use this today so this isn’t really all that important other than to know that I’ve written it and it works but if you’re doing relationship mapping which this is such a simple application that we’re going to be using to show these examples there’s no relationships and a it’s one table so but in order to do that we basically have a recursive function that goes through a bunch of row results and says hey let’s put these together based on how the relationship should map and that’s what that’s how we did row that’s how I do the relationship mapping and that’s I used this method in production code and it seems to be working fine so that’s that that’s not really what we’re here to talk about we’re here to talk about tornado and asynchronous stuff but before we do that we have to look at how you would do this in a synchronous world so we go over here and you’ll see we’ve got the world’s simplest web application ever written it’s got a single link on here it says new game when we click on it it says give me a name for this game so we’re gonna call this oh hi oh and we’re gonna hit submit it goes back to the original one and now PI Ohio is in there in the database and came from the database so like I said it is the simplest thing you can possibly implement to actually show this so let’s take a look at the code everybody can read the code right the back alright so the important things here we do a bunch of imports imports are only important as long as you make sure you have them all but what’s really important here is our model class this is our model class and it uses my very simple RM a little bit but it’s like really simple so all this is saying is here the fields that exist this is the query that you would run if you want to insert data here’s the query that you want to run if you want to update the database update the table men the actual interesting things are if you want to do get the data out or get all the data out we actually write and provide a method for that and unlike if you’re using no RM you’ll see that we are actually writing sequel which is good if you need to write really complex before you can just take really complex sequel in it returns it but this is synchronous code it is straight up here we are getting a psycho PG cursor that’s the normal getting a cyclopædia cursor we’re executing we’re fetching all this is the build relationship that actually doesn’t matter in this case and we’re returning the results same thing and to get all let me real quick show you so this is the or M most of stuff is not relevant so my admit just does some basic set up stuff to handle the fact that you can pass it and keep some keyword arguments and that they map them into the into underscore underscore dick this handles some of the relationship stuff this just returns a dictionary out so that you can get nice simple Jason encoding and then obviously this is a fairly important one if you want to use the get adder for accessing your things but the stuff that we’re really interested in here is the update which as you can see all it’s going to do is call that update all it does it calls the update query that we set in the class below save says hey if we already have an ID call update otherwise insert it so this is some really simple stuff and that’s literally that’s the entirety

of the ORM it’s you know the rest this is just some stuff for the relationship so anyways this is tornado so oh wait one more important thing here so this game composite right here this is the adapter this is the adapter for psycho PG so the existence of this is what allows us to say hey we’ve got a thing that came out of psycho PG we’re going to turn it into a dictionary we’re going to pass that dictionary into the constructor for a game class and now we have a game object coming out so for and so you have to provide one of these for every single model class that you create you can probably come up with some cool way to make that actually be part of the game class and stuff I just haven’t bothered because this is easy enough and I like to keep things simple now we’re into our controller stuff I wrote it on a single file because well it’s an example in seas so it’s transactional so when we finished the request we want to make sure he commits to the database otherwise nothing’s actually gonna happen to the database if there’s an exception we want to rollback and then here is our actual things we’re going to do so here’s our get which calls the game get all from above and then renders the HTML that you saw that you saw the output earlier here is the there’s the one for the edit you know same thing if no idea is passed in then we’re just assuming that we need to create an empty one to use otherwise we go and get it out of the database when we post we do the same thing if the ID is passed in we get it out of the database and modify it otherwise we go create a new one and modify it we call save save as you saw in the earlier code automatically knows whether or not it is a new one or an old one what based on whether or not the ID exists and then we redirect back to the main HTML page once we’re done so this is literally the entire app it’s very simple for this example for our purpose what is important is you can see we’re just doing a regular cyclo this is cyclo PG we’re starting a tornado IO loop the regular tornado I loop here and we just run it and it runs the normal way the tornado would run if you’re doing something synchronous it’s actually very boring stuff which is good because we’re gonna make it not boring here now so now so what from what we saw it is you know it’s Trent normal transactional code the one thing is is that we’re going to lose some of the advantages of using tornado because that was synchronous stuff so what’s gonna happen is you’re gonna make a request and you can have lots of requests come in but you still have the synchronous blocking on the on the database access code which would be nice to kind of get rid of that and that’s what we’re going to talk about doing next so one way to do that is to use a library called Momoko Momoko is a library written specifically for tornado to do asynchronous i/o with Postgres and i’m going to show you guys the code to do the exact same thing we just did synchronously but this time we’re going to use to do it so the first thing is we had to change in order to do this first thing we have to do is we have to change our ORM a little bit so I basically have subclass the previous one that we had this same or in that we had before but the only the difference here is now are updating our save methods our co-routines and what that allows us to do is by doing that now we’re going to instead of just calling our execute method now we have to yield it and the nice thing about Momoko is we can just say here’s the connection we’re gonna rather than normally before we got the cursor now we’re actually just saying yield off the database execute this and we’re passing the cursor factory here as a parameter instead of getting the cursor and doing the stuff Superboy it’s basically Momoko has a nice way of kind of shortcutting those two things otherwise you have to get the cursor yield that and then yield the results this is just a weighted shortcut that process of having to do

two things and and that is the change that we have to make it there isn’t me there aren’t many changes that we had to make at this level to do that you’ll see everything else is the same the queries have not changed from there from the original version what has changed though is our get and our get all just like our save and update into ORM levels it getting to get all have also changed in the exact same way with the yields here here now notice we only in this one we only have to put a yield here because this yield is saying hey this is a future and then when you call fetch all on this future inside Momoko it says oh okay go and handle that and return an actual value as the results and so the rest of that is handled under the hood so you only have to do the yield in one place here the other change is we had to make these all po routines on our controllers we needed to yield the results of our calls to the model now instead of making a straight Club the model now they have to be yielded instead and then down here we have to do a little bit of magic to get the database set up properly we have to create a pool because since we’re doing any synchronous stuff we’re going to potentially be using more than one connection at a time at the database now we have a pool of connections instead of a single connection this is just some stuff that you have to do to tell Momoko to load the get to to actually create the pool and stuff and then once you’ve done that this is a little hack I had to do in order to get the composites to register you could there’s you’d have to do some work in Momoko to actually allow it to call the register composite under the hood because it’s assuming a synchronous connection here and we have an asynchronous connection so I just make a second connection and once cyclo PG know what’s happening here is the in order to register the composite has to query the database and get the OID out of the out of Postgres for the game table in order to know to map those properly so in order to do that it means a database connection that’s the only thing it’s actually using us for the rest of that if that’s storing it in the Global’s of the cyclope g2 library so you don’t you can use psycho PG to with multiple different connections and all you have to register the composite once when you do this little equals true so that’s kind of a hack I had to do to get that to work you couldn’t fix that hack I just didn’t have time you’d have to go and you would have to go and work in the Momoko library too to actually kind of do register composite differently so I have to actually talk to the author and we’ve talked about how to do it we just haven’t written the code well no you what you would do is you would write a you would write a Momoko version of register composite that would go and do it so you know there isn’t as you can see there’s not a lot of differences here one thing that you may may have noticed was that all the transactional stuff was gone and that’s because by default when you go into asynchronous stuff the default issue is you’re now in Auto commit instead of transactional that doesn’t mean you can’t do transactional you can do transactions you just have to manually do them yourself which is kind of a pain in the butt but it can be done I didn’t bother to do it for this one because it would have made the code Messier and I was running out of time to do it but it is hard it makes it a lot harder to do the other thing that you probably saw is you have to yield and use Genco became pretty much everywhere any place you want to make something asynchronous you have to do the yield and Genco routine and the problem is once you’ve done that you cannot really unyte asynchronous things so you once you’ve made it a a synchronous thing you’ve got to use it asynchronously it won’t work the old synchronous way so you can’t mix match very well you have to go one way or the other with your stuff the other thing that is kind of sucky about this is let’s say that you were one using your models that you’ve written and you want to use them in a offline module as well as in your web application well now if you’re using multiple and you got

running for NATO i/o loop in your non web code and that’s kind of not the world’s best solution so there is a solution to that problem and that’s when we’re going to talk about next which is we could use async i/o and I hope you do and so instead of relying on Momoko and relying on tornado specific stuff now we can rely on stuff straight out of the standard library from Python 3 for AI OPG is a library for doing asynchronous i/o and Postgres No it uses psycho PG as well and you’ll see it my ide is not set up for three-four and it thinks there’s errors all over the place when there’s a yield from so so once again we have okay so once again I’ve taken the regular by regular or M that I created made a subclass of it so I could override update and save again this time you’ll notice that instead of doing a gender routine out of tornado I’m now using the standard library async ioco routine so there is nothing in here is no longer core Nadeau specified anywhere in here so you can use this outside of tornado which is a good thing the other thing that is different from the Momoko one there’s two other differences here you use yield from everywhere instead of you there are some differences between what yield does and what yield from does and they are like super technical detailing things that half the time I even forget what they are but you need to use guild from here yield will not work if you try to use yo you’re going to get all kinds of nasty exceptions the other thing is is I have if you’ll recall that was on one yield and the other one here there’s two yields and that’s simply because first you have to get the cursor and then you call execute on the cursor just like you would a normal psycho PG so this one actually looks in that way it looks more like the original code with the exception of yield from x’ instead of just calling the functions and then the same thing down here except also when you get the results we have to yield from the results as well here so the results are still a future and it’s no longer a future until we get down here where we’re actually using the results so when you’re doing so in asynchronous stuff when you’re doing a when you’re doing anything asynchronous all those yields are returning all those yields are yielding you know generative means we’re using generators here what they’re returning each time you call the yield is they’re returning a what’s called a future object and the future object basically keeps getting Pat gets passed around and stuff and that’s what actually allows the asynchronous part to happen but when you get to a place where you’re using the value as opposed to just kind of passing around this the first time you go to use it it goes and says hey evaluate evaluate it if if the asynchronous call has not completed yet right because it’s a call to the database it’s a call to the database it may not have been completed yet then we’re gonna sit here and wait and give up execution to some other asynchronous piece of code this is where the asynchronous part comes in so your code will run straight through it’ll go and tell it to run the database until it gets to a place where you’re using the results from your yields in something useful and then it’s gonna sit there and wait until the results actually come back on the database but it won’t block it what I’ll do is we’ll wait and then it’ll go and wait for the results from another it’ll go and look at the other things that you have asynchronously and try them as well so that is so this is act that’s where the important thing happens is when you actually go to use the results that’s what makes these things that’s what makes the all the asynchronous packages work we’ve talked about both Momoko and regard so once again as you can there’s very few changes we have to make except from here’s our yield from –za ghin the exact same thing that we saw just a minute ago you have to yield from the cursor yield from the execute yield from on your fetch all these are literally they a OPG was very they’ve tried to make it look as much like regular cycle PG as possible so you call the cursor function to get a car cursor so you call execute

execute a query you call a fetch all together to get the results and then you just yield from all of them and we’re doing the same thing I’m to get oh then the only other thing nothing else has changed here from the previous one except now we’re doing yield from sand study yields and one thing you’ll notice these are still Genco routines because we’re inside of tornado and for NATO is expecting the tornado stuff and tornado has some adapting that it does automatically under the hood that says hey this is a this is an async IO future but since we’re trying to have the to mix you’re allowed to take the async IO future and return it into a tornado co-routine and it works it works so the okay so here’s where the other big changes in order to get the set up to work in order to actually get the connection to work the connection is also a sinker the connection setup stuff is also asynchronous so what I had to do to make that is make a KO routine that does the database set up it does a yield from the pool in order to create the the database pool object which is basically it’s a connection object it works while I’m at you can see I used it as a substitution for the connection object in psycho PG HS and it’s actually a pool under the hood and or do that so we have to call this install which what this is saying is take the async IO loop and install it on the tornado loop so that the two loops are basically merged together now one can get the event loop we can run until complete this DB set up on that event loop which basically goes and says okay now we can go run this thing to get the pool all set up then we’re back to everything normal except for we’re now running loop run forever instead of the normal normal start app that we would do for tornado you do have a different thing there starting and that is what we’re going to do to make it work on async Iowa all right so one thing the transactional is even a little bit harder and async IO moco has some a couple of methods that kind of make the transactional harder and AI OPG they say run I call select you know to basically do a begin transaction and transaction as an actual query and that’s how you would do transactional there so transactional is a lot harder here once again exactly because and it makes sense if you think about it the rug because you can’t actually do that that way because you have two different content you you could do that and you just if you just blindly do that try to do that the asynchronous library by default is gonna go and try and get two different connections because the pool every time you call the pool saying get me a free connection and transactions run inside of a connection so if you have two connections you’re gonna have two different becoming them in two different places so that’s going to that’s gonna create problems for you there are like I said there is there are some ways around it for instance the Momoko library has a function call and basically what it does it says take all your take all your calls that go that are going into this transaction put them into a room an array wrap and it wraps basically wraps around it begin and end transaction and dumps the whole thing to the database once and then waits for the results from each of the queries as how Momoko handles it problem is is that won’t work particularly well if you want to have transactional stuff happening in three or four different functions and our those functions going to know that they’re communicating with each other so that creates so the transactional stuff when you’re getting the asynchronous stuff it makes up it’s hard once again you have to do the yield and use the async i/o co-routines just like we saw the floor you have to do the event a little bit of a vent loop switching but the nice thing about that is now because you have because your model code is written with async i/o you can run a you can run it in any place that you’re running an AC that you’re running an async IO event loop so you can run your async IO event loop in your code that is going offline and doing offline processing stuff and still using your model code without having a dependency on tornado um the

other thing that is nice is if you are a sequel alchemy user hey OPG the library that does this provide some monkey patching to allow it to work with sequel alchemy I have not tried this but I wanted to bring it up because a lot of people like seek welcoming there’s nothing wrong with it I have no issues with sequel alchemy and you can use it with this um the other thing is and I think I mentioned this when we were looking at the code the yield from is really important when I started trying to I spent two hours realizing that I was had yield where I need yield from and made it really hard so yeah you need to use yield from when you’re using async I know and use regular yield when you’re using Momoko those are very important ok so now the last one that I wanted to show you guys so last one I’m going to show you is using G event so if nobody knew you can use G event with with ug event with tornado and get asynchronous stuff out of it one thing you’re going to notice is there is no special or I’m code required for this so I have an async I own and Momoko and the regular synchronous stuff but I don’t need one for G event and that is because the way G of n is written G event for those that don’t know uses the whole green thread greenlit concept of things so you’re basically creating not real threads but little mini threads that are doing the work and the nice thing about that is G event basically does a little bit of monkey patching you have to do this at the very top in order of your application in order to actually get it to work right but basically what that does that goes and says hey any time I’m going to go and do something that will be normally that we would want to have asynchronous stuff go ahead and release the it’s not a guilt but it’s basically release the lock and viewer the normal green lid key event kind of pseudo thread and stuff that it works similar to threads but the thing is is you’re gonna see nice thing about this is the code is the exact same code from the original version get all the get everything is exactly the same we can do transactions normally commits rollback all that stuff the main places where we have a change the only changes we have its here we are in our get we’re using the regular tornado furnace it’s not a cobra key but an asynchronous request and then what we’re going to do is when we get the web request we’re going to say all right go spawn a green lamp to do this work and we go off and we do the work and we’re done and we can do the same thing here and the same thing here and the work is done in these very simple functions that are basically so it is my mind this is a far I is this seems like a much easier way to understand things it’s not true asynchronous in the way that the other two methods are but it’s a lot cleaner to read I think so the disadvantage here of course is that inside of inside of this async task everything is happening synchronously so if you went unlike our other ones we wanted to do multiple calls to the database each call to the database is going to be synchronous inside this asynchronous task whereas if we were using the synchronous code that I showed you earlier you could do every single database call as a separate asynchronous query and then you could wait we have one wait for the other one and B and have the asynchronously down to a lower level so the thing it’s asynchronous with this is what will happen though now is when this goes off to the database it’s going to give up it’s it’s going to basically give up its lock on the the Python interpreter and let other stuff running so it’s a slightly different model to be honest I will tell you right now I didn’t like performance tests any of these so I have no idea which things

work the best and what the performance trade-off is of doing it this way as opposed to doing it the traditional way but I was basically the one to present you guys with the options of how you can do it the other thing is you would probably want to actually put this in some sort of pool if you were doing this for real because otherwise you’re still actually one running off of a single database I’m a single database connection so this is not done properly for using the G event the right way but the point I was trying to make with the G of n example is it is much it’s a different way of doing it than the other ones I showed you and it’s simpler in a lot of regards because all you have to do is do this as opposed to populate you know for co-routines everywhere and it’s a very big paradigm shift to do a normal asynchronous stuff as opposed to the and basically all things I just said are repeated here I think you only have to modify your controllers the models were exactly the same as your saw which is nice the nice thing about this is if you want to mix synchronous and asynchronous code you can do that without a problem because you have a modified your models and flowing have to do your controllers to make the asynchronous stuff work you don’t have to have the co-routines everywhere and as I mentioned you can’t it’s not you can’t have easily lots of asynchronous things going on inside of a thing unless you spawn you have to spawn separate gremlins for everything you want to do asynchronously in order to get that to work so if you otherwise inside of the actual Greenland everything is synchronous so yeah the other thing is is since we’re not using the co-routines you can run the model code without the requirement of having an IO loop at all I think I really thing inside that asynchronous task once again it’s synchronous so you can use transactions just like you normally would because it’s all synchronous inside of there and the other thing is is you can use seek welcome you with this whoops okay so that blog link at the bottom is I will shamelessly tell you that I figure out how to do the G event stuff by reading that guy’s blog and copying and pasting it into my code and seeing if it work and it work so so that person’s blog is actually the go-to thing for figuring out how this works so I figured I should plug the person to actually go figure out how to do this for me I did not figure this out on my own okay so so it kind of in summary here who routines are hard it’s they’re easy to mess up they are it’s a paradigm shift you have to really wrap your head around it it’s not easy to do but the advantages you get the asynchronous stuff out of it now mind you I’ve only been talking about asynchronous from the point of your web request talking to the database as you know earlier today if we went to David’s talk he showed some asynchronous stuff from the front end side of things where where he was doing WebSocket and ancient Christy was there and that is a totally different it’s you know it’s the same kinds of things but it is a slightly different thing once you map put all those things together and you start to build a really complex that you get a lot of things but this this what we’ve really only talked about here is the backend side of doing asynchronous stuff not the front-end side and the methods that we talked about here even though they’re using we were specifically using psycho PG if you are switching it out with Redis or god forbid or whatever other thing whatever other thing whatever other things that you like to use the concepts are basically the same yes I’m opinionated I admit it so you know there are three choices here that I showed you and each one of them is good in their own way the Momoko stuff works on Python to seven as well as Python three four so if you’re stuck in Python to seven land you can use that async i/o gives you the ability to use stuff without having dependencies on tornado you know and then there’s the chi event model which makes things like there’s a lot of different ways you can accomplish

the same thing and I wouldn’t say that there’s a right or a wrong way I haven’t I have not used this in production yet I have only been using this to build some tests and samples and try and working on some projects some side projects with it so I haven’t really decided which which one I even like because I see advantages and disadvantages to all of them you know the ACE the async i/o method you can ng event you can both get to work with other ORM s particularly sequel for me which is a good thing you know I am NOT a huge RM person so that wasn’t a big thing for me but a lot of people are and there’s nothing wrong with that with caveats we happy to discuss those and the other thing is that you know you don’t have to necessarily be tied to tornado here you can use the async i/o stuff with whatever your favorite other framework is and G event will also work outside of tornado as well so anybody has any questions I’d be happy to take questions there’s lots of contact information for me feel free to contact me and whatever way you see fit and like the most any questions yeah dad can call him by name so going to auto commit just seems like a huge step backwards and I can’t wrap my mind around the implications for that but have you thought about that at all so in the one sample one of the things I was doing when I was actually trying to build something for real with a real project with this what I ended up doing is I created two connections one was a synchronous connect and this is before this was a my first start playing with this so I haven’t tried using some of the transactional things that you can do but the way I first decided to address that problem was I created two connections one was a synchronous connection and one was an asynchronous connection and when I wanted to read from the database I use the asynchronous connection and when I was doing a post I used the synchronous connection on the post and so everything was transactional inside there any more questions about anything what universe whatever and forfour was back there the yield from fetch all in AI OPG mm-hmm you had to yield from the cursor creation the execute and the fetch all yes but I don’t quite understand why I figured once once you got to the point of fetching all I thought the data was on your client machine in the psycho PG world psycho pin just simple psycho PG – so I don’t understand why the fetch all would be asynchronous so in Kop G they have decided because if you saw on the moko that was the case in the example code in mocha that was exactly what you what you said it was when you did the fetch all it actually went got it and a OPG case they’re actually waiting until you use the results fast so the fetch all is not as returning once again another future does be so it’s delaying it until you’re actually using the code inside of there so just delayed there’s basically they’re chosen to delay it to the absolute last possible minute and you can the one thing and async I owe that you can do with that fetch all that you fetch all normally in psycho Fiji returns a list in the case of a OPG it is actually returned because it’s a future and it’s a generator you can actually act on it it’s a generator so you can take that you put that fetch all in a for loop and it’s going to be treating it as a generator not as an iterator so it’s not you’re not iterating on all this trader aiding on generated now it’s good it’s still using the it’s just like fetch Hogs doing that but it’s doing it because even if you run fetch all fetch all doesn’t actually go get everything either thing it goes and gets them in batches of whatever the batch size is set to encyclopaedia any other questions okay thank you very much

Nikita Popov – What changed internally?

so yeah hi everyone my name is Nikita and I’m one of the people who works on the PHP interpreter and today I’d like to show you some of the recent changes that have been implemented in PHP internals and in that regard I’d first like to mention that we have an upcoming new major PHP version so PHP 7 is coming in about two weeks at least well if everything goes as planned but I think chances are actually pretty good that you’re going to see release on this date and I think there is a lot of excitement about PHP seven at least more than new PHP versions usually tend to get and after all this is the first major version in over a decade it has many cool new features personally I’m mostly excited about the typing improvements so scalar types and return types but really the main selling point of PHP 7 are the performance improvements so I here are some benchmarks which have been made by the HSV empty and these benchmarks test the performance of different PHP runtimes against a couple of popular applications so here we have Drupal and MediaWiki and WordPress and in blue is PHP 5 in green as PHP 7 and in yellow is HS VM and what you should be seeing here is that PHP 7 is generally something like two or maybe even three times faster than PHP 5 and this improvement is not just in terms of throughput so requests per second but also in terms of response times and I think this is a pretty significant change so essentially we means yeah you need only half as many servers to run the same application as before and what this talk is about is really explaining where this performance comes comes from because yet not not out of the blue a lot of changes have happened internally to get this kind of result and before I start talking about the particulars of PHP I’d first like to give to give you a general idea of how you optimize low-level applications so I think yeah if you optimized PHP code you will be mostly looking into making things like database queries faster and generally looking at inputs and outputs if you optimize a low-level application it’s actually pretty similar you are not very interested in optimizing computations because CPUs are like very good at adding together integers very fast what you’re interested in is optimizing memory access patterns and from that point of view there is basically if really thinks you want to look at first one was reducing the number of allocations so the allocator is the piece of code which you tell well I need um 50 bytes of memory and it ghost looks into the memory space and says oh yes here is a piece of memory you can use and it turns out this is a very expensive operation so finding a suitable block of memory costs a lot of CPU cycles at least unless you like want to waste a lot of memory and this is so expensive that PHP 5 spends approximately 20% of the CPU time doing nothing else but managing memory and well we’d like to change this change this and use this time to do something more useful so that’s the first aspect the second one is you want to reduce memory usage so people commonly think that optimizing for performance and optimizing for memory usage are like totally separate goals so there is term of the performance memory trade-off where you can improve performance by increasing memory usage and that’s true that can happen but in many cases goalies actually go hand-in-hand and the reason is that memory access has very

high latency so in the time it takes the CPU to do one request the main memory and get the result back it can do like hundreds and hundreds and hundreds of integer operations and for this reason the CPU contains a cache here–he so it has a very small level of 1 data cache which is well it’s small but it has a short access latency and then there is a level 2 cache which is larger but also has higher latency then there is a little free cache the same thing and if your data is not in any of these caches then you will have to bite the bullet and do a main memory access and this is how it looks like so these are really really expensive and for this reason optimizing memory usage also improves performance because if you have less data more of it is going to fit into the caches a kind of related point is that you want to reuse the amount of indirection and indirection is basically the case where you have a pointer and this pointer points to another pointer which again points to a pointer pointing to a pointer pointing to a pointer pointing to something you actually might want to have so you have to go through a lot of intermediate steps to get a data you want and this is I think bad for quite obvious reasons so every time you follow a pointer you are doing a memory access and that’s that can be slow you said you like to have the pointer from here right through there and yeah just so you know and this picture like it’s not a joke this is how php5 works in both places and we’d like to improve on that and this brings us to yeah the actual topic so how do we apply all of this to PHP and if you talk about PHP internals the first thing you always have to mention outset values because this is pretty much the most important data structure we have it represents all values in PHP from boolean integers to strings and objects and will at the score at set value is really nothing else from a combination of a type and a value and here on the right-hand side you can see the in-memory representation so it has a small type tag and some space for a value and a couple of empty fields so yeah you know this is probably not the whole story yet and if you know if we now consider a like more concrete example so here we have very simple code we say it’s simply say a equals 42 then this variable a is going to be represented as a pointer so it’s going to be a pointer to itself value and then it this point it’s at value and in this case it has a value of 42 is an integer but there are also many other value types and they can be split into two categories so first one is simple values these are small and fit directly in here and then there are complex values like strings arrays objects which are too large to fit directly to the value instead you have to use a separate complex data structure and you can only store a pointer to it and if you have complex data structures then the reason additional consideration you should make namely what happens if you do an assignment so here we have extended the code a little bit we simply do an additional assignment B equals a and as you should know in PHP everything uses by value semantics at least by default so every time you do an assignment every time you pass an argument every time you return the value this is by value not by reference and if you take by value semantics like literally it means you have to do a copy every time you perform an assignment or pass an argument you have to copy the value and that’s going to be a problem if your value is like an array will the million elements it’s going to be really expensive to copy this kind of data structure so on gish piece off solves to this by allowing you to share values so this is done by adding a reference count reference count just says how often is this value shared and then this assignment can be implemented very easily by adding another pointer so now there are two variable pointers to

one set value and we avoid all kinds of expensive copies by doing that that’s it for PHP 5 so that’s the the basics of how value management works in PHP 5 in PHP 7 the the idea of sharing values stays but we want to add one additional consideration to it and that’s well sharing an array makes a lot of sense because arrays are like huge structures and copying them is very expensive but sharing an integer so integer are very small and it’s much cheaper to simply copy an interview then try to share it through this actually very complex mechanism so what we do is say we move the reference count from the set value into the complex data structures and say these can now be shared directly and by doing this we make the subtle structure itself much simpler so now it’s really only a type and value no more reference counting and because it’s no longer a reference counter this part is no longer shared so each variable gets its own set value and end result is something that looks like this so you have variables each variable has its set value a separate set value but they can have shared complex data structures and yeah that’s really the the main change in pH P 7 so why is this good thing so here is a side-by-side comparison I’ve split it up into two parts first for simple types like integers boolean’s and so on and for complex lives for the simple types mmm the end result is a very compact so in PHP 7 you simply have this sub value slot just to type in the value and nothing else so you really you can’t make it much more simple than that in PHP 5 you had to do more things so first of all that that value here had to be allocated which is slow it also had to be freed again which is also slow and you have the arrow and there so that’s one level of indirection and of course it also has all this additional information for managing memory so we have the reference count but also a garbage collection buffer so this GC buffer is used for collecting recycle references not very important for the dust but that we have to store it and now we no longer have to do this at least for the simple types for the complex types we can’t make it quite that optimal because the complex data structure and still stay is basically the same you can’t really change anything about that but still we remove one intermediary level so we have dropped this container in the middle and this means we go from two allocations down to one from two levels of indirection down to one and the overall size of these structures also reduces yeah so that’s like general values in general now I’d like to talk about some of the specific types as well so I’ll start with strings because strings are the simplest of the complex types and in PHP five string a string set value basically contains two bits of information first one is the length and second is a pointer to the actual characters of the string in PHP seven the some changes a bit so we have now replaced so we know use a pointer to a custom string structure previously this year is a normal c string and this here is a custom structure we have implemented especially for PHP it still contains the character data at the bottom it also has has length and it additionally stores the hash cash so on well PHP uses hash tables a lot I will get to that in a moment and we want to really we want to avoid recomputing this hash value all the time so we just store it in here and of course we have this reference count header which is now present in all complex data structures

and the nice thing about this is that we can share strings independently or set values for example it’s now possible to share a string between a value and an array key previously that wasn’t possible we always had to copy a copy the key when you like add an element of an array now we can simply reuse the same structure and well yeah that also brings us to erase so everything PHP are implemented as hash tables and like a short info on what that means so the basic idea is that you can index memory only using integers so if you want to use a string key you first have to convert it into an integer and this is what the hash function does and then well here we have a sample key X Y Z it happens to hash to index 1 for whatever reason so we insert the bucket at this position position so this bucket contains the array key and also contains some kind of data so the array value so the data will be again a pointer to a set value if we insert another key then we’ll add another bucket with different G so here it’s foo however the interesting case is what happens if you have a collision and why do you have collisions well the space of all possible strings is essentially in finite and the output space of the hash function is very small so in this particular example we have only four possible output values so at some point you’re bound to have to have a collision so we’re two strings hash is the same index for example here we have key bar also hashes to index free and now we kind of need two buckets at one position and we solve this by replacing the individual buckets by a linked list of possible buckets and if you now like doing array look-up on this structure for key bar what you do is you find the right index go to the first bucket check the key you see it’s not the right key so you follow to the next one check the key again and then you have your resolved that’s like basic hash table structure in PHP there is one additional requirement namely that ERISA audit so in I know – if you iterate over an over a dictionary you’ll get the keys back and essentially a random order if you iterate over an array in PHP you will get the keys back and the exact same order and which to them and all to support this feature php5 stores an additional W linked list which manages this order and yeah so you can simply walk this list from head to tail to do a forward iteration or from tail tail to head to do a backward situation and this is the main thing that PHP seven tries to improve so we want to avoid having to solve this doubly linked list which means we have two pointers we need to store two additional pointers for every bucket what we do instead is well basically just look at this image and see that these buckets are already in the right order so if we can like put them in this order into memory we can simply use the memory order to determine the iteration order and to make sure the they are actually laid out like this we simply replace the individual buckets by an array of buckets so here we now no longer have one allocation for each element instead we have one large array which contains all elements and we can walk this array from top to bottom to do forward iteration or from bottom to top to do a backwards iteration so this solves the problem of storing the order but also has the additional advantage of not requiring and that extra allocation for each element which is one of our goals and it has also the kind of nice side effect that you can no longer use pointers into the structure so you no longer can no longer have a pointer to a bucket because this array isn’t fixed if you add more elements then it will have to be extended and if you do this extension operation then all pointers that previously and went into it will become invalid so we can no longer do

that and what we can use instead this is simple indexes so we don’t say yeah you have well pointer to this element we simply say that this is element 0 and next one is element 1 which is just a necessity of the new design but has the nice side effect of indexes being only half as largest pointers so we save additional memory on that and yeah so that’s I think the most important change in this area here is a table with some like more particular numbers and the interesting parts are the per element counts because the rest is well pretty much relevant if you have large arrays and the main difference you have here is in PHP 5 you have to do an allocation for every element HB 7 you no longer have to do with and similarly the the size of each element goes down from 80 bytes to 36 so arrays basically get half as large and well yeah that’s still kind of a lie it makes PHP 5 look a lot better than it actually is and the reason is that and we’re doing an unfair comparison here so the numbers for PHP 5 do not include the array values the numbers for PHP 7 do include them and the reason is that it makes a lot of difference in PHP 5 were they whether you have an array where like each element has one shared value or whether you have an array where each element has its own unique value and if you have unique values which is probably the more common case then the numbers change a bit so you will have two allocations per element and 112 bytes so in practice PHP 7 gets a lot better at managing arrays so memory usage goes down a lot so yeah that was a recent general I’d like to highlight one particular optimization namely immutable erase and well there is a sample code here it creates a nested array so we have an auto auto array with 1 million elements and each array element is an inner array with elements 1 2 3 4 5 6 7 8 and if we now do some like basic measurements on this code in PHP 5 is going to take up about one and a half gigabytes of memory so this structure will be huge and it will take over 2 times 2 over 2 seconds to run this code interestingly most of the execution time is spent destroying the arrays not creating them for whatever reason in PHP 7 the numbers go down quite a bit so the whole structure takes up 400 megabytes it’s still pretty large but better and the runtime drops to about 350 milliseconds so that gets a lot better but really these are just some the generic array optimizations what I want to want to highlight here is what happens if you enable up cache in which case the both memory usage and the run times go down by another factor of 10 and what happens here is this immutable array optimization so app cache looks at the code and if it finds any kind of constant array so which occurs literally in the code it will make it immutable and this means it will be stored in shared memory and can be alight freely shared without even doing any kind of reference counting operations and so the difference between these two columns PHP 7 and PHP 7 with up cache is essentially that in the former case we have to copy this inner array all the time and in that case we simply share it so um last type of interest objects I’m I’ll not talk about objects much I have simply like dump the php5 object layout up here but I’m not going to explain the details of it basically the important part is that you have a handle the handle can be used up to use to look up an object’s floor bucket which is responsible for managing the memory of the object it’s really useless structure and it contains the pointer to the actual object and this actual object then has things like information about what class it belongs to and what kind of properties it has and the properties are stored in a separate table each

property has one slot and yeah slots are simply the pointers to the property values and in PHP 7 we kind of cut down on this a lot so this this object store buckets thingy gets dropped entirely and these two values are in line in here and we also combine the object with the properties table so we simply concatenate them so the end result looks like this the the upper half of the object stays pretty similar values are much the same still have a class entry and and yeah plus + 3 and so on and properties have now been directly appended to the object so we no longer have a separate allocation for this but it’s being combined into one and of course as always in case be setting the property values or the set values are embedded and no longer and so you no longer have a pointer to that value but you have the set value directly embedded and if you again do a comparison here I think the significant result is the number of in directions so we go from four down to one previously you had to follow through a bunch of different stretches to get a property value and now you can simply well really you only have to do a single memory access to get a property value Oh also interesting point curious while the size of the object itself goes down the per element size so which is four objects the number of properties the property size goes up which is more kind of weird but the only reason that goes up is because this is once again unfair comparison because left column doesn’t include values right column doesn’t do them but it’s one of the rare situations where you can actually construct artificial PHP code where we end up using more memory in PHP 7 so on the last type I’d like to mention are integers so there is really not much you can change about an integer the only thing you can change this change the size of it and this is what has been done and so what has changed this integer support on the Windows platform so on Linux and Mac OS everything is the same so introduce our 46 bit if you are on a 46 bit operating system but on Windows you always only code is for it to bit numbers it didn’t matter whether your system and your CPU supported 46 bit numbers you could only use for two bits and this has changed now so Windows is now also a first-class platform with the same integer size as everything else but late but well and that was it’s about values and now I’d like to move on to like a completely different topic namely the PHP compiler so the PHP compiler is the piece of code which turns this source code into action to actually an executable opcode so these up codes can then be run by our virtual machine and this happens in two steps the first step is lexical analysis so this step will inspect the source code and group it into basic tokens for example it detects things like well dollar a is a variable end before t2 is a number and echo is reserved keyword but it doesn’t understand any of the semantics of the language so it doesn’t know that something like a equals 42 is an assignment it only detects the individual parts of it and yeah so that’s the first step and the second step which combines parsing and compilation directly turns this stream of tokens into the final and instructions which are runnable in our virtual machine so this level then includes things like an assignment instruction or additional instruction so

that’s the PHP 5 video of things in PHP 7 we have introduced an additional intermediary step so this intermediary step is the abstract syntax tree and this tree basically captures the semantics of the language so it knows what an assignment is knows what an echo operation is without actually going down to the specific details of our virtual machine so it doesn’t care about instruction scheduling and allocating temporary variables and whatever and the reason why we now have this intermediary structure are for once actually not performance reasons so it can be used to generate better instructions but the main idea behind this is improving maintenance for the compiler and not constraining the kind of language features we can implement by having a shitty compiler pipeline from like the Stone Age and well here I have added a couple of annotations how you can get at these these intermediate outputs so the tokens are directly exposed by the token get all function which should be part of every same PHP build the syntax tree isn’t yet directly available you have to use an extension for that for example this one and the up codes can be dumped using PHP debug – P so that’s also directly available in PHP 7 when PHP 5 you had to install a separate vlg extension for that and well after compilation is done we have to actually run these instructions that we have generated and that’s going to be the next topic so the virtual machine first thing I’d like to talk about a stack management so here is a like very simple piece of sample code it just defines the function foo takes two arguments ask them together and returns the result and then we call this function with two arguments one and two and this is the code that will be generated for these operations so at the top you have um the instructions for the call and the bottom you have the instructions for the function body and now I’d like to walk through what happens at run time when this code gets run gets executed so here is the virtual machine stack which is essentially I’m just the place where all the current execution status managed and the first thing that we do is execute these same value instructions which will which will push the arguments of the function onto the argument stack then next operation is the do F call do have called traits call frame for the for the next function call and this call frame has three parts so here in the middle the execute data is like some general function about general information about the currently executed function then before it here is space for temporary variables so till the zero was temporary and at the bottom we also have a couple of slots for like real PHP variables like mb and if we now run the function the first thing that happens is that we receive the arguments and what this does is copy the arguments from the argument stack into the corresponding variable slots so we have now duplicated this information and finally we can perform the actual addition which will write the result so free until our temporary if we then return of course all of this gets dropped from the stack again and we’re back to back to the beginning so yeah this is PHP 5 what you should mainly see here is that the arguments are duplicated so we have them here on the argument stack and then down here again on the variable slots and we want to avoid that we don’t want to duplicate information so in case B 7 and bytecode looks very similar only one small change namely we never start with an init F call which pushes the call frame right at the start of the call it still has the same structure only the order changed a little bit so temporaries and at the very end and if we now send the arguments these arguments will be directly written into the correct positions for their variables and this means that when we actually call into the function we can skip these receive operations because the arguments are

already where they are supposed to be we don’t have to copy them again and we’ll finally the additional instruction and gets the result so here we have avoided duplicating the argument this is like a nice optimization but it’s not completely transparent so this will this does change the way that HP behaves mainly like if you get a debug back trace of your function and you have modified the your the variables which correspond to your arguments then the debug back face will make it look like you actually called the function with totally different arguments so that’s one of the things you may want to look out for if you debug hb7 code so don’t trust arguments and actresses they can be wrong so that’s one virtual machine optimization another one are improvements to the instructions we support so there are many of these I have picked out the particular example namely inlining internal functions so there are like a couple of commonly used to general functions like stolen or type checking so is Boo is int and called user phone call user func array these now support have so we have now added instructions which perform these operations directly to the virtual machine and we no longer have to generate function calls for them so instead of generating a call to the stolen function we simply have a mr land instruction in the virtual machine and what kind of sounds nice but there is one problem in practice this only works in mobile scope so if your code is not named spaced and the reason is that if you are in the namespace like here we don’t know whether this sterlin function is really stolen or if it’s overridden function in namespace and so we can’t apply the optimization if you want to apply the optimization you have to use a fully qualify thing and and this is how you see what kind of applications we use to measure the results of optimizations and we use applications like WordPress which are like kind of not the most modern type of code and for WordPress these optimizations work really great but if you have like your Symphony code then they won’t apply at all so yeah I find that a bit sad that our baseline is old code but anyway so last which some machine optimization I’d like to mention our global registers so there are two pieces of information which we use all over the place in the interpreter the first one is the execute data which is the call frame the second one is the up line which is the currently run instruction and we can now do a really simple change here you no longer have to reload these value from memory so we don’t have to access the executor Global’s to get at the cold frame it’s simply always in that register and it also means that we don’t have to save and restore these values whenever we do a function call at the sea level so this is a like very simple change so in theory just two lines well it has a pretty significant impact on some platforms so on x86 there are and not many registers and so this is pretty expensive because two registers will no longer be usable for any kind of computation but on other platforms like PowerPC and this two line change if something like a 30% execution time improvement okay alligators alligators are very interesting I’m going to skip all of them and talk about op cash instead yes so there are two new features and up cash that I’d like to highlight the first one is a new file based caching mechanism so normally up cash uses shared memory and now you can also additionally or alternatively use a file by file based caching mechanism and it’s probably not useful for the kinds

of applications that you develop but this is something that might be beneficial for shared hosting we’re using shared memory is problematic for security concerns so if you lose something like su PHP then they can’t use chart memory but it also might be useful to avoid like really catastrophic response times after a PHP restart or after a cache reset or maybe for deployment but well not quite we yet what this is going to be used for but one of the main ideas that might improve performance for shared hosting and here I did some very crude benchmarks just running sequential WordPress requests and the result is that the file cache is 2 times slower than shared memory but it’s still 4 times faster than having no caching at all so if you can’t use shared memory this is going to be a very large change that’s one of the features the second one and also the last thing I am going to talk about now our support for huge pages and what this means is that up cache provides a new resetting and if you enable it and the code segment the text segment of the PHP binary gets remapped into huge pages in order to reduce misses in the TLB cache and what this means is so here is a like picture from the start of the presentation the CPU cache here he this cache here he doesn’t apply only to data it also applies to instructions so CPU instructions now not cage B instructions because in the end instructions are also just a different kind of data so these are all these also go through the CPU caches but that’s not the whole story yet because applications always use virtual memory addresses but the CPU caches use physical addresses at least on 50 CPUs so before we can actually do a lookup in one of these caches we first have to translate from virtual to physical memory and this is done through page tables these page tables once again live in memory so accessing them directly all the time would be like really slow and for this reason there is a additional caching mechanism which we call the translation lookaside buffer the TLB which is just a very specialized cache only for these page tables the problem is that for historic reasons thinking software everything is for historic reasons these page table entries all have so each page has four kilobyte size and the PHP binary is something like I don’t know maybe 20 or fergie megabytes in size so if you try to map the whole PHP binary using 4 kilobyte pages you’re going to need something like 5,000 pages or more and five thousand pages definitely don’t fit the TLB cache they don’t even fit into the second-level TLB cache by far so the solution to this problem is that you can use huge pages these huge pages have if they’re 2 megabyte or 4 megabyte size and if you have well 2 megabyte pages you can map the whole PHP binary using something like 10 page entries and 10 page entries that’s something you can’t fit into the TLB so what this feature avoids are not cache misses into this normal caching pipeline but this this special is still be caching pipeline which in the end really has the same effect so we avoid latency due to main memory accidents but well this feature not enabled by default because not all operating systems supported so you sometimes have to install special kernel modules a set historic reasons and especially at the CPU level these things go away even more slowly than they do in something like PHP and you all know how much legacy PHP has well anyway that’s it from me so here’s contact information and jointing so I’d really appreciate to have some feedback and well yeah do we have any questions you have time for questions

you know those on those first lights there was some benchmarks yeah and I would like to know if the the calls were done in the same way in PHP 5 or and PHP 7 or it was like using best practices so it was exactly the same the same call and also if there was input and output because since I know in PHP 7 is support for a synchronicity for a synchronous cause so then also that would cause they call to be faster in so first of all PHP 7 doesn’t have support for asynchronous calls ok so just to say that right away it has improved supports for core routines which can be used for a synchronous code but there is nothing natively in it and well these performance benchmarks are used the very same code for PHP 5 and PHP 7 and also the same configuration so though no code changes no no optimization from that point of view the question hi in one slide if you’re sure that op caster abuses memory usage ten times when large arrays are used that this works in p35 as well or only in Petrus I know this is a new thing and PHP 7 ok thank you I mix the I’m using exact for 4 lines you know sometimes now it’s not supported anymore I understand oh it’s already in the core how can we the back because I used to use X the back extension for the right so now what are the options no the bugging is still the same I think X the back even supports PHP 7 like experimentally what I was getting to it that Jesus due to these call stack optimizations the things that extra back reports might not actually match how you did the calls so if you have a call stack and you see you are calling this function with arguments a and B it might actually be that those weren’t the arguments you pass to the function so it might be you passed different arguments of the function huh it’s fine so how do you avoid it tricks oh great so it’s it’s not even the problem I think she worked fine I think all the tests work so if you can find me an example and happy to have a look at it okay I think so there are XS that she has done magic in XD back and avoids this problem so maybe you don’t have to worry after all the problems to exist if you’re using something like funky darks to implement the realloc functions but what’s really escape hi the question about immutable arrays will it resolved for example also a bit more complex values instead of like integers and strings for example if we put an array with values from constants or class constants will it also be treated as a imitable array in a sensing of cash so it depends if the constant is defined in the same class so if you’re using something that itself constant and it’s in the same class then the value will get in mind and we run constant expression evaluation and in the end we end up with the like literal array which we can make immutable but if the constant is defined in a different file in a different class then this isn’t possible and yeah it goes back to how it was before hi it’s about your side when you advise

to use the slash to enjoy is optimized ob code for some I’m part of Begbie CMS team it’s be PHP CMS project and we use a lot of this function and I just want to know if you have some benchmark to see if we have a really advantage to just update following your advice or if it’s just a monistic so just to clarify you I’m asking if it’s worth writing this backslash a is there a big advantage to use this slash or not and so I hope the takeaway here is not that you should start prefixing all your internal function calls with the backslash so that’s a micro optimization and as usual we don’t recommend doing that but if you have like really hot code it might of course be worth doing it but I don’t know the exact numbers how much I improve things because maybe we use thousands of these function in if you have some kind of commonly used string manipulation codes it might be worthwhile but really if profiling shows that it’s the hot function you can do it but otherwise not thank you any more questions okay I think I think that’s it

Objective C Tutorial

hello internet and welcome to my objective-c tutorial in this one tutorial I’m going to teach pretty much everything you’d like to know about objective-c and also as a side effect I’m also going to teach a lot about how to program in C because they are quite similar I’m going to be programming using Xcode but for the Windows users out there I’ll also show you exactly what programs you need to run this code because it will run on a Macintosh Linux or on a Windows machine so I have a lot to do so let’s get into it okay so for those people that are on Windows this is what I suggest if you want to be able to compile objective-c programs you would either use Ming w org and download mingw or go to cygwin comm and download this and you’ll be able to compile all of the objective-c programs that I have here in this tutorial now let’s jump over and start writing some code no like I said I’m going to be using Xcode here but I’m also going to be using the terminal or command line to show you how to execute those and I just opened up Xcode and I’m just going to click on OSX application and command line tool and click on next I need to give this a name I am going to call this objective-c Tut for tutorial I’m going to leave Derrick baños in there and then here you’re going to put a unique thing so I just put my website backwards and I’m going to start off actually by writing a C program and I’m going to work my way towards Objective C I’m gonna click on next and it’s going to say where do you want to save this I’m going to say that’s perfectly fine and I’m going to open that up and whenever you open up your file inside of Xcode you’re going to see all this stuff what we want to do is we want to come over here on the left side of the screen and specifically open up main dot C that is going to be where your code is going to execute and like I said this is a C program right now now basically like I said the code in the main function right here is what is going to be executed any time you run your program and if you’re wondering what these attributes are right here whenever you would run your application from the command line or the terminal you would be able to pass in the number of words being passed into this function as well a list of those words inside them in array and I’ll demonstrate that here in a second but first let’s focus in on exactly what printf is you’ve probably seen this before basically all print is going to do is it’s going to print whatever words you have inside of these double quotes and then the backslash n is for a newline which just means skip to the next line let’s come in here and let’s use the array that could be potentially passed inside here just see how that works or what the heck let’s just run it and see what happens so you can see here I just ran it and HelloWorld shows up down there so that’s all printf does it just prints out whatever you have here on our screen let’s delete this and let’s do something a little bit more advanced for looping I’m sure you’re aware we’re very often going to use for loops and they are structured inside of C and Objective C in exactly the same way first we’re going to initialize a variable and let’s just have it be I is equal to zero and this guy right here is going to change in some way as the for loop loops and performs actions that you see right here over and over and over again as long as this condition right here remains true so I’m going to say they want to continue looping and we’re increasing the value of I as long as I has a value that is less than argc this guy right here whenever we pass an array which is just a bunch of boxes that contain values into the main function what this is going to do is to allow us to iterate through all those different things so if you send in a sentence that was something like I am happy I am and happy would all go into different boxes inside of an array and they would have a label or index of 0 for I 1 4 a.m. and 2 for happy and it’s probably better just to look at this or if you have programmed you’ve seen this already before and this is just shorthand notation right here for increase the value of I by 1 that’s all that means so we’re going to do is cycle through this array and I’m going to use print F here again and I’m going to say Arg and this is going to be the argument type that we are increasing right here and I’m going to put a percent sign followed by D which means that we’re going to be placing inside of there an integer or a value that does a decimal place and a % in an S which means I’m going to be passing in a string and then a new line which means I want to skip to the next line after it does that here I’m going to then send the value for I and put it right here and then I’m going to get the value for our array that’s passed inside here and put an eye there and remember like I said everything’s going to start off with a zero n n increase a zero one two three as you’re going to see here in a moment now I’m going to use the command line on purpose just to execute this and I opened up my terminal or command line and I change the directory to where I have all of these files listed and I’m going to show them all right here you can see objective-c Tut that’s the name of the project I created so let’s just jump inside of there and then you can

see the main dot C file which is the name of the file that’s over here on the left side of the screen now if I want to compile this program I’m just going to go GCC main dot C and you’re going to do this on Windows as well and I’m going to type in standard is equal to C 99 and now if we hit LS we’re going to see a dot out is there and that is the guy that we want to execute and to execute that we’re just going to then go dot forward slash a dot out and then followed by whatever you want your string to be to pass inside of there and here you can see there is the command passed in here to this array as well as each of these string values also passed into the array and you can also see the indexes that those are all passed into just wanted to cover exactly what all this stuff means you’re not going to use it very often but now you know as well as you have an overview of exactly what for loops look like and what printf does but we’re going to get more into that later if you use an objective-c and you want to get rid of this bar over here which we’re not going to be using that much you can just click on this little guy there and that’ll go away and likewise if you do not want the debug area over here you could come over here and click on this guy and that’ll go away as well and then we’ll just have our output from our application that’s running here on the screen didn’t mention it here but this includes statement is just going to include a whole bunch of functions that we’ll be able to use functions like printf to be able to do all sorts of other different things which will demonstrate here as we go on and now I’ll jump into the different variable types that we’ll be able to use to store data now basically there’s a ton of them we have short and I’m going to also say exactly what we’re going have to use here if we want to transport a value stored in this variable over inside of here inside of the string to be printed out and in that situation it’s going to be % day just like we had before likewise you’re also going to use % D with integers and with Long’s we’re going to be using % LD floats or values that have a % are going to use % F doubles which are just like floats except they’re quite large are going to be using L F then you have characters which we’re not going to be using that much but if you ever feel the need we’re just going to use descent sign see there’s a couple other different datatypes but we’re going to focus in here on strux as well as pointers as the tutorial continues and a struct is just a custom data type which is better to understand once you see it and a pointer is going to hold the location of data somewhere inside of your memory so what we’re going to do right now is I’m just going to bounce around and create all kinds of different things I’m going to start off by creating a float and let’s call this F temp and whenever you’re defining the names for your variables we usually use camel casing which just means the lowercase letter followed by an upper case for each individual word you want to focus in on for your variables such as creating a data space for me to be able to store information now I’m going to use printf again and this time I’m going to allow the user to enter information so I’m going to say enter temp in Fahrenheit and we always want to put a semicolon here at the end of our statements now if I want to get information from my user I could use scanf and what i’m going to do here is I’m going to define exactly what datatype I expect which is going to be a float that’s what’s going to be sent to the user and then we’re going to put and f10 and we’re going to get more into what the and part is in a little bit but for now just put and and a half temp whatever the variable is now what we’ll be able to do is create another float and this is going to be C temp which is going to represent Celsius here I’m going to perform a little bit of math I’m going to say I’m going to want to get the Fahrenheit temperature and subtract 32 from it and divide by 1.8 and that is how we perform subtraction as well as division and now after I created that I could then go printf to find exactly what I want to put here I want to put a float and let’s just say i1 one decimal maximum after that float I’m going to put the F right there and degrees Celsius and we’ll throw in a new line as well and then after that of course we have to say what we want to the value of the variable we want to put right there and that’s going to be C temp and if we execute that you’re going to see down here it says enter temp for Fahrenheit and let’s just say I say 70 degrees it’s going to Chuck back 21 point one degrees is what that would be in Celsius something that’s also useful to know is exactly how big of numbers we can store in these guys basically whenever we say something has a datatype what we’re really saying is hey computer I want you to set aside a certain amount of memory which we have a limited amount of for the data type that I want to store there now the biggest integer that we could possibly store and let’s just call this big int is two one four seven four eight three six four seven and what we’re going to do is we’re going to prove that that is the biggest integer that we could possibly store and we’re going to put in an integer is what we want to store there then we’re going to get big int and add one to it well you’re going to get a negative number and this by the way is the absolute smallest number you can store in an integer so just be aware that there are size constraints in regards to how large of the different data types we’re going to be able to store now along is also a whole number type however we’re going to

be able to make much larger Long’s as you can see right there that’s the largest long we could possibly create and if we want to save that and we want to execute this you’re also going to see that that gives you a negative number and that is the absolute smallest big long that we’d be able to use so pretty much every data type in one way or another is going to have limitations but there’s outside libraries we can use whenever we want to be able to work with bigger numbers like that if we want to be able to find out the absolute minimum float that we could possibly work with you come in here and let’s put a cent sign and E and there’s actually a constant that is going to tell us exactly what the minimum float is there’s also a constant to show us what the maximum float is and we can execute that but as you see right there it actually says undeclared identifier what are we going to do what that basically just means we need to include another library and in this situation we want to use the math library and we’re also going to want to use a float library now if we run that you can see right here both the most negative of floats that we could create in our system as well as the highest possible positive value we could store of course those are also going to be decimal places however it’s very important to know that whenever we’re using floats or doubles that they lose precision after six digits and we just come in here and demonstrate that so let’s say I go and create a float give it the value of pi and then we’ll go point and we’ll go one two three one two three and then a one remember it only has precision up to six digits and then we can come in here and try to print out seven digits of accuracy and then go PI plus in actuality we could also have the computer tell us straight off how accurate is how many digits so we’ll say precise decimal digits and have that print out as well and remember this is a C program but like I said anything that’s done in C we could also do an objective-c and if we run that you see right there one four one five nine two six this is one four one five nine two six even though we went in there and added an additional digit it completely ignored it you can see right here precise decimal digits goes up to six so now that we spend a lot of time on different variable types let’s get into comparisons and being able to perform different actions depending upon a situation so let’s create an integer here equal to age and that would be 13 I’m going to put we can use an if statement that’s going to say if the age is less than or equal to 6 in this situation then and say something like you are in kindergarten like most other programming languages we’re also going to be able to come in here and go else if and put in another condition let’s say age is less than or equal to 13 and then finally as the final condition we could say something like you’re in high school and there we go and if we execute that you’re going to see you’re in elementary shows up here and the reason why is this is equal to 13 so if Sande else’s and elf if statements work in C as well as Objective C in pretty much the same way as other programming line images and the different comparison operators this is a comparison operators that are going to be available to us are also very similar to other languages we’re going to have less than greater than less than or equal to greater than or equal to equal to and not equal to so there’s all the comparison operators so what do we have in regards to logical operators well logical operators are basically going to allow us to combine comparison operators and we have and we have or and we have not it’s better to come in here and just demonstrate what those look like so we could do something like if and we could say age is greater than or equal to 12 or age is less than or equal to 13 we could then print out something if that indeed is true which in this situation it is and it prints out you’re in elementary right there basically what this is saying here is when we were used thus illogical operator or if this is true or if this is true then I want you to perform whatever is inside of there if on the other hand we decided to use the and logical operator we come in here and create a boolean for example now let’s go and import something up here standard full create a boolean type I’m going to say is elementary let me go equals and throw in the same statement we have before but in this situation we’re going to have and and what that’s going to say is this is going to get a value of 1 or true if age is indeed greater than or equal to 12 and age is going to be less than or equal to 12 if this isn’t true and this isn’t true then we’re going to get a false or a value of 0 and a boolean is it going to represent true or false or it’s going to represent 0 or 1 just like I said before so in this situation I mean here do another for an F statement put a D inside of there because it’s going to give us zeros or ones like I said before and then is elementary and you can see indeed is an elementary and it comes back with one or a value of true then finally to cover the last logical

operator we have the knot statement all the knot statements going to do is it’s going to turn truths in two falses and falses integers or zeros and ones and ones into zeroes and then we could do something like not and yes indeed we could use true here if we execute you’re going to say it turned the treu into a zero so those are all the different logical operators another thing that we have here for performing comparisons is the ternary operator so let’s go and create another boolean we’ll say something like is High School like this and what the ternary operator is going to do is it’s going to assign a value depending upon the comparison so I’m going to say if the age is greater than 13 then I want you to assign a value of 1 2 is high school so it’s pretty much used in comparisons in which you’re going to have either or come true otherwise if this comparison is not true we want to assign the value of 0 to is high school save it and run it and you’re going to see is in high school comes back as 0 another thing to keep in mind is when we are using if statements if you would come in here and create an integer called J and give it a value of 10 or whatever this guy right here is not going to be available outside of here and we could prove that right now like this and execute it and it’s going to say build failed and that just means if a variable is created inside of an if statement and later on if it is created inside of a function that does not mean it is going to be available outside of said function or if statements or for loops or wild loops which we’re going to get into more here in a second now let’s come in here and take a look at some things we can do with math basically what we’re going to be able to do is perform addition subtraction multiplication division as well as modulus which is actually done this way however if you would whatever want to put a percent sign inside of here inside of printf you would just double it up just like I did right there if we execute that you’re going to see exactly how those work exactly like you thought and if you don’t know what modulus is it’s just going to return whatever the value is of the remainder after a division another thing you need to do here is cast and that just means to convert from one data type into another so let’s say we go prune up and we want to get 3/2 is equal to and we want to float in this situation we could do so and here what we’re going to do is we’re going to say 3 divided by and if we want to cast the 2 into a float you just put this inside of here if you wanted to convert a float into an integer you would inside of there instead and you can see right there now it’s going to be able to put in the decimal places and I covered this before but if you wanted to shrink that down to only show two decimal places just point point two inside of there you’re going to say that it goes and only shows two decimal places instead of as many as it feels like showing I think it’s important here is order of operations so let’s say that we go print out and we’ll be able to see that if we go two plus one times three is equal to that is going to give us a different value then if we used brackets inside of here paste that in there except in this situation we’re going to put these brackets around here and what that’s going to allow us to do is to perform the addition first and then the multiplication thereafter you can see exactly how that works whenever we put the brackets around it it’s going to add this first and then perform the multiplication otherwise it’s going to perform the multiplication first and then add 2 to it another thing it’s important to understand is shorthand notation that is available so let’s create an integer give it a value of 0 if we would then come in here and say something like I plus plus is equal to and then put that in there for the integer what this is going to do is it’s actually going to first get the value of I currently and place that right here and then it’s going to perform the addition afterwards otherwise if we would instead put the plus plus right here it’s going to form the addition first and then after do nothing so save that run it and you can see that’s exactly what it did went through here printed the first value of I then added one then came down here added one and then printed the value out on the screen so there’s little things like that can really hang you up another thing to know is there’s also there’s all kinds of shorthand notation we also be able to go i plus equal to and let’s say 5 what this is going to allow us to do is add 5 to whatever the value of I is so we’ll go I plus equal to 5 run that and you can see that it printed out right there because it has a value of 0 and there’s also going to be shorthand notation that’s going to allow us to go i minus equal to 5 or whatever it’s going to be and we’re also to do that with multiplication as well as division now I could go into all the different math functions that are available but that would take forever basically we’re going to have ceiling as you can see right there which is going to deal with rounding upwards floor which is going to deal with rounding downwards you’re going to have absolute values square root exponents I mean there’s there’s tons of different things

that are available to you logs and powers I’ll just let it to you to go and explore the different math library and all the different things that are available for you right there okay so now let’s take another look at looping now we already talked about the for loop and you can see we’re just going to initialize a variable give it a starting value and this guy what it’s going to do is it’s going to print out odd numbers from zero to not so we just throw in our condition once again and that’s going to be ten and we’re going to increment it again using shorthand notation like before and then down inside of here there’s a couple other little key words we can use here’s our if statement and we’re going to say in this if statement if I ever reaches the value of nine what we want to do is jump out of the loop all together how could we do that we would just throw a break inside there so that’s one thing what’s commonly used with loops another thing let’s say that we also if we ever get to the point where I is equal to seven and we want to skip printing seven it’s quite easy we would just type continue and won’t continue does is jumps back up to the top of the for loop and continues going of course this is going to be incremented however and then if we just want to print out odd numbers we could say something like if I and then use the modulus statement with two which is if it’s an even number is going to give me a value of zero and if it’s an odd number it’s going to give me something other than zero which means we’re going to be printing out all of our odd numbers in that situation I’m going to go I and then I’ll go and print out the number so there we are and then throw our integer on there at the end and if we run that you’re going to say that it prints out one three and five it doesn’t print out seven because whenever it hit this point it continued never got down to this point and then prints out five and it never prints out 9 because 9 jumps is completely out of the loop so that is how we’re going to be able to use for loops now of course there’s also Wiles as well as do-while loops with a while loop you’re normally going to create a variable outside of the app the actual looping structure let’s just call it J and in this situation when you say wow J is less than or equal to 10 and we’ll say print out and we’ll just say J and pronounce the integer in this situation there that there and then another thing that’s common with while loops is we’re going to increment our variable inside of the while loop itself and if we run that you’re going to see that it’s going to succeed and it’s going to print out 1 2 3 4 all the way through 10 then we have the do-while loop which gets a lot of hate for some unknown reason what a do while loop does that’s different than a while loop is you can guarantee that it’s going to loop at least one time every time you use a do-while loop because it loops through whenever we say pin do and then it checks the while part of it so we’ll say wow and let’s create something let’s do like a guessing game or something so let’s say int and guess like this come down here and we’re going to say that we’re going to continue looping through this as long as the guess is not equal to 15 so we can go inside of here and then inside of this guy we could say something like printf and guess between 0 and 20 so we’re going to say guess a number between 0 and 20 and then we’re going to store whatever they put inside of there inside of scanf so you say D that’s we’re expecting an integer in this situation going to put and inside of here you’re going to see here in a moment why that is needed and then whenever we run that guy you can say guess between 0 and 24 take then 1 it’s going to ask us again 4 and then if we type in 15 then it’s going to end so there’s an example of a do-while loop that brings us to functions what I’m going to do here is I’m going to jump up here outside of the main air and this is where I’m going to be creating all my functions and basically how why we would use functions is it’s going to allow us to both reuse as well as better organize our code while I’m up here I might as well also talk about global variables a global variable is going to be able to be accessible meaning its value is going to be accessible in every single function that is inside of your file and how you create one is let’s say I have pi value so if we have functions up here outside of main as well as inside of main we’re going to be able to access all of those or access all of those and another type of version of this is what we would call a static variable and a static variable will only be accessible by functions inside of this file because otherwise we could have Global’s that also would be accessible from outside of it just by including them like we included here as you can see let’s create a function so I’m going to say first void what void means is it doesn’t return anything after the application or after the function executes we’re going to be getting a string here so we’re going to be using character star name once again I’ll show you what that means here in a

second we’re using pointers and here we have height and then we’re going to have another float which is weight these are going to be values they’re going to be passed inside air we’re going to be getting names heights and weights all passed inside of here and then inside of this function we’re going to do something with these guys what we’re going to do in this situation is we’re going to get the height that they passed in multiply that times 12 and then multiply that times 2.54 which is going to get us our height in centimeters and I’m just making up stuff to do here so we could also convert our weight to kilograms by multiplying that times 0.45 3 5 9 2 and then we can come in here and say printf and get it the name that was passed inside of here centimeters tall and way is and have two centimeters for that kilograms and then we can just throw in the name the new height as well as the weight and now that we have our function defined we can just call it and convert data and we could pass in Derek for example or why don’t we go and do this because I want to show you something else name is equal to dark and then we’ll pass in name here and then for our height we can say six point two five and then for our weight we could say 179 and if you save that and execute it you’re going to see down here it goes and prints all that information out and does all those conversions one thing it’s very important to understand is if we would come in here and say something like R and F and then try to print out our height which we defined inside of our function up above so here’s height right here and here is height right there but height is not down here and as you can see it has an error and if we click on it it’s going to say use of undeclared identifier height anything is declared in a function or an if statement or for loop cannot be accessed from outside of it and another thing that’s important to understand is let’s say we came up here and said name is equal to fill and then we came down here so up there we change the name to fill from Derrick we wouldn’t then be able to come in here and say name and main yes or we’d be able to do this is just not going to give us the result that maybe we expect so if we execute that you’re going to say that Derrick shows up even though Phil supposedly was changed up inside of here and the reason why is what if we pass these values up here we’re not passing the actual variable we’re just passing a value and right after I demonstrate our next function we’re going to create that’s going to allow us to return values versus void which doesn’t allow us to return them I’m going to come in here and I’m going to create a new function that’s going to return a float it’s going to receive a float and two floats and then it’s going to return none one plus num2 and we’ll be able to come down here throw printf inside of here once again and we could say something like five plus six is equal to and point one get our float and a newline and of course we could call the sum function pass that in there and it’s going to return a value just like we expected it would there you see five plus six is equal to eleven so now let’s talk about pointers now data like I said before is going to be stored in memory at an address and memory is just like a bunch of boxes and the data type that you define for those boxes is pretty much going to define how many boxes you’re going to need so if it’s a data type that is expected to be large then you might use a long or something along those lines however if it’s supposed to be really tiny might use a short or even an integer so what we’re going to do is we’re just going to start off here and dig more into pointers so let’s create an INT and let’s just call it random numb and give it a random value now if we want to come in here and get the address location for it just go ran numb location we’re going to be able to by putting P inside of here for a pointer and then to get it we have to go and random number that’s where that and is so this guy right here is going to return the address in memory for this variable right here execute it and you can see there it is a hexadecimal number and why that’s going to be valuable as we’re going to be able to store these addresses and so forth and pass them in functions if we would want to come in here and store a address we’re going to both or first off we’re going to use the same data type or whatever we’re going to be storing and then we’re going to follow that up with star ad or random num and then get the address for random num right like that so that’s important to know if you want to store an address make sure the data types are the same and then put a star before it or like that pointers are nowhere near as complicated as they seem it’s just addresses and passing addresses and then getting access to data inside of those addresses we could then come in and store a new value in that address by referring to star ad our random number 5 4 3 2 1 for example and we just copy this to save a little bit of time random number value and then like this and then

change that to an integer run it and you see right there 5 4 3 2 1 is showing up right there so if you want to store the address for a variable you start off with and and whatever you want store inside of there so this is the address of that if you want to change the value then if you have the address you proceed it with a star and then store the new value inside of there something else that might be interesting is even though we change the value the memory address itself is still going to remain the same so we can say random number memory location for example and in memory location we’re going to be getting a pointer and then put the + symbol here of course if we run that you’re going to see that yes indeed the memory address is exactly the same as it was before ff7 AC trust me it’s the same thing even though we change the value and if we wanted to we could also come in here and get the total number of bytes for our integer in this situation so random number is and to do that you go % + Z u and we’ll get the bytes for that and to get it you go size of and then pass in whatever the random number is or whatever the variable is you want to check you can see here that that is 4 bytes now something that’s really neat is previously we’re sending by value to functions what if we want to do instead send the actual variable and then you would be able to change the value there and then it would also stay true inside of the main function so let’s go and create an integer called number 2 3 4 5 and we’re going to create a function called change number just to prove that this works now to pass the address we’re going to go and and then number right like that and then after we do that we’re going to verify that the number value that we changed inside of the change number function which we’re going to create here in a second is going to remain the same outside of here now what we’ll do is come up here and actually create that function it’s called change number oops inside of here outside of the main function and this isn’t going to return anything so we’ll have it be void then I’ll have change number now if you’re going to be sent an address for a variable you’re going to put the star inside of here instead I’m just going to call it number again have to be but that’s what’s going to be here and then to change the value of the address that was passed inside of here we’re going to put the star in front of number and call it 97 whatever so they’re changed there so what we’re going to do just to verify we’re going to give number the value of one two three four five we’re then going to say that we want to change it and then we’re going to verify that it was indeed change and if we execute you can see that nine eight seven six five was indeed changed and it changed inside of main because we passed the memory address and not a value something else that’s really interesting inside of C and Objective C is we’re going to be able to create struck switch I talked about before it’s basically going to allow you to create a custom variable with more than one data type so let’s say we wanted to create a struct and let’s call it superhero we could then define the name so we’ll say real name like those and then another string inside of here and as you can see that’s what these are these are character arrays and they’re using pointers as well for wondering why they had stars inside of them and we don’t you know wouldn’t only store strings inside of them we could store Heights and we could store weight just make sure that you end up with a semicolon we would be able to come in and use this struct the super-heroes struct and let’s call it Superman and we’d be able to assign values very often like you might feel is normal with dealing with objects so real name just make sure it’s the same thing like we have right there and Superman again equal to Superman Superman again and we could assign his height and Superman weight and that if we would want to come in and use all of that data we just assigned we could then come in and say there’s a string we want to put is the hero feet tall and weighs % pounds and then if we wanted to get the values that are inside of there it’s easy we just go Superman dot real name and Superman super name height weight execute that and call Kent is the hero named Superman he is six point two five feet tall and weighs 235 pounds so that is the gist of Si and all of the comparisons between C and Objective C now what I’m going to do is focus in 100% on Objective C and talk a lot about objects and all of the different functions available only with Objective C okay so I’m back inside of Xcode and this time I’m going to create an objective-c application so we’re just going to go application command line tool again is going to work perfectly fine and we’re going to go next this time we’ll change this to Objective C and I’ll call this effective C type two and again just whatever your name is and some unique identifiers click Next where you want to store it and there you

can see everything opens up let’s get rid of this for now we are going to talk about that in a moment and you can see here once again we have what is called dot M file is also also referred to as an implementation file so there we go but this is the main part of our objective-c application now the foundation part this import up here is known as the foundation framework and it’s going to contain many fundamental classes you’re going to use your Objective C programs and of course we’re going to be importing a whole bunch of other classes in here real soon see down here there’s main again and we can get rid of this stuff right here I’m going to talk about NS log and how it differs from print F but first off let’s talk about auto release Pole now as we create objects memory is going to be set aside for our application as well as our objects and whenever those objects are no longer going to be needed there is going to be memory that is going to be D allocated so that that memory will be released for other parts of our application an auto release pole is going to do that for us you also will often hear about a RC or automatic reference counting and basically what that does is it just automatically for us signals for the destruction of objects when they’re no longer needed so that is why we’re putting all that stuff inside of Auto release pull with our little curly brackets now NSLog is going to work exactly like printout for very similar anyway you can see right here it opened up and it printed out hello world the only difference is it’s also going to put out like a timestamp there we’re going to be creating a lot of objects one of them is going to be an NS string and this is a string and it is going to more specifically it’s going to be a string pointer and very often whenever you are creating an object and you want to define it but not give it any real specific information you’re going to assign it the value of nil which means that it is a non-existent object inside of memory and all of these non existence objects inside of memory are actually going to point to the same place because this is a pointer right here once again in NS log you know start off with the @ sign and I could say something like location of nil these are always going to be the same and it’s a pointer of course and we could say something let me just point it nothing like that and you’re going to see the location in memory for nil and it is always going to be the same 0 X 0 let’s now come in here and actually create a real NS string and it’s just a string that’s all it is so we’ll just go in a string or a pointer to the string in memory I guess is what I should say and we can come in and we go at and then we could say something like there we go and because NS string is actually an object it’s going to have a bunch of functions or methods F say or refer to and now I’ll show you how to deal with them first what I’m going to do is I’m going to use the NS string objects and show you how to interact with objects that way and then I’m going to show you how to make custom objects so size of string there’s actually a method inside of the inner string object that is going to give us the length of the string make sure you put that column inside of there and I want to cast this to an integer and how you would call the quote objects length method or function is write like that put it inside of brackets put the name and then put whatever the method is you want to call and if you do so you’re going to say size of string is 40 that means it has 40 characters and if you count all that up you’ll find now that that is true so that is sort of the weird objective-c way of calling methods but you can see how that’s done now to do something a little bit more specific to NS strings let’s say that we wanted to come in here and get a specific character let’s say we want character in the index of five here we’ll actually get the character there is another method character at index five and that’s how you pass in an attribute to a function or method inside of objective-c colon and then whatever you want to pass inside of it also a little bit different from most programming languages and you can see a character at the index of five is H and if you count it you’re going to see that that is indeed true you also will be able to come in here and create a dynamic type of string so you could say my name is equal to and by dam dynamic I mean that right here this is a non dynamic it’s given a value and it’s assigned here we could put in a variable and you know dynamically generate it however if you wanted to do that what we’d have to do well first off let’s come in here and we’ll say let’s create a string name is equal to Derrick like that and then inside of here to create a dynamic string we go string with format exactly like you have right there then after this we put at and then we put something like – and there’s going to be the new string that we’re going to be adding inside of there and then name right like that and that is how you would create a dynamic string you could test if two strings are equal you’re going to be using boolean different type of boolean inside of here

versus what we had previously with our C part we call this is string equal and how we could compare whether they are equal is is equal to string is the name of it then you’re going to put in my name like that whatever string you want to compare it to and here we’re saying is the quote string equal to the my name string well of course that’s going to come back false and just to prove that you can still use printf see there’s printf even though we’re inside of an objective-c program or application so we can say are strings equal and then we get our answer right here is string equal if we run that you’re going to say that the answer are strings equal comes back at zero or false if you wanted to convert an NS string into a regular old string you could of course do that as well it’s a little bit weird because we’re going to have to use what are called nested messages this is known as a message right here whenever we are calling a function or method inside of the object that’s a method we actually put that messages inside of messages here I’ll just show you what that looks like can also create constants with Co NS T and in this situation you’re going to need to do that so see a string is equal to and we can say my name could also change it to uppercase string if you’d like to just throw that in there just for the heck of it and if you wanted to convert this into a regular string string you would follow this with utf-8 string like that you don’t need the uppercase string part here I just put that in there just to do it this is the part you need to do if you want to convert from an NS string over into a regular old string like we have right here and we close that off so what this is going to do is it’s going to create an uppercase version of this guy right here my name and let’s use printf again and to get it will go you see a string like that and execute it and there you can say it made the name uppercase and it converted in and regular string and printed it out because that’s what we have right there you could also come in and combine strings and we’ll just go in a string say something like hole quote and to do that and this is what I mean by nesting or inner messages right like this say there’s one of them and then there’s one there so we’re basically making it uppercase and then we’re converting it into a string so then make sure you caught that so if we want to combine strings we go string by appending string right like this and we could say my name so we’re going to tack my name on the end of the quote string we could then come in and search for strings how we do that is we define NS range like this and we could call this search result is equal to and we could say whole quote and then we have to define range of string and then an axon and whatever string we specifically are looking for I’ll just put my name inside of there and this doesn’t have anything to do with whether it’s uppercase or lowercase it will find it either way then what we could do is we could say if search result dot location is equal to NS not found and we could print on its log inside of here say something like string not found else in that situation that means it was found and we could say something like print up Derek is at index Lu and is Lu long it’s going to tell me the index it’s at and how much space it’s going to take up and to get that information we go search result and location there you can refer to attributes or properties or variables of the objects by using just a regular old dot operator and then search result again and then if you wanted to get the length for it that’s how you do that I’m going to show you a whole bunch of these guys like I show you every one of them but you can see index 42 and it’s five long and there’s five characters so you can see that’s true we could also come in and replace a substring by defining at what index to start replacing and then how many letters to replace how we’re going to do that is within its range again and let’s just call this range is equal to where you go NS make range like this and we’re going to start at the 42nd character because that’s where we said it was and then we’re going to say five characters is how many way we’re on we want to replace and then we can go constant character and let’s say we want to call this new quote is equal to and we could go whole quote followed by and then string by replacing characters in range after you do this enough you’ll eventually get used to using it there it is string by replacing characters in range Objective C is a little bit weird there’s some strange sort of things that wants you to do here but either way then you type in your range with straw it automatically knows what you want to put inside of there and let’s just say that I want to come forth and say I did not create that quote but it was an anonymous quote so we’ll just put anything on inside of there get rid of all this stuff and then let’s also convert this into a regular strain utf-8 string like that and like that and then we could print that out so I’m just print four enough and new quote and

there you can say dogs have masters while cats have staff and you can see that it replaced my name with a non or anonymous now one thing it is you should know about using NS string is this is what is called an immutable object sounds like a big word it just basically means that once you assign a value to it that value can not be changed we’re going to be creating new arrays every single time we make any type of changes if however you wanted to have strings that could change you’re going to instead use NS mutable strings so let’s say we wanted to create a grocery list for example we could do so and this is going to be an S mutable string like this if we wanted to define the initial capacity but knowing that it could definitely change we’re going to say string with capacity and then give it a value of 50 we could then append a value to this string by just going grocery list and append format and then put in all the different things that we would like to add to it we can go string like this and then we could say something like potato banana and pasta and that’s how we could append to our mutable string first your list if we want to put these values inside of here we’re going to put % and ampersand and then just grocery lists like that make sure you come in here and put an @ sign in there did it data and there you can see it printed out all of our grocery list items we come in and delete characters in a range also with the mutable string we’re just going to say grocery list again and then we’ll define the start and the end so to do that delete characters in range like this and then this is going to be NS make range like that and then we’re going to say start at the first and then go to 8th out and delete all those characters we can see here exactly how these would be changing there you can see potato banana pasta here we deleted the potato part off of there could also come in and insert a string at index grocery list again and then we could just go insert string that’s on and we could say Apple close that off at index and then change that to 13 renowned our grocery list again there you can see apples on there now we could then also come in and replace characters in a range we’re going to say grocery list again replace characters in range exactly like that we’re going to say NS make and we’ll say we start at the 15th and 5 characters long and then with string we’re going to change that to orange and then we could print out our grocery list again and there you can see apples been replaced with orange and now we’re going to take a look at how arrays work inside of objective-c so NS array is the name for an array inside of objective-c and let’s say we have something like office supplies we could then define them by putting the @ symbol like this followed by all of the different things you want inside of here so we’ll say pencils and arrays are just like boxes inside of boxes that all have indexes or labels or whatever you want to refer to the mast and we’ll go paper would then be able to access the different values inside of these guys by going NS log at and let’s say we want the first item inside of here we get that first item by % + @ symbol and then remember the first item inside of an array is in index 0 start off by counting to 0 and then we can come in here and print all of them out if we’d want again we’re going to do the same sort of similar thing that’s on and off supplies and we put the odd symbol in error again and this time we’ll just type in office supplies no specific anything and run that and you can see that the first thing in our array is pencils and you can see right here office supplies and it’s going to print all of those out all at one time you can of course search for items inside of here again we’ll just create a boolean value and we’ll check to say or check to see if it contains an item to do so office supplies of course is an object and one of the methods inside of it is contains object that guy right there we’ll just put inside there exactly what we’re looking for which is pencils and then we can come in and check and souls need pencils whatever you want to put and D execute and you can see right here need pencils comes back true that means true that the pencils are inside of the array could also get the number of items inside of our array quite easily at symbol and let’s say we want to say total and let’s convert this into an integer have to do that cast and then we’ll just call office supplies again and the specific method we want is count again comes back is two and we know that that’s true now that we know that the pencils item is inside there might be useful to be able to jump inside of there and get the index of it so NS log at index of pencils is at and then here we’re going to put Lu and this is going

to be an unsigned long that’s how we do a cast for that and then to actually get the index we go office supplies again followed by the method called index of object there it is and then we just tell it specifically what we’re looking for and in this situation that is pencils semicolon and index of pencils is at index zero now again NS array by default is going to be immutable which once again that just means that it is not going to allow us to change it it is going to have to create a new array each time if you want to create a mutable array that you can add objects to you go announce mutable array and let’s say that we want to create one called heroes this is NS mutable array of course and we can define a capacity to start off with but like I said we can add to it ray with capacity and let’s just start this off at five we can then easily add heroes by just going euros add object and then we can put in Batman or whatever you want to put in here and we’ll throw a whole bunch of these in here we could then easily also come in just by calling the heroes method and insert an object inside of here let’s say hey we forgot Superman so let’s throw him inside of there and we can say where we want to put them at index and let’s throw them in the second index and so automatically going to make room for them and let’s show exactly what we have here and there you can see it printed out all the heroes Batman Superman Wonder Woman Kid Flash all of them all in one place now if we can add items of course we’re going to also want to be able to remove items we can go heroes remove object and let’s say that we want to remove flash we can do that we could also remove an object at a specific index so heroes remove object at index like this and let’s say we want to remove whatever is an index zero there we go just did that we could also come in and remove objects by name so heroes remove objects identical to and let’s say we want to remove Superman we could then go in range and define a range for this NS make range and change this from zero and then change this guy to one and then finally we could actually iterate through our array and to do that just go for start at zero that’s the first one while I is less than if we want to get the number of heroes that we have heroes count and then go and a slog and print all of those out on the screen and of course we can refer to them all by whatever their indexes and there you can see it printed out Wonder Woman and Kid Flash which were the only heroes left after all the other changes we made and now it’s time for us to create our own custom objects and to do so we’re going to come over here to our project right there we’re going to go object right there and then file new we’re going to select Coco class and click on next we’re going to call this guy animal and subclass of nsobject which is the number one object that is used for everything and click on next and then we’ll click on create and here you’re going to see it actually created a header file and this is where we’re going to be declaring our instance variables or properties or attributes or whatever you want to call them as well as the methods and then in the EM file that is where we’re going to be implementing or writing the code for our methods so we’re going to start off in our header file and you can see right here the object that it is going to is the superclass for our animal object it’s going to inherit everything that is in the nsobject and in the header part dot h this guy right here that’s what we’re in right now we’re going to define our attributes for our objects and these attributes are not going to be directly accessible however getter and setter methods are going to be automatically generated as long as you want them to be and how we’re going to create those well first off let’s say we want to create an attribute that is not or a variable or an instance variable where we want to call it that is not going to be set of all what we would do is go at property and read only this is not going to have a setter method generated for it automatically and let’s just say that it’s an n/a string and it is called name so that is how we would create something that could not be set from directly for our object however instead we’re not going to do that for now instead we’re going to allow this value to be changed now let’s think about our animal and all the other different attributes that should have it should also have a favorite food probably let’s make that an NS string create another one property and a string and maybe it’ll have a custom sound that it uses let’s also create a primitive inside of here property float weight and just remember if it’s a primitive it’s not an object that means it doesn’t need the little star inside of there which is our pointer and then we need to define different methods that we want to use inside of here well every time you create an object it is going to call an initialization for object which is going

to set certain attributes that we might want to set so those are automatically generated by default for us but let’s say that we want to come in here and define a custom way for us to initialize our files now again remember we’re in the header section here so what we’re going to do is define what will be returned so an instance type which is going to be specifically an animal instance and then we could say something like init with name and let’s say that whenever this is created it’s automatically going to be passed a string have to put the star there and let’s say that it’s going to be possible to create an animal object and pass in a default value let’s go and create a couple more methods let’s say we have another method there are objects going to have that is not going to return anything and it’s going to be void and the negative for it whenever we put that there that means that this is an instance method which means it’s a method that’s specific to objects that we create of type animal if we put a plus sign in there however that means is a class method and a class method will not be accessible whenever we create an animal object we’ll get more into that here as we go on so let’s say this one is just get info it also is not passed any attributes while this doesn’t really have much to do with an animal I’m just trying to think of something let’s say that we want to return a float which is going to be weight in kilograms let’s say we have a really smart animal that can do conversions if you wanted to create a method here that is going to receive a float that’s how you would define that and you could say weight in pounds is the attribute that’s going to be passed to this method so this is going to be the method name or the function name it is going to return a float right here is going to receive a float right here and the float that it receives is going to get the name weight in pounds we could also set this up so that we will be able to return a string and in this situation go to put to the store inside of there and let’s call this one talk to me and it is going to receive and then a string sent to it and that NS string is going to be whatever the person’s name is and it’s going to pop out a little bit of information directed it whatever the person’s name was let’s say that you also want to receive multiple different parameters well this guy is going to return an integer and we’re going to call the method here get some and it’s going to receive an integer let’s call that number one and then we can go to the next line here and say next number and this is going to be an integer and number two in this next number right here this can have any name you or what it is what’s important here is get sums the name in the method it’s going to receive two attributes one being number one and in the other one being number two both of which being integers it’s going to sum them and return those as an integer well now what we’re going to be able to do is jump into the animal dot M file this guy right here and implement all of those methods that we just created now you can see it has a reference to the animal dot H file which is where we defined what we want to create and here let’s say we want to throw in the initialization file where the constructor is it’s very often called let’s do something a little bit interesting here let’s come over and open this guy up and then let’s specifically come on down here to where this guy is right here click on that then down inside of here we’re going to click and we’re going to go in it see right here Objective C and NIT method that’s going to allow us to drag and drop this over here it’s automatically going to put in all the code that we are going to need for initialization method that we want to create this is the default it’s called a net remember over here we defined we also wanted to have another init with name so one is going to set the name if it’s available and the other one is not because it’s not available and this allows us to think about a couple other different things whenever we have self inside of here self refers to the instance being initialized because we have no idea what the animal objects name is outside of here so anytime this is like this and many other programming languages so anytime we want to refer to an instance by itself then we would just use self inside of here this is a call to the superclass and it’s going to perform any initializations that are needed there and the superclass is going to be nsobject this guy right here and then down inside of here what we could do is we could say self for the object being created we could change the name or create a default name of no name whenever the object is generated and then we’ll know that our animal hasn’t been assigned a name yet now what we can do is we can create our customized and knit and how we’re going to do that is this again is going to reserve an instance type and that just means this animal instance type it’s just a generic way to refer to initializations and in this situation we have and it with name and default name you can see all those things automatically popped inside of there as we define them here see default name all this stuff automatically jumps right in there makes it very easy to create these methods and here what we’re basically going to do is

the same thing we have here except we’re going to actually define the name that we want to use which in this situation is going to be the default name that was passed inside so default name right like that now we need to define all the other different methods that are going to be needed that we defined in our header section so let’s come in and define get info first off let’s just make this really generic let’s go and it’s log and for now we’re just going to have this just be random info like that we could then go and get our float method we’re going to create we could then go and define our weight in kilograms method that we went and created and automatically generate that for us and we’re just going to take weight in pounds I’ll apply that times 0.45 3 5 we had another one this one is going to return an integer and this is get some say it automatically generated all that for us here we can just go return and then this would be number 1 plus number 2 it comes down to one of our last methods we defined which is talk to me again and a string like this make sure you put the star inside of there and then let’s define talk to me and in this situation we’re going to define ans string which is going to be let’s put a response inside of here it’s equal to in a string string with format and here we can say hello at symbol and then my name so whatever name they pass inside it’s automatically going to respond as if it knows who that person hits and we could say return response okay so now that we have those objects defined we can go back into main dot m and start playing around with them so if we want to create a new animal object we just say animal and let’s say this first animal is dog pointer to the dog object and we’re just going to come in here and go animal which is defining the object type allocate some memory for me and then we’ll call an it which is going to initialize everything for us that’s how we create in dog objectory in wall object we could then call for a method to execute dog let’s try get info and that’s how we would call that just like we saw previously we’re going to want to come up here though and import our animal dot H file sure you do that otherwise you won’t be able to call all these if we wanted to get a value that is stored inside of an instance just use an S log something like the dog’s name is and then to get the dog name will just say dog name like that automatically that’s called a getter and they’re automatically generated that’s a way to get the name for our dog we could then also come in and set the value set name that’s how it’s done and let’s say we want to call our dog’s spot no it’s going to be called spot now and run it just to show that everything’s working here say random info printed out that’s what that method did dog’s name starts off as no name and then it gets changed to spot so just to show you that the objects are working here and we’ll create an animal objects we could also call the custom in it that we generated let’s have cat is equal to to call the custom Annette we’re going to go animal allocate memory just like we did before except in this situation where you go and knit with name remember we provided that and in this situation we’ll say whiskers is the custom name and if you don’t remember that’s from over here da-da-da-da-dah c init with name so we’re calling that instead of calling this initialize file now you don’t always need to access variables using dog name like this we’re also going to be able to come in and get those using a dot operator and let’s just do that with cat here the cat’s name is so in sign at and we can just say cat dot name and then let’s just call all of the other different functions we created here just to show that they work let’s say we go 180 pounds is equal to and let’s get this converted into kilograms F kg and once again to call for that method to execute we just go whatever the methods name is weight in kilograms and then we pass in 180 there’s the attribute and there that is again we can just to come in here and pass in multiple attributes just to show you how that’s done so three plus five is equal to and that’s going to return an integer and passing multiple integers or multiple attributes we’re going to go get some call the method that we want to pass in there and we want to pass in a three and then the next number we’re going to pass in is a five we want to pass in a string inside of here % @ symbol and here we’ll get a dog talk to me and then we’ll pass in my name and there you can see I executed all those and how they all work ok so there’s multiple different ways to deal with multiple different types of methods with different types of attributes and different types of return values all on custom animal objects the other thing is neat is we’re going to be able to create let’s say another animal type let’s say a koala bear that inherits all the attributes or variables from the animal class as well as all of the methods automatically and we just come in here

and right click on this and say new file this opens up and we’re going to say source class and we’re going to say next and we’ll call this koala and subclass of this is going to be of animal and objective-c of course nothing else is going to change there and then just click on create and now we have a subclass named koala that’s going to inherit everything from our animal class and how we know it inherited everything from the animal class is there it is right there that is how we know that it’s inheriting all that stuff now in the header file for koala we can come in here and override methods for example so let’s keep this nice and short and a string and let’s say that I want to overwrite the talk to me I could overwrite everything if I want keep everything the same here in our header file then jump into this koala port right here again and a string and the method I want to override jump into here and just get this just to save some time talk to me paste that in there and we’ll say hello bah dah dah dah dah says and then we’ll get the koalas name to show up inside of there and how we can do that again is self dot name that’s how we refer to that so we went and right at that guy we could then create custom methods that are only available inside of koala jump over into our header section and let’s say void form trick let’s call it that and it’s not going to receive any attributes and then we’ll create another one void and we’ll call this one make sound just to show that we can create them all of these guys save that jump over into koala and then what’s define all those so – void form trick there that is I’m going to find what it’s going to do slog and we’ll say that we want to put the name of qual inside of here whatever that’s going to be forms a handstand self name there it is and then we’ll define also other guy and that’s make sound and a slog they’ll just say he owns self name now we jump back over into main and make our quality ice stuff so it’s an object it’s koala object and it is a reference it’s an object let’s call it herbie is equal to and it’s going to be koala object going to allocate it some memory say we want to initialize it by name but make sure we come up here and actually reference the koala header file there it is and then pass inside of here it’s calling kirby so now our koala has a name and then we can demonstrate our overridden method that we created here and we can call our herbie method talk to me and then pass inside of it my name see how that changes and actually i think i’m going to take those other methods i created in a koala and demonstrate something else so and if we run up unexpected da-da-da-dah up make sure we put an app symbol right there whoops make sure we take that out of there and execute it there you can see hello Derek and hello Derek sorcerer B so that’s how we overrode those and how they work now categories are going to allow us to split our class into many different files and at the same time keep our file size is manageable and how we’re going to create a category is once again come up here right click on this file new and then we’re going to click on Objective C file not Co class Objective C file click on next then down here click on category and I’m going to call this exam and the class specific to it is going to be animal and click on next and then click on create it’s going to create animal plus exam dot H now in our header file that we have here for animal exam at run time we’re going to be able to add methods as part of the animal class and what this one’s going to do let’s create something that’s a boolean and call it checked by that and create another one say it returns nothing and get shots then we’ll be able to save that jump over into the implementation file here dot m and implement these guys so let’s go and create a boolean check by that and what it’s going to do just keep it simple we’ll do return 1 for true save by default it is checked by the vet and we’ll go and find the other guy get shots and s log and we’ll say whenever this calls it’s automatically going to say that whatever the name of the object is got it shots there you go real simple now well we’ll be able to do jump back over into main I like this and let’s continue working with her B we could then go and it’s log at did since I’m at check if her we got it shots of course we could have that set to a variable and turn it on turn it off and get her B’s name followed by her be checked by that and then also her be get shots and call that method and then get that to work all we’re going to need to do is import that category and that’s just animal exam automatically is going to place that inside of there and all that’s going to work and there you can say did herby receive shots yes her we got it shots other thing we can do is allow files to

import a category but at the same time block access unless the class is a subclass so we’re not going to be able to work with anything unless it is a subclass of this class that we’re working with so we’re going to come over here right click on this file new file again source this is going to be an objective-c file click on next and I’m going to call this protected this is going to be a category as well actually it’s called this vet category type animal click Next great or that is jump over here to the header file and then instead of that this is going to be called protected let’s define our method we want to create here void and then let’s call it get exam results something would be maybe private I’m able to jump down here and implement that get exam results and it’s log and we’ll just put something exam is fine doesn’t matter no what we can do is jump back over into animal implementation area right here and then let’s say something like in the get info area if we wanted to specifically call that we could just very easily come in here and go self get exam results of course we have to come in here and import this there’s that animal that and then get exam results close that off and that’s always it was to add that protected method that of course we’re going to call that we could just come in here and get a dog and get info of course and that would automatically call that as you can see exam is fine print it out there on the screen now just to say I’ve covered pretty much everything I’m also going to cover protocols and I started doing that a little bit with Herbie the Koala and we’re just going to come in here again right click on this and say new file accept and Objective C file is fine and we click on next and this is going to be a protocol right here and I’m going to call this beauty contest and a protocol is just going to be a bunch of properties and methods that any class is going to be able to implement and you can see it doesn’t have any animal class or any other reference to a class click on create and here is beauty contest which is going to have just the header file part of it and here we’re just going to define the methods and then stick them in any place that we feel like putting them and I like I said I already started doing this with the koala forum trick there it is so generated that jump over into the koala and you can see I didn’t need to define it right here I just need to come in and define that I want it right here beauty contest there it is and now I can jump directly down into the implementation and define perform trick and look cute or whatever I wanted to put inside of that so let’s come in here and go look cute where’s Boyd cute and we’ll say Herbie acts super cute or at least that’s the way it works because its name is Herbie so and name and that’s in the Koala implementation file and if we jump back into main we can see that we can just go like this Herbie look cute that’s going to call that and then Herbie form trick and then to implement that you’re just going to have to go over into your header section right here and add that in as well so beauty contests like this close that off if I’ll save that jump over into main execute it and there he is Herbie act super cute Herbie performs a handstand really easy to slide those methods in right there now to make sure I cover just about everything I’m going to go over a block around an anonymous function in objective-c how you would create one of those is you would define whatever your types going to be we’re going to say at say I want to create an anonymous function called get area then we’re going to define exactly what is passed into it so the height as well as the width are going to be passed inside of it you’re then going to assign the block to get area how you do that there’s that carrot symbol float then we’re going to say float with float height to find exactly what it is going to do it’s going to return the width times the height to get our area and then make sure you put a semicolon at the end of that then you’re going to be able to come in here and just use it so we say something like at area of 3 wit and 50 poit and that’s going to be a float and then we’ll just be able to go get area just like any other thing by passing in 3 and 50 and you can see there it worked so that’s how we create blocks enums are going to be used whenever you want to define a custom variable with a set of constants and how you do that is just go enum let’s say we want to do like we ratings or something like that could come in here and go poor is equal to one okay is equal to two I don’t know great is equal to five so forth and so on and then if you wanted to assign those values you go enum ratings which is the name of it and matrix rating or for them movie The Matrix and you could just define great inside of there and you just go matrix since on you matrix writing like that up make sure you put a semicolon right there and there you can see matrix 5 shows up automatically then the final thing I’m going to talk about is dynamic binding and this is basically going to allow us to create objects subclasses that all have a superclass

type that they would share ok and to demonstrate this what I’m going to do is I’m going to go into my animal header file this guy right here and I’m going to initialize a new method and this is going to be void and it’s going to be called make sound save that then jump over here into my implementation file and fun it right like this this is very similar to what we call polymorphism just allows us to refer to a group using the superclass and let’s say that it just goes ger the default animal sound is go let’s go then and create another object so file file new and let’s call this this is going to be a coca class next let’s call this dog again some class of animal objective-c click on next yes create it and then inside of the dog file well I want to jump over into the header section first inside of this we’re going to well actually I don’t have to do anything it’s automatically is going to get the make sound method of course however I’m going to override it and I’m going to say Boyd make sound this is in the implementation file of course and it’s logged and here I’m going to say something different so we’ll just say blank says wolf and then refer to the dog’s name over in the koala did it tada what yes I automatically I went and put make sound inside here so the koala and the dog are both going to totally different sounds that they make and that’s going to allow me to come in here and demonstrate dynamic binding so I’m going to do is I’m going to create a dog let’s call him Grover equal to dog allocate some memory let’s initialize him with name also let’s come in here and import dog H there’s lies with name and his name is going to be Grover now what I can do is create an array and refer to everything as animals and SRA allocate some memory and then I’m going to knit with objects in this situation and the objects I’m going to put inside of it is going to be Herbie and Grover that last part being nil now I can create some generic IDs which are just pointers to any type of object type they’re as generic as anything could ever be I’ll just refer to them as object 1 and we’ll say that these animals just what I’m referring and I’ll say object at indexes and I’m just going to put 0 you can see I’m working with the most generic type of object possible and I’m throwing those into this array and we call this object to animals object there is the second object in that tier and now I can just come in and go object 1 make sound and object to make sound and it’s automatically going to call the correct one well change this to index and when you execute it you can see automatically Herbie says yawn and Grover says wolf so there you go guys I’m going to also include a couple other different things on my website that I didn’t cover here but I covered so many different things just when to cover as much as humanly possible please leave your questions and comments below otherwise till next time