WEBVTT

0:00:00.000 --> 0:00:08.700
<v A>Hosting provided by HostTornado. They offer website hosting packages, dedicated servers, and VPS solutions. HostT.net.

0:00:15.840 --> 0:00:20.760
<v B>Programming Throwdown, Episode 15, Lua. Take it away, Jason.

0:00:21.680 --> 0:00:33.879
<v A>Hey, everybody. So, yeah, if you're wondering why the cadence of the show slowed down a little bit—it's been more than two weeks. People don't wonder anymore. Yeah.

0:00:35.560 --> 0:00:41.580
<v A>It's because Patrick and I were on vacation. Patrick was in sunny, beautiful Florida.

0:00:41.820 --> 0:00:42.707
<v B>No, it was just really

0:00:42.707 --> 0:00:49.459
<v A>hot. Oh, really? Oh, man. Already? It's only May. Yeah, but it was like really humid in 90-something.

0:00:50.040 --> 0:01:05.978
<v B>Oh, man. And you don't realize how quickly—and we're going to sound really obnoxious, Jason, just forewarning people, because we're like, oh, sunny California. And, you know, but you really do get used to it really fast. And Florida has amazing weather. But I went back, and I sweated the whole time. Yeah, I remember

0:01:05.978 --> 0:01:15.968
<v A>when I went back to Florida to visit my fam, I remember my glasses fogging up like when I got off the airplane, and like, I couldn't see anything. And it was like just so damp. Yes,

0:01:15.968 --> 0:01:21.880
<v B>it's so much more humid and hot. Ugh. Yeah, terrible. Now we sound like whiny. But that's okay.

0:01:21.880 --> 0:02:46.587
<v A>I was in not humid Alaska for a couple weeks, and that was pretty wild. We hiked all the way up to a glacier. A couple of guys got buried in the snow, and we had snow shovels. We had to dig them out. We were walking on these like snowshoes, which are—for people who don't know, they look kind of like a beaver's tail. They're like really, like flat and wide. And the idea is, like, you won't break through because, you know, the way it works is the snow keeps piling on top, but the sun, especially during the day, sort of like heats up the snow, and it creates kind of like a shell because it's like this water is heating and then cooling a lot. And so you have this shell that's harder than the snow itself. And underneath the shell you have this soft snow. And so the snowshoes allow you to sort of walk on this shell without having to like trudge through the snow, right? But if you do fall in, your snowshoes like break through. Then like, you sink in, like—and people are sinking in like three, four feet into the snow. And then the snow sort of like—it's not like quicksand. Like, you don't sink in it or anything. But like, you fall through the snow, and then the snow like comes around you kind of and like entraps you. And especially since you have the snowshoes that are like attached to your feet, like, you can't lift them up because there's just too much snow has like collapsed on you. So somebody

0:02:46.587 --> 0:02:47.582
<v B>has to—

0:02:47.640 --> 0:02:56.500
<v A>And this is fun. Yes. We did all this to go to a glacier and take a lot of pictures. But, you know, the adventure was the fun of it.

0:02:56.540 --> 0:02:57.980
<v B>I think they have helicopters for that.

0:02:58.640 --> 0:03:09.385
<v A>Yeah, yeah. We could have taken a helicopter. Instead, we hiked it. So our parents—my in-laws came, and they actually took the helicopter. So we met.

0:03:09.385 --> 0:03:10.684
<v B>Them. Did they meet you out there? Oh, okay. Yeah,

0:03:10.684 --> 0:03:30.000
<v A>Yeah. We met them there, and then they took the helicopter back. And it was about—I think it was like 8 to 10 miles. So it was quite a hike. And we were pretty exhausted. And, you know, at one point, the tour group leader was like, 'You know, you've only done 50% because we've got to go back.' So we were really tired.

0:03:30.000 --> 0:03:30.951
<v B>Those are the words you don't want.

0:03:31.002 --> 0:03:51.940
<v A>To hear. Yeah. But some cool things about it. One, we saw some black bears. That was pretty cool. We learned the difference between black bear, grizzly bear, and polar bear. So black bears are the least threatening, and they pretty much run away as soon as they see you. Grizzly bears and polar bears are like much more dangerous. And brown bears are also pretty dangerous.

0:03:54.240 --> 0:04:38.460
<v A>What else? Oh, the tour guides made this awesome stuff. They took like cocoa powder, like you used to make hot chocolate, and Tang, and put it together. And they made hot chocolate Tang. And it tasted like—you know those orange chocolates? It's like a huge orange-shaped chocolate. Oh, yes. And you like slam it on the ground, and it breaks into pieces, you know? It tasted like that. It was really good. Yeah, sure. So, yeah, I was kind of hiking in the wilderness. But we're back with Lua. We survived. We survived. Yes, we did. It was pretty awesome. I have some pictures posted. I'll share them with the Meme Hub page so that anyone who's following the page will get to see the pictures of the hike.

0:04:38.800 --> 0:04:40.440
<v B>Or their programming throwdown page, maybe, too.

0:04:41.500 --> 0:04:51.900
<v A>That's right, the programming throwdown page. What did I say? You said Meme Hub. You have too many pages. Oh, no. I have too many. For real. I think I'm going to add a third page now, so it's going to be just ridiculous.

0:04:52.340 --> 0:05:14.665
<v B>Uh-oh. Spoiler alert. All right. So, the news of the week is Facebook. So, Jason, I think, uses Facebook some. I have an account, I think, somewhere. All I know is Facebook keeps emailing me and saying, 'You have like 30-something friend requests.' And I'm just like, 'I don't care. You should detect it. I haven't logged in in years. I'

0:05:15.272 --> 0:05:26.500
<v A>use Facebook as like the OAuth. You know, like some things now will let you log in using your Facebook ID, like single sign-on. Yeah. Yeah, yeah. I'll do that. But that's about all I use it for.

0:05:26.780 --> 0:05:56.580
<v B>So, actually, I'm interested how many of Facebook's 900 million users are doing that? Like, only interaction? Or is it 900 million is like registered? And then I forget how many they claim are active. But how many of their active users, you know, are logging onto Facebook.com, being served ads, you know, and, you know, interfacing with the content? How many are accessing it, like, on a mobile device where you don't get ads? And then how many are just using it, like you, for, you know, just logging into other websites, authenticating with stuff, or just playing games?

0:05:57.760 --> 0:06:06.758
<v A>Yeah, well, I read an article that over a third of people just log on Facebook to play Zynga games. So, yeah.

0:06:07.560 --> 0:06:15.870
<v B>Farmville. Nobody admits to playing that game. But I know there has to be a ton of people playing that game. Oh, yeah, totally. There's got to be. But, you know, I

0:06:15.870 --> 0:06:34.000
<v A>mean, even just, even if it's true and people aren't, you know, the whole wall, post on the Wall, share with your friends, if that's kind of, like, gone with the dodo, it's still pretty useful technology. You know, just being able to identify people and their relationships. And a lot of applications need something like that to be, you know, even better.

0:06:34.460 --> 0:06:49.030
<v B>But is it worth hundreds of billions of dollars? And that's the question that was asked at the end of last week. That's right. So, Facebook IPO'd their Initial Public Offering. And Jason and I are not business majors. We are not financial students. Oh, yeah, yeah. Let's

0:06:49.030 --> 0:06:56.033
<v A>put a disclaimer here. You know, we don't take this as stock market advice or anything like that. This should not

0:06:56.033 --> 0:08:43.965
<v B>be construed as trading advice in any shape or form. But, yeah, so it was really weird. We were watching it, you know, being in the tech industry. People at work were interested in this because it's a very, it hit mainstream, right? So, even the morning news was covering Facebook's IPO and it being local to this area, the Silicon Valley, that, you know, it was big news. And so, people were watching it. And it was just one of the weirdest things, you know, I've seen that people were just talking about it. And then stuff just seemed to go terribly wrong. So, when it first opened, it turns out afterwards, I was trying to read because, you know, when I, I think it was LinkedIn or Groupon had IPO'd. I tried to watch it like because I was curious what would happen. And it didn't open with the market. But this was expected. And actually, news reports said this was going to happen. But Facebook was supposed to start trading when the NASDAQ opened. They're going to trade on the NASDAQ. Or they are trading on the NASDAQ. But it turned out the NASDAQ had technical difficulties that delayed the start of trading for like almost three hours or two hours, two and a half hours, something like that. And so, I read a little bit about it trying to understand. And the best explanation I could kind of come across was that they, the IPO price, that very first price that it's going to start at is calculated by how many people kind of say, 'I'm going to buy shares at whatever price it opens at.' Right? So, before the market opens, they put in an order with their broker. I don't care. Buy it right away, you know. And those are matched, which is the whole purpose of, you know, the exchanges. So, the New York Stock Exchange, NASDAQ, the Chicago Board of Exchange, these different markets, their whole point is matching somebody who wants to buy with somebody who wants to sell. So, I don't want to derail you. Like, you can

