 So yeah, I'm Michael Harper. I am a Sun River resident, so Sun River is down or up the road depending upon how you define down or up about 15 miles. So if you are working on more than one project right now that really requires your attention and you probably shouldn't be here anyway, raise your hand. Right? Okay, now keeping your hands up, how many of you also had to remove eight inches of snow from your driveway this morning? Yeah, exactly. Okay, so I am, like I said, I live up in Sun River and I've turned out I'm 50% of the Sun River iOS developer community. Yeah, there's another gentleman by the name of Dick Lubkey and we found each other on Twitter because I think we're probably the only two people in Sun River on Twitter anyway. Apparently about 2,500 people live out there anyway. So this is, I'm gonna move this so it's a little bit less awkward. I appreciate the guys who came in front of me and set the bar incredibly high for keynote presentations. I'm assuming that they're gonna be there. I'm pleased to see all the MacBooks in the audience. There was a time when that would have been, I don't know what would have happened. Because we all think different now. So, let's get on with why I'm here. So, just briefly, my road to Objective C. Why am I talking to you about Objective C? Good question. Okay, mobile developers. How many mobile developers do we have out there? So, what's interesting is where I got started. Anybody remember a language called Fortran? Anybody know about Fortran? A prime mini computer? One. Oh, right. Yeah. That's about how important that is in my life, right? My experience actually goes back before this 1980 starting point. But that was like yellow schools of paper and pointing keywords in 110 bots. Not real applicable to what's going on today. But what I did learn when I was at Cal Poly in the 80s was I took this elective class called C. And it was on this wacky platform called Unix. And then from there, after I graduated, I went to work in San Francisco at an investment banking company and was working on doing developments on Macs that actually weren't all in one. They actually had a separate keyboard monitor at the base, and they had color. Yeah, it was exciting. So I taught myself C++, right? Kind of on the C continuum here. And then I encountered this Goofy language, a project that I started working on next. And this Goofy language is called Objective C. So, you know, I go from C to C++. And it was a good thing that I taught myself C++. It was a good thing I took the elective because, you know, otherwise I would have been armed to face the world with Pascal. Right? So I ended up working on this Next Step project in the mid-90s and encountered Objective C. And then about 10 years later, I ended up reporting that same project from Next Step to run on MacOS 10, which I thought was really cool, and to be able to see the evolution of what it started on Next. I still thought Objective C was relatively Goofy. And then, you know, we get the iPhone SDK, and we're doing mobile development on iPhones and iPod touch with Objective C. So I couldn't resist the allure of writing iPhone apps. Just too sexy and too cool to be able to, you know, pull your phone out and go, I made this, right? So I started doing Objective C programming. I don't see any Ruby or anything else on there. I must have filled it in on something else. Oh, yeah, Java! Yeah, so in the mid-90s, you know, let's see, that would be right about when my daughter was being born. I already had a son living in Marin. Yeah, I had to do something to make some dough. So that was Java Enterprise Development. So I was working for Sun, Stanford, and various other companies on this crazy platform called Tenga. Anybody remember Tenga, the precursor to WebLogic? Which is now part of Oracle, is that right? Yeah. So Oracle is like, there goes Sun, there goes WebLogic, there goes ATG. Anybody remember ATG Dynamo? Yeah. It's like this black hole up. So I did a lot of work, a lot of Enterprise working on Java, and I did that for quite a while. And then on the Java Posse podcast, if you don't listen to that, you should, because it's goddamn funny. And it's very interesting. A lot of Android stuff is on there as well. But anyway, I heard about Ruby on Rails on the Java Posse podcast, so I went and checked it out. And then ended up being asked to work on a Rails project. And from there, ended up working on a number of Rails projects. So it's not a complete disconnect that I'm standing up here talking to you about Objective-C. I do know a thing or two about Rails. So remember I said in the early 90s, I encountered this goofy Objective-C language? It's the goofy method calling syntax. You've got square brackets or everything. You've got method names and parameter names. Yeah, they have to name. They're a mile long. I mean, it's not this method selector. I mean, who would ever want to use a method selector? Why won't you just call the method on the Objective? Come on. And also, remember, this is 20 years ago. So I'm just out of college. I'm in my mid-20s. I know everything, right? So what is this class method and category and protocol stuff? I don't need to know this, right? I mean, come on, really, seriously. Why would you want to use this? We've got C++, C++ rules, right? But let me point out briefly here that I worked on a C++ project a couple of years ago, which is definitely my last one ever. I have sworn it off completely and never happened again. But, you know, this is 20 years ago. I don't need this Objective C stuff, right? So comparatively speaking, when I found out about Ruby on Rails, and then I went to, you know, after working on Rails for a while, I went to an advanced Rails studio that was taught by Chad Fowler and Dave Thomas and Mike Clark. And had the moment of zen with Dave about Ruby, which is that everything is a method, column, and object. And it's like, whoa, everything. Whoa, you know, coming from a statically-typed world of the 80s and 90s with Java and C++ and all that stuff, it's like, whoa, right? So what were my initial thoughts about Ruby? Well, you know, of course, unicorns and rainbows. Double rainbow. You can't really see it very well, but that is... All the way. That is a proprietary picture that I took. That is... That's looking towards Lenai from the Maui office, right? So it was great. I was working on a project over the last summer and I had already planned this trip for, you know, a couple weeks to Maui and I just told them that I was working for the Maui office, which I was. I mean, seriously, I was, but that was the view from the Maui office. So initial Ruby thoughts, unicorns and rainbows. Did the Maui office have a roof? I took this outside. The actual Maui office, yes, they had a roof. In fact, they had another condominium upstairs. I appreciate that. So, you know, weigh the two different lists here, right? I've got Objective C initial thoughts and I've got Ruby initial thoughts and consider that there's 15 years of, you know, experience and life experience separating the two. But, I mean, it really was in a really moment comparing my initial thoughts about the two. And as I was working for Ruby and also working on mobile at the same time, I realized there's stuff going on in Ruby that I do all the time, but I can do Objective C, right? And I didn't even clue into it until I started working with Ruby. So let's talk about the commonisms. Not the Karl Marx variety, but what the two have in common, right? So there are a number of common things between Ruby and Objective C. I'm going to talk about three of them that were important to me, okay? There are differences as well. One of them you compile things, and you don't, I get that. But these are the three things that I found were important to me that Ruby helped me to understand Objective C, okay? So one of them is the ability to modify classes and methods at runtime. And I did this yesterday in Ruby on a Rails project. I've been working mostly in mobile for the last year, but I've been helping out in my copious free time. Yeah, we all have copious free time, don't we? And we all work in it, don't we? So yesterday I was actually using this capability in Ruby to, at runtime, change out of that. That's pretty cool. Try that in C++. If you did try that in C++, tell me how you did it. You can send a method to an object. I phrased this carefully. I didn't say you can call a method on an object, because, duh, you can call a method on an object. We do that all day long. But the concept of separating the method from the object is kind of an interesting twist, a different way of looking at it. I mean, again, from C, well, we didn't have objects, right? But in C++, you couldn't really have a method live without an object. I mean, they were in that state, and you had behavior. And those were all part of the class and part of the object. So the concept of just saying, oh, I've got this method. I'll wait till an object comes along, and then I will send the method to the object and the object will respond to the method. I guess messaging is the equivalent to what I'm trying to say here is a cool concept. And finally, of course, blocks of code, blocks of code that aren't contained in a method, basically. Now, blocks of code that you can pass around. In Ruby, blocks of code that you can write at runtime. That's really cool. I did look at metaprogramming for Objective-C and got nowhere and realized, well, that's because all your code has to be compiled. So if somebody can figure out how to do metaprogramming in Objective-C, tell me about it after class here. So let's get to an example of this. Adding a method at runtime to a class in Ruby. So this is what happens when I have this string, and I call it ferment method on it. It says, there's no ferment method on the string. So I can solve this problem simply in Ruby by opening up the class and defining the ferment method. Which, of course, changes all instances of sugar to alcohol. And then when we run that at the bottom, you can see that it works. So what does the same kind of thing look like in Objective-C? Well, there's the error. It's a different kind of error than you get in the Ruby equivalent. It's this thing I alluded to earlier called a compiler, right? So you can't even compile this code because the ferment method doesn't exist. So you have to create it. So where did it come up? Okay. So at runtime, and I have elided a bunch of code that doesn't really matter. And I've also run too far ahead, haven't I? Yeah. Yeah. Method at runtime, right? Okay. Oh, notes came up. That's what confused me. I have notes on this slide. You can't see them. All right. So let's rewind here. We're talking about adding a method at runtime in Objective-C. So what you have to do is you have to, in the interface definition for the class, you create this thing that's called a category. And that's what's putting the parentheses and some name after the class there, right? You see interface NSString, NSString being the string class in ILS and in Mac OS X. That's why there's the NS. Okay. Raise your hand if you knew that. Come on. Okay. I create this category. I add the ferment method that returns a string and then I implement it, right? So basically the Objective-C equivalent of opening up a class and adding a method. And then when I run it at the bottom, you get the result that you want to see. Okay. Compile and run it. I know. So when have I actually used this? I've used this particularly on NSString to add base 64 encoding. It's a real natural thing. In fact, I'm pretty sure I stole it off the web somewhere. But the ability to do that in Objective-C is great. And I never would have thought of that if I hadn't been arrested at all and seen it done there. They do it in Rails. Just a little bit. Active support is pretty much that. Okay. So sending a method ever in time is the concept of separating the method itself from the object that it's going to be executed on. It was another kind of, oh, wow, that's kind of cool thing for me. So again, going back to our fermenting a string. And I didn't get anything. No luck for the changing sugar to alcohol. And I'm proud because I already had a couple of years. So you can see towards the bottom there, I'm sending, s.send, and then I pass in the ferment symbol. So I'm sending that message to that object and it's the equivalent of calling the method. I'm sure that there are subtle differences there, but essentially that's what's going on for the purposes of my example. How do you do the same thing in Objective-C? Well, you have this thing called the selector. This is a thing that I didn't understand 20 years ago. Why would you create a method selector? And you see this in all caps, S-E-L. That's the type of variable that you can assign a selector to. And then you can call on an object, perform selector, and then you pass in the selector. So going back to Michael 20 years ago, why would you just call the method directly? Well, let me tell you why. For example, in iOS and iOS 10, there are certain methods that you need to always call on the main thread. You may not be in the main thread for one reason or another. So you can actually call perform selector on main thread. And then you see here with the with object, you can pass in, in this case, the text that you want to actually set in the current time view. This is from a boxing timer app that I've used for about four years as an example to continue to learn personally iOS-isms. So here's another one. In the bottom half, creating a timer. You're going to schedule a timer with a time interval of one second. The target is self. In this case, it's a model. And then here's the selector that I'll call. So two real good instances in iOS where you do need to have that method separated from the object that you're going to call on. Kind of cool. There's also this class called NSInvocation. I took a look at that because I've never used it, but I took a look at that because it is apparently the blanket, totally flexible and abundantly complex way of doing the separation of target and method and parameters and the turn value. And the amount of code required to do something as simple as one of these two is pretty impressive. But that's kind of the pure way of calling a method on an object if you really want to get down with it. So the last bit I have for you here is blocks. And this is a fairly contrived example. But what I did was I added a yield to the ferment method that I used in the example. And that way, if there is a block that's passed into the ferment call, it will yield to that to get the value that we're going to replace sugar with in this string. So I have two calls to ferment. One without any block, and that is what we did before. And then I have one that does some very simple stringing catnation, some simple math on the beer string. So do you have any beer beer beer? So that's a very simple example of blocks in Ruby. And you guys all know that we use blocks like Crazy and Ruby and Rounds and iterators. When you're going through an array and you call .each and you pass in a block, the syntax there is wonderful. So how does that relate to objective C? So something popped up here again. Okay, so here's the equivalent in objective C. You have to declare, or you have to write a little more obtuse code. Basically where you can do it. It's really not that bad. Just figuring out what that definition of the block is the hardest part for me. It always involves a character. So anyway, if you look down near the bottom you can see that I'm making the ferment call with nil. And that's kind of the equivalent of not passing in a block in Ruby. And then I'm passing in a block that returns beer times three. So that's the equivalent of the beer times three in the Ruby. Again, I mean it's a compact example of passing blocks around. But it really makes your life a lot easier, specifically for me in dealing with animations in iOS because you can pass in, for example, when the animation is done, run this block of code. And I don't have to create another class or I don't have to create a delegate method to get called afterwards. Now I just pass in this block of code. That's great. So what do you notice anything about this code? Is there a times method on the screen? No, but I needed one. So I did that thing that I was talking about earlier where I added a method of runtime so that it had a times method and basically do the equivalent of what we can easily do in Ruby. See, I'm not saying that G isn't it great. We can do this stuff in Objective C just as easily as we can in Ruby. I'm saying G isn't it neat. We can actually do it. Okay, now, okay, I've got to get this stuff in place. Okay, that's good. Got it. So just a real quick example here of making array elements do stuff. I was talking about this a little bit earlier about how nice it is, the syntax that we have in Ruby to do this stuff. I really appreciate it. They've given us some helper methods for things like an SRA so that we can make objects perform selector. Remember that thing I was talking about? About having the method separate from the actual object. Yeah, cool. You can also do the same thing with block. Pass in some code and have the object passed in, have each element in the array passed into the block. So, what have I learned? Other than, man, this is a really cool room. We had a buddy's 50th birthday party next door, so I know about that, but I didn't know about this room. But I think it's really cool. That's one of the things that I learned. But anyway, I've learned that I love Ruby. I mean, I just really do. Obviously, I've been doing this a long time. And I remember when Java came along and I thought, this is great. It's taking all the rough edges away from C++. I don't have to worry about memory management anymore. Java, thank you very much. And then I spent seven years, you know, eight years doing enterprise development. It's like, okay, well, we've replaced the sharp edges of C++ with all this XML configuration, right? And I'm hoping not XML of violence, right? And then Ruby comes along and it's like, oh, thank you, thank you, thank you. And then when do I end up doing Android development? That's right. It's not that I hate Java. It's that I hate Java enterprise, right? Nothing wrong with Java. But I do. I really love Ruby. I really, really do. What else have I learned? I learned that I understand objectives C a whole lot better than I did 20 years ago. I don't know. Maybe because of the passage of time, maybe because of the fact that I realized that I don't know everything anymore, right? Probably took a while for me to understand. And wouldn't it be awesome if Ruby were sanctioned for IOS development? Max Ruby. Max Ruby. I'm sorry? They're spending to do IOS with Max Ruby. Cool. Can you circle back with me after and tell me more about that? Awesome. Okay. So Ruby, you know, I love about it. It's so expressive and efficient. And then, you know, the moment was in with Dave and metaprogramming, you know, double-edged sword. Certainly, but isn't it cool? I mean, it's pretty damn cool. And objective C, you know, my problem, my initial experience with objective C was really tainted by the fact that I came from such a statically-typed world, right? I mean, that's all I was taught in college. I had this crazy computer science degree, and we, you know, learned about lots of strictly-typed stuff, you know, dynamic stuff. Only happened in one class where we wrote one program in which, you know, all different languages. We actually called them programs back then. So I think that objective C was tainted for me by this heavily strictly-typed history that I had. And by going to Ruby and the freedom that I was allowed there, I really started to understand objective C and what it's, why it is so cool. I hope I'll make that to you today, to some degree. Shameless self-promotion. There seems to be some of that in the previous presentation so I'll go ahead and do that myself. I told you that I live in Sun River, and if you haven't been there, it is a destination resort area with 35 miles of bypass that lots of tourists get on their bikes and they've got their kids in the trailer, and they head off, and they don't know where and what they're at. There are, I think we're up to 11 traffic circles. And interestingly, in the upper right-hand corner, there's supposed to be another traffic circle that is missing. That would have been Circle 8. So there's actually no Circle 8 in Sun River. It goes from 7 straight to 9. So the joke is that the tourist is being particularly special. The tourists are want to be, as in make me a latte and make it a good one. We will send them to Circle 8 and tell them to take them. Go check that out at Circle8.net, Android, and iOS. And the shameless self-promotion. Here's where you can find me on the interwebs. I'm at the Hapa on Twitter. That's because I have a 40-year-old BMW of varia. No, it's not in 2002. It's got two more doors, right? And I'm part of the group that keeps those cars alive. So that is a Germanization of my stature. Ha, ha, ha, ha. Standalonecode.com, that's me. Standalone Code. That's me. And I'm M Harper. Sorry, I was kind of worried. So with that, I am going to ask somebody to go get me. And... What do you want? IPA. My final admission to you is to go write a test, right? Thank you to Matt and Mark and Josh and Mike, and somebody else. The guy who's getting me here. Thank you for having me, guys. I appreciate it. Thanks, Chris, for coming out all the way from DC. I appreciate that. And I hope you learned something. A question for me? If I don't know the answer, I'll make it up. The 80s, like... That was a good question. Make it up. The 80s were Genesis? Thank you, guys. The 80s were... I discovered Genesis. I discovered Genesis concerts, as a matter of fact. The 80... Oh, we pretty much had parity between the US dollar and the British panel. It was great because I was in the fund for three months. Was it cooler? Temperature-wise. I was living in the Bay Area, and so the parity was much warmer than the US. Mike. Do you always have an 11-day reminder to go to work? Actually, I know you're not going to believe this, but that's my son's reminder for him to go to work at 11. He's a lifeguard at the University of Southern River Club. How is he going to get there if he doesn't get the reminder? I'm just going to share with you a little bit more. Can we actually use some more space? Do I do church TV and iOS development? I do as much as I can. That was one of the things that Rails brought to me, was test-driven development. And then I read our... Uncle Bob's three rules for test-driven development, and didn't understand them. And then about a year later, I read them again, and then I understood them. And that was another moment for me, right? On iOS, it's... I find it more difficult to do thorough test-driven development like we can do in Rails. It's slow and not well instrumented in my experience. I haven't gone deep on the sort of in-application testing you can do, not super deep. So I tend to limit my test-driven development to more model-based stuff. Stuff that doesn't require me to fire up the application. API testing, model testing, and stuff like that. So it's half to be in iOS testing. Android is fairly similar to London. Did you find your transition to Ruby weird as well? Did I find my transition to Ruby weird? Weird is the wrong word. Challenging at times, for sure. I think it is like what you mean, I don't have to define all this crap upfront. I don't have to define the type of this variable in the same case. What's all this magic that's going on in Rails? The metaprogramming, particularly on the back of the record. So not weird, more uncomfortable to begin with. And then especially after Dave Thomas, the moment he said to Dave Thomas, it's like, oh, this is awesome. But there was definitely a transition that came here.