Programming Throwdown - Swift

Episode Date: September 8, 2014

This show covers Swift, a language developed by Apple for iOS and OS/X. Tools of the show: Jason: Nextdoor Patrick: Waze. Books of the show: Jason: Denial: Why Business Leaders Fail... http:/.../amzn.to/1rvKXbP Patrick: Red Seas Under Red Skies http://amzn.to/1oZplmS ★ Support this podcast on Patreon ★

Transcript
Discussion (0)
Starting point is 00:00:00 Hosting provided by Host Tornado. They offer website hosting packages, dedicated servers, and VPS solutions. HostT.net Programming Throwdown, Episode 36, Swift. Take it away, Jason. Hey, everybody. So, yeah, last week I was involved in this hackathon which is for people who don't know it's basically you know you have some kind of a theme
Starting point is 00:00:33 and your goal is to rather quickly come up with some prototype which you know which demonstrates some cool you know some project that project that you've been working on. So, for example, there might be a hackathon on, say, HTML5, and you make some cool way to show videos in your website that's never been done before or something like that. It's pretty cool. It's a lot of fun. I've done a lot of these different hackathons and these 24-hour code challenges
Starting point is 00:01:10 and design challenges and things like that. And Patrick, you've done a lot of rapid prototyping with Arduino and along those lines. And it's a lot of fun. Everyone who's, if you're from a hobbyist to a professional, you should definitely give it a shot. There's a ton of them on the internet um like if you're into games there's the ludum dare challenge um there's there's a ton i'm sure whatever whatever topic you're interested in
Starting point is 00:01:34 has some kind of you know hacking contest and it's cool it's a chance for you to sort of showcase something to the rest of the the world or at least to a community of like-minded people and get feedback and things like that. So you would recommend hacking at hackathons? Definitely hack at hackathons. Yeah, definitely. I think sleeping at hackathons, I wouldn't recommend that. That typically doesn't happen. That was what I would do. Yeah, for people who don't know, Patrick has to get his 8 hours otherwise he turns into a hungry Patrick I don't know what you're talking about
Starting point is 00:02:07 you get 9 hours of sleep I'm a terrible person dude I need my beauty rest in general a couple of tips for these hackathons number one go with a plan and focus on the plan like start with the ui it's it's a complete opposite of an actual project
Starting point is 00:02:34 like you want to think about it this way like think about at any moment the the hackathon could be over you know even though that's not true, like, they're usually 24 hours or something, but just treat every hour like it's your last hour. And in the sense that, like, don't spend every hour killing yourself as if it's a deadline or anything. But, you know, after one hour, you should have something, like,
Starting point is 00:03:01 that you can at least look at, even if it's just an empty screen. Like, after two hours, you should have something. that you can at least look at even if it's just an empty screen like after two hours you should have something and and kind of work backwards and you'll notice you'll find that like a lot of your ideas that get thrown out are really ones that didn't matter like for example in this hackathon i wanted a settings page where people could sort of customize their experience but you know I started backwards from the experience and I never got to the settings page. And if I had done that in the opposite order,
Starting point is 00:03:33 I'd have nothing to demonstrate. I'd be like, hey guys, here's my project. It's a settings page. You know, I would have like, would have totally bombed. So, you know, it's really good. Rapid prototyping in general is a really good skill. And I say skill because it's not something you can learn. You have to just cultivate it.
Starting point is 00:03:52 And I highly recommend it. Yeah, I think that's good advice to do it the opposite way you would normally do it. But I know a lot of people, well, I guess you should somewhat, that mindset is applicable to everyday life or everyday work. But I agree. I saw a lot of people whenever you do these kinds of things or like even in school, when people work on projects, they would end up with some sort of what they would call like tech demo at the end. They would worked a lot on some piece of infrastructure. And then in the end, they ended up with kind of nothing because they didn't, you know, it was just like some sort of
Starting point is 00:04:24 processing in the background and no kind of good visualization way. If you start kind of nothing because they didn't, you know, it was just like, uh, some sort of processing in the background and no kind of good visualization way. If you start kind of like faking the data and make it look nice, uh, and then kind of work back to actually make the processing, it's easier for people to imagine or believe that you can do the hard part, um, in this scenario. So for a prototyping, that's really useful. Like, is it worth investing in actually getting the algorithm to work right now in real life, you may actually that is the key point, right? And so you don't care about the other stuff. But for demos, it's much easier if you can say, here's what it will look like when the when the algorithm works.
Starting point is 00:05:00 Exactly. It's exactly right. You have to sort of like, as I said before, you have to like plan beforehand. And that part you can do like kind of of like, as I said before, you have to plan beforehand. And that part you can do kind of bottom up. Like when I had planned it before the hackathon started, I'd kind of started with the settings page and kind of drew little diagrams of sort of how I wanted it to look. But then when I actually got to coding, you know, when they started the clock or whatever, then it was all about the UI. So yeah, a lot of fun.
Starting point is 00:05:26 You guys should definitely try it. So this week we have a question from Mike and I'll summarize. He wrote a little bit more, but that basically he's still in school and that he gets, every time he asked for career advice, people say to get involved in open source projects or communities. And he was asking if we had any recommendations for that specifically i actually don't have a great recommendation for an open source project to join i too also got this advice
Starting point is 00:05:53 when i was in school and had the same thing if you ask people well what open source project is good to join or is open for contribution you always get this like you know we'll first start by helping to document the project or looking at the bugs and trying to fix bugs. But there's a lot of work you have to do to get to that point on any kind of mainstream open source project that you would know, I'm not saying you can't do it. And I know people vaguely who, who have done it before. But I think a lot of the open source project opportunities that you should be most interested in first are the smaller projects like maybe it's just one guy who has some interesting tool and you think of a new way that the tool could work because if it's just one guy it's much more likely that you're able to kind of understand the code base and make contributions more quickly which in my opinion
Starting point is 00:06:40 when you're first starting out is a better feedback mechanism because you see your work actually leading to something versus just spending like six months trying to figure out where to put your code. Um, you can actually make a contribution or, you know, even creating your own open source project for something that you've been using and you say, Hey, this might be helpful to someone and posting it up and see what other people that you may get harsh criticisms or, you know, shocker, the internet has some people who are jerks and they may say mean things about it but some people will have legitimate like hey you may want to
Starting point is 00:07:10 consider this or you have a security problem here or whatever and then that feedback can be really helpful and I think as far as when it comes time for a job you'll have learned some stuff there and you'll have something to point people to and say here's work I did but don't feel like you have to join like open ssl and make contributions or the linux kernel or
Starting point is 00:07:30 you know some one of these really big open source projects don't feel like when people say that that's good like those are what they mean there's a whole range of things that you can do yeah definitely i mean i feel like unless you're actually contributing to the Linux kernel, because you it's your job or something like that. Like a lot of those huge code bases are actually a nightmare. And it's nothing against them. It's just, that's just, you know, a lot of these things grow organically. And they don't grow in the, in the, you know, most pristine way. Right. And so, so yeah as patrick said your best bet is choosing something small and starting from there yeah and there may be exceptions to rule but it's the same
Starting point is 00:08:09 thing like whenever you start a new job or join a team it's kind of weird because they went through a lot of effort to get you or hire you or bring you on but then it's always like it's been my experience that many times when you first join a team nobody kind of has the time to help you everybody's too busy to help you, right? They need your help, but not right now because they don't have time to kind of help you get started. And so, you know, nice people will point you in general direction, but you spend your first few weeks kind of twiddling your thumbs a lot
Starting point is 00:08:37 because no one has the time right now to help you with something. And I think that's just kind of one of those facts of life of way things work out that open source projects are probably similar the guys or girls contributing are spending their time doing their contributions and then bringing on new people is probably like a second priority to them and so it's you know like again except maybe in some exceptions they're probably more interested in in spending their time actually doing the work. Right. And so that's what makes it difficult to join if you're not just super, super self-motivated,
Starting point is 00:09:10 which some people are. And, you know, I'm glad there are people like that in the world. Yeah, yeah, definitely. Yeah, that's really good advice. Start something small, preferably something you work on yourself. And, you know, GitHub has kind of reached this critical mass now where, I mean, I don't know about you, but I tend to, like, search specifically in GitHub for projects. Like, the other day I needed a Node.js LDAP library. And I just went straight to GitHub. And I found some guy's library that he wrote in his spare time.
Starting point is 00:09:43 It was just a one-man operation. And he grabbed it. And I found there were some bugs in it. I filed bugs. I made some changes. And so if you put your project on GitHub, write some decent documentation. And if it's something pretty niche or you're doing it better than everyone else,
Starting point is 00:10:00 you'll generate interest. Definitely. All right, time for news so yeah this is I think this might be the first time on a show we've ever made a mistake I'm pretty sure maybe our first legitimate official
Starting point is 00:10:16 retraction but well no I went and read all I listened to all the old episodes and turns out we never made any mistakes until now it's shocking but yeah so we announced last episode that Twitch was going to be bought by Google
Starting point is 00:10:32 we showed what Luddites we are when Twitch got bought by Amazon a few days ago it turns out people were overstating their belief in the rumor that twitch would be bought by google and we like the terrible people we are man i'm saying that too much tonight
Starting point is 00:10:52 like the people we are the uh innocent not believing that the internet could ever have a lie on it we just took it and said oh that must be true and yeah but uh according yeah according to this forbes article um you know they were about to be bought by google but there were some issues um related to antitrust and things like that actually let me let me be more clear there were issues about the potential of antitrust litigation that could happen but didn't actually happen so jc has no idea and he's not a lawyer and it's all yeah it's all still rumor that's right that's right well it's on this Forbes article yeah but yeah you're right it's not it's not validated in any way but
Starting point is 00:11:36 yeah so Amazon bought them which I think is pretty cool you, I personally have never liked the YouTube kind of user experience. Like, in fact, if you want to see the current live streams on YouTube, you actually have to go to this crazy, like, YouTube slash and then this hexadecimal string. And that's the only way to get a list of the live streams. And so, I mean, i know that youtube's not live streams aren't really their thing but still i just i feel like the ui i just never really been happy with youtube um from experience standpoint and so you know it's kind of like specifically for live streaming that's what you're talking about though right or like in general you just
Starting point is 00:12:20 don't like youtube i like the service i don't feel like the UI, the user experience is there. That's my opinion. Anyway, I can go into a soapbox about that, but I'll spare everyone. And actually, you know, a lot of the internet, a lot of Reddit and things like that have echoed similar statements. Oh, so you read something on Reddit. I see now. I see where this is going yeah i've been blinded by reddit no but i know i should i was it was kind of for me it was a little
Starting point is 00:12:50 bit of uh um it was kind of a relief to see other people thought the way i did because sometimes i think i'm just i'm just crazy no that's true well yeah that's also true anyway so uh they got bought by amazon um which is pretty cool you know my guess is that Amazon will leave them as is. Amazon tends to do that with a lot of their acquisitions. They don't really try to run their life or anything, which is pretty cool. I think Twitch is pretty great. I've actually been listening to a lot of streams while I've been working. So last time we talked about the Dota 2, the International.
Starting point is 00:13:29 What have you been watching on Twitch since that's over now so obviously we're watching there's a guy who you're not gonna believe this there's a guy who is this fish play pokemon i've seen that which is pretty awesome i've also seen goldfish play street fighter oh maybe that's what i'm thinking of there's both um but the one i saw is this guy he's a chef and he just kind of talks about food and stuff and he also does these like speed eating challenges so it has nothing to do with video games so you watch live streams of non-video not really yeah so i thought twitch was like solely about video games well um it could be whatever you want right i mean they can't really i've only ever watched video games on it it It is video game centric. There's no doubt.
Starting point is 00:14:06 But there's nothing to stop you from doing whatever you want. Okay. So this guy actually, the last time I saw him, heard him, he ate a pizza, a medium-sized Domino's pizza in a minute, 16 seconds. That's just gross. I know. It's unbelievable. And yeah, you just got to gotta see it if you go on youtube
Starting point is 00:14:26 you can watch a replay i can go on oh this is confusing i have to go on youtube to watch a replay of a twitch tv live stream uh yeah maybe you can watch it on twitch okay i mean does twitch have replay anyways where is this a digress digression. But you should watch it. It's pretty cool. Just put, like, Guy Eats Domino's Pizza in two minutes or something like that. Okay, Guy Eats Domino's Pizza. His name is Caleb Hart. So, here, I'll put it in parentheses in the show notes.
Starting point is 00:14:58 Okay. But, yeah, it's pretty epic. It's a very large man, and he eats a pizza very quickly. Okay, interesting. All right, I'll have to check that out later, because I'm going to get distracted if I read that right now. So my next news story is not a news story at all. Well, it's not really news, but it's a blog post that I read,
Starting point is 00:15:16 and we were discussing this at work and sharing our anecdotal stories about it. And the blog, well, you'll have the link in the the show notes um but basically it's called norris numbers that's the title of blog post makes it always sound awesome i wish i thought of cool names to title stuff like this like the norris number so uh this guy is writing about a friend who has a quote about a friend or something who's called norris cliff norris and he says that the norris number is the amount of code an untrained programmer can write before they hit a wall.
Starting point is 00:15:52 And so they were talking about like the estimates of it or whatever, like 1500 lines of code, 2000 lines of code. Now there's a whole thing you can get on about flying. The code is a good measure or bad measure or what it measures. But leaving all that aside, I feel like this is a good point that when you or what it measures but leaving all that aside i i feel like this is a good point that when you talk to people who are just fresh out of university or while you're in
Starting point is 00:16:09 university um or school that you write code that's very certain manner and very like architecture seems to be really lacking in most of those projects because it's not what it's about and you'll never write enough code that architecture will kind of really matter because you're not going to maintain it. You only are going to work on it for a few weeks. So you can just kind of spit out code. And you, in some ways, are very efficient because you know you're going to stop.
Starting point is 00:16:37 But that kind of doesn't work in the workplace. But yet in the workplace, the coding initially kind of comes out the same way. And it takes kind of training and thinking and experience to be able to kind of write something more than these people are claiming about 2,000 lines of code. We'll go with that for now. So once you get above 2,000 lines of code, for instance, you start having problems like if your organization of what code is in what files or what classes and how the data flows. Not a performance problem but a like how do i move around the code and if someone else might be working on it right like how do we
Starting point is 00:17:12 work on two things at the same time so you have to kind of learn those things before you can get to they're saying the next wall which this guy's saying is like 20000 lines of code and when you get to 20,000 lines of code uh that you can still kind of have like a you know loosey-goosey approach if there's multiple people for instance but then if you want to make it to like 200,000 lines of code you need even more very strict organization you need like uh someone really writing the for instance like style guides because you need the code to be consistent uh deciding what goes in and out of the project. So like not adding features just because they might be nice to have, but actually only writing the features you need. And so he's just kind of talking about these like leveling up as a programmer.
Starting point is 00:17:59 And I thought it was an interesting read because I personally I don't read a lot of articles that talk about the craft of programming like that uh and so it was kind of interesting to read and then thinking in my own kind of growth how that like oh yeah initially you write spaghetti code and then you realize like that doesn't work and then you do other stuff and how that like you as you're leveling up the complexity and size of the project how you have to bring new techniques to bear and a lot of times you don't know them initially like you don't know how to write a 200,000 line of the project how you have to bring new techniques to bear and a lot of times you don't know them initially like you don't know how to write a 200 000 line of code project um and then you kind of learn it over time and figure out what works and doesn't work but then you keep hitting these things that prevent you from growing even bigger yeah this is really interesting yeah i think uh it's really interesting because you can kind of see the wall
Starting point is 00:18:45 coming like for example there's one project i worked on where there was effectively like a like a main control loop file that was you know like 20 000 lines of code in one file and you just know that the wall is like evident you know like you just know that like what they're doing isn't scalable um and uh you know i'm sure you know even if you look at smaller projects you could start to see something where you it's like okay this isn't going to this is going to end badly yeah and in one measure is kind of velocity right like and even this is a little off topic from what this is talking about but i've noticed my own projects that that you, when I work on that work that you go through these cycles and some people call it like technical debt,
Starting point is 00:19:28 but like if you can keep throwing more people and work harder and trying to like add more features. But at some point if you're not kind of thinking through like re architecting the system, you eventually get this organic growth problem where you start to lose a lot of velocity and trying to just keep things working right and then you have to kind of do a re-architecting and then you can go really fast again yeah like a very common problem you see is like for example you know there's some class and the class is variable called you know latitude
Starting point is 00:20:02 and then you end up with like another variable called previous latitude and then somebody realizes oh no i need three levels deep so i need like previous previous latitude and then you find out oh i need uh i need an array of latitudes like a history so you create like a array called like latitude history but then you're in a hurry so you don't delete the previous latitude you keep it around and then like you can just see like this and you just know that this is going to end badly or like you're going to need some kind of major refactoring at some point yeah the current problem i work work try to work through is whether or not like when you first start a project how much time do you spend architecting? Because you could spend kind of an infinite amount of time stuck trying to figure out what to do without ever doing anything.
Starting point is 00:20:51 And so you've got to get started at some point. So you kind of have to pick the lines, even if you know the requirements may change. So you kind of have to do your best and trade off like getting going versus flexibility. Because you could write the most flexible system in the world, but it doesn't do anything. It's just really flexible. It can do anything, but it does nothing. Yeah. You have to make the trade off between being data driven and building a Turing machine. Right. Yeah. I mean like on one end, uh,
Starting point is 00:21:21 you want, you know, for example, like CSS, right. If you're, you know, for example, like CSS, right? If you're building a website, you don't want to have all of your style in the HTML. And then every time you want to change, you know, or in the JavaScript, and every time you want to, you know, make a font bigger, you have to go and hack code. But on the flip side, you don't want to create some, like, wild, you know, thing that compiles to something which compiles to css so that you can just like write everything then you've basically just like kind of created your own language that you're gonna have to code in you haven't really gotten anywhere and so somewhere in between there is kind of the sweet spot yep all right cool so yeah my next news is also not
Starting point is 00:22:02 really a news but it's it's uh it a really, really good read for people who are interested in this kind of sampling methods. It's called Gibbs Sampling for the Uninitiated. And as the name suggests, or as the name actually just outright says, you don't have to be initiated on Bayesian methods or sampling methods to understand what's going on in this paper. But just to give you kind of like a little preamble. So you know this, have you seen this where if you have, say, like a circle inscribed in a square and you randomly throw darts at the square, you can estimate. So, okay, one thing is, let's say you have some circle inscribed in a square and you want to know the area of that circle or you want to know a random point on that circle. Let's start there. So, one way to do it is to just, you know, throw darts at the circle randomly, or throw darts at
Starting point is 00:23:10 the square, because you can easily do that. You just pick a random X within the range of the square and pick a random Y, and you throw a dart there. If the dart hits the circle, then you use that point. You say, here's my random point on the circle. If the dart misses and hits the little corners around the circle, on the outside of the circle, then you throw another dart,
Starting point is 00:23:32 and you don't count that dart. And so it turns out, this is called rejection sampling. And so it turns out this is fine. Like doing these darts and throwing some of the darts away is the same as like from a math standpoint as like picking a random spot from the circle. But it's a lot easier to do because, you know,
Starting point is 00:23:54 it's easier to pick a random spot in a square and then throw some of them out than it is to like figure out the equation for all the random spots that could be in a circle right okay so this is sort of like an easy way to do a hard thing right and so you can actually you start to know what's in the circle versus not that's right because it's easier to know whether you're in the circle or not then it is to like know the distribution of points in a circle like that second one is hard right um so the uh so and you can do this to approximate pi right you can like you know that if you throw
Starting point is 00:24:38 like a hundred darts that all hundred of them will end up in the square but some fraction of those darts will end up in the circle. And then based on that, you know the area of the circle, right, as like a fraction of the area of the square. And then you can actually approximate pi, like if you throw enough of these darts. So this is an idea where like you use a bunch of random numbers and you figure out, like in this case, pi, you figure
Starting point is 00:25:09 out the value of pi by like what's called Monte Carlo sampling. You just try a bunch of random numbers and slowly, slowly, the number you're looking for gets closer and closer to pi, right? But you can also use it for distributions. Like as I was saying, if you want to pick a random spot on the circle, you can also use it for distributions like as i was saying if you want to pick a random spot on the circle you can use this rejection technique and you can effectively like sample from the circle and so if you're doing like computer vision kind of stuff this is pretty useful um so this is cool for say like circles but if it gets really complex and in some high dimensional
Starting point is 00:25:45 space you're doing some machine learning and you need to sample from some really complex shape in a really high dimension, then these rejection sampling techniques break down because you end up just rejecting everything or rejecting 99.9999 and just nothing gets done so this is one way to deal with that it's called gibbs sampling um and uh hopefully they do a much better job than i just did talking about this whole thing it's pretty complicated to cover but uh it starts you from the ground up and it starts by talking about just like basic statistics, like counting and things like that. And they work you through going from there to this Gibbs sampling, which is kind of like the de facto way to solve this problem. So I thought it was a really great read, and I thought for people who aren't familiar with this and are interested,
Starting point is 00:26:44 they should definitely give it a shot i'll have to i skimmed it but uninitiated doesn't mean ignorant so i need kids sampling for the ignorant you got the dummies for dummies so uh i guess this could have been the tool of the show, but I didn't have time to try it out. So I'll just make it a news item. Hyperlapse is a new app released from Instagram. And I saw something similar from Microsoft, and I don't understand the connection. I feel like it was also called Hyperlapse. But this Hyperlapse from Instagram allows you to record a video on your iPhone. I don't think it has Android yet, but iPhone.
Starting point is 00:27:23 And like you walking down the street in New York City. And of course, like as you walk, you kind of the camera moves up and down. It's not stabilized. Right. And so then what they do is make a kind of a time lapse where they fast forward you through the video, but also kind of stabilize as you go. So you've probably seen these effects in various movies or commercials or whatever um or the other classic one is like you point at the clock in the center of grand central station uh there's some fancy clock and you point at that and you have all the people like whisking around you right um and so you could set up a tripod and do this or you know if you could stabilize the video you can just kind of hand
Starting point is 00:27:59 hold it for a while and you get these really interesting effects you know instagram's all about filters i guess well it's all about a lot of things but you know people on instagram like filters so this is using time as a filter and it seems pretty interesting so i'm definitely going to be checking it out but i think it just was announced or released like today 13 hours ago it says so this is like fresh off the presses is this the same as the uh like in google plus they have the auto awesome where if you take a bunch of pictures that look like they're a sequence it'll build a movie out of it is this the same thing or is it different so you but that doesn't try to like give a coherent viewpoint for
Starting point is 00:28:38 instance right like it'll just stitch them together right this one actually tries it takes video and essentially tries to make a cool looking fast forward of the video that's stabilized so if you just fast forward normal video it's kind of like blurry but this stabilizes it so it actually like oh now i see what you're saying all right yeah you just watch the video yeah okay yeah i'll check it out it sounds cool so it definitely is it's cool it's just like a better fast forward, basically. Okay. Because you have certain videos that are cool,
Starting point is 00:29:15 like you're on some beautiful drive through a cool town or on a train or an airplane or something, and you're flying over stuff, and it's cool. But if you have to watch it at real time, it's very boring. No one wants to watch it. So wait, what's wrong with watching in fast forward? It's blurry? Well, it's not that it's kind uh very boring no one wants to watch it so wait what's wrong with watching and fast forward it's blurry well it's not that it's yeah kind of blurry because you're you're bouncing around right like the train is vibrating a little and you know you're kind of like moving left and right so they're trying to pick a point and kind of keep the what the perceived viewpoint as if you were stabilizing the camera as if the camera is being held very stable at a certain point i see so they're like basically registering the frames together yeah and then like
Starting point is 00:29:50 okay got it got it and there's some stuff about how they did it we can read about anyways yeah i need to jump on the instagram thing i totally missed that boat i missed every social every boat yeah we were just talking about this before the show where we are not socialites we're the anti-socialites when it comes to social networks okay book of the show my book of the show is denial why business leaders fail to look facts in the face and what to do about it um so this is pretty interesting um it actually it covers several different companies that have either completely failed or had to reinvent themselves. And it goes way back in time.
Starting point is 00:30:35 It actually covers Henry Ford and the Model T. So for people who don't know, someone told Henry Ford, hey, we should do the Model T in different colors because there are people who like't know um you know someone told henry ford hey we should do the model t in different colors because there are people who like you know the aesthetics uh you're changing the aesthetics and he said no and then other car companies started making cars that were you know red or or yellow or painted however you want and people loved it and he still said no and then people stopped buying his cars. And that's how that sad story ended.
Starting point is 00:31:08 It was a really sad story, actually. Yeah, and a lot of these are actually quite sad. But there's a lot to take away from them. I haven't read the book yet, but it was recommended to me by a friend. And I'm definitely going to give it a read. But it covers tech industry it covers various ones there's actually
Starting point is 00:31:28 you know how they have the tamper proof seals on pretty much everything like water has a tamper proof seal now but that all started because someone someone who is just a sociopath was poisoning bottles of Tylenol.
Starting point is 00:31:48 They're actually taking capsules of, I think it was like cyanide, that were white, to look like Tylenol capsules, and putting them in Tylenol bottles and killing people. And of course, you know, people's natural reaction is to blame Tylenol and sue the Tylenol company. And, you know, after many months, they found out that it was this sociopath and they caught him and everything. But this is all about sort of how they dealt with that.
Starting point is 00:32:19 Because, you know, from their perspective, they just saw people using Tylenol and dying, right? And anyways,, and anyways, all of these, each chapter is a different company with a, with a company, you know, breaking pandemic and,
Starting point is 00:32:33 and, and how they dealt with that or didn't. And so, you know, I just thought it was a, just a phenomenally interesting, interesting idea. And I'll definitely be reading it this week.
Starting point is 00:32:49 Mine is not nearly, well, maybe it's more interesting less interesting doesn't seem as applicable as useful to your life as Jason's non-fiction book so previously I had recommended a book by Scott Lynch called The Lies of Locke Lamora and this is actually a series. And so the next two books, Red Seas Under Red Skies and The Republic of Thieves, I've read both of them now. And so I will recommend them as well, basically recommending now at least the first three books. I really liked the first book a lot. And the second and third book didn't disappoint, I guess. You know, when you read a first book sometimes like a whole new universe right so it's kind of hard to keep it up through many books right especially if they didn't think they would be writing a second book so i think this person did scott did and uh they
Starting point is 00:33:37 did a good job so it's not like world building as much like there's a lot of weird things in the world and they've not really revealed much more i guess but um you know the story advances the characters advance and uh i i kind of like the actually the second book i like the first book a lot and i think i like the second book a lot too the third book i'm kind of wishy-washy on uh i'm glad i read it because i wanted to find out what was happening to the people. But I didn't care for the style. The style is different, actually, in each of the three books. Like, instead of the same thing, like, you know, you read some books, like, I'm trying to think of a good example.
Starting point is 00:34:16 Some books, and, like, the same things happen to the characters every time. Like, the characters don't seem to be learning. And it's just, like, a good story, right? Because, like, it's like james bond like a james bond book right like james bond doesn't really much doesn't carry over he doesn't really get better or smarter through each book um and sometimes the books are about like the characters getting smarter and more powerful as the books go on and then in this one it seems almost as if they're just putting them in very different scenarios and almost a different style of
Starting point is 00:34:44 writing for each of the books and i kind of enjoyed that oh cool yeah i'll check that out as if they're just putting them in very different scenarios and almost a different style of writing for each of the books and i kind of enjoyed that oh cool yeah i'll check that out time for tool of the show all right i'll try not to you know uh go into hyperbole here and i'll save a little bit of time my tool is actually rather simple it's next door um but you left it next door it's uh yeah so it's pretty cool basically you, you validate your address with them, and there's just a variety of different ways you can do that. And then it's effectively yet another social network that I probably won't participate in.
Starting point is 00:35:16 But this one's kind of cool. If you're having a garage sale, and you want to know if your neighbors want to have a garage sale with you at the same time or something like that, you can basically think of it as a forum or a message board but it's um private to your neighborhood and uh there's a separate message board that's private to like the all the neighborhoods within five miles um but because you know you've validated your address you typically don't have to worry about spam and things like that. Oh, I heard about this.
Starting point is 00:35:48 Yeah, it seems pretty cool. They were saying actually like a ton of people, like a lot of neighborhoods have been registered already on this. Like it was kind of crazy like how much it's catching on, but no one seems to really be talking about it yet. Yeah, I mean, you know, I signed up. My neighborhood was definitely already on. There's a number of people from my neighborhood who are already on. You know, what I found is I was just browsing some of the content, and I just didn't see a lot of content.
Starting point is 00:36:14 I mean, there's maybe one message every three months, and most of the time it's just complaining. It's not really useful. So that was kind of sad, actually. But, you know, we'll have to see what develops. I mean, you know, this could, I see great potential. Yeah, it's just a matter of, you know, whether people realize that potential or not.
Starting point is 00:36:32 Interesting. All right. Yeah. My tool of the show is Waze GPS navigation app, and as if we needed another. But this one has some features I like. So it also has some sort of social networking points earning thing uh that i don't use um and but the idea is that uh some
Starting point is 00:36:52 people do and it makes the network better because what it tries to do is use i feel like we had to have talked about this before but i looked it up and i haven't seen it uh it didn't come up that we had talked about this before um so if i did i apologize uh but if not this is awesome ways people enter like there's a policeman ahead or you know there's a traffic camera here or um you know traffic got there's a traffic accident you know on the right side of the road up ahead and people enter these things and so if you keep the app up while you're driving um you'll get alerts coming through and it'll ask you to even like validate like do you see an accident
Starting point is 00:37:29 up ahead right so they know when it clears and stuff and gives warnings but the thing for me it seems more like every gps app now says that they do kind of real-time traffic but this one seems to do a better job of it because they seem to be more quick about feeding back in like actual user reports and stuff and it'll even show you on the map like all the people driving around who have the app open um so living in the san francisco bay area there's like i forget like each morning it tells me there's like 2 000 people using it wow which is not a ton but like in a commute there's already like 2 000 people on the road um and if you kind of spread them out which is not a ton, but like in a commute, there's already like 2000 people on the road. Um, and if you kind of spread them out, this is not that big of an area. So that's a lot of
Starting point is 00:38:10 data points that they get in real time. Um, yeah, that's great. And they're feeding it back in and it works really well. They're now actually owned by Google. So I guess they'll be integrating something with the Google stuff soon. Um, but I like this app and i use it every morning to check which i have several potential ways i can go to work and i always look on this and see which way i should go um but yeah like all gps apps there's slight problems where like if i leave now and in my commute's a little longer so by the time i am halfway through right it's like 20 30 minutes later so traffic has changed a lot oh yeah yeah all of a sudden there's an accident in front of you you can't really do anything but they know like every
Starting point is 00:38:50 day there's at least one accident so i feel like they should anyways yeah that's right they should just predict like like patrick what are you thinking come on you know that I'm going to give you an accident. So, yeah, anyways. All right. All right. Time for a discussion of Swift. So Swift is a new language that was introduced by Apple, I guess, a month or two ago. But it's been in development for a few years now. And basically, the point about Swift is to replace Objective-C. So Objective-C was popularized as being the only language that you could use to make iPhone apps. And it's also used to make OSX apps and things like that.
Starting point is 00:39:46 And Objective-C has an open source compiler, so you could really use it to make anything in theory. And so Swift is meant to sort of come in and replace Objective-C and just kind of make developing for any of those devices a little bit easier. So it has a variety of features, many of which, you know, we've talked about on other episodes, but we'll cover them briefly. So it has a static typing with type inference. So if you listen to our Haskell episode, you know all about that.
Starting point is 00:40:24 But basically, you know, it has the static typing. So, you know, you can't try to, you know, set an int equal to a string or anything like that. But most of the time, you don't have to put the type either, which is what makes a dynamic type language is popular, right? You can just say i equals 3, and it knows that i should be an integer but it has to be it has to be an integer from then on well that's right it has to every
Starting point is 00:40:51 reference of i needs to be an integer that's right that's right but you know i feel like that's true i feel like with dynamic languages you should be doing that anyways i mean that's like a personal yeah there's a pet peeve there seems to be there should be some reason there's probably some clever thing you can do where i can be equal to literally anything kind of the null pointer hack but also null pointers are dangerous or void pointers sorry not null pointers but void pointers right it's kind of the same thing a void pointer can be literally anything you want uh so but yeah it's just it's just drama yeah um so it also has generics which is huge i mean objective c still had like just array and then if you wanted like an object out of the array you have to say like you know get me the item at index one and then cast it to whatever and you
Starting point is 00:41:44 know theoretically you could have an array where the first thing's a string the second thing's a number a third thing is something else and that's a terrible idea don't don't ever write code like that i mean if you really need like for example think about like say json in json you know uh an array could hold know, numbers and other arrays and maps in it, right? So like create a class that has those three things and make one of them non null, right? Like, like, don't try and rely on the compiler and the runtime, you know, casting to solve that problem for you, you know? So generic is like pair. So you say say like i want a pair but i want both things in the pair to be of the same type but i don't know which type they will be
Starting point is 00:42:29 yeah exactly so so so with generics you know that's when you're writing the pair class but as someone who's using the pair class you could say like this is a pair of a int and a double or this is an array of strings. Versus Objective-C where everything was just a pair and array and you used casting to talk about what you meant. It has string templating, which is pretty awesome. It's something a lot of people
Starting point is 00:42:56 take advantage of. So you mean built-in support for this, or is this a library that they have? A built-in support, yeah. So for Java, for example, you have to use the string template third-party library to get this um but but in general this is pretty awesome i mean basically you know you you could imagine like um having a string and then saying like in embedded in the string could be say like percent name percent and then wherever you see
Starting point is 00:43:26 percent name percent it changes it to some variable so that's basically what templating is and it's a way to sort of write code that's you know very data driven so wait so the way this works is like if i have a string that says hello percent name i don't know is that the syntax hello the syntax it's actually it's like slash open parentheses and slash close parentheses but yeah so so if you have hello and then the special thing indicating name and name is currently set to jason and then i say print that string it'll say print hello jason and then if i say exactly the string is now equal to patrick and i print the string again well sorry the name is now equal equal to Patrick and I print the string again.
Starting point is 00:44:05 Oh, sorry. The name is now equal to Patrick and I print the string again and say, hello, Patrick. Exactly. Exactly. All right. Yeah. So string tumbling is very useful. It has closures and has functions as first class citizens.
Starting point is 00:44:18 So I think we talked about these in the Haskell episode. So one thing you'll notice already is that Swift borrows a lot from functional programming. And so it's actually very similar to Java 8 when that comes out. So you'll notice a lot of similarities there. It also has operator overloading, which is pretty cool, especially if you're doing math stuff. You know, like, I don't know if you've had to deal with this, Patrick, but, like, in these, like, have you ever used, like, the Java matrix library? You know, I have mixed minds about operator overloading. Sometimes it's convenient, but sometimes it's not because if, you know,
Starting point is 00:44:58 like, we have, I'm not a high-level algebra person, but, like, you know, I kind of have like a feeling for how a plus should work. And so if you have something and define the operator as plus and the plus doesn't work kind of how I've conceptualized it to work, it's kind of bad
Starting point is 00:45:15 because I tend to just use the plus without going and looking up the comments you wrote about how plus works. Versus if you wrote a function that I had to call and I needed to go look up the name i'm probably also likely to read the comments about like any sort of warnings or you know the
Starting point is 00:45:31 exact usage of it um so for me operator overloading is kind of scary because i've had instances where i use an operator that i thought should work in a certain way and it just doesn't yeah that makes sense i'm trying to think of a good example off the top of my head but i i'm not it's escaping me right now yeah i mean well one of them the one i've seen is you know when you have two vectors and you do multiply yeah yeah that's a good example you get the dot product or sometimes you get a vector where it's like component wise multiplication yeah and it's like you kind of really know what you're gonna get um i do see that as a problem i think you know i've you know i've been like not burned but i've been frustrated with doing like matrix operations in java you end
Starting point is 00:46:19 up with this mess where it's like a dot add parentheses b like dot multiply you know i mean it just kind of it looks so hideous yeah and i think haskell had a good way of dealing with that where like you can write any function as infix so like you're saying like a dot add open paren b right you can just write a add b oh yeah that's right so you can do it or you can say uh add a b yeah so you can do them yeah so you can get what you're talking about like i think that's kind of like well i i mean maybe it's not as easy to do in something like swift or whatever but i think that's actually a really nice uh feature ofkell that you can do it that way so that you can actually write out the thing but use it in the middle if you
Starting point is 00:47:08 want. Yeah that makes sense. Yeah I think that like I think both of these are good. I think the Haskell idea is probably I agree it's probably better because you could have a name that's pretty descriptive like a like a malt malt piecewise or something
Starting point is 00:47:23 instead of using a multiplication sign but uh but yeah either way it's it's i think it's both of them are better than the java 7 way i think java 8 has operator overloading at any rate um so those are basically the big features you'll notice like swift um by itself it doesn't really do anything brand new but it takes a lot of ideas from different languages and kind of brings them together which is pretty cool it's using LLVM
Starting point is 00:47:55 so I think we've talked about LLVM in the past LLVM stands for low level virtual machine so for example like say Java, say, Java, you write Java code, and then the Java code gets compiled
Starting point is 00:48:13 to what's called Java bytecode, and then there's a JVM, which executes that bytecode, right? So, LLVM, and also another one called CLI, which is Microsoft's kind of version of LLVM, and it's for C Sharp and VS, VB.NET and those things. So both of these guys kind of take it to the next level. So they have an LLVM interpreter, just like Java has the JVM. They have the LLVM. And you can compile your code to bytecode and run it, just like you can in Java. But you can also go from LLVM bytecode to machine code.
Starting point is 00:48:57 So that's the thing that Java does not have. Now, you know, if you go to machine code, there's no going back, right? I mean, like now you've built something that only works on, you know, an iPhone or something like that. But that extra step allows you to do sort of a lot of cool optimizations, while at the same time, having the advantage of the the vm when you need it for it also has the advantage for optimization you can do work on if you're a person interested in taking something from the llvm bytecode to the machine code and coming up with clever ways of recognizing patterns of operations and the llvm bytecode, and producing machine code that's optimal
Starting point is 00:49:46 for whatever, like Pentium, Pentium threes. I don't know. Nobody uses those anymore, but Pentium threes like that, that just for some reason has this one instruction that you love and you figure out a way to generate bytecode to that. Then anyone who has any language in the front end compiles into LLVM bytecode can take advantage of that optimization for Pentium 3s. So whether it's coming from Swift or Objective-C or regular C, if it's in that intermediate format of LLVM bytecode, you kind of don't care where it came from because you can recognize patterns there and produce the optimal machine code.
Starting point is 00:50:22 That's right. So both Objective-C and Swift go to this LLVM bytecode. And then from there, they're both treated the same way. So all the work that's gone into going from LLVM to machine code for Objective-C doesn't have to be duplicated for Swift. Yay for standards. Yeah, that's right. Well, isn't that weird? It's kind of like a standard by example, you know?
Starting point is 00:50:58 It's not really a standard, but it's like, it's a reference implementation. Well, so I mean, the alternative, and this starts to get a little outside of where I have a lot of knowledge about, but the alternative, if you take kind of the GCC project, they also use kind of, they don't call it bytecode, but they have an intermediate language. So their front end is compiled to this intermediate language, but they kind of only ever meant for it to be used by their project. And so it has all sorts of nuances and complexities,
Starting point is 00:51:23 and it's very difficult to work with but it's very very optimized like you get really good code out of gcc a lot of times right but this llvm was kind of from the ground up always intended to be used in this way by many many different front ends and for producing optimal against different back ends so they kind of designed it that way so they made certain choices that kept it easy to use yeah exactly yeah it's not really a standards like i don't think there's a standards body that does it but like they made it and said hey this would probably other people might want to use this as well yeah yeah definitely yeah i think it's interesting like uh yeah it's sort of like a standard just by being a reference. I guess, like you said, you had a good way of saying it, standards by example.
Starting point is 00:52:10 It's not really standards. They just made it open source. And because they did a good job, it's become a de facto standard. There we go. Yeah, yeah, that makes sense. So, yeah, it's optimized for mobile, clearly. It has very good integration with Objective C as you might expect because they're both
Starting point is 00:52:31 compiled down to the same thing so basically have you ever used Swig Patrick? no I'm going to go with no I think I have but just go with no so yeah Swig is this thing that kind of,, like Java source code, where when you call one of the Java functions,
Starting point is 00:53:09 it knows to go and call the C++ function. This works kind of similar. So there's an idea called a bridging header, and you just tell Xcode in the project what Objective-C files you need to access from Swift and vice versa. And then it, for each of those files, generates a bunch of wrapper code under the hood. It's pretty cool. It's one of these things that just kind of works.
Starting point is 00:53:43 So the functions in Objective functions objective c you can just call them from swift and vice versa i hope it works better than this extra step swinging c++ code into java or calling into c++ from java which we do i've done before but yeah it was always kind of messy and it never works quite like you want it to um yeah i think the uh you know the issue with the c++ to java is they have different VMs. Well, that was always a problem. Well, kind of different binaries is one way of kind of saying it to hand wave a little. So you have the C++ needs to be compiled in one way, the Java in another.
Starting point is 00:54:15 But then the Java needs to know how to call into the compiled C++ and then how to interpret kind of the results that come back. Because they use a different standard for it. C++ is not a VM, and Java is the JVM, and so there's not really like a meeting point there. I would imagine that if you built C++ code with Clang, and if Clang had a Java compiler, I don't know if that's true or not or rather if llvm had a java compiler then maybe you could do something more sophisticated because then like those two languages are meeting at the llvm level so like i know there's a python can call
Starting point is 00:54:57 into c++ code it's much cleaner um yeah there's a boost python i've seen that yeah well and other ways yeah but they kind of built it in for it yeah there's like ways python i've seen that yeah well and otherwise yeah but they kind of built it in for it yeah there's like ways to do like the c++ optimization is just really fast and so you just want to have a python scripting of calling this uh and it works pretty cleanly but there again like that yeah so it can be done good or bad but you're saying that swift objective c is done pretty well. This one was done really well. I took an Objective-C library and added it to some Swift code,
Starting point is 00:55:33 and it just worked. I was actually rather surprised. But I think the reason why it works so well is because of this LLVM middle layer. And that's important for a new language because initially there won't be a lot of Swift libraries, right? It will be good that you can use the Objective-C libraries. Yeah, I mean you basically get all
Starting point is 00:55:52 of the Objective-C libraries you kind of just get for free, which is pretty cool. Cool. So yeah, there's a blog about Swift. There's a Reddit, subreddit on Swift. And check it out.
Starting point is 00:56:07 It's pretty cool. And you can be one of the first. It's still time to get on the ground floor. That's right. That's right. I mean, if you make even something which you might think is mundane, like, I don't know, a calendar app or some library to help you talk to Facebook or something. I don't know. And you use Swift, it could actually end up being really, really, really popular
Starting point is 00:56:30 because there's not many out there. Or you could fall into some sort of, it could bomb, right? We don't know. You like it, though, so Jason sounds like he gives it a thumbs up. Yeah, I think it's pretty solid. One thing they're on the fence about i'm not crazy about um the fact that this isn't like an obvious decision but they're still trying to figure out what to do with the compiler like whether to open source it or not like if you read blogs from
Starting point is 00:56:55 the developers they're they're the blog literally say we don't know whether we're going to open source it yet and uh that always makes me uneasy because, you know, if you don't open source it, it really can't gain traction. Well, it could, but it's very dependent on, in this case, Apple, right? Like, if Apple decides for internal reasons to cancel it, it may have been a good, like, community may have wanted it, right? But, like, Apple decides not to do it. They could open source it at that point but you know it's always better to kind of open source it early and have
Starting point is 00:57:29 input and everybody on board from the start like what a disaster c-sharp was like c-sharp is actually still surprisingly popular but like a lot of people they had c-sharp they had mono which was like the open source that's basically reverse engineer all of c sharp and then for a long time mono didn't work 100 the way c sharp did like the microsoft compiler did and so just the whole thing is kind of a nightmare and by the time it stabilized i completely lost interest um but you know let's hope that that doesn't happen here. All right. Well, thanks for all the letters, letters, emails and postings. We see them occasionally, although we just talked about how antisocial we are.
Starting point is 00:58:14 But we do see postings on Google Plus and Facebook and Twitter and the emails. And we do appreciate their community involvement. Yeah, definitely. Definitely. and we do appreciate their community involvement. Yeah, definitely, definitely. We definitely, you know, we've been making a habit of talking about an email or a Google Plus or Facebook post in the beginning of the show, and that's because we've been getting so much good content from you guys and so many good questions. Although we'll probably offend a bunch of people because we don't talk about theirs.
Starting point is 00:58:40 If we offended you, send us another email. You can even get all the money you paid for this back yeah that's right oh man but i can't give you back the hour of your life no that part you can't get back so uh but you can't give us back the bandwidth either so it's we're even okay this is devon all right till next time. All right, guys. Catch you later. Thank you. Thank you. Thank you. The intro music is Axo by Binar Pilot. Programming Throwdown is distributed under a Creative Commons Attribution Sharealike 2.0 license. You're free to share, copy, distribute, transmit the work, to remix, adapt the work, but you must provide attribution to Patrick and I and share alike in kind.

There aren't comments yet for this episode. Click on any sentence in the transcript to leave a comment.