0:08:43.965 --> 0:08:51.020
<v A>table this. But I was just, I don't know the answer to this. What's the difference between the New York Stock Exchange and NASDAQ? Like, are they just two different people who do the same thing?

0:08:52.260 --> 0:10:05.280
<v B>The technologies behind them are kind of different. Oh, okay. And essentially, they're doing the same thing, which is at the base level, they're matching buyers and sellers for a given stock. Gotcha. So, you know that if you want to trade, you know, I'm trying to think of something that's on the New York Stock Exchange. I'm not good at this. Like, AT&T, let's say, is on New York Stock Exchange. Then you need to go there to trade it. Versus if you want to trade Facebook, it's on NASDAQ. So, you need to go there to trade it. And your broker hides this. So, your broker's job is to talk to somebody whose job is to talk to somebody whose job is to talk to somebody whose job is to talk to the exchange. Okay. And in the old days, that used to mean, like, some person on the floor waving a piece of paper and screaming, 'You know, I have an order for five shares.' And he knows it's from some guy named Jason Gauchy. But nobody else knows. He's like, 'I got five shares.' And somebody else goes, 'Okay, I'll sell you five shares, you know.' But now that's all done by computers. And it's done at matching. And at each level it goes through. So, like, your broker, the, you know, clearinghouse for your broker, like, these successive levels away from you, they can match people who also are using. So, like, if you use Fidelity, let's say, Fidelity can match you against another Fidelity customer instead of having to go all the way out to the exchange. Because then Fidelity makes more money that way because they don't have to pay the exchange for this service.

0:10:05.300 --> 0:10:11.395
<v A>Oh, I see. It's almost like sort of like you could relate it to, like, electricity or water or something like that. Yes, you

0:10:11.395 --> 0:11:09.023
<v B>go to the nearest person who can give you the supply. Yeah, right. Right. So, okay. So, like, the NASDAQ, when it was opening, had all of these orders because, of course, you know, the people selling were in very small area, right? So, Morgan Stanley and I think a couple other investment banks. So, they were the only people who were kind of giving sell orders to the NASDAQ. And then people across all other brokerages had buy orders. And so, what NASDAQ needed to do, again, this is Patrick's understanding of reading a couple articles and trying to figure out what happened, is that they have to kind of figure out what that first price, what it's going to open at is. And so, they have to go and match. So, Jason wants to buy 1,000. Morgan Stanley wants to sell 10,000. So, okay, I need to adjust the price to and fro, do this and that. You know, they need to go through and basically have a queue of all of the buys and sells, match them against each other, and determine what the final price at the end of all of that is. But what happened...

0:11:09.023 --> 0:11:39.482
<v A>understand right, so the price of a stock... So, I guess some people say, 'I'm willing to buy but only for $30.' And someone else says, 'I'm willing to buy for up to $40.' Right. And the person is saying, like, 'I'm willing to sell.' So, obviously, like, the thing is going to try and match up the person who is willing to spend more. So, it decides, oh, the price of the stock should be $40 because this guy is willing to spend $40. But then, if the guy who is willing to spend $40 isn't buying all the shares that are up for sale, the guy who is spending $30 is buying half of them. Now, the price is $35, something

0:11:39.482 --> 0:13:37.060
<v B>like that. Yeah. So, it's whatever the last price of a trade took place. So, yes. So, normally, when a stock is not moving, it's because Jason says, 'I'll sell for $30' and I go, 'I only want to buy for $25.' And so, there's a gap of $5 between us. So, an order doesn't take place. And then, it's not until somebody else comes along. Like, maybe Jason says, 'Okay, I'll sell you for $25.' Then, that's the last trade. So, that's the price of stock $25. So, basically, there was all of these orders stacked up. And sometimes, you can say, 'I don't care. Just buy me some. I don't care what the price is.' Right. And then, what it'll do is it'll say, 'Jason's willing to sell at $30.' So, I'll buy all of his at $30. The next person's at $35. I'll buy all theirs at $35.' You know. And then, the person buying will get some at $30, some at $35, some at $40, whatever. You know. As it goes up. And so, all of this has to take place to figure out what the price is going to be at open. And what my understanding was is the way the NASDAQ software was written is that they had kind of an unforeseen consequence where before the market opened, somebody modified their order. Said, 'Oh, I don't want to buy 1,000. I want to buy 500.' You know. And they could do this because the order hadn't been executed yet. The trade hadn't taken place. But when that happened, when that queue had been filled up and, you know, millions and millions and millions of these, you know, orders were in there. That when they got to one of these modifications, they kind of had to go back to the start and go again. Because they had assumed, you know, at, you know, $0.5 million that they had, you know, an order for this. But now, the order was actually something different. And so, they would need to kind of unravel back to that point and kind of play it for it again. And so, they had this loop. But then, because they had to go through all of these modification orders and it was taking a long time because there were so many, many, many orders out there that when they came, that caused a delay. But then, during the delay, other people freaked out and go, 'What's going on? Cancel my order.' You know, 'Modify my order too.' And so, every time they would hit one of these, they kind of had to start over again.

0:13:37.480 --> 0:13:57.320
<v B>And so, they just kind of ended up in this vicious cycle of delaying for hours trying to get through this mess. And so, eventually, I guess they stopped that and, like, changed it so that it would ignore the modification orders or something. But it caused a pretty big, you know, mess—that this is a big brand name, IPO, Facebook, first day. And then, for like two hours, nothing happened.

0:13:58.220 --> 0:14:27.760
<v A>Yeah. And I mean, you know, what the article is sort of alluding to is that, you know, Facebook, before they went public, they had, you know, I think it's Goldman Sachs. I was trading these private shares so you could buy a piece—and so, basically, those people didn't have, like, all of these things happen to them or whatever. And so, they were able to sort of strategize and buy at the right time and get in on it sort of early and things like that. And those people were probably all leaving, you know, right when it died, P.A.

0:14:27.760 --> 0:14:28.536
<v B>They were all

0:14:28.536 --> 0:14:28.620
<v A>selling. Yeah, trying to sell.

0:14:28.860 --> 0:15:21.180
<v B>Because, yeah, they bought in at, like, 20, right? Yeah, exactly. So, that's the other thing is there's all these people trading beforehand. There was these issues that, you know, if you were just you or I, you'd have no idea what was going on. I only figured this out much later when I was reading about, you know, reports about what happened. And then, the other thing that happened is the stock started to drop once that problem was fixed. And then, it started to go back up. And you're like, whoa, it's going back up. Like, this is great. It's going to happen. The IPO popped. And then, it turns out that that was Morgan Stanley, the people doing the IPO. That was them, like, trying to pour all of their money into buying the shares to try to get the price to go back up and get people excited. And then, you know, Monday, it dipped even more. And so, now it's, like, on a slide downward, which is kind of bad. But all that to say that it was very complicated. And it turns out if you didn't know what was going on, you probably were just going to get hurt.

0:15:22.540 --> 0:16:26.120
<v A>Yeah. I mean, I think that, you know, people's, you know, it's one of these things, like, it's always been, like, personally, I always like to invest. Like, I've only invested a little bit. But I remember when I was in college, I had a little bit of money, and I invested it in Apple. I bought, like, I think I bought, like, one share or something like that because, you know, you're, like, a broke college student. But it's, like, fun to invest in things that you believe in. And sometimes, you know, if you believe in something, it's sort of, it's more than just, like, trading based on the statistics. Like, you're trading based on, like, kind of, like, educated insight and things like that. It's, like, at the time, I bought, like, one of the first, I think I bought, like, the second-gen iPod. And I was, like, this thing is great. This music player is awesome. So I'll buy, like, one share or whatever. And, you know, it'd be fun to sort of do this with Facebook and say, look, Facebook, they're providing awesome technology. And, you know, it's a way to sort of bring people together, et cetera, et cetera. But if you try to buy, at least right now, you're just going to end up getting caught up in so many people who are just playing this as a game and not, you know, as an investment. Yeah, absolutely.

