Programming Throwdown - C Programming Language

Episode Date: March 9, 2011

This show covers C, the foundation of all programming languages. We begin by introducing ourselves, then jump into talking about the PS3 hack and Nokia cell phone strategy. The tools of the d...ay are Comix the comix book reader and Bitcoin, a virtual currency. ★ Support this podcast on Patreon ★

Transcript
Discussion (0)
Starting point is 00:00:00 this is the programming throwdown episode number one all right that sounds good we should keep that i like that all right so why don't you introduce yourself? All right. My name is Jason Gauci and I'm a software engineer, but by day by night work on emulators work on like main with the main team and Mess the mess emulator and different open source projects and just overall general hacker. All right, that's pretty good I wouldn't what about you? What are you up to? It's pretty modest sounding, but I know you do a lot more than that. Mine pales by comparison, man. I'm Patrick Wheeler, and coder by day, and general do house chores around the house at night.
Starting point is 00:01:01 Sleeper by night. Yeah. I was digging in the dark tonight trying to fix my sprinklers so oh man how did that go it worked i i finally got it done in the pitch black spraying myself with reclaimed water so oh nice but it's all fixed now oh man i raked my yard and it's uh there's nothing underneath like the rake i just kept raking when i was done there's just dirt so i'm in pretty coding is way more fun than digging in the dirt yeah definitely agreed uh good stuff all right well let's go ahead and get get started here so you have any news for us jason yeah let's see so yeah i guess we have this news
Starting point is 00:01:36 about this ps3 um hacker guy getting back at sony and sony going back and forth with him. George Hotz, GeoHot is his internet pseudonym. And he's one of a group, I guess he's teaming up with Failoverflow, which is another hacker group. And together they were able to hack the PS3. And this is pretty cool for people who want to sort of run homebrew software, whether it's emulators or just nice little apps you want to just take advantage of the ps3 hardware in a way that uh you know no one else has really thought of um this gives you that that opportunity i think it's really
Starting point is 00:02:15 interesting yeah i saw a little bit about that the way he did it uh he's like he's able to figure out the private key for the that son Sony was using to sign its executables? Yeah, so the key is all based on this random number generator. But they found out, diving through the assembly code, that the random number generator was just returning six. So that's a random. Yeah, so totally the encryption completely falls apart when the RNG is just returning 6 the whole time.
Starting point is 00:02:49 And between figuring that out and some other hacks in the hardware, they were able to completely unlock the PS3. They were able to get to the point where now they can write, or even you at home can write signed apps for the PS3. And the PS3 hardware thinks that you're a professional developer even though you're some kid in your basement. So that must make Sony pretty scared, right? No control of their platform now. Yeah, I mean, Sony's lost that DRM that they were really trying to hold on to.
Starting point is 00:03:18 And they'd prided themselves on being the only console that hadn't been hacked. So yeah, they're going and suing George Hotzz and they're also trying to shut down his website it's gone so far they actually sued or they actually commandeered the ip addresses of anyone who's been to his website and the username of of anyone who's uh seen his youtube video so i mean this is really starting to get into personal privacy that seems ridiculous yeah i can't imagine that you know they can get away with stuff like that yeah visiting a website is now a crime i don't yeah yeah i mean it's something straight out of 1984 right they're gonna start knocking on your door i'm not a lawyer but that didn't sound very
Starting point is 00:04:03 good precedence to say. No, definitely. I just hope that they can appeal that and then it can go further on in the courts and everything. Is it too late, though? They already got all the IP addresses? I mean, once you have that information, I guess the ISPs have to comply so they can figure out who those IP addresses really are. Yeah, I don't know like if you know if you if you can appeal something like that i'm assuming you can do it before they get the ip addresses oh that's true they probably the judge orders you know whoever to turn over the ip address but they don't do it immediately
Starting point is 00:04:36 they probably have time to do it yeah exactly there's this awesome video uh let me see if i can find it here these fail overflow guys going in a like explicit detail on what they uh you know how they pulled off this hack and everything is this a watch at your own peril video yeah this is the kind of video that if you watch you might end up um as part of some court case so uh let's put that disclaimer out there you might need to opt out next time you go to the airport if you watch this video yeah that's right yeah they might take naked pictures of you if you if you watch this video but yeah we'll put it on the blog uh link to it with a disclaimer okay all right sounds good what about you you got any news today oh man so i saw today that nokia is gonna you know try to sell
Starting point is 00:05:21 off or relicense their qt and um i guess this is as part of them switching from their own os the symbian os i guess to windows 7 or at least have that emphasis so as part of that i guess they're trying to divest the qt stuff yeah i mean it makes sense nokia's kind of in trouble right because they yeah uh they were doing so good you know they had such a huge market share originally because they didn't they were doing so good you know they had such a huge market share originally because they didn't have any competition like once the smartphones started coming out they're just really in trouble well this is interesting to me uh you know from a technical standpoint from the market i guess not from the technical standpoint from the market standpoint
Starting point is 00:05:59 though that it's my understanding nok has a huge market share overseas. I know some people from Africa, and they were saying all the phones there are Nokia. And they're mostly the, what do they call them, feature phones, right? Not smartphones. So I guess it's a matter of pride for Nokia to say they have the best smartphone or a great smartphone. But it seems like you can make a pretty good living off of you know dominating the non smartphone market which at this point is still bigger than the smartphone market yeah definitely i think also another uh direction another avenue that nokia is trying to get into is the trying to
Starting point is 00:06:36 cut into blackberry's market a little bit they've been teaming with microsoft yeah microsoft's really the only person out there who can compete with BlackBerry on the enterprise level, you know? I mean, no one can sync with Outlook like Microsoft, you know what I mean? I would hope. So, yeah, maybe not. At least Microsoft might be able to do it. Yeah, potential is there. So, if they team up, you know, they might be able to edge BlackBerry out, which is just another competitor for BlackBerry.'s i think in some trouble i think competition's good you know drives innovation at some level so yeah it's true there's competition on the on the you know i guess the consumer side with with the iphone and the versus the android and so but
Starting point is 00:07:21 really blackberry's sort of in its own world, and corporations don't really have a choice right now. So on that note, Friday, iPad 2 is coming out. Are you going to be in line? Oh, yeah. I'm thinking about it, but I'm just not sure. The Zune looks really good. It's kind of pricey, though. In the end, most users out there you know don't need all that uh all that memory you know all that uh um ram uh what does it use does it use like flash yeah okay yeah most people don't need that much flash um i sure i i sure don't i mean my plan would be to put uh comics on there and i could put just you know pretty much every every i have every x-men comic and it's only like four gig so uh and i don't need all that on the pad so the zoom's
Starting point is 00:08:11 looking pretty good but at that price point i don't know i think i'm gonna have to stick with the ipad too might be in line when it comes out yeah i think uh i might i'm probably gonna pass for now but i think my dad's gonna get one so that should be oh really yeah my brother maybe too as well so if they have them and are playing with them I'll probably get envy and might show up with one shortly after nice did either of them have a mac like a macbook pro no actually interesting enough nobody in my family has uh any macbooks or mac computers we do all almost all now have iphones though oh okay What about iPods? Did you guys jump on the iPod thing? No, no.
Starting point is 00:08:48 I had no interest in getting iPods. Really? Yeah. I mean, the iPod Touch was really nice, but by the time I was interested enough to do that, I had an iPhone. Yeah, the iPod Touch came out a little bit too late. I think it actually, didn't it come out after the iPhone? Or maybe like right around the same time? It seems like it did,
Starting point is 00:09:04 yeah. Yeah. So, but yeah, before that, I that i just had generic whatever you know sansa mp3 player you know it wasn't uh it wasn't an apple product so your dad isn't going to go for the zoom i guess no not the zoom i don't know oh zoom yeah yeah i thought you were saying zoom and i was just mishearing you but okay yeah we're saying saying Zoom, which is the Microsoft MP3 player. Oh, is that what that is? Now all our listeners are completely confused. Yeah, everybody is just, oh, it's all over the place. You can send emails care of Jason for
Starting point is 00:09:33 confusion. Yeah, so that's a good point. If you want to write hate mail, write it to P Wheeler. Actually, you can send email. We have our email address programmingthrowdown at gmail.com they can that's right yeah we're both we're both reading that so yeah um definitely you know send us your comments give us your feedback tell us what languages you want um because we will learn
Starting point is 00:09:57 just about anything or at least oh we should try to learn anything well okay hang on hang on one more one more news item i had uh facebook bot beluga and this is not terribly interesting in itself beluga is a group messaging app i guess that basically you send text messages to a beluga number and the beluga re-sends them out to people in your group so it's a way like if you know you and a group of friends go to a theme park you can all keep in touch with each other over text messages and not have to pay to send it to four people, just to one number,
Starting point is 00:10:29 and then that number will redistribute to everybody. Oh, interesting. So that's kind of interesting. And there's a couple other applications doing something similar. But then I saw some analysis where people are saying that they think Facebook's going to make a run at the SMS itself by every phone now having a Facebook application. If you can send SMS from within Facebook, that'll be data, not text messaging.
Starting point is 00:10:52 And a lot of people will be happy to get rid of those expensive text messaging plans. Oh, that is so good. That is fantastic news because SMS is just ridiculous. They're just making a killing off that. Yeah. So that was the last bit of news I had. Okay. So now on to what you were talking about. So what is the purpose of this podcast, Jason?
Starting point is 00:11:13 Let me tell us. All right. Let's take a shot at this. So basically what we want to do is throw down a new language every show. In this case, we're looking at making a show every couple weeks. And what we want to do is just take on a new language. We'll spend a couple of weeks beforehand learning it ourselves, and then we'll spend a couple weeks after continuing what we've talked about and advancing on that. And the goal is just to learn new
Starting point is 00:11:43 languages all the time, find out what languages are appropriate for what tasks what are the pros and cons all that good stuff and to just share that knowledge with you guys out there and to also uh you know give you guys some uh more tools for the toolbox when you guys are out there uh you know doing engineering and coding things up yeah tools for the toolbox that's always like to think about it that way. Yeah, yeah, definitely. Right tool for the right job. Yeah, I mean, you know, nowadays,
Starting point is 00:12:09 languages have come so far and there are some languages that are so high level and so efficient, such as, you know, Java and Python. And there are other languages that have been extremely optimized with, you know, SSE and different compiler tools. So namely C and C++, that you just have a wide array of opportunity as a programmer.
Starting point is 00:12:31 Yeah, yeah, that's true. So what languages right now, before we embark on this journey, what languages would you call yourself qualified to program in? My favorite language has always been C++. That's what they taught us in school, you know, in ninth grade or whatever. So I've been kind of sticking to that. But I'm also pretty familiar with C, like Java. I like Python a lot. Getting into, I did a little bit of Lisp, and so I'm starting to get into Scheme a little bit just to understand it.
Starting point is 00:13:06 But yeah, I'd say those are my favorites. What about you? Yeah, mine are pretty similar. I actually started off learning, I guess, C++ in high school and college did Java. There's some interesting stuff there, especially since it hasn't been that long since I've been out of school. But Java's come kind of far even in just that little time as far as fixing a lot of the complaints about slowness. That's been interesting. Yeah, definitely. Also do a little bit of Python.
Starting point is 00:13:30 Done some kind of crazy stuff in, I guess, what is that, LabVIEW and Visual Basic here and there. A little bit of C Sharp. Oh, nice. And did a little iPhone programming. So that'd be Objective-C. Yep. So that's pretty much it. But mostly, you know, I'd say 90% of my stuff's been in you know cc plus plus yeah definitely i mean those are you know as a
Starting point is 00:13:50 programmer out there if you're uh you're a kid starting to get into programming those are going to be your core languages that you'll always have to keep you know coming back to yeah i mean i think and in some places i guess people tell me you, it hasn't been my experience yet, but people tell me that there's places where Java is, you know, the de facto standard. But I think learning C or C++ or Java, you can transition back and forth with a little bit of training, but not too much. The concepts are pretty similar. Yeah, yeah, definitely. And then there are some languages like Go and Erlang, you know, and Lisp and Prolog, which are just way off the charts. And you really have to change the way you think and change your paradigm to get your hands around those languages.
Starting point is 00:14:35 Yeah, yeah. I mean, I had a conversation about this with somebody at work talking about that. I had been doing C++ for a little while and really liked some of the, you know, object-oriented stuff that we were doing in there. And then had to write some C code for a very low-level processor. And was able to take a lot of this stuff I learned out of C++ and use it in C. Even without, you know, just doing classes, the stuff that you learn is applicable. And I try to do the same with, know Python or you know hopefully as part of this getting into you know like Haskell OCaml like you talked about you know Lisp Scheme whatever
Starting point is 00:15:10 those kind of languages and not even just writing code in them but taking the lessons learned the way of thinking and applying that to my everyday coding yeah definitely it always seems like every language has one or two things that it can teach you just about programming and about about computation in general yeah make you feel a little bit smarter yeah that's right that's what we're doing our goal here is to make everybody out there feel a little smarter and a little better about you know software engineering and make you feel good about yourself and challenge you to broaden your horizons. That's right.
Starting point is 00:15:46 That's right. Horizons will be broadened. Whether you like it or not. But hopefully you'll like it. It could be against your will. It's possible that you have this playing in your car stereo and you're engaged in the highway
Starting point is 00:15:59 and cannot turn it off. So we apologize. We pity you. Pull over now. Yeah, it's not worth it it i know you have to get to work but and if you're still with us despite all of that convincing persuasion that's right so yeah let's talk about the tool of the day all right uh let's see what would my tool of the day be do you have one now i'm just going through my programs here. Are you looking on your computer?
Starting point is 00:16:26 I guess I could talk about comics with an X. Comics with an X? Yeah, let's do that. All right. So my tool of the day is comics, C-O-M-I-X. And the way this works is it's a comic book reader. Oh, actually, if you search for comics, you get a bunch of weird... Yeah, it goes under the title GTK Comic Book Viewer.
Starting point is 00:16:50 But basically, the way it works is comics come in this format called CBZ. And they also have another format called CBR. And all it is is just a zip file with a bunch of images in it, or in the CBR case, a RAR file. What this comics does is it opens the zip in memory, it loads all the pictures, and it provides this really slick interface for you to go through the comics. So it'll actually, you can hit spacebar and it'll go from frame to frame, like it kind of intelligently figures out the layout or guesses at the layout of the comic
Starting point is 00:17:23 and it'll let you navigate through and let you read the comics faster. It does also some sampling and things like that to make them a little sharper, make the images clearer. I use it a lot. I like it. Do you use this mostly on your computer at home or on your phone? Yeah, so I mainly use this on my MacBook when I travel. That's most of the time when I'm reading comics, I'm traveling. And I believe they have a version.
Starting point is 00:17:49 If it's not comics, it'll be something else. But they have comic book readers for the iPad and for the iPhone too. So keep in mind if you're a big comic book fan and you subscribe to digital comic books, those CBZ files and Cbr files um can be opened in a ton of different viewers and uh some of them have some really smart capability like this comics one so just keep your eyes out and you can make your comic reading experience a little better nice nice yeah i just never really got into comic book reading growing up i don't know why so oh really but i do on occasion like reading
Starting point is 00:18:25 comic book see i i never got into it until i found out uh like the world beyond superhero comic books you know like i never really got into spider-man i got into x-men a little bit it wasn't really into batman but then i started finding out about you know i guess i'll say more modern ones like the walking Dead and – 300. Yeah. Scrooge McDuck is a comic. It's actually endorsed by Disney, but it's not like a little children's comic. It's actually kind of –
Starting point is 00:18:54 Really? Yeah. It's kind of like has – I wouldn't say an adult theme because adult has sort of connotations there. But it deals with some kind of mature topics. The humor is sort of high concept it's really surprising for disney um so you're saying is if i read it i wouldn't understand it yeah it's kind of high concept so it's no way of saying you know i don't know i see your nose pointing high into the air sir yeah that's right What are you reading there, sir? Scrooge McDuck. Yeah, only the finest.
Starting point is 00:19:28 I'm sure the Dos Equis guy reads Scrooge McDuck. The most interesting man in the world. Okay, interesting. I'll have to call and ask him. Yeah, maybe we can get him on the show. Oh, there you go. I could see him, you know, I don't drink, but when I do, I like Dos Equis and my Scrooge McDuck comics. It just, it flows.
Starting point is 00:19:48 You should be a screenwriter. I don't know who would watch your shows, but they'd be funny. So what about you, man? What's your tool of the day? So you and I talked about this a little bit before, but I have my tool of the day just for sheer interestingness of concept, the Bitcoin. Oh, nice. So Bitcoin, the reason part of it, I was just thinking about it again today as I saw that they released a Java version of it. But Bitcoin is a program that you run on your computer that's a peer-to-peer program for doing money transaction. So, you know, eventually it's a new currency based on, I guess, cryptographic principles. I still haven't fully put my head around what it is yet,
Starting point is 00:20:34 but a way of creating a finite supply of things, which if you have a finite supply of things can become money, I guess, or, you know,. And doing transactions, so a way of doing transactions in a peer-to-peer manner that's more easily authenticated in a non-centralized way. And it's a very interesting concept. And so part of the initial thing now is doing the computations to generate these Bitcoins. And if you get this Bitcoin client, not only can you do transactions, you can also be involved in essentially printing money or printing BitMoney. That's pretty cool.
Starting point is 00:21:09 Yeah. Yeah. The whole, you know, if we look back at currency, you know, in history or whatever, they always look for things that are hard to generate or hard to replace. So like, you know, the Greeks, I believe it was the Greeks or maybe the Romans used salt for currency. That's where salary comes from. Oh, not know that sal salt so salary was your being paid in salt busting out the verbal skills there it's impressive that's it i'm done no more that was the limit oh man that's your one time no so uh so you know they used uh they used salt and then later on you know i mean even to this day gold is used uh you know, they used salt and then later on, you know, I mean, even to this day, gold is used. You know, money used to be actually backed by gold and you could trade it, trade one for the other.
Starting point is 00:21:51 Well, I guess you can still at some level, right? I mean, you can't trade a dollar bill in and get the government to give you gold, but you could trade your dollar bill to somebody in exchange for some amount of gold. Yeah, yeah, definitely. A very, very small sliver of gold at this point. Yeah, that's right or you can trade in your watch to some guy in the in the mall who will give you a small amount of money for it yeah trade in your thirty thousand dollar gold watch and he'll give you twenty bucks for it
Starting point is 00:22:16 isn't that crazy the we buy gold frenzy that there is out there well i mean i guess the price has gone up so much but the problem is that they're giving you aside from the scamminess of some of the people i mean they're giving you the price for the raw material of gold in the item not the workmanship craftsmanship you know intrinsic or the what is i guess extrinsic value or intrinsic extrinsic value extrinsic yeah yeah so i mean they're not giving you anything for that so the fact that it's a lovely crafted you know gold chain necklace they weigh it see how much gold's in it and that's what they're going to base their payment to you often yeah that's interesting you know because in the commercials that make it seem like all of these necklaces and rings are going to some foundry and getting melted down well in practice they're probably you know just turning
Starting point is 00:23:03 that around and reselling it that's true they probably make more money that way yeah i think people probably feel more comfortable knowing that you know grandma's brooch is getting melted down so then somebody else is going to be wearing it yeah keep the facade going and i think i don't know if it was you or someone else someone was telling me that they actually uh take like the diamonds out like some people will turn in a ring with a diamond in it and they'll just pay them for the gold but then they'll turn around and sell the diamond too oh no that wasn't me that's i i know other you know kind of scams that work like that right you know you go to the flea market or go to some place pawn shop right and you try to pawn something and
Starting point is 00:23:38 if the guy thinks you don't know what the value of the item is he'll try to you know basically give you as little as possible for it yeah yeah definitely you have a you know original monet picture you know and he says oh this is a print you know i give you 20 bucks for it and he turns around and sells it for 30,000 oh man that is that is pretty shady i have no idea how much art sells for so i think 30,000 that's how much every piece sells for uh that's how much I'd pay for it in modern art. That's right. We should have a board game of the day sometime. Oh, interesting.
Starting point is 00:24:13 The board game programming language or something. So tell me some more about Bitcoin. So basically, some computers, I guess, are calculating Bitcoins, but there's only so many of them. Eventually, you'll get to the point where no amount of programming will get you the next coin. Right. The pool will be exhausted. And at that point, you will trade services if you want Bitcoin.
Starting point is 00:24:37 Services are bits or atoms. So it may be, for instance, you want to have web hosting and you could exchange some of the bitcoins that you spent your time on your pc to make for web hosting on somebody else's computer which they can use to turn around and trade for actual dollars to do something else with or whatever i mean at that point it is it's just another currency it's just how many people will actually accept it as payment and as a form of trade. gave Gmail accounts, like some of the first Gmail accounts, to people who participated in a Topcoder Collegiate Challenge back in like 2003 or something like that, when Gmail was brand new. And at the time, people were selling their invites.
Starting point is 00:25:34 Like if you could invite somebody else to Gmail, he would give you a free tour of D.C. It's like they had a whole list of things that you could buy for your Gmail account. Yeah, I i mean anything can become currency i guess it's just how many people will accept it and i guess the idea with bitcoin is that it's a provable finite amount of things and it's because of the peer-to-peer decentralized nature it's very hard to scam or do fraudulent activities on so that math it's kind of a mathematical proof of uh stability i guess so other people
Starting point is 00:26:06 should be willing to trust it as opposed to uh regardless of your political beliefs um what the government has decided to do in our country which is just print more money and so kind of breaking the fundamental assumption that you know at a derived level how much money there is by how much things cost and then all of a sudden you know if there's twice how much money there is by how much things cost and then all of a sudden you know if there's twice as much money in the world your money is half as valuable yeah exactly i think there's like oversimplifying to a great extent macroeconomics yeah they must publish right how many bills they print otherwise there'd be no way to you know keep track of inflation right i i it gets beyond my grasp to think about things like that
Starting point is 00:26:46 yeah me too it's very interesting i love thinking about it but it's outside of my comfort zone yeah there's like an economic podcast out there where they're explaining everything in detail and uh and we're just making it up so yeah but hey. It sounds good to you. No, that's bad advice. That's bad advice. So, you know, the other thing about this Bitcoin is because it is peer-to-peer and because it's free to sort of, you know, join this network, it could get very popular, which is really important. Yeah. Yeah, I mean, one of the big failings of sort of early civilizations were, you know, each colony had its own. I know in the Roman times, each emperor had their own coin. And so none of them really carried, no pun intended, but carried their weight because they were constantly getting phased out by something else.
Starting point is 00:27:37 So it'd be interesting to see if Bitcoin sort of survives the test of time and if it gets popular enough to, you know, hit that critical mass where people will start trading real money for it yeah i got interested in it for a while then kind of just thought it maybe was just a curio curiosity and then i saw it pop up again today and it's kind of like oh i keep hearing this maybe i can get on the ground floor or something awesome yeah it's good stuff all right so so for the programming language of the day, I guess for this first podcast, we decided to talk about C. Yeah, definitely. C is an awesome language. It's a procedural language, which means that it's designed to go kind of one line at a time, as opposed to some of the other languages, like Lisp, which is functional,
Starting point is 00:28:26 in which case, you know, you don't necessarily know where you are at any given time. You know, and with C, there's like a very specific main function. And, you know, you're calling other functions and things like that. But it's rather easy to sort of step through a program in C and see what's going on. Right. I guess the other word for that sometimes imperative. Yeah. Yeah, definitely. So I guess it's kind of hard to talk about C because most of my other things are defined
Starting point is 00:28:54 in terms of how they relate to C. So it's like defining the base thing. It's kind of. Yeah. It's like it's like the dictionary definition for the must have the in it. You know, I'm assuming. I don't know. It's just not like the dictionary definition for the must have the in it, you know, I'm assuming. I don't know. It's just not in the dictionary. Yeah, it might not be.
Starting point is 00:29:10 So C is, interestingly, a lot of C is written in C. And this is something that is a trend that you'll probably find as you listen to the shows is that a lot of languages are written in themselves and what that means is you know they come up with very low level interfaces to the uh you know to the language usually built in a lower level language so for example uh c has functions like open and write which are directly go down to kernel function calls which end up working their way down to assembly. So C is built on these low-level assembly routines. But then also there is like fwrite, which is writing to a file, and fopen, which is opening a file. These functions are written in C. So someone has gone in and written a definition for fopen,
Starting point is 00:29:59 which invokes the write kernel calls depending on your OS and things like that. So, I mean, I guess the way that works, you know, is that the first version is written purely in assembly, and then somebody is able to compile C to assembly and do that to a point where you can do everything you would need to do. And then I guess at that point you bootstrapped, and then you can have a compiler entirely in the language which it's compiling. Exactly. That's exactly right.
Starting point is 00:30:28 So C, you know, the whole or the vast majority of the Linux kernel is written in C, if not the entire thing. Linus Torvalds is a huge C fan. He has this part on his blog where he just is tearing apart C++ and all these other languages. I didn't know that. Yeah, let's see if i can find it here if i find it um that's that's that's interesting yeah i'll send this to you and i'll link it to the forums yeah i mean there's a lot of people i know who um especially in the industry where we're at that claim to write c++ you know and that just means that they have a dot cpp file, but in reality,
Starting point is 00:31:06 they're writing C code. Yeah, yeah, definitely. Which at some level, I mean, C++ and C code are very, very close to each other. And in fact, I mean, you can, it's perfectly valid to write C code in a C++ file. But I guess it's more of the style that we're talking about there, the way you kind of break things down, write classes, those kinds of things. Yeah, so C++, which we'll talk about in another episode, but adds sort of an object-oriented layer on top of C. But in fact, the very first C++ compiler is actually compiled down to C. So the first one written by Strauss-Stru or whatever was, its output was a C file that you then compiled again. So C would be then a very low-level language, right?
Starting point is 00:31:52 Yeah, in fact, you can actually type assembly code straight in line with your C code. So you could be writing some C code, you could be saying F open to open this file. And then, you know, load this, load, you know, int I equals zero. All these C things that you're used to seeing. But then all of a sudden you can put ASM, open parenthesis. And now you can put assembly code right there. Bam. Whoa, that's pretty hardcore. Yeah, I know.
Starting point is 00:32:19 This is like emerald cooking here, you know. Bam. Bam. There's assembly right there. Yeah, and if you look at the Quake 3 source code, which is, you know, Quake 3 is open source now, you can actually see there's places, especially in the physics routines, where he, you know, there's all this C code. And it gets to the point where he wants to do some math, like, say, figure out gravity's effect on everything in the game. And, you know, for those old processors, it all had to be done in assembly and you'll just see a huge block of
Starting point is 00:32:52 assembly code there. Wow. Yeah. I mean, I have done that before once or twice, put some assembly code, but I won't lie, it was for the most part looking up, you know, needing to do this to kind of get the OS into a certain mode or do something kind of finicky. And I pretty much just copy and pasted. Yeah, yeah, definitely. The little bit of assembly I've done has been kind of the same, just looking up on the internet what to do. And I don't know, does anybody really program in assembly nowadays? Yeah, I mean, I did program assembly in college working on DSP-type things or the Motorola 6812 kind of CPUs, the old-school stuff. I mean, you can write in assembly, and it works pretty good. I mean, for something that has really fast interrupts you need to be able to do or a really low-level processor that doesn't have a really good C compiler,
Starting point is 00:33:45 or a C compiler that has a lot to be desired, you can get a big advantage writing an assembly. So yeah, there are still people that do it, but it's probably very minute at this point, I would say. Somebody will write in and say that's all they do and prove us wrong. We welcome programming throwdown at gmail.com. That's right. If you use a lot of assembly at work,
Starting point is 00:34:08 we'd like to hear from you and hear about kind of your experiences with it and what its applications are nowadays. And actually, I take that back. I did some assembly, but it was SSE. So I was writing SSE code for, did some work on the bullet physics engine so it's an open source physics engine
Starting point is 00:34:28 but again it's basically it was like I just need to loop through these numbers and multiply these two arrays together and so the code ended up not being very complicated yeah interesting yeah I guess people still do it for a lot of things
Starting point is 00:34:44 it's one of the things i guess it just falls out of the mainstream and people kind of forget about it yeah yeah i wonder you know as time goes on if if you know c and c plus plus are going to go sort of the way of assembly it's hard to say yeah i mean because i did sse stuff but i did it in c um they have c i guess bindings for it or i don't know what the right term is there. But you can actually write C code to do SSE. And I have done that before. But it's pretty close to assembly.
Starting point is 00:35:11 I mean, it's nothing fancy. It's not much better than just the writing in assembly probably would be. Oh, gotcha. But yeah, other things about C. So I got this link you sent me. Yeah, I guess Linus Torvalds does have a big beef against C++. I know. I would hate to go up against him in a C competition.
Starting point is 00:35:31 Here you go. C++ is a horrible language. It's made more horrible by the fact that a lot of substandard programmers use it to the point where it's much easier to generate total and utter crap with it. I think that, you know, this with it i think that you know this is a case of um you know i mean linus dorvalds is is extremely gifted right um but he did a lot of his stuff when c++ compilers were terrible and i think that you know that technology has come a really long way i kind of had this this experience with Python where in the beginning
Starting point is 00:36:07 at Python, let's say 1 or whenever I was looking at it, it was just extremely slow and every line was interpreted. You don't have Psycho, which is a just-in-time compiler for Python. That wasn't around then and all that stuff. So I got really bad taste from all that. It was just extremely slow and it had bugs. I got this bus error. I didn't know what that meant. And it really took going back years later and discovering the language again to get an appreciation for it.
Starting point is 00:36:38 And I think that might be a little bit of what's going on here. Yeah, it's written pretty recently, 2007. So it wasn't that long ago yeah i mean when he wrote it the compilers are definitely in a good state yeah so maybe it is a holder i don't know maybe we'll get him on the show and we'll ask him yeah oh that'd be sweet we can have wishful thinking here in our episode one that that doesn't sound you know we should yeah gotta set our sights high shoot for's right. Shoot for the moon, and if you miss, you'll land upon the stars.
Starting point is 00:37:07 That's right. Swing for the fences. Or if you're being held up in an alley, you swing for the nuts. Did you just use a sports analogy on a programming podcast? Fail. Oh, man. I never played baseball, so. I don't think I've ever even watched baseball.
Starting point is 00:37:23 Really? You've never seen a baseball game? I mean, I saw it on TV once. Oh tv once oh yeah i guess it's just oh yeah oh i'm gonna we're gonna get tons of people let's stop this all right so uh this is interesting um you know glancing over this linus torvalds thing he has a point here that that i've seen some stuff recently about that's kind of interesting where he says that um that he says quite frankly even if the choice of c were to do nothing but keep the C++ programmers out,
Starting point is 00:37:48 that in itself would be a huge reason to use C. And this is kind of interesting. I saw somebody else, who was it? We'll find it later. But somebody was writing and saying that one reason to use new programming languages like Scala or Clojure or some kind of fancy new thing is that if you write your applications in that language and you're a, I guess, small enough, agile enough company to be able to do these kinds of things, that if you write
Starting point is 00:38:19 your application in those things, you're going to attract kind of the best programmers because the run-of-the-mill average programmers aren't going to go out there and learn these complicated functional programming languages. So if nothing else, the people who are going to apply to your job openings, who are going to want to work on your projects, are going to be people who are kind of the, you know, cream of the crop, who are out there trying to pursue these interesting and, you know, perhaps game changing ideas. And so if you, you know, kind of similar to Linus's point here, can we call him that? Should we call him Mr. Kornwalds? You know, to his point here that,
Starting point is 00:38:57 you know, it's interesting, you're, you know, kind of the theme of this podcast, choosing your language kind of chooses who's going to be attracted to working on it or working with you. And that has consequences, good and bad at every choice. Yeah. I mean, so, you know, continuing with that, the more programming languages, you know, and that you can sort of put on your resume and, and speak in an educated way about the better you're going to do, because if you find that one guy who, you know, who Ada is his is his love and joy. And if you can talk intelligently about that, you might have an advantage. Yeah. And you had a good point there. Put programming languages on your resume that you
Starting point is 00:39:37 can talk intelligently about. That's a pet peeve of mine. People who put programming languages on their resume and they couldn't even write a hell of a world in that language. Don't do that. No, do not. That makes you look terrible. In general, you don't want to put things on your resume that you're not really good in. Just because if nothing else, let's just say you're this guy and you're just interviewing you. You're on the other side of the desk, and they just randomly pick at something,
Starting point is 00:40:06 and it happens to be something you don't know, I mean, it's going to be devastating. So you want to make sure that if someone throws a dart at your resume, it's going to land on something that you can speak about. Yep. Yep. It's good stuff. Good stuff. I mean, you got anything more to say about C? There's so much to say that it's almost hard to pick what to talk about. Yeah, so let's talk a little bit about just the sort of different characteristics of C. So C is very low level. It relies heavily on the compiler. So C doesn't have its own memory management. It doesn't have like a garbage collection or anything like that.
Starting point is 00:40:43 You have to do all the mallocs and frees yourself. And that's a pro and a con. Yeah, it's a pro in the sense that, you know, if you program something, you have a good idea of how much time and how much memory it's going to take. It can also be very consistent. You know, you can allocate your memory up front versus something like if you've used MATLAB or Python. Every time you do an operation, you might be allocating more memory. And that very next operation might be the one that allocates so much memory that your computer has to sort of reorganize. And that could take a very long time.
Starting point is 00:41:21 In C, C puts you in the driver's seat. So you know when you're allocating and deallocating memory. You know when you're going to take a performance hit for doing something. You know, you can watch your buffers, and if they start to get too full, you could decide when to, you know,
Starting point is 00:41:38 make them larger, et cetera. C really leaves you in your own hands there. Yeah, I mean, I guess other languages try to address that, right? I mean, in Python, you can do stuff to try to make it allocate in advance, but ultimately that's not the way it's intended to be used. And C is kind of the default way is to make it be used that way. Yeah, yeah, definitely. But a lot of people mess it up.
Starting point is 00:42:00 A lot of people forget to free stuff or try to dereference bad pointers. And they get tripped up in managing their memory correctly. And that's a dangerous thing because it can make your program crash. Yeah, definitely. And yeah, the other thing, C does not give you a safety net. So in Java, if you have some array that's 10 elements and you try and access the 11th one, Java has a virtual machine. So Java has a sort of like a computer inside a computer. And we'll talk about this more later.
Starting point is 00:42:32 But, you know, the simulated computer on the inside will fail and will throw an error back. In C, you're talking straight to your hardware. So you're talking straight to your memory. So you're talking straight to your memory, to the processor, to any disks you have. And if you have an array of size 12 and you go for the 14th element, it's just going to pick whatever is there in that memory and return it. It'll probably be some crazy number. If you're expecting in between 1 and 100, you might get 2 million. But it will let you do that. The real danger isn't that, though. That is dangerous.
Starting point is 00:43:08 The danger is when it works most of the time, but then the critical moment you're demoing for your boss or, worse, the customer. All of a sudden, that's the time that the way it's allocated happens to be that that memory is being used for something else. Or it's used by the operating system or something and it's instead of returning the value you've expected every other time like let's say zero now it does return something different because you it isn't what you thought it was yeah yeah definitely and you know these problems they start to show up um in production so for example uh let's say you have an array of 10,000 for your, let's say you're Amazon and you're categorizing books in C. And you gave space for, you know, let's say a million books. But now you roll this out to the production environment and you surpass a million books or a million comments on books.
Starting point is 00:44:00 Now you've overridden that array and who knows what's going to happen when you go back to your simulated environment you're never going to find that error because it depends on something that you can only experience in large volume also points out the importance of testing yeah definitely so we should actually maybe the next show
Starting point is 00:44:19 our goal is to kind of do like a little explanation of language and on the next show kind of do a little recap. Maybe in the recap and kind of tool section, we'll talk about Valgrind and some of those other tools that you can use. Yeah, yeah. So, I mean, we probably should, you know, maybe we should have done this before. But, you know, probably should come up with kind of a format for everything. Like I was thinking about, we should also talk about libraries. So, for instance, C, you know, libraries, a lot of people kind of call c well later programming languages kind of poke fun
Starting point is 00:44:50 at c by saying these languages are batteries included that's a python saying i guess right that you know it comes with all of the other stuff you might need versus c doesn't um but there are a lot of libraries you can pull from that give you a lot of powerful tools in C, and especially, I guess, C++. But a lot of libraries out there that give you functionality or reusability and help you build up that code base a lot faster than if you had to do everything from scratch. So it has good library support, I would say. Yeah, definitely. support I would say yeah definitely CNC plus plus it seems like every every you know program out there either has a C C++ version or or is solely C C++ and then has bindings for everything else but those aren't always straightforward
Starting point is 00:45:36 I mean having used a number of libraries they can range in difficulty from very easy to integrate to next impossible to get working in your program yeah definitely not a lot of consistency on that front no and yeah that's actually a very easy to integrate to next to impossible to get working in your program. Yeah, definitely. So not a lot of consistency on that front. No, and yeah, that's actually a good point. So let's talk a little bit about the different C standards. I don't know a lot about the history of it, but at this point right now, there's basically two C standards.
Starting point is 00:46:01 There's the, I guess we'll call it the microsoft c standard and then there's the uh was it c99 well there's ncc and then c99 oh okay yeah i'm calling that the microsoft one since they're the only ones that really like you know stick to that one but um but yeah there's so for example to ncc no no no no no ncc, I mean, that's what like GCC complied to, right? Before now like C99 coming out, right? I mean, Microsoft kind of invented their own subset of ANT-CC that they complied
Starting point is 00:46:34 with. And then they've gotten better over time to now they're actually pretty compliant in my understanding. Oh, maybe I'm thinking Oh, yeah, I'm thinking of ANT-CC I think. That's what I was talking about. Alright, so keep going. Go to your original point anyways. Well, let me, I'm looking it up right now. Okay, so then there was C99,
Starting point is 00:46:50 which, I mean, didn't change anything drastic, right? I mean, it just kind of added support for some new data types and bigger numbers, that kind of stuff. Yeah, let me, all right. The other thing that if you hear people talking about C, there are a lot of bad things you can do in C. C gives you a lot of power, but with great power comes great responsibility.
Starting point is 00:47:14 That's right. And so, you know, they'll do things, they give you like macros, they give you all sorts of ability to, you know, have pointers to functions and, you know, have lists to functions and, you know, have lists of functions that you can call and change with what function does when. And I mean, it gives you all sorts of, you know, we say crazy things, but in some cases, those are really necessary to
Starting point is 00:47:35 be able to do those kind of nonstandard, unexpected, hard to wrap your brain around functions. But in other cases, they can be used for, you know, obfuscation or not that any of us would ever do this, but showing off. And so people will try to show off by using what are those called the tertiary operators, you know, questions. And, you know, if you've ever seen the obfuscated C contest, people can write, you know, just completely unreadable c source code that's completely valid complies with the standards and compiles and is fast um but you could never read it yeah it's much less change it uh so here's what i was thinking okay yeah back there is and yeah it's fine there's ncc and then there's c99 which is i guess the newer one and so microsoft Visual Studio doesn't support C99. It only supports the NCC. And this is a problem because like FFmpeg, for example,
Starting point is 00:48:31 which is a video streaming library, is written in C99. So to use it in Visual Studio, you'd have to just go through and hack the entire code base. And everywhere where you see something that isn't compliant, you have to go in and fix it. Yeah, it'd be massive. So there are two different standards. And the hope is that all of the compilers will start to get to the point
Starting point is 00:48:55 where they're supporting C99. Yeah, the cross-compiler, cross-platform, and C, C++, because are you know compiling right down to machine code it's a pro and a con but you know the con is that you got to be very careful about what you're doing because the way one thing works on one platform could be completely different from the way it works on another yeah let's talk about that a little bit so the difference between C and C++ from other languages like Python or Java is that, as we talked about earlier, they're talking directly to the machine. And more specifically, they're talking directly to the operating system.
Starting point is 00:49:36 So you have to use a compiler specific to your type of hardware and to your OS. So in the case of Windows, you have some choices. You can use Visual C++, which is a Microsoft product. You could use GCC for Windows. It's called MingGW, which is a minimalist GNU for Windows,
Starting point is 00:49:57 is what MingGW stands for. You can also use Intel. They have a compiler. On the Linux side... there's a couple of others too right uh less popular now but there's the um borland have one for a while right oh yeah that's right yeah okay but sorry go ahead not to interrupt you oh no it's cool i threw you off here i'm pulling up no no it's cool i'm pulling up c compilers right now yeah on wikipedia you'll see there's a ton of them turbo c you remember that back of the day all right so well now on Linux oh yeah on Linux
Starting point is 00:50:29 there is um you know GCC is the heavy hitter on Linux you know just about everything is going to be built in that ICC which is the Intel compiler our Intel C compiler that that's also on Linux but oh so the point of this is the programs that you create with C or C++ will be specific to that operating system and that hardware so you know in Java for example you can create a dot class file which is you know your your compiled source code and run that on any machine. So I can compile some Java code on my machine and then go to another Linux machine or go to an ARM machine or go anywhere and run that code, and it'll run just fine.
Starting point is 00:51:15 If you build an executable in C and then take it over to your Mac and try and run it, you're going to be in trouble. It's not going to know what to do with that. You can do cross-compilation, though, right? I mean, on a Windows machine, you could tell your compiler to compile it for a Macintosh. Yeah, definitely. That's a good point. So you can do that, but whichever you decide, it's going to be set to that.
Starting point is 00:51:38 So you can't compile something that will work on several different architectures. And the other thing to point out, I mean, I guess to us, we kind of forget about it, but you don't have to have an operating system to be able to use C. I mean, there are many people writing, the operating system itself is written in C or C++ for the most part. I mean, there are exceptions,
Starting point is 00:51:58 but most of the serious ones, like you pointed out earlier, Linux, I mean, Windows is written in C, C++. So the operating system itself is written in those languages because it doesn't presume that there's an operating system running. I mean, it can. So if you write code compiled for Windows to do GUI stuff, for instance, it's going to assume there's an operating system there.
Starting point is 00:52:19 But there's other ways to write it where those assumptions aren't necessary and that you can have code that runs without an operating system yeah yeah definitely and so if you're wondering why this is you know why in java and python um you can write your code and you can create the pyc files in python or the class files in java and and just send those around across the internet and just know that they'll work on the other person's machine that's because those people it's like guido in the case of python or uh do you know who made java oh i should here let's look it up don't put me on the spot you're making you're ruining our street cred uh history i guess james gosling gosling james gosling mike sheridan and patrick and there's a couple guys there who are kind of famous and have gone on to work on other languages as well I guess James Gosling, Mike Sheridan, and Patrick...
Starting point is 00:53:05 I mean, there's a couple of guys there who are kind of famous and have gone on to work on other languages as well. But I'm not as up on that history as I should be. You were supposed to tell me we're going to talk about this before. So I could sound smart. We'll cut all this out. Actually, we'll say we'll cut it out and we won't. Yeah, just kidding. I'm lazy. So these people have gone to painstaking time and effort into making sure that when you do, you know,
Starting point is 00:53:31 0.5 plus 0.5 in Python, that it's going to give you 1.0 on every single machine. Or when you, you know, create an array, when you create a string, or when you try to access a GUI, when you try to access a gui when you try and create a a gui that it um that it works the same or or as close to the same as it can in every os that's one of the nice things about java is you can make a gui and and just know that it'll work
Starting point is 00:53:56 on every computer you know with c and c plus plus you're typically coding for your hardware and your OS. True, true. Yeah. There are some libraries that can sort of make things cross-platform. And maybe we should talk about some of those. Yeah, we'll have to get to those. Definitely, definitely. Yeah. So much to talk about, so little time.
Starting point is 00:54:17 Yeah. I don't know of any C ones. I use mostly C++ ones. But I guess I'll mention a couple. Agar is a C library for um for guis that is cross-platform what does that use uh like open gl on the back end or right do you know yeah it so it actually has several different back ends um but i think open gl is one of them okay um do you know any like you want to throw in one or two C libraries?
Starting point is 00:54:49 See, I'm going to say something and it's going to be C++ and then we're going to feel kind of bad. Yeah, it's so hard, right? Because it's hard to know. I mean, a lot of the stuff I do for like low-level timing, doing analysis on my code and profiling type stuff, most of those are, you know, just c just for the sake of they don't need to be c++ and that keeps them more compatible yeah yeah definitely there's a number of platform specific libraries that are c for for instance if you do coding on the ti dsps ti has a set of fixed point libraries that are in c oh true because some of their dsps don't have floating point support or the floating point support is large or slow and or slow yeah yeah another one is uh expat which is a xml parsing
Starting point is 00:55:34 library are you just continuing to show me up by telling me how many you can name and i can't name yeah this is like name that i guess well was there a game show like that where it's like yet to keep going we should invent one yeah we'll invent our own game show like that where it's like you have to keep going? We should invent one. Yeah, we'll invent our own game show. We'll write it in C. How about that? And then we'll win. That's right.
Starting point is 00:55:51 And we'll have a memory overrun. Oh, and that's something else we should point out, the security. There's a number of security problems with C and C++. Not inherent, but if you're not careful, for instance you take input from uh from the command line somebody could give you a just absolutely gigantic uh string and cause a uh i guess at that point a buffer overflow yep so we don't we don't have time to get into that right now but yeah we can do a whole show on on all that stuff but yeah i mean if you you know you're reading the news as we talked about the beginning of the show that guy who hacked the ps3 and whatever and a lot of these hacks these hardware
Starting point is 00:56:27 hacks what they're doing is c is such a low level that they're going in and adding electricity to the traces running between two chips causing numbers to be bigger than they should be and they're just waiting for someone for for a flaw in the c program and for them to be able to get access to some block of memory that was generally restricted. This is good stuff. So, you know, I think call it here for our first episode.
Starting point is 00:56:53 It's been pretty good, Jason. Yeah, I think this has been great. I've had a lot of fun. All right. Well, that's it for today. See you guys in two weeks. Yeah, definitely. See you guys later.
Starting point is 00:57:04 Hope you have fun programming and see go out and learn something new 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 attribution to Patrick and I, and share alike in kind. The intro music is Axo by Binar Pilot.

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