Jake Johansson joins us. He is no stranger to comedy fans. He's never been on the show before, but he's no stranger to my listeners. I've mentioned you a lot. Dennis Miller used to say to me every comic when they're starting out picks a guy who he uses as a yardstick, who he measures his career against. I made the mistake of measuring my career against you, Jake Johansson. This was a big mistake. We started together. We hung out in the open mics in San Francisco and I would measure my career against you. That was a mistake. Well, this sounds like it could be flattering to me, so I hate to interrupt you. Well, let me introduce you. I'll tell you why it was a mistake. Jake Johansson has appeared. Oh my god. Hang on. Let me steady. Let me get steady here. Jake Johansson has appeared on David Letterman 45 times. 46 days.  It's all I've got. I need that. Let me give you. This is not an introduction.  Countless specials on HBO and Comedy Central. His podcast is Jake this and he will be at Hilarides in Cleveland, Ohio, June 15th through the 18th. Go see Jake Johansson if for no other reason to punish me. This is what you say on your website. This is so brilliant. This is amazing. The difference between watching stand-up comedy on television and seeing it live is like the difference between watching a porno and actually having sex with a real person. You might enjoy them both, but one is a lot better. That is so brilliant. Well, thank you, David. I think that it's true and I'm surprised more people don't bring it up. But that tells you it's you and several other people who are visiting my website and I don't know. Thank you. That's nice of you. I think that it's apt. I think when you're watching stand-up on TV, what you're doing really is you're watching and someone else watch a comedy show. I mean, you're watching it, but you're kind of watching them watch it. That's why you need to be able to hear them laugh and they don't show the audience as much now as they used to. But when you're at a comedy show, there's a much more of an immediacy to it. And it is actually happening to you. Because it's dangerous. Well, it's dangerous or it's just intimate. You're involved in it. When you watch it on TV, it doesn't feel vicarious. It feels like it's really happening to you. But believe me, I have people who come to comedy shows and tell me about exactly what I'm talking about on my website and what we're talking about right now. It's just as different. You may not believe it if you're just hearing about it, but go see a great comedy show and whoever, somebody that you're really into. But when you're in the room with them, it's very much more immediate and intimate and intense. So my theory about you when we were starting out is that I was trying to make the people in front of me laugh. You were thinking of the bigger picture. Hmm. Well, I don't I that's funny because I always when I if anybody wants my anyone wants my advice, I would I would advise someone who's auditioning for something. If you're going on a showcase and there's going to be scouts from Letterman or The Tonight Show or whatever, HBO special in the audience, I would say do not think about those people at all.  So that's that's kind of what I'm always trying to think of. But you may be maybe you're talking about subject matter as opposed to to just approach. Yeah, well, I have two thoughts about that. I put you up there with Larry Miller in that you're pretty pure with your material. I don't want to embarrass you, but but you always had class. You never rolled around in the gutter on stage. You never worked filthy. I remember driving to L.A. with you and John Ross. I had a job at a radio station, and you had heard some of the stuff that I was doing was a lot of flatulence jokes and the two of you and I never forgot this.  You have to work to the audience as better angels. How did you know that so young and so early? Well, I don't remember being quite that philosophical that young, but I definitely felt as I yeah, it's hard for me to know now or remember now how I thought of it then so I can more talk just about how I feel now and I think now again, this is kind of in that category of who gives a shit about my advice, but I think that if you want to be a good comic, you need to really think about what is funny to you and what is the most efficient way of communicating that to the audience and the alternative path is people think that there's some kind of reverse engineering method that you can use where you figure out what the audience you figure out what you think the audience wants to hear and then you serve that up hot and that may work for a while if you have some angle and are able to figure out what the audience wants, but eventually they're not you and you're not going to know what to say. So what if you what if you figure out what's funny to you, but it's so inappropriate, you can't do it? Well, I don't think of you as inappropriate, David. In fact, if we're, I wasn't talking about me. Sorry. But what about our big thing? What if we're handing out compliments now? I mean, I feel like you've invented a thing that is almost impossible for anyone else to do because I don't even understand it sometimes when I'm watching you do it where you'll do a joke that's sort of through the looking glass, but then satirical and, you know, the audience and I'm laughing, the audience is laughing and I can't tell if they're laughing what I'm at what I'm laughing at. I don't know what your actual point of view is if this is a satire or if you really think that and there's something about it that's so kind of hilarious and disorienting that I think it's incredible. Well, that's high praise coming from you. All I wanted to do was be the worst human being on stage that I possibly I'm being serious. My goal is to be the worst human being without cursing, without resorting to vulgarity and without going into the gutter. That's, but I can't, you know, anyway, but thank you for that. Yeah, I mean, I figured I was so unlikable that I would just make myself so unlikable that some people would like me is back to you because I do have some questions and there is value to not being in the same room with you because it feels pure and I can ask these type of questions to you. Oh, boy, the sense that's I just it should we just let me I just want my imagination to have a chance to run wild with my my assumed respect. Am I going to be mad? Am I going to be violently aggressive? I don't know. We'll see. No, I'm just curious if there's some questions I have about growing up. It seems to me that you have impeccable taste in comedy. You hung out with Ellen and Tom Kent.  And this is how I rationalize this. I say you grew up in the Midwest and you have good wholesome values which you struggle with. But basically, you know, right from wrong. And your comedy comes from that. And you had disdain for vulgarity. Did that I think that's a fair statement about you. Well, I don't know. That may be how it seemed to you. I would say that it from my perspective in those early days in San Francisco, you know, I was from the Midwest. I had just lived for five years in Iowa where I was going to college. And I didn't understand. I think a lot of people who aren't into comedy still don't understand the way comics can tease each other and say really mean things. And that's they like it. You know, I remember having girlfriends back in the day. And even before I got married recently, well, 15 years ago, I got married. And they would say, how come your friends are so mean or how come you're so mean to them? And the thing is like, I'm not being mean to them. They like that. It's like dogs who are biting each other and rolling around on the floor. But I know that now at the time when I first moved to San Francisco, that kind of way of interacting with other people, it just seemed mean to me. And so the people who are good at it, you know, and I would put you in that category, I just didn't understand. I couldn't tell like, do these guys like me or do they really not like me? I mean, I was very insecure about that. And so I avoided those situations because I mean, the response is either to, I knew I wasn't the right answer to fight and to be mad. And I didn't think crying was going to be helpful. So I ended up, you know, maybe befriending some of the gentler. Right. Souls. Yes. That's absolutely correct. I gravitated towards the aggressive, hard drinking, mean spirited comedians.  The gut level laughs. Were you watching television at the time? Were you at the time in the 80s when we were starting out? When you were starting out, were you going home and watching television? Were you watching Letterman? Were you keeping an eye, for lack of a better word, on the marketplace? Were you looking at the marketplace? No, I've been watching Letterman when I was in college. He had a daytime show, so I was watching that. And I suppose we were all watching Letterman at night because it was like, ah, can you believe that this thing is on? And it only started, I think his nighttime show only started in the, like I started doing stand-up in 82. And I think his nighttime show came on in 84 or something like that. So I didn't watch. I didn't watch. I really didn't. I was so relieved that I was no longer watching television. And I really didn't start watching television until I started writing for it. So you were watching, did you go to watch, what was it, the Circle in the Square or the, what was that theater and not San Bruno? Yeah, I think that was in Berkeley or Oakland or someplace, but no, I didn't. Would you pay money to go see somebody like Howie Mandel or Billy Crystal? No, no, I never did that. I mean, when I was in high school, I went to see Steve Martin. That counts. But I never, no, I'd never, and this isn't any kind of point of pride or anything, but I never paid to go see a comedy show. I never paid for it. You went to see Steve Martin. How old were you? I would have been, I guess, I must have been 17. Was that the first live show you ever went to? Probably live stand-up show. I didn't really even understand when I started doing stand-up comedy, it was, I came to San Francisco to do that because I met another guy who was a Chicago supposedly and he had cut this article out of Newsweek or Time because his dream was to do comedy in San Francisco. He wanted to go where Robin Williams started at the Holy City Zoo, and so that's why I was going to do that. I don't know what I thought, but I didn't realize that you could make a living in just working comedy clubs. You don't have to be hugely famous to not have a day job, and in fact not only not have a day job, but to have, I've got a nice house near the beach and it's all from doing stand-up, but I didn't know that that was an option at the time. I thought I was going to San Francisco, I was going to do whatever stand-up comedy was and was going to go on stage and do something silly that would get me a TV show and then I would become rich and famous like Robin Williams. Right. Now I remember this. I remember being more successful than you early on. This is just what I tell myself. I remember taking the lousy gigs, playing Fremont and Hayward and Newark, not Jersey and California, and being told by Tom Sawyer, don't take these gigs. It's easy money, you'll regret it, you'll pick up bad habits, stay in the city, punch it out. My recollection was, and this isn't true, but this is how I remember it, coming back from Hayward in a zoot suit flashing wads of cash in front of your face going, look what I did. My recollection is early on I went for that cash and you didn't. I think more to me, I would remember it as you became more able to succeed in, I could go on at the other cafe, which was one of the nicer, quieter, more behaved audience rooms and have a good set, but you had developed an ability, a skill, I think, to succeed and to engage and get laughs from an audience under many more circumstances and difficult circumstances. You got to do those more roady East Bay rocket room gigs. Before I did, I ended up doing them. Sometimes I would do all right at them, but I used to console myself after I would say to other people, the worst thing that can happen to you at the sunshine saloon is that they want you back. And yet, how did you know that? I guess you're born with those kind of values because I would say they want me back. Well, right. No. No, but you're right. And you were right. And Tom Sawyer used to say this, there were two types of, as I remember San Francisco, there were three major clubs. There was the Holy City Zoo, the other cafe and COBS. And I'm going to say it. I don't want to use it. There was a zoo was the opposite of the other. And COBS was was a synthesis of both COBS reflected Tom Sawyer's views of comedy. And I think to this day, I think he had the best taste in comedy, but the Holy City Zoo was rough and tumble. It wasn't easy. You had to punch it out. You could lose the audience at any time. The other cafe was in the hate. It was very gentle, very snobby. The owners were snobs. They liked their, they liked you and Paula Poundstone and Rob Schneider and Alan. They were very protective of their audience. They didn't want to crass and vulgar. And then and then COBS combined those two. Tom took both types of comics, but they had to be great. You were an other cafe comic. I was a zoo comic. Is that fair? Well, yeah, that sounds, that sounds, yeah, I feel like that's a close shorthand. Tom, Tom became a supporter of mine before I won the comedy competition in 1986. And so in 85, I think, or maybe even as early as 84, he had said, look, one of the things I'm going to try and do is have a somebody who I'm really nurturing to move forward. And so that's going to be you right now. I'm going to give you one week of hosting the show per month. So you'll have a week's worth here at COBS every month. And so while I think sensibility wise, the other cafe thing is right, but COBS and Tom have always, I mean, he's responsible for a lot of that early success I had, development. And then I worked, he made an exclusive deal with me just a year after winning the comedy competition. So from roughly from 89 until whatever a few years ago when he sold it, I was exclusive in San Francisco at COBS and up there often twice and for many years, three times a year. When do you think you figured out who you were on stage? I think I had a little bit of a penny drop moments when just just around before the comedy competition, I won that in 86. And so I would say in that 85 time, 84, I kind of had this, I don't know about figuring out who I was, but I stopped trying to be somebody else and just sort of went with whatever. I took the easy route and just was myself, I think that's the way it felt to me anyway. You did something. I remember my father told me about two comics. He told me about you and Dennis Miller. And he said, my father said, there's this guy, he's seen you on Letterman. He's telling stories. He's the only guy who's up there building a house and hanging his jokes inside, but he's got this house. How did you know how to do that? Even Dennis Miller, when I worked for Dennis Miller, he didn't build the house. First he gathered up all the furniture and artwork and said, let's build a house around this. Seems to me you built the house first and then decorated it. I feel like I'm always trying to, you know, that's a tricky thing. I feel like if I could describe what it is I'm doing in an articulate brief way, that would have been helpful to me in terms of getting a sitcom or really getting anything. And that's another skill though. I feel like I can do it, but I don't always know the best way to talk about it. But to me, I'm talking about things that I think are funny. And a lot of times that starts off being a story about something that happened to me or something that I saw read about, but that it's me telling, trying to communicate that to someone else. And there's a personal sort of awkwardness and searching for the right way to say it that goes along with the actual telling of the information that makes it funny.  No, I'm fascinated by this because I've wanted to ask you these questions for a long time. You had the courage not only to do what you wanted to do and what struck you as funny, you had the courage to stick to a process that every other comedian I know in our group didn't have the wherewithal to pull off. And that is not to lead with the laughs, not to lead with the jokes, to lead with the truth, to lead with what you wanted to say and get the laughs from the honesty. Yeah, you know, I did this. How did you know to do that? Well, it was instinct, I guess, right?  And that's when I was talking earlier about the way you do comedy, I feel like that's what you're doing also. So it's not really a calculation. And it's also not something that as much as, you know, for comedic purposes or emotional, your own personal emotional reason, you're not so different in that sense.  It just, I maybe figured out or was objective about it sooner than you were and you were more, you got there and then realized what you were doing. Well, I failed so much that it was just, there was so much failure going on and desperation. And there still is Letterman. The first time you did Letterman was what year? 87. Five years in. Was it terrifying? I would assume five years in. Did you feel ready or did you feel it was too sudden? It was pretty scary. I mean, I, it's funny because you brought up Dennis Miller a couple of times and I really have to say thank you to him. I've said it a number of times and I know I've said it to him, but I really would like to just stop right now and say thank you to him on your show just because he and I worked together in Sacramento and he was obviously the headliner and I was the feature actor and that would have probably been in 85. And he was very supportive to me, said you got to come down to LA. Then I won the comedy competition in 86, but I had been down to LA before then and kind of been around. He helped me get in at the comedy magic club. He got Louis Anderson to sit next to Mitzi while I was on stage and say something nice about me at the comedy store. And then when I won the comedy competition and got management, and you know, they were saying you got to go to more Robert Morton had seen me for Letterman out in San Francisco, but you know, I didn't have management and he was like, I like you, but you're not ready. When I was in, I was talking to Dennis who would, by that time, he had gotten Saturday Night Live. He had, he let me stay in his house in LA when I came down here and took me around. Then he relocated to New York to do Saturday Night Live and was living in an apartment and on brand new on Saturday Night Live. He says, come out here, you got to, Morty's got to see you out here. You can, I slept on his floor in New York City while he was in the, in that, you know, boiler room of SNL at the beginning. He took time to support me there, let me stay in his place was encouraging of me. I mean, he was so helpful. And then later when he had his own talk show, he had me on a couple of times. He's just, I think now people have an opinion about him because he's got this conservative thing going on, but he was just so helpful and kind to me early on. It was great. So that's it. And that is his reputation in that if he thought you were funny, he would go to the mat for you. And he did. Yeah. So, so, so I went out to New York, I stayed at his place. Morty, Morty saw me, Robert Morton saw me again. My managers were also Letterman's manager. So that didn't hurt. But you know, there's nobody's getting on that show unless Morty and Dave, you know, there's no Dave's not doing anything or his system isn't set up to let anyone in who is not going to be pleasing to Dave after it happens. But so I passed all of that and I flew out to New York for my first appearance and, you know, you fly to New York, you run your set the night before in a comedy club and have a conversation about the jokes and how it's going to go.  I got to assume you completely tanked it the night before in the comedy clubs. Well, you sort of always do. It was you'd go on a catcher rising star, which at the time they had a band would go on. So, so the comic would perform and it's mostly comics going up and doing 20 minutes sets. So the comic would perform. He'd say, thank you. The audience is clapping. The band would come on stage along with the host who would then do five minutes or 10 minutes and then introduce the next comic and the band would play while you walked on stage and then you had to stand on stage until the band got up and walked off stage and then you're just going to do five minutes and then say thank you and then the band's going to come back on. So there's a lot of freaking traffic and busyness going on and it's so it's really hard and you're showcasing your letterman set. So you're not coming out and going, hey, how's it going? Or what happened today in the news?  So it was sort of set up to be a little bit of a dud the day before, but I had run that set so many times. That's why they have you run it so many times because being on national television is exciting. And back then it was even more exciting. There was, you know, not every, not many people had cable TV and there was way more people watching this. It was a big deal, a bigger deal than just, than it is now just because now there's people are watching stuff on their phones now. But so you'd go out and you'd do that the night before and it would go, it was okay. And then you go in and it's my first time and I'm cranked up and I'm excited and I can't believe I'm on this show hosted by this guy who, you know, he's older than us, but he was just older than us. So he's really the hero that you can relate to because he's just, you know, he's just ahead of you in the game. So I was very excited and I'm backstage and the guest before me is on and they come back and they said, okay, when he or she is finished, then it's going to be you. So get ready. And then when they went to commercial, Morty came back and he said, hey, Jake, we're sorry, but we've run out of, there's not enough time left for you to do your whole set. So we're just going to have the person who's out there now is going to talk for three minutes and then their band's going to play a song and that's going to be the, we'll have you back. You're bumped. But I was only bumped till the next night. So I didn't have to, I didn't have to go back and ramp up everything. I could, and it was good because of my breathe. I didn't couldn't calm down my breathing and I was kind of shaky. And so I realized the next day, look, just get up, don't drink any coffee, just drink water all day.  Yeah. Yeah, you're going to be so jacked on adrenaline that you got to focus on the opposite, keeping yourself calm. And so it was actually good to get bumped.  You just do the jokes in the order that you do them. And all you have to do, you don't have to remember your whole say. You just have to remember the first thing you're going to say. And then it all comes out. And then at the end, you say, thank you and the band plays. And the next thing you know, you're backstage and it's over. Did they let you use bullet points back then? No, there wasn't any, there wasn't any bullet points or cue cards. I don't remember the first thing in terms of time, but I remember then almost every time after that, they would go, okay, so you're going to do at the beginning it was six minutes, but then it got down to four by the end, but they would say, okay, there's going to be a guy gives you the one minute to go and a 30 second to go. And it's like, I just, I was like, okay, they can do that. But I'm going to do it's not like I'm going to drop my last joke because it takes longer on TV. I got to do the script. I'm going to do my jokes and then you're going to have to, you're going to have to trust, figure it out. I can't, it always amazed me that they would go, they're going to do some countdown thing.  Did you have a friend with you the first time you do the letterman? I must have. I, so many of the times I had a friend of mine that was, um, we met because our girlfriends were friends in San Francisco and then he moved out to, to New York before I did letterman. And I think he came to the first one of the 46. He was probably in attendance at the 35 of them. Wow. My friend Evan Elkin and, uh, so he, uh, I think he was probably at that first one, but I don't remember for sure. All right. So you're waiting to go on. You're terrified. I doubt you can remember this. Was there any moment during your first letterman shot where you thought, Hey, this is fun? Um, no, no, it was it. I, I had, I did it many times before I kind of realized like come out, stand there for a second and look around. So get in. It's going to seem like forever to you, but it's just going to seem like two seconds and completely natural to the audience, but let yourself absorb a little bit of what it's like to be out there. You know, that's the advice that I get people when the, if, if I know somebody's getting married, I always say, look, Hey, be sure and stop and just take a breath and look around and soak in the day. Shoot a little bit of, of a movie for yourself that you can play back later.  Cause that's the last time you're getting late. See, this is why I never made it, Jake. So it's kind of jokes. How many times in were you finally relaxed around Dave? Because there is this dichotomy. You're trying to make the audience laugh, but you're more importantly, you're trying to make Dave laugh. It's almost like you can not make the audience laugh, but if you make Dave laugh, you're fine. Did you ever get, I'm going to assume this without getting too personal. This is what I assume. I'm going to assume that to the very last shot, you were never completely relaxed around Dave Letterman. I don't think anybody is. Well, I mean, people say, look, Hey, you've been on there 46 times. Dave must like you.  I mean, he enjoyed having me on the show.  And so we want to have you on because Dave really likes you or Hey, it's Dave's birthday. We want to have you on because it's Dave's birthday. Wow. And then, and then you figure out that the, this is, this is how famous that David Letterman is. He doesn't, he not only doesn't pay to go see comedy shows, he sees comedy, he sees comedians by having them on his show. So he's a fan of comedy and he has comics on that he likes and he is there watching and, and I think hoping to enjoy your performance. And I, and I, and I, he said very many nice things to me afterwards. You know, Hey, great set or I've heard him laugh or re say a punchline afterwards to me that he liked and, but we were never hangout kind of guy. I never, I never went up to the office and smoked a cigar watch a basketball game or something. I feel like if I went out to a restaurant and I saw him at another table, I would, it would be all right, but awkward over to say hello, but I would keep it brief and make sure that he knew that I was going to keep it brief and just say, look, hi Dave, I haven't seen you. I really miss you. It's great to see you. I hope you're well, you know, right, right. That's one of the things I learned early on is that if people got to know me, the idea, if you're a civilian, you think, well, if he gets to know you, he's going to want you on more often. The minute I started doing stand up, I realized I have zero charm. My stand up has to speak for itself because if anybody gets to know me, they're not going to be, they're not going to want to hire me and have me around. And I think it's very wise. I think the mistake you could have made is to have been too comfortable around David Letterman, right? Well, I think, I think the people who he was friends with, who were comics that he was having on the show, he was already friends with them ahead of time and, and they, you know, John Witherspoon and George Miller, those guys Dave was friends with before they were going on the show, but he wasn't having them on the show unless he thought they were funny. I mean, so I think, yeah, if he wanted to make friends or have me over or something, that would be fine, but I don't think that's what gets you back on the show. Right.  Are more of your friends comedians or more of your friends?  Well, I think that's a word that we comics use a lot, but it seems weird when you let other when you when you let them, you say it, you know. But do you gravitate because I found once the kids were born, I moved away from I said this to Larry Brown. Larry Brown and I talked every night bubbles. I could not fall asleep unless I talked to Larry Bubbles Brown, who continues to make me laugh really hard. But the minute I had a child, I realized Larry was not going to be the guy I could call it for in the morning to help me if something happened. So I gravitated towards normal people. Did you? How do you live your life? Do you like being around comedians or are you comfortable around people who do other things? I definitely like comedians, but it's they've got to be comedians that are geographically, you know, it's funny because I when you asked me to be on the show that I went and looked at some of your episodes to see why I should listen and see what what's going on on your show right now. And so I listened to Greg Fitzsimmons, who I am. He lives in the neighborhood and our kids are close to the same age. And so I hang out with Greg when he's around, but he's pretty busy and he's on the road. So we maybe we have dinner with them. You know, he and his wife and my wife and I have dinner once or twice a year and maybe I see him one or two other times. I would say my closest friend right now is a comic who's, you know, probably 16, 17 years younger than me, but he lives in the neighborhood and he's on my podcast quite often Nigel Lawrence. And that's, you know, we have a similar sense of humor and he's available to hang out with when I have my free time during the day. Once my wife goes to work and my daughter is at school, that's when I can hang out. I can't be going out for beers in the night, evening time. And I can't be driving across town to have an hour and a half lunch, drive an hour to go have lunch for an hour or to drive an hour back. I can't be doing that. So so the most of the people that then I live my life with besides Nigel or when when our mutual friend John Ross lives nearby, he had a wife that had been married, that we had been married the same amount of time and our daughters were born three months apart. So the fact that we were best friends then our families could be best friends because of that matchup. But that's what happens when you, when you get married, now you're spending time with your wife.  But if I'm on the road two weekends a month, then the two weekends I'm home, you know, my wife wants that to be us time. So we're going to hang out with other couples. And then once you have a kid, well, the ideal other couple is a couple that's got a kid that can play with your kid. So you know, this is the problem with my 50th birthday. My wife was like, I want to have a 50th birthday party. And I said, like, I don't want to have a 50th birthday party. She goes, why not? I want to have a 40th birthday party. I don't want to be 50. I said because it's because of the people who come to your 50th birthday party, you know, when you're single, you're hanging out with your friends and your friends on a scale of one to 10, not one to 10 objectively, one to 10 subjectively. Subjectively to you, your friends that you hang out with when you're single are eight, eight, nine or 10s. You're not hanging out with any sevens because you're the person who's casting this movie. It's for you. Right.     It's terrible. So yeah. Yeah. Do you see what I'm saying? You are normal, though. In that you're, and I, and so is John Ross, because we were, you know, we were best friends and hung out, but you guys did normal things.   You got married before either of John and I. How normal is that? And you had a kid. You had two kids.  I just became more of a hermit. I was already a hermit, and then once you have kids and a wife and responsibilities, it gives you more reasons not to hang out. Well, right. You don't have as much free time. I mean, that's the other truth about our relationship is, you know, you've got, you're not in charge of 100% of your time. You're doing things with the other person, which hopefully you also enjoy. But sometimes you're compromising or going to the thing that they want to do. But whatever you're doing, you don't have that time to go hang out with your buddies anymore. So you do compromise. You do.  Yeah, except we don't go. I just, I'm sort of off going to movies now. Like I, we went to the first Guardians of the Galaxy and I'd like to go see the second one because that was the first movie where my wife, my daughter, and I all had a great experience at the theater. But I find oftentimes the movies are, you know, you're going because that's the night that you've got a babysitter and you can go and then you're picking the best thing that you can of the options that are available. And then it's like, God, what's the point?  I think of you early on. I apologize for going back down to the 80s, but I just have some preconceived notions about you that one, one of those notions is that you instantly said, this is my life. This is my structure. This is how I'm going to live. Whereas somebody like me or John Ross is constantly saying, is this my life? Is this who I am? Is this my life? I think early on, you set up a schedule, a vision of what your life is, who you are, and you compromise, but you've kind of stuck to it over a long stretch of time. Yeah, I've been blessed and cursed by being able to get work in comedy clubs for all those many years and then, you know, corporate things and every once in a while, I get a pilot for a TV show or a little part in a movie and stuff. But most of the time, I've just been working on stage doing my show and I kind of focusing every August and September on filling the calendar up for the next year. And I've been able to do that for all this time. And so I hadn't really thought about it. A little bit of it was always kind of a nail biter at that time of year. What does that even mean August? I don't even know what that means, August and September. For the longest time, comedy clubs would be filling, they would book their next year's calendar in August and September. In other words, by December of 2017, January through December of 2018, they would have mostly already on the books. For the longest time that was the case. And so that's how I was just geared was filling up my calendar as much as possible and then the spaces that were still open, calling my manager, agent and saying, look, I've still got these availabilities that I'd like to fill in my calendar and hustling and then going to do the gigs. And then now social media and podcasts and all that other stuff. You've got so much more responsibility of promoting your own shows that yeah, I kind of settled into that rhythm. I don't know that it was as conscious of embracing of it as you're kind of portraying it. That has to be, I didn't even know this about being that successful as a standup where you actually see the year ahead of you. That's a great way to live. If you can pull that off. Well, it was great. And I would say only now am I now having to try and figure out how to do like I've got the Cleveland date that you mentioned the week after that, I'm going to do Pittsburgh. And then then I've got this kind of fun theater show that I'm doing in Great Barrington, Massachusetts. But then I'm combining that with a show in Manchester by the sea and another one of my friends got this barn at his bed and breakfast in New Hampshire. So I'm going to do a show up there. And so I'm trying to do these other shows to still be able to engage with the crowd and write material and keep it real. But now it's a little bit more of putting it together on the fly that way than it used to be. And there's an excitement to that. I feel like we're kind of coming to a point where there's so many great comics and there's so many great comedy clubs that but there's I still feel like there's there's there's new ways to go out and do shows to call there's a lot of comics now that are just doing shows and music clubs. You know, they're doing they're doing a tour where they're just in St. Louis for one night doing a show. And then the next night they're going to be somewhere else. You know, Stan Hope, that's how he's doing his tours now. Stan Hope at one point would come to your house if you could guarantee an audience. Well, I didn't know that, but I've talked to some music musician friends of mine and they were talking about house concerts and doing that. And I would I would consider you know, there's the creep factor that you got to try and watch out for now. And I heard you talking to Greg Fitzsimmons about the whole like we're from this time before where you wouldn't put anything out there unless it was your polished best version of yourself.  And the next thing you know, you're famous Angela Johnson. She's famous from that nail salon bit that she does somebody she didn't even record it. I talked to her somebody else recorded and put it up and it just blew her up. So it's hard to know what to do to promote your show or where the best shows are. And you know, it's funny. It's funny to me to still have people I'll go and do something on Facebook and Facebook live and people are nice. They're like, oh, that's great. When are you coming to Philadelphia?  And it's like, hey, why haven't I been to those places?  If it's a house party, I suppose I might be open to that. Who were you measuring yourself against when you were starting out? Or did you not measure yourself against somebody else? Was it John Ross? I don't know about that. I feel like I had a really when I won the comedy competition. And then also you've already mentioned that three times, Jake. Yeah, I got on it. You did say that you wanted to talk about that. So I just want to make sure that I have actually, I was teasing. I have a question about the comedy competition. So go ahead. So I did that happened in 86 late 86. And then I also picked up my managers at that time, because at the same time as that competition was going on, they were casting the HBO 10th anniversary Young Comedian special. So I got on that. And then two years later, I was on Letterman. So that was a big I kind of went from hustling and trying to get to fill up my calendar as a as a middle act in comedy clubs. I got to be looked like a headline and I was working all over the place and I was in LA and I was trying to do a sitcom. So that was a really fast kind of success. And I don't know that I compared myself to anyone. And I don't know really I remember that my agents and managers to me, you know, that's so funny.  And they're going, What do you want to do with your career? And I was like, I don't know. I don't know. What can I do? What are my choices? You know, and thinking, Well, yeah, it would be cool. They at that time it was that you got to get your own sitcom. It was before Jerry had his show. But you know, it was Roseanne was doing it. You know, that it was going on. And I was thinking, I don't want to be a sitcom. What I thought I wanted to do then was I want to be Tom Hanks. I want to, you know, he wasn't the famous dramatic movie star, but he was doing comedies and he was doing other sort of kind of serious movies and it looked like really fun. And it's like, Hey, if I get to pick, if it's like, what do I want to do? I want to do, I want to be that guy. I want to be Tom Hanks. Who doesn't want to be Tom Hanks? At that time, being Denzel Washington was not one of your options. But you know, now who doesn't want to be Denzel Washington?  Look at what Jamie Foxx has gotten to do. But you know, you can't measure your career by somebody like that.  Did you, well, I know you've been generous with your time. Just give me five more minutes. Okay. Yeah, sure. Okay. This is what I remember. You had Buddy Mora, who was Robin's manager. And I thought there was somebody who could just open the door and tell me the truth. Just this is, here are the keys to the kingdom. This is what you need to know. That never happened for me. Is it fair to say that nobody can help you, that you have to figure it out all by yourself? Yeah, I think that that's true.  You had Woody Allen's managers. You had the greatest managers who nurtured the greatest talent. Did you think once you were accepted into that fold? Well, I left them because I was kind of mystified. I didn't really understand what they were doing. And whenever I would try and ask, like, Hey, what are you doing? And what's the next thing? They were always very much about kind of, Hey, trust us, we're on it. Don't worry about it. Then when I left, they were kind of like, what do you mean you're leaving? And I felt like, look, I don't understand what it is. I went on Letterman one time. They were his managers. I remember this. I'll tell you what he said. Letterman said to me, Buddy Mora, what does he do? On the air. He said that. Yeah. So I didn't really know what they were doing for me. And I left really, I think possibly before they were able to do the most that they could for me. But they were very old school management. They were like, we're in charge of that.  They were great. And I've since I've talked to Buddy and I went to his retirement party. I have nothing but respect and gratitude to him. And sometimes, you know, when you look back on your life, I wonder, look, if I hadn't left them, would things have been a little bit different? I don't know. But I think I needed to, for me personally, I needed to leave because I needed to find out what do they do? What could someone else do? What do I want to do? And, you know, I've always made choices in my career based on what I thought was the coolest thing to do. You know, like I, and right or wrong, I've said to my manager, like, hey, maybe I should have, when they came to me to offer me this hosting this thing, or I had a chance to, to do that, whatever game show or talk show thing. And I said, I wasn't interested in that I was going to do this. Maybe I should have taken that job. And I should, even though I didn't think it was going to be good or rewarding or creatively satisfying, maybe I should have just done it and then gotten more famous so I could, so I could be more successful now. And she said, well, you, you could have tried to do that. But she said, I know you, you would have taken that job. And then you wouldn't, you would have been so miserable.  Right. You know, I know that doesn't seem like the guy that I am, but I feel like guy, I operated from, from a position of feeling like, look, I wanted to do what I wanted to do. And whether it was right or wrong, that's what I did. And I have the, had the career that I have had. And it's been, it's been great.  When I look back on my career, and when I think about what, you know, that moment when it's like, what do you want to do with me saying like, I want to be Tom Hanks, you know, the, the reality of where I am and where he is, is, is pretty radically different. So in that sense, you know, I'm a massive failure, but in another sense of like, look, I've had a really good time and I've had the respects of my peers. And I still enjoy, I still love what I'm doing. I still love hearing my name and walking on stage and making people laugh. And, you know, I may not be a genius at social media in terms of I don't have a hundred thousand followers, but I find it very satisfying to go on, do a little something on Facebook or Twitter and have people give me a little shout out compliment. Hello. You know, and, and, and I've, you know, you included the people that you get to hang out with as a standup comic are just some of the most fun people.  But if you want to get into standup because you want to have some great conversations and laugh and always have a phone full of numbers of people that you can call and, and enjoy a conversation, then standup is for you. Right. Like me last night at one in the morning, I was talking to Greg Fitzsimmons. I got into a little trouble and we were, I mean, I was, you know, I don't want to talk about it, but I was in a little trouble for something I did. And he kept saying, you got a great story out of this. This is so funny. This is so funny. You were in a little trouble, Dave. Huh? You were in a little trouble. Little trouble. Yeah. But it's a funny story that I can't share before you go.  He gets me into trouble. Yeah. Okay. Well, I don't know. I have no idea what you're talking about. Okay.  I, if the joke is sitting there and it's bad taste, I have to go for it. I just can't help myself. So you said you only wanted to do things that were cool. And when he meant was fun, things that interest you. Yeah. I feel like, you know, I wouldn't say that I've 100% been true to that, but I've, I've made, I've made choices that to me were about what I was most interested in doing. And we're not always, or that's been the criteria for making the choice. And I've, and I've, I think it's cost me money and it may have cost me a little bit of fame to have done that. But, but it's, but I'm not miserable and I'm not broke. Right. And you never found yourself in a situation where you were doing it solely for the paycheck. Oh, there are those, there are those moments. There's always, no matter how you do your life, those gigs where, you know, I was, I, the thing when I, when if you're doing a show and it's going, uh, not so great, you just pat yourself with your right hand over your heart because that's where the check is. But you never found yourself trapped in a job. No, it wasn't relentless. It was always like, oh, I didn't see this coming, but ha ha ha, it's, this happened again. You know, I, I, I did a show in Peoria. There's a funny club in Peoria called the jukebox that's owned by a real character, this guy, Dan, and it's such a throwback and you know, I don't know if you know that our friend John Means, Dr. Gonzo, who's near there. So I hadn't seen him for years and he came up and he has his own restaurant in his town. So he came up to the late show on a Saturday night and I haven't seen it. This is only maybe five, six years ago. And, uh, but I haven't seen him in 15, 20 years and he shows up so good to see him. We're laughing and he stays for the show and it's literally 30 people and 20 of them are two separate bachelorette parties that are sort of in a competition with each other to see who can be the most drunk and disruptive. And it was funny to me to be in that situation at this point in my career in front of John Means. It was just such a throwback to those early days. So, so from the outside of, you know, if my wife or any friends were at the show, they would think, oh my God, this is terrible and Jake must feel desperate and suicidal after this night. But to me, it was just such a funny, fun story and moment to share afterwards. You know, when you say thank you and the bachelorettes, they've had a great time. They've had a great time. I've probably been on for an hour and I've done maybe 13 minutes of material because most of it's been like, what about you and then what's going to happen when you get married and you're drunk? You know, it's just been talking to them. And after the show sitting down with Gonzo and having a beer and laughing about it, it was it was a great night. Dr. Gonzo, what I have to have him on the show. I remember he did something for me that was life altering. I had just started doing stand up. I moved to San Francisco. I gave him a ride home and he said, come on into my apartment. And I said, okay. And he, you know, he was Dr. Gonzo. People lined up around the block to see John. It was he was the biggest thing in San Francisco. And I'm in Dr. Gonzo's apartment. And he took me into his office and he just walked me through the steps of getting booked. He said, this is a map. This is my phone book. You got to get a phone book. You got to get names and addresses. This is you got to get an eight by 10. You got to mail them out to club owner. I mean, he walked me through the entire process of getting yourself booked as a comedian. And I never forgot that. I thought, what a gender. I remember calling my parents and telling them about this Dr. Gonzo show. By the way, before you go, by the way, about age and time.  We started exactly. So I don't think of you as a senior, an elder statesman, right? Oh, yeah. Well, that is, yeah, go ahead. But if Larry and Milt Abel and John Ross, like John Ross started maybe a year before we did. Do you still view John as an elder statesman? I do. Even though he had a year under his belt, I still see him as an upperclassman. Larry, I did these shows with Larry Miller, who I think is just one of the greats, but he had an accident where he hurt himself, fell over and hit the back of his head. And he wasn't able to perform his show up to his standards, but he was still going out on tour and he needed someone else to go on and carry some of the time. So I did these shows with Larry that were just so much fun and it's such a pleasure to hang out with him backstage. And if you're listening to this and you have a chance to go see Larry Miller, I don't know how often he performs now, but please do yourself a favor and go. But I feel like Larry was one of those guys that I worked with in the early 80s when I was the opener and he was the headliner elder statesman at that time. But now when I'm hanging out with Larry, I think to he and I, it seems like we're contemporaries. And I feel like I was doing a show in God, Hartford, I think it was Hartford, Connecticut. And it was one of the funny bone improv things. And the feature act was this really funny guy. And you could really tell he was going places his name and he's been now he's been on Letterman a bunch of times Tommy Johnnigan, right? So I'm hanging out with Tommy and we're laughing and you know, the shows are going great mutual respect. I really like Tommy and I he's a contemporary. That's what it feels like to me. And that's what I think it felt like to him. It's like, hey, we're two funny guys hanging out. We share kind of a similar kind of appreciation for a certain kind of comedy.  And like, it's just so one point. And we've been hanging out for a couple of days. I go, Tommy, how old is your mom? She's a year younger than I am. So I still feel like all these, if you're walking on stage and talking into a microphone after somebody introduces you to comedy club, I consider you a contemporary. And that's sort of how I look at all of this stuff now. So, so John's a contemporary, but Tommy Johnnigan's a contemporary. And you know, the next person I meet a contemporary, you know, I don't know if you know, do you know who Ms. Pat is? No. Well, she's going places.  And she's been on Harry Connick's talk show now, but she's great. And so she's one of my new people who's just, I've met her kind of at the, just at the cusp of her exploding on the scene. And that I feel like is one of the things about this job to me that I've, I've enjoyed spending all this time in comedy clubs and, and working on stage. That's how I've earned, you know, guy like Greg Fitzsimons, he's earned a lot of his money writing for shows and then also performing, but back and forth and doing the thing. But I've been mostly on stage and out there in the clubs in the world. There's been such a pleasure to be able to call these people contemporaries and to see them before they had the success and then after they had the success, you know, to work with Mitch Hedberg when he was my feature act and then go out and see him become this amazing, amazing hero of a lot of comedians. You know, it's been great. But, but I consider, I consider people more contemporaries than, than that kind of elder statesman or new kid on the block kind of a thing. Jake, this, you started, I was going through your files. I, for some reason, thought you start. I knew, I remember you telling me you were doing a podcast, you started in 2011. Right? Yes, that right. Yeah, that could be, that could be true.  But I've only been doing it like two years longer than you have. But for some reason, I'm thinking, well, I've been, I'm compared to Jake, I've been doing this much longer, but you've been at it for a long time. What is Jake this? What do you do? I'm Jake this, you know, it's, it's a lot of me talking to people who I know and I'm interested in. And I haven't really tried to focus on the guest angle. It's more just if you are a fan of mine or you enjoy listening to me talk and you'd like to listen to me talk to people who I'm interested in listening to, then you'll like it. But it's, it can be all over the place. You know, I had, uh, Kostaki Akonomopoulos was over the other day and he said, I was listening to try and prepare to the pod for the podcast. And I listened to this guy. There's Todd McComas, who's a comedian, but he's also, he was a undercover police officer in Indiana, Indiana. And he has these great stories. So there's an episode with him, there's an episode with Miss Pat talking about selling crack when she was a teenage kid and then became a single mother at 13 years of age.  So it's kind of all over the place. I, again, I, if you like it, yeah, check out, check out Jake, this to our listeners in Cleveland, June 15th to the 18th, go see Jake at Hilarides and you're playing a bed and breakfast. Where that's, that's to me. That's the most exciting. I swear to you, when you describe that, I went, wow, the week after Cleveland, I'm going to be in, um, Pittsburgh at the Pittsburgh improv. And then I'm just now looking to the, the bed and breakfast is, I'm, hang on, because I'm just, I've got to open this document. While you're opening it, when you describe that, I thought a friend who owns a bed and breakfast and performing there, to me, would be so much fun to do, so relaxing and no pressure. And well, he used to manage, um, musicians and I met him down in New Orleans and it's called, uh, The Barn at the Farm Stand and it's in Tamworth, New Hampshire. Wow. And it, go to my website, check this.com. I think there's a link to the Eventbrite site. You know, I'm going to hang out with him and we're going to do the show and, uh, it's, I think there's only a hundred or so, maybe a hundred and twenty tickets, but it's going to be a fun night. That sounds fantastic. Thank you, buddy. All right, Dave. Thank you. My pleasure. Anytime.