0:16:26.599 --> 0:16:37.980
<v B>And I think it's one of those things, and you have to be honest with yourself. If you're buying it for a long term, don't look at it. But if you find yourself looking at it and thinking about it, you're not in it for the long term. Yeah, good point. Good point.

0:16:39.081 --> 0:17:40.980
<v A>And I really don't know if, like, I mean, so many people have said, oh, I have this great strategy. And we're constantly, like, on the Neuroevolution users group. Every week, somebody's like, oh, I want to use this Neuroevolution program to do stock market trading. And just, I mean, if I give you one piece of advice from someone who's done a lot of AI in his life, just don't bother. You know, I mean, invest in companies that, like, you either believe in or you, you know, you see they have a good future, things like that. And just keep your money in them for a really long time. And just treat it as sort of, you know, and if it goes up and down, like what Patrick's saying, just ignore it. And all of this, like, trying to, like, do all this gamey stuff and things. I mean, there's just so much infrastructure in place to do all of this. Like, we went to one talk where this guy was doing, what was it, like, nanosecond trading or something like that. And they had written their own operating system to do this trading. It's just insane. So, yeah.

0:17:41.139 --> 0:17:57.220
<v B>This is just another case of that. And if you think, I don't know, like, if you hear people saying they've got a system, they're probably not very successful. And that's why they're trying to talk about it and sell something. Yeah, that's true. If they were really successful at, like, this system, they would just use the system until they didn't need money anymore.

0:17:57.980 --> 0:17:58.940
<v A>Yeah, yeah, exactly.

0:17:59.360 --> 0:18:01.971
<v B>Now, that's not completely true. There's caveats to that. But for

0:18:01.971 --> 0:18:06.179
<v A>the most part, the people who are loudest about the stocks are typically the worst traders.

0:18:06.760 --> 0:18:09.540
<v B>People who are really good at it tend to be quiet and not say much.

0:18:10.540 --> 0:18:53.880
<v A>Yeah, that's right. And I mean, it's fun to fantasize about being like some kind of crazy white hacker, AI super genius who makes some program that, you know, makes a bunch of money. But in reality, there's just massive, massive hedge fund-based institutions that have hundreds and hundreds of postdocs and professors, ex-professors, things like that in AI who do this kind of stuff. And that's just for them, it's just like owning a construction company or something. They go in, they put on their hard hat, and they just hack the stock market all day, you know? So just one person, no matter what kind of talent or anything, is just not going to stand up to something like that.

0:18:54.080 --> 0:19:17.560
<v B>Yeah, there are always exceptions to the rules, but it's like anything. You have to look at the odds, right? That you always hear the kid who wants to be the NBA basketball player. And I feel bad for them, but I try to point out that's statistically unlikely. Yeah, that's right. But you don't know. I'm really good. I'm like, you're right. I don't know how good you are. But, I mean, unless you know you're the best in your state, the best person you've ever played basketball against, you're not making it to the NBA.

0:19:18.240 --> 0:20:00.560
<v A>Yeah, and I mean, and again, that's a perfect example. The people who make it to the NBA, by and large, are people who played in amateur athletic union, played in high school, played in college. And by the time they get ready to enter the NBA, they have this whole history. And they have like an entourage. That's not the right word. But they have connections. They know the ins and outs. Like, they know how the play is supposed to be run. Like, they can go to the coach and they speak the same language. Like, there's all this infrastructure, social and physical infrastructure in place already. Like, you couldn't take somebody who has just incredible natural talent and expect them to make the NBA without going through these phases.

0:20:00.980 --> 0:21:27.000
<v B>Yeah. So well, our second news story, not to dwell on finance stuff forever. This is a programming podcast. Yeah, totally. Twitter has changed. They want to do better at recommending who to follow, what to do, you know, what things of interest. And so they're going to start kind of, I guess it's going to be opt-out. But they want to start doing more tracking of their users to figure out what they're doing, to figure out what they're interested in. So they can provide better recommendations. And, of course, as always, people are upset. You know, Twitter wants to track you. They're invading your privacy. And although, in one hand, I guess that's technically true, it comes down to the thing I want to bring up with this article is this problem, this walk that these companies have to do to straddle making something that's useful to you and respecting your privacy. Some things you can provide in a perfectly anonymous manner. But it is actually what they're trying to do. I feel it will be better if they track me. But them tracking me means they have information about me that I don't necessarily want them to have. And so how do I make that decision? How do they make that decision? How does somebody who doesn't understand any of these things make that decision? It's very complicated. And it's something more and more that I think Facebook, Google, Twitter, all these people are having to address. How do they provide tailored, personalized, useful results to their users without invading their privacy too much?

0:21:27.780 --> 0:22:33.200
<v A>Yeah, definitely. I mean, that's a huge, huge concern, right, for these companies. Because like let's say Twitter makes this and there's a hole in it and somehow advertisers get access to your interests at a very deep level. And let's say they get access to your address even and things like that. I mean, this sounds really far-fetched. But I actually went to, and this is real, I went to a what is the word, a conference where somebody was giving a talk. And they actually using Twitter posts or tweets, I guess, they were able to determine someone's location of where they lived with like remarkable accuracy. And they used the so Carnegie Mellon has a Twitter data set. So I don't really know much about how it works. It's somehow anonymized. But basically it's like a slice of all of Twitter's data. And so researchers can use this information that's been scrubbed somehow to, you know, do various experiments and things like that. And the kind of things that people can deduce is just shocking.

0:22:33.200 --> 0:22:45.820
<v B>Well, I saw one that it was just by the dialect, like, the words you use are regional. So you can identify where somebody is in the country by just the words they choose to use even in their 140-character tweets.

0:22:46.400 --> 0:23:59.140
<v A>Yeah. Yeah, that's a big part of it. And they also do, it's based on your connectivity, like, people you're connected to. Because you think about this, right? Like, if, you know, if they could figure out for half of the people, then they could just use the connectivity, like, who's friends with who, who's following who, to figure out the other half, you know? So if one person says, oh, I went and saw the Giants, I walked to the Giants game today, then, you know, it could use that phrase to figure out, well, they must be really close if they walked. And so everyone they're following, you know, is statistically likely to also be in San Francisco, et cetera, et cetera. And they can, you know, build all these inferences and layer them on top of each other. So, yeah, I mean, the short of it is there's an incredible amount of thing, of interesting things that they can deduce from your information. And they can use that to sort of provide like really, like, targeted-based, you know, whether it's advertising or whether it's giving you information, whether it's assisting you with your searches. Or there's tons of things that Twitter can do with this data. But, yeah, at some point it crosses the line of being creepy. And that line is different for each person. That's what makes it so difficult.

0:23:59.540 --> 0:24:04.960
<v B>Or not even the creepy, but just like you said, the risk of somebody leaking out information you didn't want leaked out.

0:24:05.700 --> 0:24:08.160
<v A>Yeah, yeah, both of those are just really dangerous.

0:24:09.900 --> 0:25:01.900
<v A>Like, that was one of the big things with, oh, there was some social game, I can't remember what it was called. But it was basically like you managed an aquarium and, like, there was different fish and your friends had fish or something. And they were doing pretty good. It was like a startup. And they had like a few million users and people were buying fish and things like that. Then they did something which was kind of sketchy. Like, I can't remember what it was. Oh, it was like somehow they'd figure out where you lived based on, like, your Facebook posts and things like that. Then they'd try and, like, put you in an aquarium with other people who lived near you. And the whole thing died. Like, people got freaked out. And, like, a bunch of people canceled their account. And that startup went under, like, almost immediately. Wow. Yeah, it's like a huge concern is, you know, walking this line between, oh, this is really cool and this is totally creepy.

0:25:04.700 --> 0:25:33.000
<v B>Well, on to something completely different. I read this article that I thought was really cool. We've talked in the past about microcontrollers and embedded programming. And here's a guy, we have a link in the show notes, but who is programming and controlling his Arduino, which is one of these small embedded microcontrollers with JavaScript. And I thought that was really cool how somebody had a passion. They really want to write stuff in JavaScript. And so they actually figured out how to use JavaScript to do something you wouldn't expect.

