Programming Throwdown - C++
Episode Date: April 9, 2012This show covers C++, a general-purpose programming language. News: Visualizing code to fail faster, the future of the used game market, Prince of Persia source code found. The tools of the b...iweek are sfxr and DC universe online. ★ Support this podcast on Patreon ★
Transcript
Discussion (0)
Hosting provided by Host Tornado.
They offer website hosting packages, dedicated servers, and VPS solutions.
HostT.net.
Programming Throwdown, Episode 13, C++.
Take it away, Jason.
Hey, man. So I had some friends over, some friends of the family over from Florida visiting the San Francisco area.
It was pretty fun.
I got to show them around.
We actually went to the Monterey Bay Aquarium, and then we went to San Francisco proper, I guess you'd say.
And I showed them, like, have you seen that really old vintage
arcade museum in san francisco i saw you post pictures of it it looks pretty cool but no before
that i haven't seen it yeah so folks at home check out the my g plus page and you'll see uh
an original pong which is pretty awesome and uh some other some other really cool like old school
like we're talking like 1920s or something
um arcades like they actually have a bunch of these manual um arcades everything's driven by
servos and all that oh i would love to get one of those in my house oh it'd be awesome they had one
that was a a real bb gun that shot bbs and you had to like hit real targets that moved around it was crazy
bad idea yeah i mean like it shot like of course like low velocity or whatever but
oh okay pretty uh still um yeah but one of the interesting things so i have a tablet i have i
think of a motorola zoom and so i was kind of like playing music in the kitchen with the tablet.
And, uh, you know, my friend from Florida was like, you know, I really want to get a tablet.
I'm kind of really, you know, the, my techie side really wants a tablet, but I have no use case for
it. And, you know, I started, you know, like I bought a tablet, so I feel like I need to like
argue on the, you know, the other side of this. So I was like, yeah, but, but, you know, you can
play music. Now I play music in the kitchen and he's like, well, you know the other side of this so i was like yeah but but you know you can play music now i play music in the kitchen and he's like well you know i could just play music
on my laptop i can carry my laptop from one room to the other and it was like really hard you know
i thought about it and i was like yeah you know i bought this tablet and i really don't do a whole
lot with it so i don't know it really made me think about how I can sort of better utilize it. Wait, so not only did you not convince him to buy a tablet,
he made you feel bad for owning one?
Yeah, pretty much.
Wow.
The only thing I really had was that I watch movies in bed before I go to sleep.
And it's kind of cumbersome to do that with a laptop.
You could hold a tablet up in the air.
So I don't have a motorola
zoom but i have an ipad and uh i will say that although it might be hard to come up with specific
use cases i have uh like a backup system on my computers that you know automatically backs up
to the cloud or whatever just you know for for, for, for safety reasons. And, uh, it sends me an email
when a computer isn't backed up in a certain timeframe. And I keep getting emails from my
laptop because I literally do not turn my laptop on maybe once every other week. Oh, wow. I don't
just don't use it anymore. And the reason being is that, well, first of all, if you have a young
child, like I have a baby that when you're're feeding the baby or holding the baby, you can't hold a laptop or you don't want to risk the baby fluids coming onto your laptop.
Plus, it's just being cumbersome.
But you can hold a tablet and use it while you're having to hold the baby or feed the baby or whatever.
So that's one good use another use i found is that if i'm doing casual web browsing it's a much better
experience um to do that on a tablet than on a sitting in front of a computer or a laptop where
you're not needing to use the keyboard so why is it there and you're having to use this weird touch
pad or a mouse and i just it's not like i find myself sometimes tapping on my monitor by accident
it's like oh why is this not working and uh so i find
that it's useful it's one of those things is not necessary it doesn't give me any capability
really that i didn't have before but it's such a better user experience i can take it from room to
room the battery on my ipad lasts an entire day of light usage um versus my laptop will hardly last
a couple hours normally three hours that's true
you know I didn't think about that but yeah I mean the the zoom lasts forever like I don't even plug
it in like I basically you know when the charge gets low I plug it in but I mean that's after
weeks yeah and like for a laptop I find I almost always use a plugged in because the battery just
tends to run down so quickly yeah I'm sure there are nice laptops which don't do that but um not mine and not most people i know yeah and so so that's a
really good experience also like a tablet if you're going on a car trip it's very easy to just pick up
your tablet and use it in the back of a car um and it's kind of designed for this like pickup put
down so like you can just put it to sleep you know and it's instant turn back on versus a computer
you can't just like set it there for like half an hour know and it's instant turn back on versus a computer you
can't just like set it there for like half an hour and then pick it back up because you had a
conversation because you either would have shut it down suspended it hibernate it like whatever
but it'll take 30 seconds to come back on and that's annoying yeah that's true you know i did
one of the you know most recent times where i used my i my my tablet heavily was I went on a ski bus trip.
And there's this program which will let you use a Wiimote to talk to your tablet.
So I actually had Nintendo games running on the tablet.
And the Wiimote was the controller.
Oh, that's pretty
cool yeah it was pretty awesome i was actually amazed that that worked at all because i kind of
like i had the idea and i was like oh let me just see if there's some program like that'll let me
use the wii mode on the on the market so i just went on market and looked up which i guess now
is called google play oh yeah i went on google play and looked up, you know, Wiimote,
and sure enough, someone had written some driver for it.
Nice.
So, yeah, I mean, tablets, I feel, are very, like, when I go on a vacation now,
I'm not stressed that I need to bring my laptop with me
so that I'll have connection to the internet.
I'll just bring my tablet.
That's true, but one time i got burned by that like
when we went to uh we went to vegas and uh the room only had wired internet and we're so used
to wi-fi that we only brought the tablet and we were kind of out of internet the whole trip
so so the the way around this is that if you know this in advance but you can typically look it up
um and once you have one you have it you one, you don't need to keep buying it again,
but they have travel vacation routers.
So it's like either they have some that are even battery-powered,
but they also have ones that are really small, which are just a very basic,
you know, just supports a few connections that's like $30 or $40 or whatever.
What? Really?
And you can plug it into the wall.
Yeah, it's like a travel router is what it is that's amazing for this very purpose
because the other thing is if you go to a hotel and there's a wi-fi and you pay to get on the
wi-fi some whatever outrageous rate they tend to charge and the nicer the hotel the more they
charge um which is which is terrible uh and so you can use this pay for just the wired plug this in and then
broadcast it and then you know everybody traveling with you can share it versus if they only have
wi-fi or you pay to use wi-fi you're stuck only using because it's like tied to your mac address
typically so you only can use it on whatever device you paid for it on is it pretty small
do they make pretty small ones?
Yeah, yeah.
I mean, I don't have a specific,
I don't actually own one,
but I know people who do.
And the ones I'm thinking of are like maybe a couple packs of card size.
Wow.
Oh yeah, I totally have to get one of these.
Okay.
I'm costing you money.
I think there's a high probability
that I'm going to get one of these.
But for me to know,
I'd really have to construct a graph and do a probabilistic graphical model.
Oh, okay.
You're leading us into our next topic.
Somebody happens to be an expert on that.
No, no, no, no, no.
So we talked last episode about Stanford's online classes.
And so I actually was really bad.
And I had signed up for them, but I didn't realize signing up you know for like interest
wasn't enough to like enroll you in the class so i thought i was enrolled and then i like got an
email like oh hey enrollment is ending this day so i like went to check and it turned out i wasn't
enrolled in you know a couple of the classes i had picked out so i was like no i had missed the
enrollment deadline because they try to keep everybody kind of starting at the same time
because they have forums and stuff and they want everybody to be around the same part of the class
and so uh yeah anyways but i did i'm going through the videos of two of the classes and i'm not sure
that i'll actually do the homework because i've just been really swamped um with family and work
stuff yeah but i have been going through the videos of game theory and probabilistic graphical
models awesome the game theory one is just kind of high
level there's not like programming or anything involved in it um and so that was kind of
interesting uh class is it under economics or is it under computer science i don't know okay
yeah because usually i think i took a game theory class i think i took a game theory class in grad school
but it was actually taught by an economics professor so this one isn't like game theory
like how to write video games it's just like the you know i guess economics version you know the
nash kind of game yeah that's the best so um yeah it's very intriguing and interesting
and probabilistic graphical models is turning out to be quite interesting as so um yeah it's very intriguing and interesting and probabilistic graphical models
is turning out to be quite interesting as well um it there's not an easy way to describe it and
anybody who's not very technical or math oriented would be like why are you taking this for fun
but but the idea is like how do you represent like dependencies so their basic example just
to be short is like you know if you want to
predict somebody's grade in a class like the grade in a class that they're taking is going to be
dependent on their intelligence their sat score maybe um you know the how hard the class is
you know just like various other factors and so you can kind of draw like a dependency graph um
so like maybe sat is really
only dependent on intelligence and intelligence can also be a factor of um what the grade in the
class will be and so then you don't really need it and you kind of just draw connections between
all these different factors and then you assign weights to uh the probabilities of various
conditioning have condition in happening and you can kind of work out things that at first would seem very, very complex to determine.
And I assume it will get even more complex as it goes.
But basically having these models be created by just looking at the data and the algorithms to take data and generate the models.
So when they say probabilistic graphical models, they're not talking about like graphics, like computer graphics.
They're talking about like graphs.
No.
Is that right?
Graphs.
Yeah, like directed acyclical graphs.
Ah, okay.
Gotcha.
Gotcha, gotcha.
Yeah, I got confused with that at first too.
So is this similar to like Bayesian?
Yes, Bayesian networks is a key part of this, yeah.
Okay, gotcha.
Now that we just probably like totally people are like,
oh, man, what? what are these guys talking about?
Well, basically
Bayesian networks is, or they're also
called like deep belief networks.
This idea that like
if like they try to figure out if
like things are correlated, like if one thing can
influence another or not.
So in other words, like if you tried
to see if there was like a Bayesian relationship
between like when you flipped a coin the first time and when you flipped a coin the second time, like a deep belief network would tell you like, no, you know, you flipping a coin the second time, like is not influenced by flipping it the first time.
Like if if the first time you flipped it and you got heads the second time, you still have a 50 50 chance you know but like something else like uh
like weather would have a bayesian relationship like if it rained yesterday it's probably more
likely to rain today than if it didn't rain yesterday you know what i'm saying so um so
yeah so that sounds awesome man i mean i i, I think I might start looking at that class myself.
That's pretty awesome.
So, yeah, so it's been pretty interesting.
So we'll see how it goes.
There's some programming assignments in this one.
I want to do them.
I'm just not sure that I will do them.
Gotcha.
It's hard to do them on the tablet while holding your baby in the other hand.
Yeah.
But one interesting thing that I would like to talk about is that,
uh,
I've done online classes as part of my,
you know,
formal education,
but I'm doing them here.
It's interesting that you're watching the video and I normally,
uh,
people at work think I'm weird,
but I do my programming and I'll have one of these videos running in the
background.
So I'm like half listening to it.
Oh,
that's great.
But every so often they'll interrupt the video with like a quiz question and it's not like scored or anything but instead of asking about something
you've just seen to see if you're paying attention they ask actually ask you to answer something that
they haven't quite covered yet like the next thing they're about to talk about like you know so they
draw some probability and then say what would the probability be and then give you multiple choices
so it makes you like in class when you're actually sitting there you're kind of having this
interactive what is it the socratic method or whatever right like how would you do this what
would it be and so they're kind of trying to elicit the same uh engagement from you and i
thought that was really interesting yeah that's totally awesome man it's killer yeah and the
first couple times i rewind i rewound the
video you don't have that just went back i just clicked back not like there was an actual rewind
um i went back in the video because i thought i wasn't paying attention and it was like oh wait
no they're asking about something that hasn't occurred yet nice so if you get it wrong then
what happens because like it could now they just tell you why and then you watch and they typically explain okay what the quiz just was yeah gotcha so so i think it was interesting i
think if we tried to do some of the um programming problems we'd probably have a lot of trouble
especially me i've been i think i'd fail pretty fast and unfortunately i just don't really have
a way to visualize code so that I can fail faster.
Wow, you're on point today, sir.
We have a new story about this.
So this is actually by, I guess he's a fairly popular blogger, Jeff Atwood.
I think he currently works at Stack Exchange, which is a startup most of our listeners are probably seen before um and he had an article
where he's writing about i guess he actually posted a video that somebody else about a
presentation and then a link to a website but uh it was more just the notion i wanted to talk about
which was that um he points out that we've kind of almost regressed in the advanced this of our
ide's so integrated development environments
that he's talking about.
If we could do better at trying to show programmers
the impact of what they're writing,
that they could think through the possibilities
much more quickly.
So that's kind of vague and okay,
I don't know what you're talking about.
But at a basic level, if you've ever used Eclipse,
first time most people use Eclipse,
or maybe less so now because other things do it as well,
but they draw the squiggly line,
like the incorrect spelling under any sort of compilation error
that you have in the code.
And you can just kind of hover it over,
and it tells you what the error is, offers suggestions.
And this is a very quick way to actually help you correct the problems.
And it's a delight.
And so that's like at a basic level now we're like i'm
at the point now we're like i i purposely so for example like let's say i need to reference
something in another file like rather than like add the statement at the top this is like include
this slash this slash my file i just put what i want in the code i wait for eclipse to squiggly
line it yes and then i go over it and I have Eclipse add the line
because I'm too lazy to do it myself.
So I'm lazier than that.
I just add a bunch and then I do Control Shift O,
which basically has Eclipse try to guess
at what the right imports are
and ask you if there's any sort of ambiguity.
That's hilarious.
I didn't know that existed.
Yeah, it also deletes anything that you have that isn't being used.
Like if you have any imports or includes that aren't being used, it goes ahead and removes them for you.
Oh, that's awesome.
So that's like at a basic level. even more advanced which is like if you had like a pathfinding algorithm or a PID proportional
integral differential a method of controlling something and you wanted to see how it would
be affected based on various input conditions you could do graphical representations of it
you know and allow like a person to have a slider and see what would happen as they adjusted various
thresholds in their code or even better like you, take it up a higher dimension and show them a plot of,
on like X, Y, here's what various inputs and settings
for two different variables will give you.
And just like, wouldn't it be cool if we could think about this
and kind of try to make our development lives easier by doing this?
Yeah, that's awesome, man.
I feel like like you know like
ide's do a pretty good job about code like but um like you know about analyzing code fixing code
things like that but like that kind of stuff's actually really hard to do like they spend a lot
of time because there's lots of customers of eclipse right but for most things like like
scripting engines for games and
things like that it's just in general it's just like really hard to do this kind of thing where
it's like you're constantly simulating what would happen as you're making code changes and stuff but
i mean if there's some way we could like we could make that happen like in a way that was like
generic it'd be amazing it's one of the things people talk about for
concurrency that multi-threaded is so hard because it's just too much to keep track of in our brains
and so we you know really have to advance the state of the compilers and the development
environments to help us with this yeah yeah it's one of these things that like doesn't seem like
look at just even just undo right i mean think about undo undo you have to there's only two there's only two ways i can think of anyways
to implement undo one is for everything you could possibly do in your program you have to have
another function that undoes it right that's pretty hard and then you have to keep a list of
all the things you did that probably isn't the way most undo's are written, right?
The other way is that anytime you do anything, you keep like a snapshot.
And then undo is just going back through these snapshots, you know.
But both of those are hard, you know.
One means you have to be able to serialize, which means serialize means turn like a bunch of data that you have in memory,
or like a bunch of things that you're representing, like turn them into a block of ones and zeros
that you can load back later. So you either have to like serialize everything, so that you can
deserialize it when you do the undo. And then just keep all of these serialized copies of
the world around.
Or you have to, as I said before, create a reverse function for everything.
And I mean, think how hard that is.
Let's say you have a function that deletes a line of code.
Well, the reverse function has to, like you have to have the line of code somewhere
so that it can know what you deleted.
You know what I mean?
Just adding an undo is pretty hard.
And so something like this is really hard, but it'd be totally awesome if it was
yeah i'm totally not saying it's easy it's very hard yeah yeah yeah but it'd be totally sweet if we had something like that like imagine like it's one of those things that's interesting to think
about yeah like you have some kind of game and you're like oh what happens if i like change like
the ai behavior if i make the ai more aggressive and, and you're like, oh, what happens if I, like, change, like, the AI behavior?
If I make the AI more aggressive?
And, like, while you're playing, it's, like, getting more aggressive.
Or what if I change gravity?
Or, you know, it just does all these crazy things.
Yeah.
And I think there are some things that get closer to that.
Like, I don't know if you've ever watched any of the demo videos for the Unity game engine.
But they have some stuff that's kind of like that, where it allows you to kind of just jump in the game very quickly and see the effects of the changes you've made and
then kind of jump back out oh nice yeah i haven't seen that that's pretty awesome or maybe i'm
making that up i think i recall that okay maybe i'll have to send you some videos to prove it
all right so next article before before you lead me into it uh so there's a lot of news coming out
about the next generation of game consoles the wii u i
think is supposed to be out this year or very soon and the next generation xbox and playstation
are supposed to be out and uh i don't think that wii u has had anything about this but the xbox
and playstation have both had uh these rumors come out that they're going to block uh the ability to
have used games so either the distribution will be all online,
so think like Steam,
or that you'll have these one-use codes,
which are becoming more and more common in games
for at least some portion of the features,
that you have to enter a serial number
or some sort of activation code to be able to play the game.
And now it's mostly used to play it online
or to unlock some special in-game thing.
But in the future, you could actually just block the game if you don't have this code.
And that will not allow people to sell the games when they're done playing them.
Right, right.
So what will happen?
What will that do?
So will that make the prices of games lower because now the you know people
are making more money or will they not sell as many copies because you won't buy a 60 game
knowing that you can sell it back for 30 later yeah you know it's interesting i don't i don't
really know much about the dynamics of used games like i've never actually returned a game um but i i it makes sense you
know like it's it's effectively a waste of money to keep around a game you're never gonna play again
so so the way i see it is like you know i have an xbox 360 um but i don't think oh for my birthday
i got a game that was new but aside from that one game i play only games
that are like two years old and i just find like i go and look at the magazines online or whatever
and find like what were the best games of two years ago and then i buy them really cheap used
and i have no desire to play the latest and greatest games i love playing really awesome
old games and then i can get them for like five5. And I much prefer doing that. And this way won't allow me to do that.
But then if you look at something like Steam,
I do buy games on Steam,
games that are, again, you know, like nine months, a year old,
and I can buy them for very, very cheap.
So what you're saying is like,
if they keep reducing the price over time as the game gets older,
then for you as a consumer it's effectively the same
but the difference is instead of gamestop like getting this like essentially like arbitrage
um you know you're buying it straight from the publisher again and the person who
would have sold the game new can't so the yeah so i i don't know exactly what i'm saying but uh i i do think there is an interest
here like to see what will happen and like one part of me says like oh it's in their you know
ability to ban used game sales if they want but then the other part of me says it's my freedom
like i should be allowed to sell my game like i own the game and i don't really like the idea of
we're going to this subscription or license-based model like you bought this software cd but you didn't really
you don't own the software you own permission to rent it for an you know unlimited time but only
for you and i don't really like that really yeah you know a lot of people come up with this argument
like with music and movies and things like that personally it's it's never really bothered me
it only bothers me when steam goes down and then you know it's one of these things it's so funny
right like i could go weeks without playing a video game but then like steam goes down and it's
just like instantly it's like oh i really want to play and i can't you know what i mean like it's
yeah i don't know it's like the forbidden fruit i guess or something there's something like psychological thing going on there but uh well but yeah it's
really frustrating when you can't play because it's down that's one aspect of it so always being
needed to be connected to the internet or at least often being connected that's kind of annoying
because you could be extended periods of time where you're not yeah and that would be bad but
the other thing is like i run into occasionally where like i have a computer and then i have my laptop and my wife has a computer and i
feel like you know i want my family like i don't want to give it to other people but i want my
family to be able to share one version of this and i don't like the idea that i have to keep
buying it over and over again oh that's what amounts to like one shared use because it turns
out like we're only ever using one at a time like i'm not
using at the same time as my wife at the same time as you know my kids like it would only be only one
of us using it at the same time but we want to be able to have it on different computers at the same
time yeah like steam kind of allows that but like other things don't it's pretty bs that like you
can't have two instances of steam running at the same time so like in other words
like i couldn't play one game and my wife play a different game on the same steam account at
the same time like that seems ridiculous you know what i mean like like not being able to play the
same steam game i i mean i personally think that's not entirely fair but i understand how that could
be exploited you know but if you have three games you should be able to play all three of them at the same time so wait so with steam if you have the same account
you can't even like own two copies of the same game in the account and then like two people
play them you have to have right like a separate account on the second version yeah as soon as as
soon as you log into steam it kicks you out of all your other instances, like if there are any.
Yeah.
Well, speaking about changing like offline or something.
Sorry.
Oh, no, no.
I was going to transition.
That was going to be you.
It's okay.
So Prince of Persia.
I remember that game.
That game was pretty awesome.
Yeah, Prince of Persia, definitely no DRM on that. It came out 23 years ago.
But did you ever beat that game or get like really far no that game was so hard man like like we all played it when we were kids
and i don't know anybody who got you it actually had different themes like you started off in the
castle and then you went to like some cave theme supposedly i i think it's i don't think any of
this really i don't think i ever beat the first level that's what i think it's i don't think any of this i don't think i ever beat
the first level that's what i'm saying like i don't know anybody who got past the second or
third level of that game and it has like supposedly like 20 levels or something like that what yeah
it's like uh there's another game like this uh oh it's like frogger like did you know frogger has
like all this complexity like after you get past this, like, the first level, you have to get all the little frogs in the top, right?
Then the next level, the cars move faster, and there's, like, a snake that goes on the sidewalk before you get to the turtles.
I think I've been there before.
Yeah.
And, like, it just gets crazier and crazier.
The third level has, like, alligators.
And then, like, the fourth level has like alligators and then like the fourth level has
like other kind of cars the fifth level like it gets to the point where like you have to save
your girlfriend frog and she has to go in the same hole as you yeah no it gets i'm serious dude
you have to watch the video or something it's crazy um anyway so okay so why we were bringing
up prince of persia yeah so the prince of persia awesome
game came a long time ago maybe we'll go back and play it now that we're older and we'll still suck
at it but anyways uh i have it on my ipad but i'm still just as terrible at it that's hilarious
um yes the guy who wrote prince of persia lost the source code and uh i actually from the article i don't think it talks about how he lost
it um let me just scan it really quick along the way he misplaced it yeah so somehow he lost the
source code maybe a hard drive crash i don't know and uh uh you know i guess forever like you know
he he always kind of wanted to go back and have the original i'm sure it's been recreated 100
times but there's a lot to be said for have the original. I'm sure it's been recreated a hundred times,
but there's a lot to be said for having the original code
with the comments and maybe the jump used to be longer
and he shrunk the jump speed or something.
You see the organic nature of the game, right?
So it turns out his father was going through some of his old boxes
and found the source code on some floppies
and uh he's going to uh get him and he's got somebody who's going to port the game i'm
assuming to sdl or something something where we could play it on modern pcs and then open source
the whole thing cool so yeah it's pretty cool you know i mean when they open sourced like doom
and quake 3 and stuff like that,
it's always like, yeah, I'm going to make my own game.
And then you get into it.
It's like the code is such crap.
Like you'd be better off buying a game engine, you know.
Well, let's be polite.
Let's be polite.
It's a complex game that's very difficult.
And the people probably were awesome programmers.
But it is very difficult to read not knowing what's going on.
Yeah, actually, yeah, you're right.
We should do this justice. so the code's crap but no but basically
you think about it you know prince of persia you look at the video and we have the link you can
watch a video of the gameplay and you think oh you know i could hack that up i could write that
in javascript or something like an html or something you know but at the time this totally pushed the limits
like like having like a panel that fell when you walked on it was like whoa big deal like like he
had to like write his own memory manager to make that work or whatever you know because so so
because of the because of the you know for one the technology being new like either they were pioneers inventing the technology
as they went um or you know it just come out a combination of that and just the limited
computational resources there's just the code is almost always full with filled with tons and tons
of hacks and things like that yeah but that in and of itself is interesting to read so when the
source code comes out we'll definitely revisit this and uh you know take a look at what sort of you're gonna go through it
and give us your uh line by line commentary yeah i'll dive through the code line maybe
i'll do a file by file it'll probably all be in one file prince.c next episode will be jason reading
the code of prince of persia to us yeah exactly bedtime stories with jason yeah that'll
definitely i'll make myself fall asleep oh no are we ready for our tool of the bi-week tool of the
bi-week are you go first what's your tool well uh keeping in my theme from last week uh or two
weeks ago of completely absolute opposite of tools and instead things
that waste your time uh this week not that i've had much time to play it but i did play a little
bit of dc universe online which is a massively multiplayer online role-playing game and it's
free to play now and i'm a lot of these that are free to play like i've tried them a couple times
and they always want you to end up buying something oh but this one actually has a lot of content
like i didn't feel like i don't even know where you were supposed to buy something at like i was
just playing and it was not a big deal wow and so that that's really cool and i didn't get very far
and like i said i've been pretty busy so i pretty much just installed it and played around for like
an hour or something um but it is really cool so if you're uh interested in being some of
the cool comic book heroes uh check it out dc universe online.com and it's free to play now
and as far as i can tell you can do a lot in the game without needing to pay anything extra
so how many people do you play with like i know it's massively so there's different kinds of
massive multiplayer right like there's eve online where it's like literally like thousands and thousands of people yeah
and then there's also like on the other end of it there's yahoo games which has like 10 000 people
playing chess but you're only playing with one person you know what i mean right both of those
are considered mmos but you know so where does this fall in that spectrum so um i don't know that i
ever ended up kind of like doing a mission with somebody else but it kind of depends on the
mission like there's some stuff you can just kind of go off and do yourself and then there's other
stuff where you can be in a party of you know probably like six or seven people i don't remember
exactly how bad it was but yeah so it's not and i mean sometimes you'll be in an area where there
are many many people but it's not like you're all you'll be in an area where there are many many people
but it's not like you're all doing the same thing together oh did does they have a do they have a
pretty good uh character customization yeah yeah yeah because i was playing star trek online and
they gave you like a little bit too much freedom with the character customization and
uh i'll just put a screenshot or something
but it's it's pretty epic i have this i have this character and she has so you know they have
like a ton of sliders like you ever play this game where it's like wait wait wait should we
just cut this off before we even go there no no no it's not it's not no one's gonna be offended
by this but but they have you know like you play you play like, I think Skyrim has this,
where it's like they have a slider for your nose,
and you slide it all the way and you get a huge nose or a tiny nose
or slider for your cheekbone height or whatever.
All this crazy stuff.
So this game was like that, just pages and pages of sliders.
And so I made a character that had huge legs like really really long legs and then extremely tiny
waist extremely tiny torso extremely tiny neck huge arms and then a huge head and so it basically
looked like a four-armed octopus and like because the legs were so big and disproportionate the character floated this is on
star trek online the character floated above the ground because it was so glitchy the character
like the legs clipped through each other when the character walked and the head like clipped through
any doorways because the character's like eight feet tall or something and so and the arms were
so long that they cut through you know the legs
too like constantly clipping through and uh you know i played a mission and literally like i'd
walk around like the hub area and people would just give me money and laugh at me because my
character is so bizarre then finally we did a mission and at the end of the mission everybody
did some kind of like dance or salute or something and and
my the rig got so thrown off with these proportions that the character actually the arm inverted
like the arm went inside like through the inside through the arm socket like back out the head or
something it was totally awesome man yeah my character like purple skin
so if you see somebody matching this description online say hi yeah that's probably me oh man
so all right so what about your tool the tool of the bi-week is uh x f x oh sorry sfxr which is a pretty cool 8-bit sound generator um and a lot of people have used
this if you've ever played the game vvvv it's like a like an indie game like a platformer and
it looks like it was a commodore it's a way to die 10 times in three seconds yeah exactly i think i
died like they show your death count at the end of the game, which is ridiculous, like 8,000 or something.
Wait, you beat the game?
Yeah, I did eventually.
Yeah, because you have...
You made me feel so bad.
You have infinite lives, right?
So eventually you'll get to the end.
Yes, but I just kept dying for like an hour.
Yeah, I pretty much, I died for like a week, and then the game ended.
You've died 1,000 times.
Congratulations, you win. Yeah congratulations you win yeah sticking through it
but uh this guy was part of a indie game hackathon where it's like make a game in a day kind of thing
and uh he had some background in audio and so he he made an 8-bit uh you know sound generator and
it's pretty cool like you can you can actually put bullet and it
will like click random and it'll make a bunch of random, like eight bit sounds with square and
triangle waves that, that kind of sound like a bullet. Like it's, it's hard. I don't have any
background in audio, so I don't really know how to explain it other than to say, you know, there's a
bunch of buttons, but not so much that it's overwhelming and the buttons are
pretty intuitive like like angry or something like that you know and you just sort of like
weld all these adjectives and nouns together and then click random a bunch of times until you get
the kind of sound you want but it's really cool yeah make some great sounds exports to wave which
you know then you can put in audacity and export to Aug or MP3 or whatever.
And yeah, definitely, if I ever need to make sounds for anything,
I'll definitely be using it again.
So good stuff.
Well, if you're ever making a game,
what programming language would you use?
Well, if I was making a game,
I'd want something that had a lot of performance,
so I'd definitely be writing that in c++ oh okay well that that was maybe a little bit unfair but it's a transition to our programming
language of the episode it's a shame we haven't talked about c++ and people just can't make games
because you know we haven't given them any guidance yeah i think there's other ways to make games too but yeah probably anyways so the history of c++ now c++ uh is obviously the plus plus meaning that it wasn't the first
so there was something before it and we've talked about that before that was c yep
and uh somebody had the idea to kind of make c better uh and that person was, would you care to pronounce?
I'll do my best.
I think it's Bjarn Straustrup.
I don't know if that's right or not.
I've actually only read the name, so never actually pronounced it.
Yeah, so he, Mr. Straustrup, we're going to get all sorts of corrections.
Yeah, he had the idea
that you know he wanted to to add classes to c and so um you know with anything as c was coming
out people were hesitant because they wanted to write everything in an assembly and then as c plus
plus came out you know oh we're gonna have these classes thing he wanted to be able to show people
look it really is just kind of like c but better and so the original compiler was actually just to compile c++ to c and then use the
existing c compilers to generate machine code yep i mean if you put yourself in his shoes like people
had been really working on c compilers for a long time um you know and they were highly optimized
and things like that and you know you want to invent your own language.
If you make your own compiler to assembly,
it's not going to be anywhere near as good as C
because they've done so many optimizations.
So as a first step, it makes sense.
He wrote the C++ compiler to go to C
and then you can use your highly optimized C compiler.
It's sort of like what's going on now with LLVM.
Yes, yes.
And, I mean, people eventually started to come around and say,
wow, this is nice.
But there was the original versions, and you'll still hear
if you go to somewhere where people have been programming for a long time,
especially performant programs for a long time, a lot of people still have a hesitancy of C++ because they think it's so much more inefficient than C.
Right.
And that just has to do with the idea that those original versions, when you were translating from the C++ to the C, it generated kind of more C code than a hand-coded C program, just like, you know,
program written in C generates typically more instructions than a hand-coded assembly program.
Yep. Yeah, totally. I mean, I think that one of the things too is, and, you know, we've touched
on this before, but just to recap, it's in the end, it really comes down to how you use the
language. Like for C++, for example uh you know as we mentioned
it's c with classes if you have uh you know let's say you're doing some kind of like fluid dynamics
right and so you have a bunch of a bunch of cells which have you know water in them that are moving
in a certain direction well if you make a separate class for every cell and then you try and do some kind of fluid dynamics
where you go to all the classes and then in each class you do some like computation that's going to
be way slower than just having an array of floats right or something like that so like that's an
example where like you don't really want to make a class for like everything you just want an array
of floats and then maybe just one
class that does like the fluid dynamics for the whole world or whatever you know so you know in
the beginning with most languages people it's a combination of the language isn't optimized but
then also people don't really know what to do with the language but then over yeah over time people
start you know the language as it gets adoption, people start to understand the best ways to use it.
Now, C++ doesn't have versions like some other languages.
Like, there's not C++ 1.0, 2.0.
Right.
There's nothing like that.
Yeah.
Yep, go ahead.
There is a new version coming out.
And have you studied this at all?
I did look into it a little
you know having some background in c++ i was very intrigued like oh they're upgrading you know what
are they going to add like how are they going to bring this into the you know kind of 21st century
and uh so it was originally you know going to be called c++ you know 0x or whatever you know
implying that it would come out in the single digits of the 2000s.
But they kind of missed that deadline
in getting agreement on what they were going to put in.
So I think the official name ended up being
C++ 11.
Oh, I didn't know that.
Coming out in 2011.
I always thought it was C++ TR1 or something.
Oh.
Well, I think that was one of the early versions
of the 0x before it X fully ratified or whatever.
Got it.
And so C++ 11, which we haven't talked about all about what C++ has, but they just try to make the language a little easier to use while at the same time keeping it being powerful and adding try to add some stuff for, you know, the idea of multi threading and and concurrency which wasn't as big when c++
of course was in earlier versions and then just making some things nicer like kind of inferring
what values should be as opposed to having to make them explicit or if you have like a constant
function you can create an array by calling that function and you know like adding a number to it
so like if you have a function that just returns the number five, you can make the size of the static
array be, you know, calling this function plus two, and it'll be, it knows to make it seven.
Whereas before that would have been illegal because in C++, the static arrays, you know,
have to have a constant size definition gotcha yeah one of the big things
that's in the new c++ um that that uh you know it's probably actually it's probably not that big
but it's really important for me anyways because uh it's good for people who want to develop quickly
is something called a shared pointer and so what this is is as we talked about in the c podcast
you know c++ and c most of the time you're dealing with pointers that you allocate.
So you say, you know, hey, computer, give me a chunk of memory so I can do something with it.
And usually, you know, in C++, in C, you'll say malloc.
In C++, you say new.
But they do, like, close to the same thing and uh and then later on when you're done with that
memory in c you would say free and then the chunk of memory in c plus plus you say delete but it's
the same kind of thing once you're done with the memory you have to delete it otherwise uh you're
in control of memory management right right so and if you don't delete the memory then eventually
you will run out of memory because you'll just keep creating, asking the computer for memory and not returning it back.
Right, you'll leak memory.
So what shared pointer does is you wrap your new inside the phrase shared pointer,
and it knows when to delete it.
So basically it does what's called reference counting.
So if you say, like, shared pointer x equals new int,
well, now, like, x contains a reference saying,
hey, right now, x is using int.
So, you know, we got to keep it around.
Then later on, if you say y equals x, now there's two references.
So behind the scenes, it's saying, hey, two people, y and x, are both using this integer, so we can't free it.
And then eventually your program keeps running, keeps running, and then just as part of the program, y and x, let's say, fall out of scope.
Like maybe they're part of another shared pointer like they're in a class that is itself contained in a shared pointer or your program ends or whatever um it says hey
there's no more references to this int so now i can free this int so it does all the freeing for
you um that's one really nice thing that was added in the new c++ so does that mean they've added garbage collection to c++ um boy that's a
hard question answer i guess technically so so for people i don't know if we've explained garbage
collection i think we did a little when we talked about java but i'm okay well we'll explain it
really quick garbage collection is the idea that um you know over time there so some languages
like Java you don't free things and but because of there's like actually so no
it answers a question now now then I thought about it no it doesn't implement
garbage collection and so what that means is let's say you have um shared pointer x that uh points to
some class and then that class has a shared pointer y that points to x so you have a loop
right so x refers to something that has y and y refers back to something that has x
in java the garbage collector will run every now and then and it'll say hey
you know these two things are referring to each other but they're nothing refers to them
they're isolated and there's actually no way to get to x because there's no way to get to y and
y is the only thing pointing to x so so we're going to delete x and y that's garbage collection or that's one part of it um so c++ doesn't do that
so actually if you have a circular reference and um you don't sort of clean it up yourself
then um you'll leak memory that way so that's actually a really good point very subtle but
it happens yeah yeah so i mean it is kind of of a loose approximation of it in some ways.
But some people don't like garbage collection because the idea that –
and Java has gotten better about, like, allowing you to specify when and how garbage collection will run.
But the idea that something is going to run that you don't have control over.
And a lot of uses of C++, people want to have absolute control over everything that's running and when it runs and how it runs.
Right. want to have absolute control over everything that's running and when it runs and how it runs right like you'll see in a lot of like a lot of games especially like the critical you know
graphics or physics loop in a game they allocate everything up front so in other words you know
they create an array like right when the game starts they create an array for like let's say
it's nba live some basketball game they create an array for 30 players like
they include the players on the court and on the bench right and for 30 ragdolls in their physics
engine and they just that's it you know and so so when the first player gets initialized like after
you pick your team you pick philadelphia 76 or whatever. And it starts initializing players.
There's already locations and memory for those ragdolls.
And then it just kind of fills in the specifics.
But all of the memory gets allocated up front.
And that's because, as Patrick's suggesting, you don't want to be allocating and deallocating memory while the game is running.
Because what that means is you have no way of guaranteeing how long something will take.
Like, if you're writing C++, you're often in an environment
where your boss is coming to you and saying,
look, Patrick, you have 10 milliseconds.
You know, like, every cycle you have 10 milliseconds.
That's probably a lot.
You have one millisecond dedicated to like the graphics engine and so if
you ever take more than a millisecond some red flag is going to go off right the game's going
to stutter yeah that's right you're going to get frame drops yep and so uh yeah if you use something
like like python or java or something like that you run the risk of oh every 300 frames or so the garbage collector kicks off
and uh now you're you're you're hiccuping so so we we got a little ahead of ourselves maybe
somewhat talking about kind of how c++ is used um but so what are some of the features that c++
has that people like yeah so these are the big things that, you know, as we mentioned, C++ is used for like really time critical programs and things like that.
But you might ask yourself, well, why not use C?
Like what does C++ really bring to the table, right?
And one of the biggest things is obviously classes and the things that come with classes like virtual functions with inheritance.
C++ actually has multiple inheritance.
Wait, what does that mean?
Yeah, so in Java, we might have talked about this inheritance,
but basically, let's say you have a class.
Let's say you have a class called shape.
Shape.
That's amazing.
Okay, so you have shape and then square and circle both inherit from shape.
And shape is an abstract class, which means that shape contains some functions that aren't implemented.
And because it's abstract, you can't actually create a shape.
So in C++, you would say abstract class shape, right?
And you'd give it a function, let's say area, get area.
And get area would be what's called a pure virtual function.
So in C++ lingo, pure virtual function means that someone else who's implementing or inheriting this
class has to create the get area function because the shape class can't
do it so then you have say square and the square class inherits from shape and
square class will define get area so it's a you know int get area and then do
side time side right you'd
also have the circle class and the circle class inherits from shape as well
and it's get area function would do what radius times pi right or radius was it
radius squared times pi or something for the area yes yes pi r squared yeah
that's right so so it's two different classes that have different get area functions, but they both inherit from shape. Then what you can do later on, let's say you're making a physics engine or something, you can have an array of shapes, even though you can't create a shape directly, you can do what's called downcasting. So you can have an array of shapes,
and then you can say, oh, I want to add a square to this array.
So I can say, like, shapes.add new square,
shapes.add new circle,
shapes.add new square for another square.
And then you can go through this list of shapes
and get the area for all the shapes.
Even though, you know, you don't necessarily know which one's a square and which one's a circle,
you know that both of those have the getArea function
because they extended or they inherited from shape.
So that's kind of in a nutshell inheritance.
Now, what multiple inheritance means is kind of what the name suggests,
that you can inherit from multiple things.
This is really useful.
Especially, let's say...
Let me think of an example.
Let's say a square is a shape,
but a square is also something that can be drawn, like a renderable.
You're making a game.
You have these squares. Let's say you're making a game you have this these square let's say you're
making like angry birds or something right so uh and you have something called circle which is going
to be your angry bird so circles are renderable like you want to actually draw you know a little
bird shaped circle but then it's also a shape in the physics sense like you want it to bounce like a circle so your your class your
angry bird class would extend would inherit um shape and inherit um circle at the same time so
multiple inheritance actually gives c++ a lot of power and java does try to handle the same thing
but it does it through what's called interfaces. So you can
kind of inherit multiple inheritance by inheriting multiple interfaces, but interfaces are restricted
in what they can be. And C++ basically allows you to inherit from multiple things, which are
more complex than just an interface. Right, exactly. And then one other comment, I think
abstract is a Java term, right? I think in C++, the class just has a function which is defined as virtual
and then set equal to zero to make it an abstract class.
Oh, really?
Yeah, I think you might be right.
I thought it was.
It's okay.
I've been doing Java for too long.
We both know C++, but we've both been doing Java recently.
So if we get a little sketchy, we're sorry.
I thought that, is it a virtual class then or no?
It's a virtual class if it has at least one virtual function.
Oh, that's right.
Is that right?
You're totally right.
So yeah, and C++ is just a class.
You don't put abstract in front.
In Java, you put abstract in front.
But if you, as Patrickrick said if you have any virtual
functions and the way you make a virtual function is you put the prototype like in the case of the
shape you'd put you know int get area um and then parentheses but then instead of and all right
yeah virtual and get area in parentheses but instead of putting uh you know function there you'd put equal right you'd
put equal zero and uh that lets the compiler know that you know anyone who that that anyone who
extends or anyone who implements this function or this class is going to have to create the get
area function yeah they must override it because you can't come up with a good generic implementation
of it right yep the other
thing that c++ allows you to do is something called templating um which a lot of high level
languages allow you to do but this is basically instead of having to have so like in let's say
get area you might want to be able to get areas with integers but maybe also doubles or maybe i
don't know like imaginary area is that even possible i don't know, like imaginary area. Is that even possible? I don't know. Complex numbers.
Complex number area, I guess, maybe.
Anyway, so you might want to have
like all these different things,
but instead of having to write,
if the way it's handled is very similar,
then you may not want to have to write like
get integer area, get double area, get float area.
That would be very tedious.
So templating allows you to write the function once
if area is just, let's say in the case of just squares and rectangles, width and height,
and you're just multiplying together, and it doesn't matter what type they are,
then basically it allows you with a special syntax to define like,
hey, the person has to specify what type it is when they call this,
but I don't care what type it is.
Or even like I care, but only in a certain way.
And so that then it's just, you know, width times height.
And you don't care if those are integers or floats or doubles.
It'll just kind of handle it for you.
Right.
Yeah, it's really interesting what the compiler actually does with templates is,
you know, it looks at all the times you use the class
and it creates that many copies of the class.
So in other words, let's say you had a list and the list class was templated.
Then later on in your program, you have a list of integers.
And then later on, you have a list of shapes.
And then later on, you have a list of floats throughout different places in your program.
Well, the compiler will count all
those up and then it will actually take your list class and create copies of it so you'll have a
like a float list you'll have a int list you'll have a uh you know a shape list but it does all
this for you like behind the scenes so you don't have to actually go through all the trouble of
duplicating copying and pasting all of your own code and that is powerful the reason that it does that allows you to do which we won't
get into because i don't even know if you could describe it in a podcast it'd be kind of hard
verbally but templated meta programming oh yeah that that which are programs that you write
that get run at compile time not at run time yeah totally so there are some things
you need to do yeah i'll just i'll go real real quick okay all right you can try there are some
things that you need to know at compile time but you need to use equations let's say you have
three plus four in your program well you know the computer the computer the the compiler doesn't know that that's
seven the compiler like you have to actually run the program and then your computer once running
the program will do the three plus four and then return seven but there are some things like some
computations that need to be known at what's called at compile time. So like while the compiler is compiling,
it needs to know that this three plus four is seven
or this X plus Y is whatever it is.
And so to actually do this plus at compile time,
you can actually do things like this using what's called,
as Patrick mentioned, template metaprogramming.
But it's pretty, it's very rare that you have to do something like that,
but it does come up.
It's one of those things that's really cool,
but if you use it, chances of other people
understanding what you're doing are low.
Yeah, exactly.
Something else that C++ adds is operator overloading.
So once you define a class,
it would be really nice if you could do something
like I want to add two of my classes together.
Like my classes represent probabilities and I want to add these two probabilities together and have them be added in a way that is unique to the probabilities of my classes that are defined.
And so I want to redefine how the plus is what happens when I say you know my shape and then the plus sign and or
you know my probability the plus sign and then you know another instance of my probability and c++
allows you to do that so you can still use the plus sign but it knows to call special code that
you wrote to do that operation yeah totally and i don't think java supports that right
oh you put me on the spot i'm not sure i mean i know it didn't used to it i mean
now they've been adding a lot of stuff to joe no i'm pretty sure let me just double check but i'm
almost 100 sure the one that we you know there's many many things that we can talk about but
another one we talk about is that c++ adds exception handling and uh this is kind of a
controversial topic you know whether or not exception handling and uh this is kind of a controversial topic you know whether
or not exception handling is something that should be used or shouldn't be used how expensive is it
how cheap is it and everybody's got their kind of thing but c plus plus if you want to use
exception handling so throwing and catching exceptions it does add that capability so
interestingly enough i'm really glad i looked this up. So Java doesn't support operator overloading.
So what that means is, and the example they use is there's a class in Java called bigInteger.
As the name suggests, it can hold an integer of effectively infinite size, right?
It'll just keep allocating memory as much as it needs to hold any size number.
And so to add two big integers, you actually have to say a.add parenthesis b.
Because you cannot do a plus sign b like you can in C++.
But Scala, which is a language derived from Java that we probably should do a podcast on sometime.
Scala actually does have operator overloading. Oh, okay that's pretty wild yeah that's cool but yeah c++ uh as patrick mentioned
clearly has operator overloading and it's amazing so useful it is uh but it can catch you if you
think plus does what a normal plus does and somebody redefined it to be something else
yeah that could be dicey or they can redefine what the square brackets are so normally that's like
indexing an array but you use it to mean something else yeah that could be bad yeah i don't think you
should do that typically if you if you operate if you overload an operator there's this understanding
that you're going to do something that's intuitive to everybody so like
even if you could you know let's say add two graphs together typically you'll use a function
for that just because you want to have a function with a descriptive name like maybe like like merge
graphs with edges or something like that like you want to let the person know kind of when you add these two graphs together what are you really doing if you if you do
like just an operator a plus sign for two graphs then what somebody else
thinks adding two graphs is might differ from what you think that can cause the
strengths of C++ we already kind of started on them and some of it is that traditionally it's been kind of the, well, you know, along with C, kind of the very fastest way to get stuff done.
Or at least relative to most other programming languages.
Right.
Like just to give an example, I wrote a, I actually wrote a NESizer, which is just a name I made up, but basically it takes pictures and it does like,
takes the NES, like the old Nintendo palette, like the color palette for Nintendo, it's like 54
colors or something. And it, um, it does like this K-means clustering. It does like way more than it
really needs to, but it, it tries to make the image look like it would if a nintendo like video
game designer drew it so you could just give it a picture of your face and it'll look like your face
like belonged in a nintendo game but awesome but yeah i wrote it in python and it takes like
probably 10 15 it probably takes about a minute to run. And to test it became hard to debug
because it would literally take a minute.
I'd find a bug, it'd take a minute.
And I rewrote it in C++, and it runs almost instantly.
Now, there were probably things you could have done in Python
to make it run faster.
Yeah, I mean, I could have used...
But the idea is that out of the box,
the generic way of writing it in Python versus C++ will end up being faster. Yeah, that's, I could have used... But the idea is that out of the box, the generic way of writing it in Python versus C++, C++ will end up being faster.
Yeah, that's a good point.
So Python actually, ironically enough, Python has what's called C types, which adds support for C and C++, like, data structures.
And I could have used the C types array and stuff.
So don't take that as a slam on Python or anything like that.
It's not like your code will just... It's not magic
or anything like that.
So, you know... But yeah,
if you just code normally,
your code will
typically be much faster on C++.
So another thing is that
the object-oriented allows for
collaboration amongst very large teams in an easy way.
So Jason's working on the shape class, and I'm going to inherit from it.
And I don't really – well, that's a bad example.
So we both have the shape class, and I'm going to implement square, and he's going to implement circle.
And, you know, as long as if we have kind of the interfaces between those defined, we can all work at the same time on our own pieces of code.
And that's very nice.
Yeah, definitely.
I mean, it makes it very easy to write APIs.
And one thing about C++ that a lot of languages don't have,
C++ has separate header files and source files.
And so the idea is the header file, also called like the.h or the.hpp file, will sort of have a description of what your class looks like.
So it'll say, hey, you have this class.
It's called Patrick Wheeler.
It has this function called getArea.
It has these functions.
You have this shape class. It has getArea has you know some other thing like get boundaries get center or something
like that and then it also in addition to the dot h file there's a dot cc file or dot cpp file
depending on what extension you use but both of them are the same, which actually has the implementation. So if you have some class, let's say it's file reader, you know, the.h file would just show,
like, there's a function called read, there's a function called read line, there's a function
called close. But then if you go to the.cc file, you'll see actually what read does and what
close does, you know, what read line does.
And so this is really nice
because you can give people the.h file
and they can get an understanding really quickly
of what your program does
without having to,
or like rather what the architecture of your program is
without having to know what each function does.
So if you're on like a huge team, you and the other thing is the dot h files you might make
those like up front and not change them very often so let's say i'm working on some graphics engine
i can just hack together some dot h files i can say okay i know there's going to be a
graphics engine and it's going to have a list of shapes and the shapes there's going to be a graphics engine, and it's going to have a list of shapes. And the shapes, there's going to be a square and a circle,
and there'll be some get area functions and some rendering functions.
And I'll just send this to Patrick so he has an idea of what I'm going to do.
And then he can code to those.h files, and he can include them in his code.
And then, you know, we can both work in parallel that way.
So it's a great way to communicate.
The language itself allows you to do things like that so some of the weaknesses we talked about that you
have absolute control over the memory and so it's in a similar way just in having memory leaks you
can also have memory corruption that you know you can overwrite other pieces of code if you're
you know c++ has a notion of a pointer so it's this variable holds a
memory address but I can change what the memory address points to and as long as
if my program has permission to write there I can write whatever I want to
that right yeah I mean a big case where things like this happen is let's say you
have an array and the array has the array has ten elements and you're looping through the array.
So you might have a loop that says,
like, go from 1 to 10.
Like, you might say at the top,
it might say, okay, int size equals whatever the size is.
So now my size variable is set to 10.
And then I write this for loop that goes from 1 to size.
But I never try to recalculate size. I just know it's 10. And I go through this for loop that goes from one to size but but I never try to recalculate size I just know it's ten and I go through this for loop and do some stuff well what if my program is multi-threaded and while I'm in this for
loop somebody else goes through and deletes like a few elements well now I'm
going to go through one to ten but there's only five elements and C++ it
won't give you an error or crash or anything like that
It'll actually just read whatever memory is there
You know and like this happens the worst
Case where this kind of happens even worse than adding element or removing elements is you might add an element
so let's say you add the 11th element and
that causes your vector to shift to another location in memory and you just you end up
with all sorts of crazy stuff where you know you're just you're reading memory that doesn't
make sense and but you're not crashing you're getting data it's just bogus and so these are
incredibly hard to debug and this is why a lot of old school games have these really esoteric, really interesting errors.
Like, you ever see the negative one world in Mario?
No.
Oh man, you should watch his YouTube video.
There's a glitch in Mario, and you can exploit the glitch and actually go to the world negative one.
There's another bug in castlevania 2 for nintendo where you can uh and these these are
both written in c but the same kind of bugs can happen in c++ where in castlevania 2 you can
actually fall through the ground at like a very specific spot and you're in like random memory
in the game and so like effectively like some percentage just based on you know
randomness or whatever of the ground is hard and the rest of it is fall through so like you're not
stuck and you can actually people have like just spent days just going through this crazy world
where you're just walking through the memory and everything's crazy and one guy got to the spot in memory where the the time was being like you know
put and so like as the seconds ticked like the the world shaped in like weird ways it's really trippy
and so but the point is like you don't get a crash with like hey at this point in your code
you know something weird happened you just weird things happen with with no way to track them down yeah yeah so that's my
soapbox all right so we're running a little long so before we keep people past how long they want
to listen let's uh you want to you want to do a few more weaknesses or you want to go ahead and
move on to tools for working with c++ yeah yeah let's let's jump to tools um all right i i
personally really like code blocks have you ever used code blocks
i have not um so you know i do a lot of development on linux um but there was a time where i was you
know doing my home development on linux but i was doing my work stuff on windows now i happen to
actually be on linux 100 but at that time, I really wanted something where I the same IDE on
on Windows and Linux. And code blocks does exactly that it actually works on Mac, Windows and Linux.
It's very consistent. And it does sort of, you know, it's not as nice as Visual Studio.
But it does like 99% of what you need. And totally cross-platform yeah what about you another yeah
another cross development uh cross-platform development is eclipse cdt we talked about
eclipse and eclipse originally came out as java only but since then people have added some c
functionality in the what's called cdt c developer for and so it it basically does the same thing for see it
requires you know some extra setting up and handling um but it works pretty good oh nice
yeah i haven't tried it on windows um but uh but i'm sure it's a lot better now i i used a really
old version of eclipse um but i'm sure they've come a long way. And then aside from just tools to use to write code, I also wanted to talk about Boost, which
is a very popular library for C++, which adds a lot of the features that were now added
to the new C++ 11, so like shared pointers and stuff, and just a lot of common usages that you might want that instead of having
to implement yourself you can just use the boost libraries version and it tends to be very good
and well supported yeah definitely yeah as patrick mentioned uh shared pointers have actually even
though they're just coming into c++ now they've been in boost for years and years and years so
um you got to be using boost if you want to get all of the productivity out of your
C++.
So C++ is commonly used.
We talked about game programming.
We didn't really talk about it, but we kind of alluded to it, which is embedded computers.
So things that are low power, low memory, things where you want to be able to have tight
control on everything that happens. They're used there what where else are they used jason
or c++ used uh so all web browsers right chrome firefox internet explorer all these are written
in c++ um most you know huge programs that you can think of um are probably written in C++. And that just goes back to our, you know,
our explanation of just how, like,
it's possible to make just gigantic programs
and many libraries and, you know,
and all sort of coordinate.
Yeah.
So I think that pretty much wraps it up for C++.
I wanted to say thank you.
A number of people have written in
to say how they're glad the show is back.
It's been encouraging.
We've had a number of comments and suggestions and that kind of stuff.
That's appreciated as well.
We're glad to hear from you guys.
We enjoy doing this.
We're glad that some of you enjoy hearing it.
Yeah, totally.
We used to announce Programming Throwdown at Gmail.
It's probably good to mention we don't follow that as much
now that we have the programming
throwdown page on gplus
so if you
want to write to us
we do follow like we check it maybe
once a week or something like that so
you can definitely write to us if you have
something you don't want to share to the public or something
like that but
most of the time you definitely want to share to the public or something like that. But most of the time, you definitely want to check out the G Plus page.
Google Plus.
That's right.
If you go on Google Plus and you put in Programming Throwdown,
it will take you to the Google Plus site for Programming Throwdown.
You can feel free to leave any comments.
We post all the show notes there in addition to the blog.
So, yeah, definitely in addition to the blog. So yeah,
definitely add it,
add it to your circles until next time.
See you guys later.
The intro music is Axo by Binar Pilot.
Programming Throwdown is distributed under a Creative Commons Attribution
Sharealike 2.0 license.
You're free to share,
copy,
distribute, transmit the work, to remix, adapt the work, 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