Hi, everyone. Today I'll be speaking about building an ORM with Irid. My name is Vipul. I'm supposed to be presenting this along with Prathamesh, but apparently he wanted to go to RubyKaigi. He's presenting there, and he's having fun with lots of food and nice Japanese cuisine. I work at a software consultancy based out of Miami. I work remotely. It's mostly Ruby on Rails, building web apps and things like that. As you mentioned, I run Ruby India back in India.  I do a newsletter which is named as Ruby India newsletter. You can check it out on rubyindia.org. We've recently started with podcasts at rubyindia.org, where we do a lot of podcasts from a lot of people from the Ruby Indian community. Also, we are going for the past month I've been traveling, so I got a chance to interview people like Koichi Sasara or Fabio Akita and such people. So you can go ahead and check it out. A bit about Ruby Indian conferences. So there are lots of Ruby Indian conferences that are coming up, main among them is Ruby Conf India. How many of you have heard of Goa? So if you like Goa, you should attend Ruby Conf India. You get to stay at a resort. There's Garden City Ruby Conf which is in Bangalore and Deccan Ruby Conf which was held two months ago in my hometown, Vijaspune. So if you'd like to visit India, do come around in one of these events. Before we begin, it's been ten years for Rails, so maybe a round of applause for that. We had this awesome event where we celebrated launch of Rails. And this is one of the issues which was by Hiro Osari on Rails issue tracker. So if you get a chance, go around this issue which is 16.731 and do show your love for Rails. Anyone who's from the Rails team over here? No. Anyway. So yeah, as you mentioned, when in San Francisco, wear your own plain t-shirts, I was wearing a brainy t-shirt which I got in Madison and they were like, yeah, anyone from Braintree? Okay. So I got people asking me, like, five or ten people asking me, oh, where's your office? Or do you know Jack? Oh, is your office in Massachusetts also? And, like, it was really embarrassing. So wear your own t-shirts. Coming back to the presentation, I'll be walking through. It will mostly be a code walkthrough. We'll be seeing a lot of hands-on code. So please bear with me. There's a lot of code to see, so I'll be a bit fast. Before that, we'll need to take a look at how do we create caches, but he has already covered it. So why build our own ORM? Basically, we'll try to experiment and build a tiny ORM, which I'm calling a storm. We'll try to take a look into what are the different aspects involved in an ORM and get a bit better understanding of what different things go around in active records so that we get a better idea of what we are dealing with. And if we fall into, like, different bugs or we fall into hurdles, we get a better understanding of whatever we are working with active records. So what is ORM? ORM is in scientific terms. It's something which is used for converting into incompatible types. We can call it as a virtual object database, so, like, from a database to helping it out for accessing in your native language, like, in our case, it would be Ruby. There are two basic patterns for implementations for ORMs which are used, which are implemented in Ruby, one being the data mapper. We'll be taking a look at active record today. So what active record is going to wrap a row in a table and encapsulate accessing of that particular row, giving you methods like instance methods for accessing information on that particular row. And on top of that, you can define your own domain logic for what needs to be done on that particular top of that particular row. Different components we'll be taking a look at is database connection, how do we actually connect with the database? We'll be taking a look at Postgres today. Query generation, which will be where Arial will be helping us to actually generate the whole queries, attribute accesses, which we'll be taking a look at and type casting mechanisms. So what we essentially want is if we have this kind of table structure where we have post model, sorry, post table where we have ID, name, content, authors, and so forth, and we have this information over here, we essentially want it to be represented in the form of a basic object in Ruby, which has ID, name, content, author, and so on and so forth. Behind the scenes, what will be happening from our ORM is it will be converting all of these single fields into integer strings based on whatever value is being written to us from the database. So what we want to achieve is something like this, what you can do an active record, post equals to post dot new, pass a hash off values and you can do post dot save, you can do post dot find and so on and so forth. How we are going to do is we are defining our own ORM over here, which is storm, tiny ORM. I'll be giving links later for checking out the actual code and if you inherit from this particular model, you'll be able to perform different operations similar to how you do it in active record. What is the role of Arial in whole of this? We are going to use it for actual query generation. A bit about Arial, it's an acronym for relational algebra. It is mainly used for, it is a SQL EST manager, like all of the different things that are involved in a query, they are being, like the different things which are involved in the query, like select or all of these things, they form, they are formed as an EST and Arial is helping us to create that, traverse this particular query. It can generate a lot of complex queries like unions, joins and other things and it adapts to multiple databases. You don't need to worry about in case of Postgres or in case of MySQL, how does the limit clause work or how do different things like Windows work in different databases? It works on its own. These are the components, basic components of Arial's EST. As I said, it is used for actual having information of parts of the query and it works in terms of nodes. So every single node has one basic information of how to work on, let's say, where or limit and so on and so forth. We have visitors which are going to traverse through all those, that particular EST and work on that particular nodes and find, convert it into strings for execution. And we have managers, visitors don't know how to traverse a particular tree. So managers are going to help the visitors to actually find out, like, in case of insert, we have insert manager, in case of insert you have to go this way, in case of update you have to do updates, in case of delete you have to delete. So this is essentially what we are going to implement today. We have the O and M sitting in between of database and Arial and RORM will be allowing access, will be exposing access to the database to the user. So Arial will be used for generation of queries, which are sent to database. So the first part that we need to implement is basic engine, which is going to handle, which is going to provide information to Arial regarding the tabular structure, the column structure. How is the table? What kind of database does the table have? It is going to provide database adapters. So in case of active record, currently we have SQLite, or we have MySQL, MySQL 2, or Postgres. This is being provided by database adapters so as to, so as the, like, Arial knows what kind of coding mechanism or what kind of actual processing of coding should be happened by the database adapters and what kind of connection should be used for accessing the database. Then we have data type mappings, which are used again for typecasting and other such things. So let's take a, let's start and take a look at this engine skeleton. So this is not live coding, but this turns out to be hard sometimes. So this is a basic engine that we have over here. Right now it doesn't have anything, but in our, in our module Tom, we have this engine over here. It'll have more methods as we go ahead. Next we have our model over here. We are defining bare bones, crud operations over here. And thing to note over here is the Arial table that we have defined, the table we have defined over here. So if you, if you see over here what we're using is we are making use of Arial table and we're passing the name of that particular, name of the table which you want to access from the database. And next thing that we're passing is Tom engine, which is going to, right now it is empty, but later on we are going to fill it and it is going to, it is going to be used by Arial to find out information about coding on that particular column and other such things. Here we are just passing, right now we are just passing appending an S to that name of that particular class. So if it is post, it is going to be post active record. You make use of active support for inflections and finding out properly how you're going to pluralize a particular table name. So yeah, that's the basic thing we are done with the basic engine skeleton setup. Next thing that we need to define is database connection, how you're going to connect with the database. So yeah, we have gone ahead and defined a Postgres adapter we are going to work with, we are going to work with Postgres over here. We are making use of the PGM as you can see over here, we have hard coded database name which is Tom development in our case. In, in the case of active record you're providing, you're using database.byml and it is passing and then from that it is determining what, what, to which table we are going to connect. Another thing to note over here, we are defining visitors. As I told, like, as I mentioned earlier, visitors are used by ARL for determining what kind of, for, in case of Postgres, what kind of, what kind of syntax should I be using? So here we are defining that our visitor to be used is Postgres. So it will be defining, it will be passing the tree and it is going to define statements in terms of Postgres. We have some other, other simple methods over here for quoting of table name, column and quoting of values. Right now these are very, very basic and we are just, we are just going to say whatever value is coming, just return that value. Here we are quoting the value, we are just going to mention quotes for, this is basically when you are creating a query for insertion, the value should be coded. We have gone ahead and started using this Postgres adapter which you are seeing over here and defined a method called as connection. You can see over here we can, this now is going to be exposed as an adapter and it is going to be used by our ARL table which we had previously, previously being passing into the model. After we have set up the database connection and it has information about accessing the Postgres, Postgres database by use of PGM, we are going to define columns. So let's take a look at, oh, so we are going to define this class over here which has information, which has three basic attributes which is name, SQL type and CAST type. Name is the actual name of the column, SQL type is in case of, in case like the actual database type, it can be var char, float, decimals, so on and so forth. CAST type is, we are not passing it right now, we will be passing it later. CAST type is, how we are going to, we are going to define types which are going to take care of type casting to and from database or from a user to the database. After we have defined this, we are going to define something in our Postgres adapter. This is a big carry, you don't need to know about it, you don't need to worry about it. What we are doing is, this query is being extracted from right out of ActiveRecord. What it is doing is, we are passing over here the name of the table, we want the information of that particular table and it is going to return information like the name of that particular, name of that particular, information about the columns, like the name of the column, the data type of that column, other information like default data type, like default value or what the value should be in case of a database. Right now, we are going to, we are not going to worry about all these other things. What we are worried about is the name and we just want the data type which here it is showing it is integer. We are using this column definitions and we are iterating over all the, you can see over here, we have array, we are iterating and creating, we are creating a particular, we are iterating through all of these and we are defining columns for all these different values which are being written to us by column definitions. So after we have information about these columns, which is an array of, as we have seen in the column class, we are going to go ahead and define a schema cache. So every single time you want to access information about a particular column, you don't want to go ahead and query the database and get information about that. That's why we are going to define schema cache, which is going to act as a, it is acting as a simple hash which we are, which is going to define, which is going to associate all the different columns that information that it has along with the, along with the table name over here. As simple as that. So the next thing that we have is after we have set up this basic things, which is schema cache, you can see over here, what all things we have defined. We have defined the postgres adapter as you've seen over here, which has basic information. We have defined column, we have defined engine, we have defined a model. We are going to go ahead and define some basic tests to cover basic scenarios. So to start with what we are doing is we are defining this model over here, which we'll be using in our tests. So we are defining class post and inheriting it from top model. So this is a basic model, which we are going to use in our tests. We are defined our test over here. You can see post model over here and we have defined some basic tests, as you can see over here, where clauses, which we have not defined yet, setting of the error table, which we have seen, initializing like what we essentially want to achieve is something like when we are doing post.new and passing this value, we are able to access this value on that particular instance that we have created. Right? Saving of new records, deleting of records, which we'll be taking a look at in the next slides. So till now is everyone with me? Yes, no? Okay, great. So this is a basic structure that we have right now. Now we are going to build on top of it things like attributes. So please bear with me. It's like it's like a lot. Sometimes people miss it. So after we have this basic structure setup, what we want to do is we want to define attributes. Attributes are the basic unit of access of a particular value on an instance. So when I do post.new and pass some arbitrary values to it, author, subject or something like that, and from that particular instance, I want to access the value like post.name. For doing that, we want to define attributes. It needs to work both ways, that is from the database and from the user provided values. For that, what we are going to do is we want to support data types. We are going to handle only two data types. One is string and one is integer. Another one is integer. Casting to and from the data types, database types. Attribute maps, so we have lots of attributes providing a simple access for all the attributes. Accesses for that particular, on that particular model. So as I said, post.name, that is an accessor, that is a method for assigning or reading a value from that particular instance. How we are going to achieve is we are going to define types, type map, attribute, attribute set, which we will be taking a look at now. So let's go in code. Okay. So to begin with, we are going to define a generic type. You can see over here, which has information about type, what kind of type it is, type casting, for a database. It has basic three methods, which is name of the type, type casting for a database, type casting from a database. This is generic if you don't know information of how to handle a particular type. We are going to just use this type casting, which is taking in the value and just returning that value back. We are going to define two other types in our case, which is, first of them is integer. You can see we have defined type being integer over here and type casting for that particular value, simple type casting, which is taking the value and determining how to handle that value. You can see in case of Boolean, we are doing one on zero and in other case, we are just using two i. Similar case, we are going to provide type casting for strings. We are defining type cast name as strings and we have simple mechanism over here based on different scenarios, how to convert that particular object into a string. After we have defined these basic types, we are going to define a type map to hold together all of these types that we have defined. Again, it is just a basic hash for which allowing us to access the types easily. Two important methods to take a look at over here, it is register type, registering a new type. In our case, we will be registering two types, which is string and integer and another one being lookup. Here, what we are doing is, what we will be doing is we will be passing name of that particular SQL type and on that basis, on the basis of the SQL type, they are going to determine what kind of type casting object, like is it a string or is it an integer and on the basis of that, we will be returning that particular class for use for type casting. If nothing is matched or nothing is found, we are going to return the default value, which you can see over here is just the value, the generic value, which is going to take the value and just return that value. We have a generic type set, integer and string types. Next, we have the type map. After we have the type map, we are going to go ahead and define our attribute. Attribute will be consisting of three particular values, name, value before type cast, without any type casting mechanism and type. Type is again the three classes that we have seen, string, integer or generic. Here, we have all convenience methods, which are initializing over here, conversion from a database or from a user. Again, these are all convenience methods, no need to worry about them right now. This is the basic unit of, as I spoke earlier, for handling of a particular value. All of these attributes, we are going to club together and provide something called as an attribute set. When we are creating post.no, we are providing a hash. All of this hash is going to convert into individual attributes and they are going to club together into what is called as an attribute set. Again, it is just a hash and it has information about how to write and read from a particular hash. Important thing to note over here is we are defining attributes variable over here. In case of active record, if you have seen, if you do post.no and pass some values and on that instance, if you do dot attributes, the hash which is being returned of name and value of that particular whatever is being stored in that instance, this is something similar, this is something similar which we are trying to achieve over here. That's attributes. So, after we have attributes set defined over here, again, we are defining some convenience methods for taking in values, hash of values like name and what value to assign and using it for building our object. Here you can see we are taking, when we take value from the user, we are going to build attributes from that values, which is we are just going to iterate through all those values and build one single attribute for that particular value. If you don't have value provided by the user, if we have five columns and user is providing only two values, we are going to initialize the other values with nil, like nil values, like the name of that particular type and initialize with nil. So, after we have this builder set up, right now we are on the stage where we have attributes, attribute sets and we are able to provide attributes to a particular instance. Next thing what we need to do is provide a database with readers and writers. So, we are going to go ahead and define something called as read methods. You can see over here which are singleton methods for if you have ID, name, author, they are going to define, just going to define singleton methods on that particular instance for accessing those values. Here you can see it is just fetching the value from the attributes which we have defined. And then we have write methods over here, again, which are singleton methods if you can see over here, we are just taking the values from the user and assigning them, creating a new attribute. You can see over here based on whether it is from database or whether it is from user. We are going to convert and type because that is basically being handled over here. All right. So, after we have these readers and writers methods set up, when we do post.new and passing that values, we need to handle how the initialization works in case of TomModel. So, we are going to go in our model now. Yeah. So, here you can see we are passing, if you pass hash of attributes, what it is doing is, first of all, it is going to initialize with nilattributes for all the columns that it has. It is going to initialize attribute methods, readers and writers for all the columns. Then it is going to take all the values that are being passed by the user and or in case of database, database and initializing like loop through all the values. You can see away the stringifying all the keys just for convenience and it is going to assign all these values that is using our, we have previously defined our assignment writer methods. We are going to use the writer methods and assign these attributes by just doing a public send. So, hopefully now we have reached to a stage where if we do post.new and pass a hash, we are able to, after we are doing, we have done that, we are able to access the value which is being passed to that particular new object. So, if we go back to our tests, something like this, like post.new, subject, something, something, this test should pass in our case because now we have provided the reader writers and handling of the attributes. So, let's go to our terminal and take a look at the tests. Yeah. So, we are able to now handle the situation where passing of attributes is being converted into a model. The one test that you're seeing failing over here is creating of a new, like saving, persisting it to database which you have not handled yet. So, all the other tests are passing. So, next what we need to do is we have this whole model thing working. Now we are going to work on persisting that is saving to the database and back from the database. So, things that we'll be handling is CRUD operations. Yeah, let's go back to the code. All right. So, we are defining, we have defined some basic operations as you can see over here, CRUD operations, create, update, destroy. Let's start with the easiest one, which is create. Again, create is going to take, if you know an active record, it takes a hash of values and it is going to create a new object and return that object. This is something what we are going to do over here. We have already seen, we have already defined new. So, we are going to, first of all, in case, we are going to take the values and create a new record. We are going to make use of ALS insert manager and going to, so you can see over here, we are using insert manager over here and going to provide information to this insert manager on which table we want to insert this particular query, what values you want to insert. So, from that record, we are going to extract all the current values that it has. You can see over here, it is using current attributes. It is just going to loop through all the values it currently has and pass it as a hash, which we are passing it to the insert manager. The insert manager on firing two SQL, it is going to return an SQL query and that is something that we are going to execute. After the create statement, we are going to return, we are not going to worry about what is being inserted. We are just going to return the last record which is inserted. So, we have defined last method over here. Last method is making use of primary key sequence. We have defined a custom sequence over here, which is going to increment whenever a new value is being inserted into a table. We don't need to handle this in case, like, if you are defining an auto increment on a primary key or things like that. So, yeah, we are making use of primary key sequence over here and we are passing it to lastinsert.id, which is going to execute this query and return the last value for this particular ID. So, this last ID that we have, we are going to pass it to find. Find is select, basically select. What it is doing is, we are using it where, where over here, which is being provided to us by Arial. It is just going to say, like, convert your tool and say where ID equals to so and so value. It is going to build us a query over here and we are going to say project. Project is another term from Arial and we are seeing that project all the values, like, give me all the values which are present in that particular, in that query, I want to find all the values. This find clause, again, we are going to go ahead and execute query that is passing this, passing it to the connection, like, pggem, which we have defined. It is going to, we are using two SQL over here, which is converting that into an SQL query. It is going to fetch all the values, which is, again, a hash. From this hash, again, we are passing it to new and it will be creating a new object for us. So, here, we are being returned after insertion of a new object. We are being returned with a new object which has information of last inserted object. In similar way, we have update. You can see where it is taking values. It is using update manager from Irel. And, again, we need to provide table information, what ID, for which ID we want to insert that update for that particular value and what values are needed to be updated. Yep, in case of, in case of this, we are just going to say find and the ID of that particular value. Similar way, we have destroy, which is taking in, which is going to make use of delete manager and it is going to say from which table we want to delete which value, like, in case of, here we are passing ID, so it is going to say where this ID delete this value. Yep, that's about it. Like, we have create, update, destroy. Next thing that we want to see is save. Again, it is a convenience way when you do post.new and you have the instance, you say save. If it's a new object, like, if it's already, if it's an old object, if it is being persisted to the database, in our case, we are just going to handle persistence by identifying if the ID value is there or no, in case of active record, it has a lot of checking, like dirty, if the field is dirty or no and all those things. Right now we are just going to say if the instance that is currently there, if it has information about ID, so it's being there in the database and we are just going to say update, which is this method over here which you have seen already. Else we are going to say create and go and create a new object and return it to the user. Yep, so we have seen these basic code operations. To support us in our tests, we have different operations for querying, find count, where delete all, these are some of these operations where Arial provides us with a method for where, which simplifies, which is just going to rotate through all the values and going to say for where clause, this value equals to this value. Here we are just, we are going to take a hash of values and convert it in, so that it is compatible for Arial. Count, we are just taking the name of that particular table and executing a simple count. Delete, we are using delete manager for deleting all the values. We have seen already, we have already seen primary key sequence. So let, so if we go back to our tests, we have different scenarios over here, which we have seen earlier, like initializing to an empty object, creating of an object, like you see over here, we are using delete also with, it deletes all the values and then we are going to create a new value and it should be persisted. Yeah, updating of a value, deleting, destroying of a value. So if we go back and try to run these tests, all right. So it is executing all these statements, which you can see over here and we have a basic tiny ORM, which is able to perform all these credit operations. And if you'll take a look, we have achieved this in only five, 60 lines of code. So that's about it. We have taken a look at database connections, creating columns, schema, cash, attribute types, attributes and attribute accesses, database statements and querying. There are other different things like associations, migrations, callbacks and validations, which we are not supporting right now, which can be, which are being supported by active record, but which are trivial to handle. And that's about it. Thanks a lot.