0:25:33.000 --> 0:26:15.060
<v A>Yeah, yeah, totally. That's pretty awesome. That's a benefit between, you know, I mean, remember, like, it wasn't too long ago where compilers were totally closed source, locked down. And it's like you would take your C or C++ code and you'd build it using GCC. You know, and then you'd build it with the Intel compiler and you'd build it with, like, this other compiler. And all these, you know, it'd be so much faster and things like that. And it's just nice to see that, like, the whole industry is really matured. And all of these tools are just totally open and accessible. And if you want to do something crazy like this, like recompile the JavaScript virtual machine for Arduino, you have the freedom to do it.

0:26:15.500 --> 0:26:59.540
<v B>Yeah, so, well, so I guess the way this actually worked is there's Node.js, which is C++ JavaScript interpreter that actually, I guess, powers Chrome. It's the same one. So V8, is that what it's called, I believe? That's right. Yeah, and so in there, because of the C++, they could basically create a crafted interface between the JavaScript portion and the C++ portion, which had access to the serial ports. So you could control commands out the serial ports. And then with a little bit of fiddling and magic wizardry, we'll call it, the serial commands that got sent across, you could send across special ones that were interpreted on the Arduino side to blink a light or read a sensor or whatever. Ah, nice.

0:27:02.320 --> 0:27:23.976
<v B>That's awesome. It's pretty cool. It's kind of crazy to see what lengths people will go to to use something that isn't necessarily the first closest tool for the job that you would expect. So people would normally say, like, oh, C or C++. But here's a guy who took JavaScript, maybe one of the least likely ones, you would say, and got that to work as well, because that's what he liked. Yeah, isn't that crazy?

0:27:23.976 --> 0:28:14.534
<v A>How popular JavaScript is becoming? Like, it just blows my mind. There's Node.js, which is pretty awesome. Then there's, oh, I'm totally drawing blank. Oh, oh, the Android, what is it called? I think it's called, like, Mojave or something. But basically the thing is you write JavaScript code, and then it turns your JavaScript code into either, like, or it has, I guess, a virtual machine written in Java to run your code on the Android. And it also has one written in Objective-C. Let me see if I can find this. Okay. But, yeah, basically, so people are writing native, like, phone code in JavaScript, and then it's, like, then they're just compiling it or they're running it on all the phones. So they

0:28:14.534 --> 0:28:15.394
<v B>don't have to, like,

0:28:15.394 --> 0:28:28.660
<v A>write their code in Java, write another copy for the iPhone, write another copy for the Windows phone, et cetera, et cetera. Oh, cool. Yeah, yeah, JavaScript is becoming extremely popular. I mean, it already was popular, but it's just growing at an alarming rate.

0:28:30.200 --> 0:29:36.664
<v B>Well, on a similar topic to controlling real-world things through your computer, I guess this is another dream of science fiction. But I read an article about people controlling robots with their brain. And so this one was actually, I think she had this lady who had a brain implant was able to get a robotic arm to bring her a cup of coffee and actually tip it into her mouth so she could drink some. Why use a very steaming hot beverage? I guess just to show how confident you were in your system. But that seems dangerous to me. But it is an amazing feat, and there's a lot of problems. And they said that they had to do it multiple times. And, like, I think they said it worked, like, four out of the five times or three out of the five times or something. So there's times she was burned horribly. Oh, no, no. I think she just, you know, dropped it or tipped it over or whatever. But, yeah, so it's kind of cool. This brain-computer interface is for paralyzed people. And that's, I mean, that's just amazing what it might be able to do to help those people. And then one day, you know, maybe even the rest of us to be able to do that. Like I said, a dream of science fiction and young kids everywhere. Yeah.

0:29:37.238 --> 0:29:40.120
<v A>I mean, everyone should watch this video. It's amazing.

0:29:41.693 --> 0:29:48.949
<v A>So. How does that work? Is it based off, like, I mean, it's not literally, like, it hasn't punctured her skin, right? Yeah,

0:29:48.949 --> 0:30:26.395
<v B>No, no, no. This one has. So what they do is they. Oh, okay. I think it's a sensor, maybe, like, the size of a grain of rice, something really small. And they bury it in a certain portion of the brain. So they kind of, like, drill a hole in your brain and put this long needle with something on the end of it into this certain point. And then there's a bunch of little probes on the end is what I understand. And they measure the electrical spikes in the area of your brain. So neurons, when they fire and talk to each other in your brain, when your brain has activity, those emit EMI signals, electromagnetic signals. And so when, or I guess just EM signals. I

0:30:26.395 --> 0:30:27.200
<v A>didn't get extra letters.

0:30:27.740 --> 0:31:17.060
<v B>And they're able to pick those up, you know, measure those and see that your brain has activity. But at first it just kind of seems random because you have no idea what neurons you're next to or what exactly they're for or what they're doing. But then, you know, kind of like a child learns, you learn that, oh, when I think of the color green and smell the color coffee and try to move my left finger, you know, my left index finger. Like, I noticed that the arm kind of does this wiggle motion. And so then over time your brain kind of learns to think in a certain way to be able to control it. And what it is is just these electrodes picking up the signals and detecting that your brain is emitting a certain pattern. And then they interpret that pattern as, you know, move left or move right, move up, move down. Ah, that's amazing. But this one actually gets implanted in your brain, the one they're using.

0:31:17.780 --> 0:31:22.020
<v A>Yeah, because we've seen one where we were looking into one a while ago.

0:31:22.100 --> 0:31:23.480
<v B>Right, that goes on the outside.

0:31:23.940 --> 0:31:27.679
<v A>Yeah, yeah, but that one had mixed results. But it looks like this one is much more fidelity.

0:31:28.040 --> 0:31:33.060
<v B>Yes, because the skull blocks a lot of that electromagnetic signal.

0:31:33.639 --> 0:31:40.037
<v A>Yeah, that makes sense. Makes sense. So, cool. So, yeah, the next article we have is why

0:31:40.037 --> 0:31:47.969
<v B>Airplane bathrooms have ashtrays. And I assume it's not just because the airplane was built before smoking was banned. No. So that's

0:31:47.969 --> 0:31:54.240
<v A>the shocking thing. And even new airplanes that are built now have ashtrays with no smoking symbols on them.

0:31:54.879 --> 0:31:57.480
<v B>Wait, the ashtrays themselves have no smoking symbols?

0:31:57.570 --> 0:32:51.459
<v A>Yeah, you should see some of the pictures of this article. There's literally an ashtray with a big 'No Smoking' on it. But, and so you think to yourself, well, this is like some kind of corporate, you know, bureaucracy kind of thing. Like somebody didn't do their paperwork or something, and now all the airplanes have to have, you know. But no, it's actually, it's actually a result of something that was quite tragic. Like somebody smoked, was smoking on an airplane while it was in flight. And, you know, there's nowhere for them to put their cigarette because smoking had been banned. So they flushed the cigarette down the toilet. And this seems like very bizarre to me, is what I'm about to say. But somehow that caused the plane to crash. Like almost everybody died. Like I don't understand how flushing a cigarette down the toilet can do that. Maybe they didn't flush it down the toilet because it said it was like poorly disposed of. Maybe they just put it in a trash can.

0:32:51.459 --> 0:32:53.719
<v B>Oh, maybe they put it in where you put your paper towels.

0:32:53.720 --> 0:34:21.818
<v A>Oh, yeah, that makes much more sense. But, yeah, basically somebody did that and the plane crashed and everybody died. And so they decided that they're going to put ashtrays on planes, mandatory. And the idea is, you know, where they're getting at here is, yes, you know, in a perfect world you would have the 'No Smoking' symbol, you know, above their head. You have the 'No Smoking' on the entry of the door, the 'No Smoking' all over the bathroom, the signs everywhere. And people just wouldn't smoke, right? But the reality is that, you know, eventually you have to come to terms with that, you know, this is an addiction and that people, you know, their tendency. Like if you did a use case study or something, you would find that people just have to smoke, right? And there's like one in a thousand or however many that just have to do it. And so by putting in the ashtrays, they're saying, well, look, you know, you know, if somebody has to smoke, if they're going to just like if they're willing to take that risk of the fine and the alarm detector going off and them going jail and everything, and they're still going to do it, then like we have to have a way for them to do it without blowing up the plane. And then it goes from there into like a little bit of hyperbole, but it's actually really interesting on sort of like how do you design for human nature? And it gives like a doorknob as an example. So I thought it was pretty cool. So definitely give that article a look-see. Yeah.

0:34:21.860 --> 0:34:40.980
<v B>Well, so it did say that the airline crashed because the smoke, so however it was improperly disposed of, it filled the cabin with smoke. And a bunch of people died from smoke inhalation because there's no, like when just pressurize and everything, there's nowhere for the smoke to go. Oh, wow. And so it just keeps building in the cabin.

