Programming Throwdown - Python Programming Language

Episode Date: March 25, 2011

This show covers Python, a popular interpreted language. The show begins with discussion on javascript and browser updates, then goes into the Goldman Sach's stolen code trial, eco-friendly p...rogramming, and the origins of Oregon Trail. The tools of the day are Fossil a distributed version control system and Unison, a two-way file synchronization utilities. ★ Support this podcast on Patreon ★

Transcript
Discussion (0)
Starting point is 00:00:00 Welcome to Programming Throwdown, episode number two, Python. Take it away, Jason. Hey, how's it going? So, how was your day today pretty good pretty good i've been practicing my radio voice oh yeah i've been i've noticed that i turned to youtube for um for learning just about anything like i i wanted to cook snow crab so i went on youtube and i saw how to cook it and then i i cooked it but you know the snow crab has a really tough you know exoskeleton so I couldn't figure out how to get the meat out of the crab so again I turned on YouTube and put in how to eat the snow crab our brains are have been offloaded to Google yeah pretty much anything I
Starting point is 00:00:57 need to know how to do I've gone to YouTube it's kind of sad pretty soon it's gonna be like how do I feed myself? How to flush toilet A flush toilet I need to figure out a way to pull my pants up So I did you know I do realize when you write stuff down it's good But you don't remember it like if I write something down I never remember it anymore because like I know it's written down. I don't need to remember it So I guess once you look up how to learn how to eat snow crab it's just always going to be online you're never going to remember yeah that's true i saw a guy on uh wrote a book i think it's called
Starting point is 00:01:34 moonwalking with einstein uh supposedly it's about a guy who uh tried to become like the world or the u.s champion of memorization and i don't know i haven't read the book i just heard about it but uh sounded interesting i'm gonna check that out because i always wanted to have better memory i'm pretty terrible at it oh nice did you see that uh math magician on ted on the ted talk no yeah so this guy uh basically he built himself like a base 300 number system where like he took a bunch of words and he associated them with large numbers. So he can do like really amazing things. Like he's like, you know, give me two six digit numbers and I'll multiply them in my head.
Starting point is 00:02:18 And he does it by converting each of the numbers. It might even be more than 300. But he has this whole lexicon and he knows that like slippers is 493 or whatever you know wow and so he converts your number to some really high base and then does the multiplication in his head and then converts that that's a cool parlor trick i guess and really awesome yeah yeah this guy was like i mean he goes around just you know i guess he's a motivational speaker too, or maybe that's all he does, but I guess that's how he makes his living. Wow, well that's pretty cool. Yeah, Mathemagics.
Starting point is 00:02:52 It's called Mathemagics, okay. We'll make sure to link to that video. Oh yeah, yeah, it's a great TED Talk. It's one of the best. Well, you know, it's more like entertainment than the other technology or design. But you tend to say that about almost every TED Talk you watch. This is the best. It's true. It's true. It's like everyone you watch is like, oh, man, this is life-changing.
Starting point is 00:03:12 And then you get to the next one. Although, you know, they've been going downhill. Yeah. They franchised. Yeah, they franchised. And now, like, the TEDx talks sometimes take the front page. And you can just tell the quality isn't there, you know. Yep. All right. Well, you want to go and get started with the news yeah sure so what's your uh what's your new story so the uh first news story i had was uh an interesting thing um you know had a little bit
Starting point is 00:03:35 of delay in recording this podcast so saw this a while ago but i thought it was really interesting that with the new version of the iphone os i, I guess iPhone and iPad and iTouch. But Apple had an upgrade to their JavaScript engine. And I don't know if they started calling it this, or this is what it's always been called, but I guess it's Nitro. I know, I think Google's is V8 or something. So everybody, I guess, has their own cool name for their JavaScript engine. But they made a bunch of performance updates
Starting point is 00:04:03 to actually improve the speed of JavaScript on their JavaScript engine. But they made a bunch of performance updates to actually improve the speed of JavaScript on their iOS platforms. And it did a really good job and everybody's pretty excited about it. But then people figured out that if you do, if you don't have an iOS device, you won't know this, but you can like bookmark a page, a webpage to your desktop basically
Starting point is 00:04:23 and run it from there. It's like if you double click on it it's like a hyperlink and it just kind of runs it in the browser oh sorry no no so you can do that um but i was missing some people just have apps that run um basically websites from within the app so they're kind of like an embedded browser or whatever but they're really just like um google's works this way so google's app mostly just you know reference this stuff on internet and if you're using i think the way it works is if you're using the embedded browser instead of using you know natively written ios stuff you don't get the speed ups that they gave to all the other safari stuff so it's kind of an interesting thing that they left that i guess it could be a bug but people are suspecting maybe they did
Starting point is 00:05:02 that on purpose so how does it so the embedded browser i guess it's just a completely different engine than safari well it's supposed to be the same same engine i guess like it's supposed to be a version of embedded safari like within that app oh i see so maybe it has more restrictions right i guess they were saying for possibly for security reasons or something but i thought that was interesting that they yeah that they would you know kind of cripple those interesting because you can do with the html5 stuff you can do a lot of things that you would normally do in a native app apple is always so paranoid about someone writing some app that compromises you know either the hardware itself or even worse like your information or your contacts or
Starting point is 00:05:45 something like that right so maybe in doing so they left out you know some of these updates i always felt like you know there should be kind of like one browser engine to rule them all you know like and i and there's it's kind of starting to head this way with webkit like webkit webkit is i believe it's on the PlayStation and WebKit is part of, you know, Google Chrome. It's like the engine for that. But yeah, there's no like just generic engine that isn't really tied to like a particular OS or anything like that. Like there's no web engine that just writes to OpenGL or something like that. But I guess that's good because, you know, the competition between them, they drive features from each other so kind of relating spilling transitioning into our next topic um you know
Starting point is 00:06:29 talking about the new release of firefox 4 and ie9 that uh they've both picked up i guess what was started with chrome i believe with the the tab styles where instead of having the traditional file edit view menu whatever at the top um they just kind of have tabs at the top and they get rid of a lot of that extraneous stuff unless you go looking for it right um so i guess that's good right because if you only had one it just would always stayed kind of what it was yeah that's true that's true i just i feel i think that because you know what they want to do is is tie into the theme of the particular operating system so like in the case of windows if you change your theme they want you know to that theme to be reflected in your browser windows
Starting point is 00:07:10 which makes sense and so yeah that's fair and but because of that they're kind of tied to um you know those particular os's so there isn't just some generic like right to a frame buffer or something like that yeah um know, web layout engine. So have you downloaded the new Firefox? No, not yet. I want to. Actually, I have the beta on one of my machines, and it seems to run well. I haven't had any crashes or anything with it.
Starting point is 00:07:38 But one thing I have done is in Google Chrome, I went ahead and changed my YouTube settings so that they use HTML5 instead of Flash. That was pretty cool. They didn't have the, like, seeking in the video. I don't know if maybe I'm using too old a version of Chrome or something, but I have to play a video all the way through, which kind of sucks. But the support is there.
Starting point is 00:07:59 I mean, it's using the ON4, I guess, video codec or on one or something like that. And yeah, it works nice. Works well. Yeah. So I've been using the Firefox four since, yeah, like I guess it's like beta four or beta five or something. It's been a while. And I kind of went upgrade. It was even pretty good back then.
Starting point is 00:08:19 And yeah, it's been nice. I haven't really noticed that much difference to going to the actual, you know, now the full release. But yeah, I've been running it for a while and things have been nice i haven't really noticed that much difference to going to the actual you know now the full release but um yeah i've been running it for a while and things have been nice a couple of the plugins i like to use um haven't been ported over yet i guess but other than that i've had no problems oh nice oh it's called onto onto is the company that google bought and they created their own video codec called vp8 oh yes yeah the interesting thing about it is there's no patents at all i guess it's a completely different um you know um setup or completely different algorithm than you know h264 and uh when google bought it they opened it up completely which is which is really useful because anyone who's done video compression knows or even audio mp3 compression
Starting point is 00:09:04 knows what a nightmare that stuff is with respect to patents and all that. An interesting thing, I've long abandoned Internet Explorer. I've just been burned too many times in the past about terrible experience. But I saw with the new release of Internet Explorer 9, some of the JavaScript performance testing actually showed that Internet explorer 9 is the fastest browser in the west yeah that's interesting i wonder if you know microsoft decided to really
Starting point is 00:09:33 kind of pick it back up because they have just gotten so much flack nobody seems to like internet explorer and remember that thing on the white house where uh somebody asked um hillary clinton if they could have firefox in the white house and she you know she clearly had no idea what firefox meant i mean for her it was like she thought that something was burning you mean the internet it's the internet no no no the thing you use to access web pages yeah the internet so yeah here we'll link to this video i'll put it in the agenda okay but yeah it's a a staffer asked hillary clinton why internet explorer is mandated even though firefox which is free and is security approved and uh her answer was that saving money is complicated
Starting point is 00:10:16 non-answer that's funny all right uh so it looks like you got the next news item here. Yeah, let's see. So former Goldman Sachs employee goes to jail for eight years. And so the deal is this guy, you know, he worked for Goldman Sachs. He's making, let's see here, I think it was, yeah, $400,000 a year to write code for their high-frequency trading applications. And so for people who don't know, there are, you know, many of the financial institutions have computer programmers that go in and write software to trade at extremely high frequency. So what would you say, Patrick, like nanoseconds or something? Yeah, I mean, it's, yeah, sub-millisecond trading times is the stuff I've seen. I'm not an expert by any means, but it's really fast. Like, you know, hundreds of thousands of transactions a minute kind of stuff.
Starting point is 00:11:10 Yeah, insanely fast. I think they do arbitrage, but they also speculate, right? You know, in that short amount of time. Yeah. And so this guy is writing the software that, you know, essentially becomes an arms race. You know, someone has this kind of software and then he writes this, this you know software that learns to exploit their software and so on and so forth um they're paying him 400 000 a year and uh he decided that he was going to take his software over to a small company that they offered to double i think double his salary um so uh he
Starting point is 00:11:43 tried sneaking the software into that company he got caught and he got yep eight years of federal jail time which is serious business straight out of office space oh man okay uh yeah we'll just move on um so don't steal code ladies and gentlemen yeah yeah so this is interesting right for for several reasons's, you know, he didn't actually make any money off of it or steal any money. So in that respect, it seems like eight years is extremely serious. You know, but this goes to show that, you know, people in companies take this stuff extremely seriously and it's your responsibility you know as a as a software engineer to uh to you know be ethical and these types and not try and pull these types of shenanigans yeah definitely that's hmm i mean i guess it's good that it shows that you know he
Starting point is 00:12:37 didn't get off easy for doing something that's you know stealing essentially the livelihood of the business not that i'm a big defender of the banks, but still. Yeah, yeah, exactly. It's wrong. Yeah, definitely. Yeah. I mean, you can definitely get hit hard. So if anyone's thinking of,
Starting point is 00:12:54 if anyone out there works for Goldman Sachs and is thinking of trying to pull a stunt like this, this dude got eight years in federal penitentiary. If that's the average salary, $400,000 a year at Goldman Sachs, please donate to our show, Programming Throwdown at gmail.com. Yeah, we'll set up a PayPal account just for you, Mr. Goldman Sachs employee. Yeah. Oh, man.
Starting point is 00:13:17 Those guys work crazy hours, and they've gone through a tough spat, so don't envy them. Yeah. No, this is hard times for everybody, and I'm sure those people are no exception. Right. So I have another news article. Do you have one now, or do you want to go back and forth? No, I think we're done with mine.
Starting point is 00:13:32 Okay. So this is kind of interesting. This is from NewsWise. And this guy wants to start investigating. It's a professor, a young professor, and he wants to investigate green computing or energy-efficient computing. And so, you know, programming languages, they usually serve, you know, one of several purposes. One is, you know, let's say efficiency, like in the case of C or C++, where you just really need to push data through or do some, you know, expensive computation.
Starting point is 00:14:03 Or they work on the, you know Or they try and maximize productivity. So Python, one of the languages that we'll be talking about later today, is sort of focused on productivity and trying to save your time and be programmer efficient, if you will. No one really that I know of has up until now looked into this energy efficient computing. So this is really quite interesting. And as we're moving to mobile devices and in general, as being green is kind of in right
Starting point is 00:14:31 now, this was, you know, this has Wynn written all over it from a professor standpoint. So he got some really nice grant money. And I thought this was pretty cool, pretty cool stuff. I like to see kind of what comes out of it. That's interesting. So, you know, in compiler optimization, you can compile for code size, compile for speed, compile for memory footprint. Now I guess you're going to have a compile for energy. Yeah, I mean, what does that mean? I mean, I guess in a superficial sense, you try to limit the number of instructions.
Starting point is 00:15:03 But then even then, I mean, you know, you might try to get more cache hits. Maybe that then even then i mean you know you might try to get more cache hits maybe that saves energy i'm not really even sure but those same things that would you would do already just to improve performance i guess if you're willing to sacrifice this would be a hard thing to do but if you're willing to sacrifice you know kind of the deterministic execution speed you could you know do things like pausing and collecting up all the disks accesses or ram access accessing at one time and kind of do them all in a bundle even if it means waiting to do it but it seems like they kind of already try to do that yeah it's hard to think of things that are energy efficient but not but that don't increase productivity um trying to think of
Starting point is 00:15:43 something off the top of my head. I mean, I've heard before, this is at a much, much lower level, but the whole idea, which is extremely fascinating, and if you want a time sink of black hole of your effort for the next couple of days, look into reversible computing. Really? I've never even heard of that. There's this whole, and I'll quickly show how much I don't know to anybody listening who knows anything about this field, um i guess it comes down to kind of information theory that one of the reasons why we're hitting an upper limit on the density of um you know
Starting point is 00:16:15 transistors and and doing stuff in our chips and is that when you do an operation so like an and right so you do one and one is one. One and zero is zero. But zero and one is also zero. So you're losing some information there. That operation is not reversible. Neither is an or. Most of the operations are not reversible. A not is reversible, right?
Starting point is 00:16:38 Because you just nod it back. So that you don't actually lose any information. So the idea is that when you destroy information, that is kind of somehow related to energy. And so when you lose information, you know, kind of destroy it, you're going to expend energy. That information has to go somewhere
Starting point is 00:16:54 and it dissipates into heat or whatever. And so the idea with reversible computing is to say if you can kind of keep track of all these sets of operations and be able to at some level undo it and you kind of accumulate this log of everything um that you'll run more efficient and then at some point you could kind of choose to get rid of all the information all the bits you don't need and kind of exude power at that point on your terms and your choosing uh it's very it gets very weird and the information theory gets crazy
Starting point is 00:17:25 it gets tied in with like you know black holes you just blew my head black holes destroyed do they destroy information or not um yeah it oh and then there's the maxwell's damon oh i guess there's like several so you're saying there's a bunch of instructions that don't destroy information and those cost less energy or cost no energy so i don't the way i've seen it explained is with billiard balls so you can make an end gate out of billiard balls but you can also make um that that kind of you end up with so if you do an and you end up with the output of the and and also like another bit that represents to distinguish between the 0, 1, 1, 0 case. So you end up with this extra bit of information that kind of allows you to know how you got to
Starting point is 00:18:11 having the zero, whether it was from two zeros, a 0, 1, or a 1, 0. And so you kind of record, or maybe you end up, yeah, maybe you end up with three bits. Somehow you end up tagging along that extra information that allows you to reverse the computation. like i said it's a time sink i don't really understand it and i probably just made a bunch of people who know what they're talking about uh realize how stupid i am but that's okay no i think you just made them angry which is okay that's one of the goals yes if we can't teach you something we at least want to piss you off write write to us and tell us how we messed it up and maybe we'll get you on the show and have you explain it to us for reals. Yeah, that's right. If you hate us, give us five stars.
Starting point is 00:18:48 That's the worst rating you can give us on iTunes. So I think also not just extending you know, in this particular article they're talking about making energy Java, which is an extension of Java that would somehow be more energy efficient. But also more different languages, I think, would be inherently more energy efficient, provided
Starting point is 00:19:11 that you're running on a multi-core system. And so, for example, a GPU per watt or whatever can deliver a lot more computation than a CPU. But it has limitations because, for example, all the cores in a GPU have to execute the same instruction at the same time. So if you have a programming language or a construct that sort of helps guide you to work within those limitations, then maybe something that is very highly multi-threaded could you know allow you to save energy because that's really where a lot of energy is wasted and is is in the bottleneck where you have this huge bank of memory but then only one small
Starting point is 00:19:58 tiny sliver of it can be used at one time on a single core processor. I guess that's why we have research, right? So if we knew the answer, we wouldn't need to research it. Yeah, exactly. So this is a news article on Brainiac, and it was on the origins of Oregon Trail. And I don't know if you had this, or if this was just something we had in Canada, but in Canada, we had uh uh these apple 2es you know there was like a computer uh computer i don't know i guess using period in school and we'd jump on these apple 2es and play oregon trail and odell lake and did you guys do that yeah at some extent yeah we did oh man yeah so it's just good memories like where in the world is carmen san diego oh yeah that one was fantastic and uh this article is talking about just Oregon Trail where it came from is actually programmed or and uh designed by um um by some teachers who
Starting point is 00:20:55 just happen to be really geeky and into coding and uh they were inspired by choose your own adventure books and uh it was really you know the thing about oregon trail is it's a complete simulation i mean it's you know it's very uh egocentric um it's not like other wagons are passing you by or anything like that um but you know in the sense that you know you're traveling along this trail and you're having to deal with hunting for food and the uh environment can influence you know the hunting grounds and things like that. It's almost a complete simulation, which makes it just very interesting that something this old, that old, could be that powerful. Yeah, a lot of people seem to remember that.
Starting point is 00:21:35 Most people our age kind of remember playing it. You've got dysentery. Yeah, that's right. It's funny, in fact, the news article has a caption, or has a figure, and the figure clearly states that Nicole has dysentery. And you can go on virtualapple.org. I don't know if you've ever been on the site. Oh, yeah, it's great. www.virtualapple.org. And it has a number of, you know, Apple IIe games. I'm not sure. It says that it's copyrighted,
Starting point is 00:22:08 all rights reserved, etc. I'm not sure what the legality of it is. It seems legitimate. It doesn't seem like they're doing anything illegal. Maybe they have permissions. I'm not sure. Oregon Trail is on there. Yeah, that's right.
Starting point is 00:22:21 Oregon Trail is on there. Odell Lake is on there. It's actually a java applet so someone built an apple 2e emulator in java and uh runs right there in the browser it actually might even be a browser plug-in interesting well i don't want to open this up right now i'll end up messing up on the trail i'll end up messing up our skype connection and or man get that deer get the deer get the deer i should have fjorded the river oh yeah remember there was one where uh yeah i guess i had no idea never mind okay sorry go ahead yeah i mean at nine years old you know we had no idea so there's this river it was like uh i don't
Starting point is 00:22:57 know swanee river i don't remember but it was it was something like like 20 feet deep and i was like oh yeah just forward it just walk across you know, and then you lose everything. You have been washed away. You end up crying at recess, yeah. Okay, we're nerds. Alright. So my tool of the day is a cool distributed version control
Starting point is 00:23:18 system, so, you know, in the vein of Git, Mercurial, what are the other big ones? There's a couple other ones but um subversion well subversion is not distributed though oh that's right so um so distributed ones but this one's interesting so the thing i kind of like and i've been trying to do better about um it's not really the new year anymore but my semi new year's resolution for the last couple of years has been to do better about version control at home slash for personal stuff. And one of the nice things Subversion has some tools will let you do that, but it's not really set up to do that. The nice thing about the
Starting point is 00:23:54 distributed stuff is that that's kind of how it always is, is you can just have a repository on your local machine. And then at some point, you kind of merge repositories with other people who could have previously, you know, had a version from yours and they kind of split up and move throughout. There isn't a one central repository that's the repository
Starting point is 00:24:15 everybody refers to. So that kind of confuses people, makes it a little bit hard. And I'm not an expert by any means on version control, much less distributed version control. But Foss fossil is nice because it's a single executable um that you you put in your path and you're able to so i use it on windows and you're able to like check stuff in and out and there isn't a complicated you know system behind it i've used mercurial before and get to some extent
Starting point is 00:24:41 and they're they're nice but they're kind of, you know, tangled up in, they do a lot more. This, you know, I guess it probably does a lot, but it's really simple, just, you know, one executable, really basic. And I've been using it to do, you know, version control on my local computer for stuff that I should have been always using stuff for and just haven't really been doing. This looks nice. I've had so much grief with Git using GitHub. I've gotten to the point now where I use the Tortoise Git to do a Git commit because I like that interface better and it integrates with Explorer and all that good stuff. But then I have to use the Git GUI, which is a separate program that comes with Git, to do the push. It has something to do with I i could never get the ssh key
Starting point is 00:25:26 working right in tortoise git enough i've just it seems like i just have so much trouble with git so this this looks awesome definitely going to check this one out yeah so i you know like i said i'm not an expert but i liked it and it has the ability to set up a server within it so like you know i could put it open and then um somebody else on my network could you know download my repository or whatever and clone it so it's nice i like it it's worth looking into so what would you say is the difference between a distributed version control system and just a regular version control system i'm gonna really get people mad at me now quiz mode i'm really gonna get people mad at me because i I'm ashamed to say I'm not very
Starting point is 00:26:06 polished on my knowledge of version control. No, me neither. So the way I understand it is Subversion, CVS, they kind of work on the idea of a central repository. There's one location that is the master. And you, depending on your workflow and the exact nature of the system you check out files or you know get a copy of repository work on your own and you submit back to that central repository so you can like lock files there you know work on them and then resubmit them back with changes and then other people go check against that can pull changes um you know do their updates fix stuff whatever um the difference with a distributed version control system uh is that certain operations which are
Starting point is 00:26:53 complicated to do um in one of these others are become very easy to do like branches branches are really easy to do um and having multiple versions of the code existing at one time, like, you know, eight different kind of parallel paths going at one time isn't really a big issue. And the way that you do and even on your computer, having multiple versions is easy because there is no central repository. You can have one, right? Like you and I could say, oh, we're going to, you know, host, you know, on GitHub. That's our, you know, official repository official repository but in reality it's just another version of the repository and everybody's is just as important or um authoritative as anybody else's and so for instance i could um push to you my changes you can make them in your repository and then you could push them up to the github server um i don't have to push them to the github
Starting point is 00:27:41 server you get them bring them back down we can can share with each other and co-mingle those because there is no one branch that everybody has to come down from Oh interesting In Subversion, if you were to create a new branch, you would have to go to the master server and say I want you to split and make
Starting point is 00:28:00 a new branch for me whereas it sounds like with this system you're making your own branch and you don't need the server's permission and like with this system, you're making your own branch and it has nothing, you don't need the server's permission. And the server doesn't even know you have your own branch. Right, right. And I can make multiple revisions, multiple check-ins against myself. For those to you, you merge some changes, do additional, and then you merge back to the quote unquote, you know, central, you know, authoritative, whatever base. And then if you actually look at the, it's kind of cool when you look at the, you know, authoritative, whatever, base. And then if you actually look at the – it's kind of cool.
Starting point is 00:28:26 When you look at the, you know, version history, you see all these merges and splits. And you can do things that would just cause a nightmare under most repositories. Oh, nice. That's good stuff. I'm definitely going to check out this also. That's awesome. So, yeah, I guess my – What is your tool of the week?
Starting point is 00:28:42 My tool of the day, or I guess of the bi-week, isn't quite as cool. Oh, my gosh. Sorry. My tool doesn't have fossils or tiger blood, sadly. But it is actually extremely useful. I've been using it for a while now and I think it's fantastic. It's called Unison. Specifically, I'm talking about the Unison File Synchronizer. What this does is you give it two directories and they could either be local directories or one can
Starting point is 00:29:18 be an FTP, one could be an SSH location on a remote server. And it essentially compares the two directories recursively and then gives you a list of changes. And it can do this in a variety of different ways. It can compare the dates. It can actually compare the content. And in the end, it presents you with this list. If one of the files is newer on one of the directories than the other, it will automatically suggest to move the newer file over to the older one and vice versa. Otherwise, if it can't figure it out, either because it doesn't have access to one of the dates
Starting point is 00:29:57 or it gets confused or something like that, or if both files have been modified since the last time you ran Unison, then it will put up a little question mark and you can make the call on do you want to diff these two files manually and merge them together that way or do you want to just pick one file or the other in general it's great for synchronizing your usb stick so if you have a bunch of docs or a bunch of files on your USB stick, you don't want to run the risk of losing the USB stick and losing all of that data permanently. So you can run this Unison program and put your USB stick and then put a directory on your hard drive and it will
Starting point is 00:30:39 sort of keep everything in sync. Very cool, very cool. I've actually been looking for something like this, not quite like this. This is interesting that ours are almost tied together almost like version control for usb stick but uh that's funny yeah i almost made the same thing but um so i don't know if you use dropbox before but dropbox you know uses their server in the cloud to kind of take data from a folder store it there and also push it out to other folders kind of keeping them all linked up together um right and i've then looking for a version that I could host like in my home network and do the same thing across all my computers so like keep all of my my documents together and there's no you can do it with Dropbox
Starting point is 00:31:18 like that'll work fine but there's a limit to their free size and you have to pay if you want more and I kind of just want something that you know I don't care about how much data is thinking across and I found one but they're not in release yet and I haven't tried it yet but it's called sparkle share and that's kind of that it doesn't help you with like USB sticks like you're talking about but keeping you know multiple computers in your household synced like I'm constantly moving from my desktop to my laptop and I would love to be able to just know that all the files are on both and not have to worry about, oh, that's on my laptop. I need it on my desktop.
Starting point is 00:31:50 Let me email it to myself or put it in a USB stick or whatever that is. Yeah, this is interesting. This is good stuff. Yeah, it seems like it shouldn't be that hard. They have to kind of hook into the OS, but whenever they see that a certain file has changed in a directory that they're monitoring, they can go and propagate and give that file to everybody else. It's one of those apps that seems kind of straightforward, but then the devil's probably in the details there,
Starting point is 00:32:16 especially if you want to make it run on Mac and Windows and Samba. Yeah, reliably. It has to recover. If one of the machines goes down, when it comes back up, it'll have to try to, you know, get him back in sync and all that. Right. Not trivial, but if somebody could do it in an open source package, that'd be awesome. Yeah. Yeah, definitely.
Starting point is 00:32:38 So, well, is it time for the throwdown of Python? I think so. Let's throw it down. So I guess I'll cover this. So Python is an interpreted language. It is semi-compiled, which means that there is a Python virtual machine similar to Java, and you can compile Python files into bytecode
Starting point is 00:33:02 for that virtual machine. So in that sense, it can take advantage of compiling. But overall, it's generally interpreted language. And the goal of Python is productivity. So Python boasts a 4x increase in productivity. So in other words, if it takes you four weeks to write some app in C or C++, then in theory you can write it in a week in Python. I assume that would be an experienced Python person could write it in a week in Python. Yeah, oh yeah.
Starting point is 00:33:33 This doesn't have magical powers, does it? I think it does. I think genies come out and actually plug in little Bluetooth USB keyboards and just write alongside of you as you're writing. What? Where has this been all my life? I know, it Bluetooth USB keyboards and just write alongside of you as you're writing. What? Where has this been all my life? I know it's the genies. They're just, they're there. I think that, yeah, you're right. You have to be experienced in Python. And it's one of those languages that does come with a learning
Starting point is 00:33:57 curve. One of the big things about a lot of these high level languages like Python is that it gives you a lot of flexibility. But because it does does that you can kind of hang yourself with all the rope that it gives you and so that's why you know having a strong foundation in one of the imperative languages kind of will allow you to sort of remain grounded in your in your architecture even with you know all of the flexibility that Python gives you. So why is it named Python? Oh, that's a great question.
Starting point is 00:34:30 Do you know the answer to that, or are you just quizzing me? Oh, it's a Monty Python reference. No way. Yep. Oh, wow. I'll have to look that up. No, definitely. So I figure any programming language that uses Monty Python references sprinkled throughout has to be good.
Starting point is 00:34:45 That's true. Or at least british i don't know oh yep you're right oh what oh hang on theme music theme music where is it you're like you're uh uh that's gonna get saved like that's gonna be dubbed out now whenever we have an argument you're gonna bring that back yeah remember about the python interesting so yeah so let's talk a little bit about more about python it's garbage collected similarly to java so in other words you don't have to you know as you might remember from our c podcast a couple weeks weeks ago. In this case, you don't have to tell the system when to allocate in free memory. You just say, hey, I have this list of data. I have this dictionary and it's a dictionary of phone numbers. And I want the phone number of Joe to be 999999. And
Starting point is 00:35:41 it automatically decides I'm going to create a dictionary. I'm going to allocate memory for that dictionary. There's a new entry. Maybe I have to increase the size of the dictionary to handle the new entry. It does all of that. So you're completely oblivious to the memory manager. Sounds powerful and dangerous. Yeah, I mean, definitely. If you're working on a system that doesn't have a lot of memory, such as an embedded device,
Starting point is 00:36:08 you have to watch out for running out of memory. And in fact, with Python, this is especially an issue because it has a virtual machine. I believe the virtual machine has a memory limit. So in the case of C++, you can, for the most part, allocate memory and just keep on going, keep on allocating memory. And it'll eventually start putting memory, what's called virtual memory, it'll start creating memory regions on your hard drive. But it'll essentially give you the freedom to do whatever you want. In the case of Python, there's a hard limit in the virtual machine. And if you try and allocate, I don't know, 27 gigs of memory, it's just going to throw up.
Starting point is 00:36:45 It's going to cause an error in the virtual machine. So I see this phrase batteries included. What does that mean? Yeah, so Python comes with the Python standard library. And the Python standard library is actually just extremely massive. So yeah, one module in the library is pickle, which I'll talk about a little later for doing serialization. It has zlib. So if you've ever had a.tar.gz file, if you've ever downloaded one of those off the internet, that's using zlib and Python supports
Starting point is 00:37:18 that natively. So just let's look at that for example. Let's say you wanted to write a C program that opened a.tar.gz file. Or let's say you wanted to write a C program that opened a.tar.gz file. Or let's say you wanted to write a C program that created one of those. You would have to go grab the Zlib library, compile it along with your code, read up on the API and work your way through that. With Python all that stuff is included. So you don't have to worry about building Zlib and what sort of compile parameters you need to give it and things through that. With Python all that stuff's included so you don't have to worry about building zlib and what sort of you know compile parameters you need to give it and things like that. All that stuff's in there. It has you know
Starting point is 00:37:52 comma separated values for writing stuff that could be read by Excel. It's got hashing, just tons JSON encoding and decoding, email handling. It actually the Python standard library has a HTTP web server built into it. So you can host your own website using just Python. So you can get hacked without even needing an extra library. No, I'm just teasing. That's right. You can have your user's email addresses leaked like TripAdvisor did earlier today without anything
Starting point is 00:38:27 but Python. So that's cool. That's cool. Now, the fact that it has all these libraries, is there good documentation for those? Yeah. So there's docs.python.org, which is, you know, Python's own documentation system. And that is extremely comprehensive. And I think you've also found a couple of websites that kind of learn Python as well, right? Yeah, so, you know, under the kind of one of our charter goals here is that help people, you know, see the uses of other languages.
Starting point is 00:39:01 So, for instance, we talk about Python being, helping you be more productive potentially. And so as part of that, you got to learn those languages so that you can exploit the benefits to the fullest. So talk about, you know, a little bit about our experiences, if we have any with learning the language. And one interesting thing, if you've, if you're listening to the show, and you don't yet know any programming languages, I think a lot of people consider Python a good first one to learn. What do you think, Jason? Yeah, definitely. I think that I think Python was one of the goals of Python was to sort of be simple to use and to understand. And it seemed like there was almost an educational focus to Python. And because of that, I think that
Starting point is 00:39:43 yeah, Python would definitely be a great starter language. One of the things that you really have to watch out for in languages like C and C++ are dealing with these sort of these really high level structures and manipulating structures and memory and reading and writing structures to files can be challenging. And so Python obfuscates all of that from you. I mean, you don't really have to deal with a lot of that low-level stuff, and you can get right to doing what you want. I mean, typically, you know, what people want to learn programming so that they can do something, so that they can accomplish something, whether they want to write their own, you know, little
Starting point is 00:40:21 web calendar to keep themselves focused, or whether they want to just kind of make a game or something to entertain themselves and their friends. And you don't want to get bogged down in a lot of the details, especially as a beginning programmer or working on a project by yourself. And so Python really does a lot of that heavy lifting for you, you know, at the expense of being slower than one of the more low-level languages. Yeah, definitely. And so my first kind of learning link that I had here is something I ran across, and of course, already having a fair amount of experience with programming, this was not that helpful to me, but it was really interesting.
Starting point is 00:40:57 And I believe the guy who started this, but it's kind of a community effort now, I think his name's Zed, Zed Shah, maybe. And he has Learn Python the Hard Way. And we'll include the link in the show notes, but it's learnpythonthehardway.org. And it's kind of interesting. It's a book and it kind of goes through and says, look, this is going to be confusing. When you learn these programs, it's not going to be easy and straightforward. So he kind of starts out by going through stuff that, you know, would have kind of been nice in the, I remember learning, you know, programming kind of on my own without before going to, you know, you know, school for it or having a class on it. And it's, he kind of
Starting point is 00:41:35 takes you through what I think a lot of people end up doing, which is, you know, type this code in, you're going to make mistakes, but type it in, you know, just copy this code into a thing, don't copy and paste it, type it in, and you're going to begin mistakes, but type it in. You know, just copy this code into a thing. Don't copy and paste it. Type it in. And you're going to begin to kind of understand, become familiar, and intuit what the programs are doing. And then also, that'll kind of, since you've typed it in, you'll kind of lead you to experiment and start trying little things and seeing how it changes or reacts or what breaks. And kind of approaching it from that way, which is an interesting way. I hadn't really, it's a refreshing take on how to learn programming.
Starting point is 00:42:10 Yeah, that sounds awesome. I'm definitely going to have to give that a shot. So the other resource I had here is PyCon, which is the big Python conference. I think just recently the 2011 PyCon happened. I think it was in Atlanta. Is that right? Yeah, that's right. And the next one, 2012, is going to be in Santa Clara, California, which is right next to Google, right next to Mountain View. Now, actually, that's a good point. Google uses Python a lot, right?
Starting point is 00:42:38 Yeah. So Google has employed the creator of Python, Guido von Rossum I believe he worked at a number of you know large well-known companies but right now he's he's been employed by Google and Google is definitely taking Python seriously they're one of only two diamond level sponsors of PyCon 2011 and so yeah they Who's the other one? The other one is QNX. I think that's embedded, right? And RTOS, isn't it? Yeah, that's right. Why don't you explain RTOS for a bit?
Starting point is 00:43:13 That's totally not related to Python, really. Here, I'll do it really quick. Basically, most people are familiar with OSs, operating systems, like Windows, Linux, OSX, etc. RTOS stands for Real-Time Operating System. And to make a long story short, basically, they operate within certain limitations.
Starting point is 00:43:39 So in the case of Windows, again, going back to this memory thing that I talked about earlier, if you want to allocate a gig of RAM and you don't have a gig of RAM on your machine, it'll go into virtual memory. So it'll make a space on your hard drive and treat that space as memory. So a real-time operating system has certain limitations, like you cannot do something like that because it would take away from the real-time nature. It just takes too long to do something like that. And so there's many other, it gets complicated, but the basic gist of it is that they're interested in high-performance, low-power operating systems. Interesting. So yeah, actually that gets to an interesting point, which is another lesson of this is it's true that Python has a reputation well suited for being slow. But again, it comes down to how the language is used and a lot of the algorithms that are going into the language.
Starting point is 00:44:39 So, in other words, you can write some code in Python, someone else who can write the same code in C, and it could be a hundred times slower, just because of the way that you designed your algorithm. Let's say they're constantly creating and deleting arrays. And in your case, you were able to use just one single array. So, you know, a lot of the speed issues can be solved algorithmically or using, you know, a lot of the speed issues can be solved algorithmically or using, you know, being efficient in the way that you allocate and deallocate memory. And, you know, I wouldn't worry too much about Python being, you know, slower than other languages.
Starting point is 00:45:17 Yeah, I mean, especially for, you know, prototyping or even in full-out production stuff, using it as the scripting aspect. We haven't talked about this yet, but Python integrates really well with C code. Of course, one of the good paradigms to go by in your programming is don't optimize too early. Don't worry about getting your code to run
Starting point is 00:45:40 fast. Worry about getting it to run first. Donald Newth, one of the founders of computer science, said premature optimization is the root of all evil. So yeah, definitely. And I think that, you know, to sort of extrapolate on that point, you know, the biggest thing I see with like a lot of kind of new or green engineers, is that they'll write some code, it will be slow, and they'll sort of look at things which are somewhat myopic,
Starting point is 00:46:11 like maybe if I do a compiler optimization or if I change languages. But really, there's something fundamentally slow in the algorithm or in the architecture that can give you just a gigantic speedup. Definitely. And being aware of how the computer operates operates which we don't have talked about here yet but i mean understanding at a fundamental level why your computer does what it does how it ticks even down to you know not you have to go that far but that we were talking about and gates and or gates a few minutes ago but i mean understanding a computer at that level helps you write code that uses a computer in the best way possible yeah definitely okay so do you want to talk about oh go ahead
Starting point is 00:46:51 well sorry so so we got in a little bit of a rabbit trail but um so pycon the python conference just finished up in atlanta and um they actually and i i don't know if they posted all of them but they have a lot of videos, recordings of their sessions posted online. And we'll post a link, but it's pi-con.blip.tv. And I've been watching a few of them, and they're actually pretty good quality and really interesting. So, you know, if you've always wanted to go to a conference or never thought about going into a conference, and you look at the topic list and see some interesting things there, go check it out and watch some videos.
Starting point is 00:47:25 Most of them are, you know, 30 minutes to an hour in length and talk about everything from everyday parts of Python and panels on what's the best IDE to use for Python all the way to like really, you know, specific optimization, you know, kind of libraries and techniques. Yeah, this gets to kind of a little digression, but I think an interesting point, which is, you know, many of you out there work for, you know, tech companies or maybe IT companies, but work, you know, sort of in the software engineering industry. And, you know,
Starting point is 00:47:56 you should definitely, you know, ask the, you know, your management if they can send you to PyCon or one of these conferences. That's sort of a win-win. Most of the time, most companies have a budget for training, and very often people don't take advantage of the budget, and that money gets wasted. By going to one of these trainings, you can learn a lot about Python or something else, and you also become more valuable. I mean, your employer knows that you've went and gained this skill set
Starting point is 00:48:30 or you've went and gained some connections with the top people in a certain field or in a certain topic. And that can really help you along further down the road. It's an investment. Yeah, hopefully people's jobs are amenable to those kinds of things. Yeah, definitely. It's an investment. Yeah. Hopefully people's jobs are amenable to those kinds of things. Yeah. It never hurts to ask, right? What are they going to do? Tell you no? Yeah. I mean, worst case, they tell you no. At least, you know, even by asking you, you can, you know, remind them that you're inquisitive. You know, I think that it's useful.
Starting point is 00:48:59 Yeah, definitely. And I think we could all stand to be told no a little more often. Oh, yeah, that's right. What is it you're trying to, I think your metric was to get told no once a day, right? Yeah. So this was an interesting thing on Hacker News a while ago. I haven't seen anything about it recently. And I don't remember exactly how they phrased it, but it boiled down to this guy came out and said, you know, we assume too much in our lives about restrictions and barriers placed on us and so if you just make it a goal every day to get told no on something anything you know not a silly thing but an actual something get told for real no um that you will learn quickly that people don't we're trained from very young age not to say no to people um so for instance he
Starting point is 00:49:43 i think one of his examples was he was in some big city and took a cab ride and said, oh, I forgot my wallet, or was getting in the cab and said, oh, I forgot my wallet. Do you mind taking me for free? And the guy's like, oh, okay. You know, just kind of like,
Starting point is 00:49:58 you know, didn't want to tell him no. Or he would wander around areas that looked restricted and people would come up to him and say, what are you doing here? He's like, oh, I don't know. I'm just wandering you doing here he's like oh i don't know i'm just wandering around and he's like you know do i need to leave and they're like kind of um but they had a really hard time telling him like yes you need to leave um so this is amazing yeah so his thing is you know go to your boss and ask you say well no i don't want to be told no they're gonna think i ask too much well go ask because you don't know
Starting point is 00:50:24 like jason pointed out they probably have a budget for it and if that budget's not getting used it'll told no, they're going to think I ask too much. Well, go ask because you don't know. Like Jason pointed out, they probably have a budget for it. And if that budget's not getting used, it'll disappear. So they may in fact be glad to send you to the conference. Yeah, definitely. Okay, let's talk a little bit about virtual machines. Python is kind of interesting in that it actually has several different virtual machines and they all have kind of really unique purposes. So the first and the most common is CPython. Well, hang on. Oh, go ahead.
Starting point is 00:50:52 So what is a virtual machine? Oh, yeah, this is a good question. So a virtual machine, and I'm probably going to butcher this because I'm not going to work with you. It's okay. I did it twice already this time, so it's your time to sit into the hot seat for a minute. Oh, man, I'm in the hot i'm sweating so the virtual machine a virtual machine is basically a software implementation of you know the fundamental components of a computer
Starting point is 00:51:16 and what that means is essentially a memory space so a a block from which you can allocate chunks of memory, a processor which you can pass instructions to, and a set of registers which you can pass sort of as arguments these instructions to do computation. So let's talk a little bit about an actual machine, about a computer. Basically the way the computer works is you have a bank of memory and we'll just say the memory is indexed by a number. So you can get memory location 0 through 10,000 let's say. And if you want the number that's in memory location 650, you can go and query the memory for that information. Once you get data from memory, it goes into registers, which are locations on the processor
Starting point is 00:52:12 itself on the chip that hold information. Once you've sort of loaded the registers with information, you can run computations on them. So you can load two registers and then add them together and put the sum of those registers into a third register. That would be an add instruction. The instructions can be simple like that add. They can also be very complicated. So on the VAX machine, there was actually a hardware instruction
Starting point is 00:52:40 that would sort a list. So you gave it 16 registers, 16 operators, or 16 parameters, and you gave it the sort instruction. And in hardware, there were physical copper traces that did the sort algorithm for up to 16 elements. So that's the way a real machine works. In the case of a virtual machine, everything is in software. So in other words, the implementation of your instructions,
Starting point is 00:53:09 let's say you have a sort instruction, the sort is actually done in software. And the sort is actually done by, in this case, using some for loops or whatever, which execute on the actual machine. Your registers are also just locations in memory on the actual machine. Your registers are also just locations in memory on the actual machine so there's no chip in this case because it's virtual and your memory corresponds to memory in the actual machine so that's not too different. So the interesting thing about a virtual machine is that for one thing you can give it any instruction you want you can
Starting point is 00:53:44 make your own instructions because you're not actually doing anything in hardware. You're just composing new instructions from the instructions that already exist on your machine. You can also, you have more error checking. So if you, let's say, do a divide by zero in hardware, that's going to produce some answer i mean the electricity is going to flow through those wires and something's going to happen you're
Starting point is 00:54:10 going to get a number so it'll probably actually i think you get a sometimes you get an interrupt oh you can get a divide by zero interrupt usually you get on most os you get a nan yeah so usually you'll get a nan it'll It'll make, there's some specific number. Oh, right, that's right. So there's some specific number that corresponds to not a number, and you'll get that number. On the virtual machine, if you do, you know, a floating point divide by zero or an integer divide by zero,
Starting point is 00:54:40 you can crash the virtual machine. But, you know, because the virtual machine is all done in software you're not actually crashing something you know on the hardware level and so it's much easier to debug uh you know one of the bad things about a virtual machine is that it's inherently slower so if you call add uh well that's kind of a bad example because it just calls the machine ad but let's say there's some like let's say there's some instruction called... Foo. Yeah, there's some instruction foo, which actually corresponds to doing 10 ads or something like that.
Starting point is 00:55:13 Then that instruction is actually going to be quite slow because it's going to actually turn into many different instructions. So... Oh, go ahead. No, no, go. Yeah, so basically a virtual machine sort of gives you a lot of control. You can see exactly what's going on with the system. Since it's all in software, you can take a snapshot. So you can save the state of the virtual machine and then go back. So you can reload your crash over and over again and see exactly how it happened. Interesting. It also provides portability, so running across different actual processors, you can provide the same interface to your program. Yeah, definitely. So
Starting point is 00:55:53 let's say, for one example, if your processor has SSE on it, you might have access to SSE hardware instructions that, you know, someone else doesn't have access to. But in the case of the virtual machine, all of your instructions are in software. So as long as you can compile the virtual machine for your particular computer, you know that you have access to every single instruction. And interesting things, which are another kind of gotcha but you know the virtual machine on the computer with ssc could have ssc acceleration but then you can run on another computer and assume that that's there because those instructions are still there but that acceleration can't happen
Starting point is 00:56:36 because there isn't a hardware so that has to be done in software right that's right yeah so that's actually interesting the virtual machine can run faster or slower depending on the specs of your actual machine and what instructions are actually there. So what's the difference between a virtual machine and an emulator? Oh, interesting. So that's a good question. Okay, I'll give my opinion. Okay, yeah, you go first. Then you can tell me if I'm right or wrong. Okay. So an emulator, which we haven't talked about, is kind of taking a real-world, and these are generalizations, but taking a real-world device. And so we're talking about the Apple emulator online before the Apple IIe emulator. So taking a real device and creating a program that runs on other hardware typically so for instance in this case a
Starting point is 00:57:27 windows os running on an intel processor and simulating every ask every hardware aspect of the apple 2e that matters so that you could take a program that was written for an apple 2e and without changing anything in that program run it through your emulator and it would know no difference and it would behave the same and the user could interact with it if it's a user interacting kind of machine. Versus a virtual machine can implement essentially a hypothetical machine,
Starting point is 00:57:55 a machine that doesn't exist in the real world. So Python doesn't implement a virtual machine that is a facsimile of another machine. It could have 1024 registers where no real machine's gonna have that many registers. It could have, in theory, an infinite stack that no hardware could actually have. It can do stuff that isn't possible in real hardware
Starting point is 00:58:18 or even has just never existed in real hardware. And it's not bound to trying to emulate some other kind of hardware just providing a consistent interface to programs that are written for it yeah i think that i think that makes sense i think that you know the point the biggest point there is the uh the fact that you know like you said the emulator is actually emulating another system whereas you know a virtual machine can be completely virtual but i guess fundamentally they're the same though so yeah i don't think that i think a lot of it is connotative you know
Starting point is 00:58:50 emulators are typically you know where you're going and trying to emulate a machine uh you know a specific piece of hardware like a nintendo or something whereas a virtual machine is often referred to um you know emulating an operating system, like running Linux inside of Windows using VMware or something like that. Yeah. Or in this case, running a Python machine inside of a Windows or a C-based machine. Yeah, so let's talk a little bit
Starting point is 00:59:18 about the different Python virtual machines and why they're important. Sorry, I got a little side talk there. No, it's good. It's good.'s good so uh so there's c python which is which is the original python virtual machine and it's as the name suggests coded in c um it uh it's compiled for whatever you know actual machine you're running it on so uh if you're you know on linux you're using a Python virtual machine that was compiled for Linux.
Starting point is 00:59:45 And there's a bunch of compile defines to try to use the same code base on many different machines. There's also Stackless Python. And Stackless Python is actually quite interesting. It gives some extensions to Python that make it more multi-core and multi-processor friendly. And do you know, have you ever used Stackless Python? I have not. It has, yeah, it does a lot more for multi-processing types, for parallel processing, right? Yeah, one interesting thing about Stackless Python is it's used by EVE Online, which boasts the largest single online server user base of any multi-user environment.
Starting point is 01:00:32 So I believe there's tens of thousands of people on a single bank of servers that can all potentially interact with each other simultaneously using EVE Online. So World of Warcraft has millions and millions of users, but it's split up into several what's called shards. Actually, sorry, it's split up into several servers, and each server is split up into shards. So what that means is, let's say I might be playing on Server X and Patrick is playing World of Warcraft on server Y. We have no way of really interacting with each other.
Starting point is 01:01:11 We're in completely different universes. And so they're completely disjoint. So you can think of each of those as a completely different game. Then on top of that, different areas of the world of a single server are sharded so if i'm in one area and patrick's in another area of the world we're on different physical servers so in contrast with eve online everyone can be in exactly the same location um at one time all of the users in the entire um game there are no you. There isn't multiple servers. And so they boast that they're able to do this
Starting point is 01:01:48 because of Stackless Python. So they can have gigantic flash mobs. Yeah, that's right. And there's crazy news stories on the New York Times and other papers on just crazy things that have happened. I think one time one faction, or I think it's called a corporation, went to war on another corporation. And over the span of a few weeks, something like $10,000 or $20,000 of real money, because apparently there's a conversion between real money and EVE Online money. Like $20,000 was lost in this battle.
Starting point is 01:02:23 It's just insane, the magnitude. And so, yeah, Stackless Python works basically by enhancing Python using something called tasklets, which are... Actually, I think in Python they're not called tasklets. I think they're called micro threads. But basically, just to explain it briefly, you know, variables and data, you know, when you're doing programming, you might have access to a certain set of data and you're doing computation. And you might say, okay, I want to sort both of these arrays. There's these very large arrays and I need to sort both of them. What I'm going to do is create two threads. And in the first thread, I'm going to sort the first array.
Starting point is 01:03:09 And in the second thread, I'll sort the second array. And if you have a multi-core CPU, it can do both of those things simultaneously. And that gives you a 2x speedup in time. So Stackless Python has a very high affinity to being able to create threads. Typically, when you create another thread, you have to sort of tell it what variables are yours, what variables are mine, and you have to create what's called a frame for that thread. With Stackless Python, you can create micro threads, which don't have a frame and don't have a context. And because of that, it runs extremely fast.
Starting point is 01:03:51 So if you need to create a lot of threads, you can do so very efficiently. So to go back to EVE Online, they might have a thread for every player that's constantly updating the player statistics and things like that. And that architecture is what allows them to scale to those levels. So we got CPython, StacklessPython, any others? Yeah, so there's PyPy, which is a Python virtual machine written in Python. And I always thought that this was sort of an educational thing, something that Python developers can use to learn more about the language. But I'm learning more now that Python, that PyPy actually runs Python code faster than CPython. And it gets really hairy as to why this is, but
Starting point is 01:04:42 basically it boils down to, again, coming down to these frames. So in CPython, every time you enter a new function, it has to create a new frame. So if you create a new variable inside of a function, it has to know that that variable's with that function. And when you return out of the function, that variable needs to be destroyed. So the set of all variables inside of a function is called a frame. Local variables. Yeah, local variables, that's right.
Starting point is 01:05:13 So CPython, I guess the frames require a lot of overhead. And as you're calling functions and returning out of functions, you're wasting a lot of time. And PyPy somehow gets around this by using something called virtualizables. So yeah, I still have more to learn there, but it is another Python virtual machine to consider if you're developing in Python and performance is important.
Starting point is 01:05:36 They also do a number of interesting tricks, which probably we're running a little long in time tonight, so we won't necessarily talk about, but just-in-time compilation and stuff as well, right? Yeah, I mean, just really quickly, the way that kind of works is, you know, computers like absolute numbers. I mean, if you have a loop and you're trying to loop through these items in a list, and you loop from one to the size of the list, but you don't really know what the size is, the size could the list, but you don't really know what the size is. The size could be changing. Computers, you know, they can't optimize that because they don't really know every time
Starting point is 01:06:10 they go through this loop, they don't know if this is going to be the last time or not. What Adjust In Time Compiler does is it's able to say, okay, I know that the size isn't going to change in the next millisecond, so I'm going to lock that down, and I'm going to tell the system, the actual machine, that I'm looping from 1 to 30 instead of from 1 to the size of the list. And so because of just-in-time compilation and being able to limit what things are changing and at what times, the actual machine is able to run much faster.
Starting point is 01:06:44 Interesting, interesting. Good stuff. Yeah. Do you have anything else to add on Python? So much stuff to add, I'm sure. But I think we covered it fairly well. I mean, at least at an introductory level slash deep level, we've kind of been bouncing around a little. But I think that's good. It'll cover all parts of our audience. Yeah, I think that people who are just learning python or learning programming for the first time
Starting point is 01:07:08 can sort of go back later and learn more about you know virtual machines and things like that um by you know listening to this podcast a second time and people who are you know really experts can uh hopefully uh learn one or two things from from uh from us today definitely and i'd be happy if they listened to it once. We'll worry about them listening to it the second time later. Let's get enough people listening to it the first time. Yeah, that's right. So on that, I guess as a conclusion,
Starting point is 01:07:34 I don't know if you're listening to this, you probably found us on either our website or on iTunes, but we are now on iTunes. So that's a little bit of a yay. Yeah, that's awesome. And we're starting to get a few comments and ratings in. So if you like what you hear, or if you don't remember, Jason said, how, if you think we're terrible, just give us a five-star rating and make us feel so bad
Starting point is 01:07:55 that you think that we're terrible. And yet you still gave us a five-star rating. That's right. And if you liked us, give us a five-star rating and tell us how great we did. Yeah. Yeah, definitely. And if, you know, if you a five-star rating and tell us how great we did. Yeah, yeah, definitely. And if you have any comments, you can email us, programmingthrowdown at gmail.com. Or you can post on our blog, programmingthrowdown.blogspot.com. Yeah, absolutely. In all fairness, we really would like to have any sort of criticisms you guys have, constructive or otherwise, just so that we can try to make this better. We're doing this to help you guys and and to have a great time yeah definitely okay so i guess i guess that wraps this one up unless you have anything else all right so that's us signing off
Starting point is 01:08:36 see you guys later bye the intro music is axo by biner Programming Throwdown is distributed under a Creative Commons Attribution Share Alike 2.0 license. You're free to share, copy, distribute, transmit the work, to remix, adapt the work, but you must provide an 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.