0:34:41.860 --> 0:34:46.160
<v A>Oh, so it's probably what you're saying then. He put it in where the paper towels are and it caused a huge fire.

0:34:46.160 --> 0:34:48.360
<v B>But it was in 1973, so it was actually a while ago.

0:34:48.920 --> 0:34:49.797
<v A>Yeah, yeah, definitely. All

0:34:49.797 --> 0:34:50.370
<v B>Right.

0:34:51.120 --> 0:35:02.259
<v A>Is it that time? It's time. Tool of the bi-week. Yeah. All right. You're up first, man. All right. So my tool of the bi-week, it's actually two tools.

0:35:02.500 --> 0:35:04.967
<v B>Wait, wait, wait, wait, wait, wait, wait. I know. That's

0:35:04.967 --> 0:35:06.940
<v A>Not fair. I'm breaking the rule, man.

0:35:07.161 --> 0:35:07.735
<v B>Now you're twice

0:35:07.735 --> 0:36:19.032
<v A>As awesome as me this week. We've been on vacation. I want to come back, you know, all pistons firing. So you're going to only use one of these tools, though, depending on what language you're programming in. The tools are BerkeleyDB and JDBM3. And basically what these are, let's say, you know, let's say you want to store a lot of data. So what you want is a database, right? But when most people think of a database, they think of, like, MySQL, let's say. So, you know, here you are. Let's say I'm writing some program to, I don't know, just, like, count the number of times someone visits my site and just store it on disk, right? So if I do MySQL, I have to set up a MySQL server. I have to, you know, like, have that service running on a machine somewhere. I have to open that port because MySQL communicates through TCP. I have to write some MySQL client, which uses the TCP socket. I have to serialize all my data and take my data, which might be a bunch of classes and functions, things like that, and turn it into, like, MySQL tables. I have to create the schema. Like, there's so much overhead, right? You

0:36:19.032 --> 0:36:22.040
<v B>Can avoid some of that by using SQLite, but maybe that's for another week.

0:36:22.580 --> 0:36:24.668
<v A>Oh, yeah, yeah. Well, even with SQLite, you have to do a lot

0:36:24.668 --> 0:36:26.300
<v B>Of that. Yeah, but you still have some of those problems, yeah.

0:36:26.380 --> 0:36:28.026
<v A>Yeah, you have to create the tables. Sorry, not to

0:36:28.026 --> 0:36:28.600
<v B>rain on your parade.

0:36:29.600 --> 0:38:21.280
<v A>Yeah. So the simplest thing, the simplest database that, well, that I can think of at least is a key-value pair, right? So basically you just have a list of keys and, like, a hash table, basically, but on disk. And so that's exactly what BerkeleyDB is. It's just a simple hash table that persists to the disk. And you can put in keys. You can put in key-value pairs, and then later on you can search for the key and you can get the value. And it does some clever caching, but if you fall through the cache, you know, it has a backup on disk. And it's also transactional. What that means is you can queue up a bunch of commands, and then you can commit the commands. And so let's say, for example, let's say I load Patrick's profile. I'm a web server, and Patrick logs into my server on his computer. And he goes and, like, changes his password. But then at exactly the same time, evil Patrick, who's masquerading as regular Patrick, is on Patrick's phone and changes his password right there on the phone, too. Or changes something else. Changes his, like, profile picture to a Hello Kitty picture. Like, at exactly the same time. You know, that can cause issues. Like, you could end up, like, saving two things twice, and one can collide and things like that. So you need to support transactions to deal with things like that. So the thing that comes in second, the transactional fail, it'll say, hey, something weird has happened. This data has been modified. You need to take a look at this and sort this out. So it handles, like, the very basics of what you need to have what's called an ACID-compliant database. And ACID, I don't remember, do you know what it stands for, Patrick? It's, like, atomic...

0:38:22.120 --> 0:38:25.409
<v B>Consistency? Something like that. Isolation.

0:38:25.409 --> 0:39:50.678
<v A>Durability? Ah, there you go. Perfect. So, yeah. So you want that. So BerkeleyDB has a bunch of bindings, like C, C++. You know, I think there's a Python binding. Actually, I think it's part of Python, actually. Now, so if you're using Java... Now, Java already has a really nice collections framework, right? Like, Java has Map and, you know, HashMap, TreeMap, ArrayList, all these cool things. And since Java already has all this infrastructure, there's something called JDBM, which basically what it does is it gives you a Map, like a Java Map, but that map is backed by back to disk. So, in other words, like, you just... You could write your program and have everything in memory, like all your usernames and passwords and all that in memory. And then once your program gets more mature and you say, okay, I want to deploy this, you can just replace the new HashMap with JDBM3 HashMap. And it'll just deal with everything under the hood. So it'll put things to disk when you need to go to disk. It'll load things from disk, etc., etc. And actually, BerkeleyDB is the most popular database because it's installed, like, multiple times on everyone's machine. Like, even if you run Windows, Windows actually uses BerkeleyDB for a number of things. Oh, wow.

0:39:51.060 --> 0:39:56.200
<v B>So this doesn't handle over the network, though, right? Like, this is just for, like, local persistence to disk.

0:39:56.660 --> 0:40:05.020
<v A>Right. That's right. And the other thing is it doesn't handle multiprocessor. Although now there are some versions that are starting to get into that.

0:40:05.220 --> 0:40:05.440
<v B>Okay.

0:40:05.440 --> 0:40:35.009
<v A>But for the most part, it's, you know, if you have a single program, it could be multithreaded. And I think we talked about this. But just to recap really quick, multithreaded means you have, you know, a bunch of different threads that could all be doing different things, but they're all sharing the same memory. Versus multiprocess, each one is a completely different program. And so BerkeleyDB and JDBM don't support multiprocess yet, but they support multithreaded. Nice.

0:40:35.839 --> 0:40:38.974
<v B>Yeah. So, I mean, unless you're, you know, a lot of websites

0:40:38.974 --> 0:40:51.023
<v A>use MySQL. But really, unless you're, like, some kind of powerhouse, you'd be totally fine. Like, if you're doing your own coding, you'd be totally fine using something like this. And you'd save yourself a ton of

0:40:51.023 --> 0:41:14.300
<v B>time. And then I think if you use, like, a key-value pattern like that, right? So if you can reduce it to something simple like that, then I think it would be easy to move it over to network. Like, I think Redis and other databases are kind of the same idea, but for network-connected things. So if you wanted to add in sharing with other people, if you're using this key-value mentality, there are other solutions that will take you to the next step.

0:41:14.960 --> 0:41:25.740
<v A>That's right. There's CouchDB, Redis, there's HBase. There's a ton of them. And we should maybe talk about, dedicate some time to that, you know, in the future because those are actually really, really interesting.

0:41:26.520 --> 0:41:28.160
<v B>Right. All right.

0:41:28.700 --> 0:41:28.960
<v A>Yeah.

0:41:29.340 --> 0:42:25.580
<v B>So what about your tool of the bi-week? Like, nothing nearly so enterprise-y or, I don't know, anyways, Audacity. So I thought, well, for sure we've talked about Audacity before. And maybe we have, and maybe my show notes are lacking. But I looked through all the show notes and I couldn't find it. Wow. And I decided we needed to talk about it because it is what you are listening through us, the power by which you are listening to us now. Definitely. So that's what we use to record this podcast and edit it. And, you know, before to do this kind of thing, you used to have to buy expensive software. And then, you know, when Audacity came around, it really changed all of that. So you can record, you can clean up, you can edit, you can mix multiple tracks together. If we had cool sound effects, we would be able to put them in. For right now, like we use it to do our intros and our outros. You know, all that kind of stuff we do using Audacity. And it's amazing and it's free. And it's open source.

0:42:25.580 --> 0:43:00.640
<v A>Yeah, I remember when I used to use Adobe Premiere. And then I think even before that, I used something called CoolEdit. Or maybe that was after. But, yeah, I mean, at some point I used these programs. They cost like hundreds of dollars. And it was just like they were very slow and clunky. And, you know, Audacity works on Windows, Linux, Mac. It works on anything. Really nice interface. Let's you do all the, like, they added all the polish, you know. Like, for example, you know, I'm on my headphones and there's an option so that it won't use your speakers. Like, it won't use your microphone that's hooked up to your computer if you have the headphones plugged in and things like that.

0:43:01.299 --> 0:43:16.560
<v B>Yep. Very nice. Very powerful. And if you don't know about it and you want to do any sort of audio editing, that's where you should go. Yeah, totally. Totally. So. All right. Let's talk about Lua. Lua. Now, how similar is Lua to Luau? Wow.

0:43:17.760 --> 0:43:26.037
<v A>Very similar. Because I like Luau's. I love Luau's. The only thing, sometimes, like, you see,

0:43:26.037 --> 0:43:31.977
<v B>that pig. What is that called when they have the pig with the apple in its mouth? Yeah, yeah, suckling. Suckling pig. That's

0:43:31.977 --> 0:43:38.880
<v A>right. Yeah, the suckling pig. I think Lua core dumps a lot more than the suckling pig, but that might be because the pig is dead. Oh.

0:43:42.080 --> 0:43:45.140
<v B>Okay, we might have lost people from our trying to be punny.

0:43:46.480 --> 0:44:02.780
<v A>But yeah, so Lua originated in Brazil. It actually has an interesting history. At some point, Brazil actually had, like, some kind of law where they weren't allowed, you weren't allowed to import source code. It's like the craziest thing I've ever heard of.

0:44:03.000 --> 0:44:08.500
<v B>Yeah, it's almost like a trade embargo of sorts. Yeah. It's like, we want our country to stay behind in technology.

0:44:08.980 --> 0:44:31.259
<v A>Maybe that's why so many of them use Orkut. Oh, man. But yeah, so there's, so for people who don't know, Orkut is a social network, sort of like predecessor to Facebook or any of these. It was, like, even earlier than Friendster. And for some reason, it's, like, massive adoption in Brazil, but that's it. Yeah.

0:44:31.359 --> 0:44:36.962
<v B>Although they said it's not anymore. Facebook surpassed Orkut popularity in Brazil. Oh, really? Well, it's

0:44:36.962 --> 0:45:08.740
<v A>About time. But anyway, so yeah, it started off in Brazil as a need to sort of create embeddable language. But, you know, actually, although it sort of sounds like something, you know, it was created because there were no alternatives in Brazil. The reality is it's a fantastic embeddable language. And, you know, at the time it was created, the only language even remotely, you know, similar in its ability to sort of integrate with other languages is TCL or Tickle.

0:45:09.820 --> 0:45:11.400
<v B>Yeah, we're talking like 1993.

0:45:12.640 --> 0:45:23.031
<v A>Yeah, yeah, this has been around for a long time. And I don't know, I've used Tickle a couple of times, like, very, very light usage, and I couldn't stand it. Is that how you say?

0:45:23.031 --> 0:45:27.620
<v B>It? I don't think I've ever heard it said that way before. I always just called it TCL. Yeah, I've heard both. Okay.

0:45:28.140 --> 0:45:29.939
<v A>Let's see if, here, I'll dig it up while you talk a little bit.

0:45:29.967 --> 0:46:06.029
<v B>No, it's okay. It doesn't matter. But, yeah, I mean, Lua goes way back, and it's been around for a while. And the interesting thing about it is that a lot of those things that used to exist around, you know, aren't really around anymore. But there are certain artifacts we have today that are just from, you know, older than you would imagine. Like, even just like the Bash shell and Bash scripting and, you know, scripting on Linux or Unix-type terminals. Like, I mean, these things are things that have been around for a while, and they haven't changed much. And even things like Java. Like, when was Java first? When did Java first release? Uh-oh. We did not do

0:46:06.029 --> 0:46:10.100
<v A>research. I was in high school, so it must have been like '98 or '97.

0:46:10.100 --> 0:46:23.339
<v B>Yeah, so, I mean, you're talking about even older than that. It's saying 1995 was when it was first released. Yeah, it was. So, Lua was a year, two years predating even Java, which is kind of crazy. Yeah, yeah.

0:46:23.460 --> 0:46:24.500
<v A>Lua's around forever.

0:46:24.819 --> 0:46:26.020
<v B>And it's still relevant today.

0:46:26.740 --> 0:46:30.540
<v A>Yeah, totally. So, it is Tickle. Okay, according to Wikipedia.

0:46:30.839 --> 0:46:32.740
<v B>I will correct my language from henceforth.

0:46:34.244 --> 0:46:45.640
<v A>But yeah, so Lua is interpreted. So it's like Python where it's compiled, but it could be compiled at runtime. So you know, it has that interpreted feel.

0:46:45.640 --> 0:46:47.439
<v B>So it's kind of transparently compiled.

0:46:47.939 --> 0:47:15.200
<v A>Yeah, exactly. So you can create Lua—I think it's called LuaC files, just like the PYC files in Python. Okay? And then you don't have to do the compiling. Save yourself a little bit of processor. But yeah, for the most part, everyone just uses the source files and treats it as an interpreter. It's similar to Python as dynamic typing. But one thing that's very different in Lua, everything is based on tables and metatables.

0:47:17.160 --> 0:47:43.431
<v A>And you know, as opposed to so if you think about like Python, for example. Python has you know lists, has dictionaries, has classes. So a class in Python has that sort of dictionary meta information and then has the class assignment stuff. I think does Python have anything else? Core structures? I think that's

0:47:43.431 --> 0:47:44.410
<v B>all of them.

0:47:44.819 --> 0:48:12.962
<v A>I mean, there's like sets, but sets are based on lists, you know? And then it has the usuals, like string and number and all that. In Lua, all you have are tables and metatables, which is something we'll talk about in a bit. But you know, with just tables and the primitive data types, you can actually create a wide array of things in Lua. Should we try to do an example of metatable? I think I can try. I'll try and

0:48:12.962 --> 0:49:05.400
<v B>pull this off. Okay. So there are features in all of these languages which people tend to get excited about or like talk in depth about on the internet. But that doesn't mean they, and I don't know if this is the case with Lua or not. I personally haven't used the metatables part of Lua. But I mean, just before you go into the explanation, Jason, not to interrupt you. Oh, totally. Yeah, so I mean like there's even like we talked about in C++ about metaprogramming, you know. This is something that gets talked about a lot because it's kind of cool and nifty and whiz-bang. But that doesn't mean that the majority of code even uses it or ever thinks about it or ever even comes close to thinking about it. Like, but it might still be talked about all on the internet. And there's something that as programmers, we need to do a little bit of due diligence to avoid. And again, I don't know that this applies in this specific case. But just because something is discussed on the internet or talked about doesn't mean it's something that you need to have in your program.

0:49:06.300 --> 0:49:33.743
<v A>Yeah, totally. I mean, I wrote Lua for a little over a year as a scripting language to another program that our company is working on. But yeah, we didn't use metatables or anything fancy like that. And to Patrick's point, most of the time in Lua, you're just taking advantage of how Lua can work with other programs. And so you're usually doing the fancy thing in that other program. But

0:49:33.743 --> 0:49:34.920
<v B>Yeah. Sorry, metatables.

0:49:34.920 --> 0:50:08.400
<v A>Yeah, I'll give metatables a shot. So first let's talk about tables briefly. A table in Lua is a hash table. It's an associative array. So for example, if you want in Lua, you can say, you know, you can create a new table like myTable equals, you know, open brace, close brace. And then you could say like myTable key Sunday equals zero. And myTable Monday is one, Tuesday is two, Wednesday is three, et cetera, et cetera. And so then later on you could say, well, what is Wednesday? And it'll tell you three for the third day of the week, right?

0:50:10.380 --> 0:50:17.145
<v A>Or I guess the fourth day of the week is zero-based. But basically, you know, it's an associative array.

0:50:18.647 --> 0:50:36.180
<v A>So it just uses the equals operation for whatever type it's using. So you could have a table with tables in it. Or you could have a table that maps numbers to strings. It doesn't matter, right? Because it knows how to compare if two things are equal. And so it can just hash anything.

0:50:37.160 --> 0:51:41.600
<v B>So, I mean, this is the second time we've kind of brought this up, but maybe a quick explanation of hash tables. Just like the idea of hashing is just taking one thing, running some sort of function on it, and producing a number. So, like, if you take one number, you might multiply it by 10, and that's your hashing function. That's not a very good hashing function. And then typically, like, the simplest way to think about a hash table is just an array. So let's say you have an array that's size 10, and you want to store things in it that aren't necessarily obvious, you know, that it should be an array. So, like, to Jason's point, if you want to store the day of the week Sunday somewhere in there, where should Sunday go? Well, you could take the letters of Sunday and, like, add the ASCII value of each of the letters, you know, modulus. So divide that and take the remainder of 10 and say, like, that's the index in the array I'm going to use to store anything that's Sunday. Or, like Jason's saying, you can use it kind of, like, more like maybe an enumeration where Sunday is kind of like the zero-th object or store zero in it. So when you look it up later in the table, you can pull out the number zero, and you know that that is the value Sunday should have.

0:51:42.480 --> 0:52:36.580
<v A>Yeah, totally. And so there's something in hash tables called collisions. So let's say, for example, let's say you did what Patrick was saying where you add up all the ASCII values and modulus 10, and just coincidentally, let's just say Sunday and Wednesday, when you did that, they both had eight. That doesn't mean that Wednesday is going to replace Sunday. What happens with the hash table is when it goes to insert Wednesday, it'll see, oh, Sunday is already in this table, but Sunday and Wednesday are two different things. So then it'll do, like, what's called a deep compare. So first it'll compare just the hashing, the hash function. And if there's a collision, it'll do a deep compare and say, 'Is this the same item? Should I replace it?' If it's not, then it'll—there's many different things it can do then. But, yeah, basically, a hash table is a way to get really fast lookup and entry of items.

0:52:36.580 --> 0:52:46.894
<v B>And the reason why is because you don't have to search through the whole array or whole, you know, storage because you know exactly where to go. Because of this hashing function. Right? And you don't have to sort.

0:52:46.894 --> 0:52:47.738
<v A>Either. Or,

0:52:47.738 --> 0:52:54.977
<v B>Like, try and put things in order. But it doesn't help you. If you do need a sorted list, a hash table won't help you. That's right.

0:52:55.416 --> 0:54:47.620
<v A>Yeah, so table. So in Lua, let's say you have this table with days of the week: Sunday, Monday, Tuesday, etc. But you want the table to do something special if it gets a string it never saw before. Like, this is sort of a weird example coming up with on the fly here. But let's say you had a table where if someone, let's say this is some kind of, like, cache. So it's a table to get the day of the week, but it's not always accurate. So, for example, let's say the table just has English days of the week. So as the keys in the table would be Sunday. So Sunday would map to zero. Monday would map to one. Tuesday would map to two, etc., etc. But then you could end up getting... Domingo. Yeah, Domingo. Thank you. I couldn't remember any day for any language. Okay. So let's say you get Domingo. What you could do in Lua is you can create a meta table. And what the meta table would do is if there isn't a key in the table, but you try to look it up anyways. Like, you're trying to look up Domingo, but it's not in the table. It could fall back on the meta table. And the meta table might do something like go to some database that has, like, all the days of the week for all the foreign languages. So by using this meta table concept, you know, if you want Sunday, you get it really quick. You know, it's in the table. It's in memory. But if you want Domingo, which maybe you don't want that often—let's say because the majority of your business is in the U.S. right now—but occasionally there's a Domingo that comes across. Then you want to have this meta table that captures that, hits the database, and then returns, you know, whatever. What is that? Six or something? Is Domingo Saturday or Sunday?

0:54:49.940 --> 0:55:06.366
<v A>Sunday. Oh, Sunday, because it returns zero for that. So that's what meta tables that you do. And if you look on Wikipedia, there's some pretty clever examples. There's one where they do the Fibonacci sequence, which for people who don't know, it's, what is it? N

0:55:06.366 --> 0:55:12.300
<v B>Plus N. The sum of the two digits of the, or the two prior entries in the series. Right. Right.

0:55:12.620 --> 0:56:27.700
<v A>So, for example, like, you know, the Fibonacci number of one is one, and two is one. Two is one. But then three is going to be two. F of one plus F of two, which is two. And the Fibonacci sequence of four is going to be F of two plus F of three, which is three. Right. So, they were able to use the meta tables to say, 'Okay, I'll create a table, and one is one, and two is one.' And then I create a meta table where if they want anything besides one or two, it's the table entry of N minus two plus the table of entry of N minus one. And so, that'll kind of recurse backwards, and Lua is smart about caching. So, let's say something happens where all of a sudden you have an influx of Spanish-speaking people hitting your website, and everyone wants Domingo all of a sudden. Lua will actually cache that value, so you won't have to just keep hitting the database. That's clever about that. This is also called memoization. Memoization when you do, like, well, memoization is more with respect to recursion, but if you do these kind of things where, like, you cache data in a table, in a hash table, so you don't have to keep calling a function, Lua will do that for you.

0:56:27.720 --> 0:56:46.839
<v B>It's just pretty clever. So, it's cool because in some ways you're able to just use a table that, in theory, has infinitely many entries in it. It has all of the Fibonacci sequence in it. But then, only when you actually try to use some entry of the Fibonacci sequence does it actually go and figure out what that number should be.

0:56:47.480 --> 0:56:55.120
<v A>Right. This is also called lazy, like, either lazy loading or, in this case, lazy calculations. It only calculates what it needs to.

0:56:55.960 --> 0:57:12.720
<v B>That's right. That's right. Interesting. So, what are some of the—so we kind of hinted at some of the strengths of Lua that we already mentioned that it was used as, like, a scripting language. And it kind of uses scripting language, I guess, because it works so well with C and C++. It's really easy to embed it. And you said you've worked with it this way before?

0:57:13.700 --> 0:57:45.759
<v A>Yeah, definitely. So, Lua was designed to integrate with C specifically, but later on with C++. And so, you know, just to put this, like, in just a contrast, let's say you want to embed, like, Python, for example. Well, you have to use this, like, really clunky, like, Python C API. And, like, everything is kind of based on these functions. And you have to, like, convert, like, Python—oh, you know, I forgot the—

0:57:45.760 --> 0:57:54.940
<v B>Well, so there's calling C from Python, and then there's scripting events in C with Python. Right, yeah.

0:57:55.060 --> 0:59:43.640
<v A>And so, both of those get complicated because you have to transmute the types. So, in Python, you have lists, you have dictionaries, you have all these different types, right, as we talked about at the beginning. And each of those, you have to create some kind of analog on the C or C++ side. Or you have to create some kind of, like, accessors. So, you have to be able to say, like, oh, this is a list in Python, so I want to get the fourth element in this list in my C++ program. Or I have this C++ array. I want Python to think of this as a list, you know. And this kind of stuff ends up becoming, like, no matter how you do it, it ends up becoming really clunky. Lua, you know, it's kind of a double-edged sword. Like, it only has tables, but on the plus side, it only has tables, right? Which map exactly to C++, you know, hash maps. So, it makes it very easy to integrate the two languages. And even easier because people have, since so many people are doing this with Lua or embedding it, they've created some amazingly streamlined libraries to make this happen. So, one is LuaBind, which I used briefly. But the second one I'm more familiar with is called Diluculum, which I think it's some African word or something. But we have a link in the show notes so you guys can look it up. But basically, it's for C++, and it has a thing that maps, like, Lua tables—actually anything in Lua—to the analog in C++. And it sort of does it all transparently. So, you can just say, hey, you know, go to the Lua world and get me this variable. And even, like, on the other side in your Lua program, you can say, hey, go to the C++ world and get me this variable. And it does it all, like, very transparently. Nice. Yeah, it's pretty awesome.

0:59:43.980 --> 1:00:25.780
<v B>So, because of that strength, you can think, like, anywhere you'd want to script something. So, things you might want to script, like, often you hear this in, like, video games. So, video games want to have some scripting done where you control what happens when a player swings a sword and hits somebody. You know, like, what happens? You can script that event. Like, I want to decrease damage by 10. And I want to, you know, trigger, affect magic lightning bolts, you know, onto the screen. And these kinds of things, you can imagine, like, through playtesting and stuff, you might want to tweak those. But you don't want to have to go in and actually, like, you know, edit the code or have to even know what the code means. You might want to have other people be able to make those changes. And so, scripting languages provide that flexibility to you.

1:00:26.400 --> 1:01:24.872
<v A>Yeah, exactly. I mean, you know, most of these game studios, the people who are creating the content, they're not programmers. You know, they're just, they're often, like, game designers who are just sort of, like, playing with the different variables. Like, oh, if I make magic more powerful, how does that affect the game? And let me play for a few hours on this setting. And they can't afford, even if they did know how to program, they can't afford to be recompiling code all the time and things like that. They want to just make changes quick. And so, Lua sort of gives them that flexibility. Yep. Yeah, Lua is also very fast. You know, because it only has tables, basically hash tables, you know, it doesn't have to do a lot of thinking. It doesn't have a lot of complicated instructions or anything like that. And so, the execution speed is awesome. And you can even use Lua on, like, embedded devices and things like that, which don't have a lot of, don't have strong processors and not worry about it. Yeah.

1:01:25.500 --> 1:01:45.966
<v B>So, there's some good strengths and weaknesses. I think you kind of already alluded to the fact that they really only have tables and meta tables. So, I mean, that's a strength that it's very simple that way. But also, like everything, that can be a weakness as well. That it doesn't always obvious how to get what you need to get done. Yeah,

1:01:45.966 --> 1:03:23.980
<v A>totally. I mean, people have tried to shoehorn so much into the tables and meta tables. Like, someone created, like, a class-based infrastructure where, you know, if you have getters and setters as, like, items, keys in the table. But it's really hacky. And then once you start doing things like that, performance sort of goes down the tubes because the language isn't really designed for that. It's not really designed for you to hit a meta table every time you want to access a variable. And the other weakness is that it's just not very fully featured. You know, I mean, no one's taken the time to bind your favorite library to Lua. Chances are. You know, like, I mean, if you really like fluid dynamics or you want to use, like, some kind of physics engine or if you want to do something like some kind of heavy, like, differential equations or something, you know, chances are that that hasn't been, you know, there's no binding for Lua for that. And that's mainly because, you know, Lua is designed to sort of be a supplement to another language. So you're just not going to get the kind of features you get. Like in Python, for example, if you want to just—let's say you have—you're streaming out a bunch of data to disk and you want that data to be compressed. Well, there's a gzip, you know, library, like, which is part of the Python standard library. So there's compression built in. You can say, look, write this to disk and make it compressed so that it doesn't take up as much space. You're not going to find that kind of functionality in Lua. So if you need those kind of bindings, you're going to have to write them yourself, which could be really tedious.

1:03:24.840 --> 1:03:46.440
<v B>Yeah. But there are some libraries. It's not to say that it's not fully featured or functional. And we have a link here. But, I mean, there's—there are libraries for it. And, you know, it's fairly well supported. It's not—again, being around so long, it kind of has to be. And it's just one of those things you're going to have to go in and say, this is what I get and not expect that when you find a cool tool that it will have a binding for Lua.

1:03:47.080 --> 1:04:02.100
<v A>Yeah. Yeah, totally. Yeah. I mean, to Patrick's point, there's—we post a link. We'll post a link on the show notes. And there is a ton of—there are a ton of, you know, different libraries for Lua and things like that. So, definitely, I wouldn't shy away from it because of that.

1:04:04.280 --> 1:04:15.280
<v A>But, yeah, I mean, definitely, if you have some existing application and you find yourself just constantly recompiling it and changing constants and recompiling it, then you probably should just be using Lua.

1:04:17.460 --> 1:04:46.630
<v B>So, the people that use it—I mean, we talked about it—tends to be scripting. So, World of Warcraft uses Lua as their scripting engine. Yep. So, you know, other people—I know there's some mods and stuff that are written with scripting language in Lua. Also, I use this program to do some photo editing, Lightroom, which is an Adobe product that does workflow for taking pictures and editing them, and then, you know, kind of making libraries or catalogs and saving them out. And all the

1:04:46.630 --> 1:05:55.024
<v A>UI in there was scripted in Lua. Yeah, I mean, UI is an obvious choice. So, in general, just to talk a little bit about things like why you need scripting, right? Now, we talked about a couple of the reasons, you know, with the recompiling and things like that. But also, some things like UI specifically is just a pain to write in a, you know, statically typed language like C++. So, for example, let's say, you know, you want to hit a button or a menu item, and when you hit that button you want a function to be called. Well, in C++, to do that you have to create some kind of interface class. It's a virtual class which has some method called, you know, like perform function. And then all of your classes which need to have this function need to inherit from that class. And you need to, like, downcast the class when you pass it into the button. And it just—you have to go through all these hoops, right? But if you have an interpreted language like Lua, which is driving your GUI, then you can just bind different actions

1:05:55.024 --> 1:05:56.140
<v B>to different buttons.

1:05:56.400 --> 1:06:09.040
<v A>And Lua doesn't care about the types of the, you know, actions. So, it doesn't care if, like, oh, this one function was part of a class and now, like, you have to do all sorts of crazy wizardry to get access to that.

1:06:09.216 --> 1:06:10.971
<v B>Lua, you know, because it's a

1:06:10.971 --> 1:06:15.720
<v A>scripting language, it doesn't have any of that overhead. And so, it makes it great for doing UI.

1:06:16.660 --> 1:06:17.860
<v B>Yeah. Yep.

1:06:18.900 --> 1:06:27.000
<v A>So, Lua. Yeah. Give it a shot, man. Don't write your UI in C++ if you can help it.

1:06:28.420 --> 1:07:15.920
<v B>So, on general notes, I guess meta notes, kind of like meta tables. Anyways, we have gotten some good feedback from people, some extra language suggestions, some people writing in to tell us that they've found tips or tricks that we've mentioned useful. And, as always, we appreciate that, you know. We are always glad to be out there and helping people and at least entertaining you, hopefully. Yeah, totally. So, if you do have something to say, you can check us out on Google+. We have a Programming Throwdown Plus page, and we're pretty good about putting the new episodes linked there. Or, you know, if you have comments, you can, of course, put them there. Hopefully positive, but we're willing to take criticism as well. Yeah, totally. You can always, if you have something you don't necessarily want there, you can always email us at programmingthrowdown@gmail.com.

1:07:16.460 --> 1:07:30.182
<v A>Yeah, one interesting thing. Somebody wrote in and said that I guess they can't access the G+ page unless they have a G+ account. Is that true? Oh, I don't know. Yeah, I don't know.

1:07:30.182 --> 1:07:32.005
<v B>honest, I haven't tried. We shall try. I

1:07:32.005 --> 1:07:46.500
<v A>thought it was public. Like, I thought there was a public section. But, yeah, as Patrick was saying, just to reiterate, if you can't access us on G+ for whatever reason, don't hesitate to shoot an email to programmingthrowdown@gmail.com.

1:07:46.820 --> 1:07:52.103
<v B>Yeah, and I guess if you can't see the Plus page, you can also check out the blog. Oh, that's

1:07:52.103 --> 1:07:52.305
<v A>Right.

1:07:52.560 --> 1:07:55.020
<v B>Totally. Programmingthrowdown.blogspot.com.

1:07:55.460 --> 1:07:58.860
<v A>Yeah, you can follow the blog. We definitely cross-post everything on there.

1:07:58.860 --> 1:08:11.374
<v B>Yeah, and so then there's also, you can put comments there. And I believe that generates—we don't check that very often, but I think it does actually send us an email when somebody posts a comment there. That's true. Yep. So we try to be easy to reach. We're here for you.

1:08:11.374 --> 1:08:22.939
<v A>People. Definitely. You know, if you have any—we've had a couple of requests, and we want to fulfill the requests. So definitely Java is going to be coming down the pipe, and Go is going to be coming down the pipe.

1:08:23.779 --> 1:08:24.030
<v B>Oh,

1:08:24.030 --> 1:08:36.420
<v A>You're foreshadowing. Now we have a lot to live up to. But if there are any other requests from the audience, don't hesitate. We definitely read every one of them. And, you know, we have a backlog that we're getting to.

1:08:36.740 --> 1:08:44.979
<v B>Yeah, and don't be offended if we don't reply to you or, you know, whatever. We are listening. We are taking it in. And, yep. Hopefully we'll get there one day.

1:08:45.359 --> 1:08:53.039
<v A>Yeah, yeah. I mean, if you say you want a language, you're going to get it. It just might—it's just in the pipeline. I'm actually surprised. I did make up a list, and the list is

1:08:53.039 --> 1:08:54.203
<v B>pretty long. So there are a

1:08:54.203 --> 1:08:55.760
<v A>lot of languages to go through.

1:08:56.180 --> 1:09:10.774
<v B>Yeah, totally. And then probably it's one of those things where more is there more created than we're talking about? Like, is there at least one created every two weeks? Oh, man. There could be. Uh-oh. We might never finish this job, Jason. Oh, it could go on forever. Now I

1:09:10.774 --> 1:09:42.320
<v A>Know how movie critics feel. All right, on that note, that's all you got, everyone. Have a good time. All right, see you guys later. 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.

