Programming Throwdown - Source Control
Episode Date: December 7, 2015This show covers Source Control: Various tools that keep history of your code and enable code collaboration. Book of the Show Jason: Kobolds Ate My Baby Patrick: Firefight ★ Support this... podcast on Patreon ★
Transcript
Discussion (0)
programming throwdown episode 48 source control take it away jason hey everyone sorry for the
late episode uh we had some issues recording this
episode and so we this is this is take two but uh this is a very important episode uh personally i
can't stress how uh how important this is for you uh starting developers and really for anybody
using a computer and so happy to talk about it again for the first time.
But in this show, instead of doing news,
we have something kind of like a public service announcement.
I want to talk about backing up.
So backing up is related to source control,
but it's sort of even more sort of fundamental is this idea that you need to keep copies of things.
And so I didn't know this.
When I was in high school, I used to make a lot of StarCraft maps.
Because you were a nerd?
No, we all are.
Yeah, exactly.
So I made these StarCraft maps.
The maps I made weren't popular enough to make it on a website or anything like that.
I mean, this is 1996, so I don't know if there weren't even that many websites uh like it wasn't like everything was indexed like it is now there's there was actually rings remember web rings
yes where you go to one of the sites and it would link you to all the others and you just go through
anyways so um i wasn't popular enough to make it into a starcraft map web ring i just had
my maps on my computer and but for me they were very cool because i the maps actually told stories
they were like rpgs it wasn't like typical starcraft where you're you know playing this
tactical game it was like all about this story that unfolded you have this character and you
know how you level them up change the story and it took a lot of time
it's like a ton of different macros and triggers and all that and my hard drive crash i lost all
of it um and like to this day you know i have a lot of other projects that i haven't lost and
every now and then i go and look at them uh and it's kind of cool uh and have a little nostalgia
trip uh but you know i lost a ton of projects when that hard drive died.
So don't do that.
Don't be regretting that.
There's plenty of ways to back up.
You could use source control.
So I'll tell you sort of what my backup strategy is.
I have source control for projects
where it's a lot of small files, text files, where source control does really well.
For things that are kind of small but aren't really source code, for those I do Dropbox, Google Drive, iCloud Drive, these kind of different projects that sort of back your stuff up in the cloud.
All of them have limits unless you want to pay money.
I've been backing things up since I was in college and very poor.
And so I used to do a whole bunch of crazy R syncing
among computers and things like that.
Now you don't have to do any of that.
You can use BitTorrent Sync,
which is actually one of our tools of the show
earlier you can also use sync thing which is an open source version of bit torrent okay so this
is a side topic but i was thinking about this other day people on the internet uh were saying
that oh don't use bt sync because it's closed source you don't know what they're doing you
can't trust it use sync thing because it's open source you can trust it blah blah what is your opinion do you use both
like is there a legitimate reason personally i'm not going to go audit the source code
right like i'm just gonna be honest i'm not gonna do that so is there an advantage like do you
put an advantage on something which is open source versus something that's not you just go on features like
how do you make that decision personally um okay so for me i'll look at open source for cost reasons
uh you know in other words like i i got into emacs instead of visual studio just because i didn't want
to pay for visual studio and and it just kind of grew on me there. I don't really buy the argument
that open source is more audited
because although we have this fantasy
that open source projects,
everyone's looking at the code all the time
and there's all this third party.
The reality is if you look at most big open source projects,
it's really just one or two entities pushing the project.
And so I don't feel like there's that many more eyeballs on the source code, honestly.
Also, you know, if you want to do something malicious, you have access to the source code.
And you don't have to do any reverse engineering or tamper protection or tampering or anything like that.
So, you know, I tend to to i would think for security reasons i would
go closed source um i feel like security reasons i'd probably go open source really because yeah
because i feel like someone will have taken a cursory look to say like hey but you know like
you said i have no proof of that um i mean but i feel like long term it's hard to say for something that
doesn't have a server that's like like for something that's just run on my computer or
like run between two computers on my home network it doesn't need to reach out to a third party
like i don't worry about it as much and i would only start to worry about it if it's
like i'm depending on someone i'm buying a piece of software and I need them to be doing something on an ongoing basis as well.
Like that makes me a little less happy.
Yeah.
Right.
Well,
yeah,
definitely when BitTorrent sync was,
uh,
you have to pay per month.
I didn't use it because,
uh,
yeah,
yeah.
Anything you have to pay per month,
it just,
it definitely like turns me off.
I think we talked about this in the last episode.
Yeah.
Um,
but you know, now it's just, I think it's $50 one-time fee,
so it's totally reasonable.
At the time, SyncThing blew up your processor.
Not literally, but SyncThing would just max out my processor 24-7.
And I had some very large directories full of pictures,
and for whatever reason, the indexing just wasn't optimized or what have you.
And even though nothing would change, I wouldn't even add any pictures,
one of my cores would be at 100% and my laptop battery wouldn't last and things like that.
Since then, they fixed a lot of that.
But I'd already migrated over to BitTorrent Sync, so I'd have to migrate back.
But I did, just for experimental reasons, I did reinstall SyncThing and try it, the latest version, and all those problems are fixed.
So I guess if I had to tell people, I would tell them to use SyncThing at this point because it's more mature.
But when I started, it was in bad shape i use bit torrent sync in all fairness also because it has mobile clients oh that's true
um i forgot about that but uh but yeah the mobile client is amazing it just every time you take a
picture and i don't need it that often but i do occasionally and also for like you said for pictures okay so you use rsync sync thing btsync
between two computers you own right so for files that are too big to fit on the cloud without
spending money i'll use you know btsync yeah like you know if you have like in my case i have you
know terabytes of photos um i don't know what that would cost me per month but it's much easier for me to i
actually have bt sync running at my parents house so like literally i take a picture with with my
phone and then the next time i'm on wi-fi it goes to my parents and to my desktop yeah i need to set
something like that up because that's really important uh is not just computers you have in
your house because if you have fire or theft or
flood or whatever it may be and ever you lose everything in your house you really can't rely
only on that yep that's right although it's much better than having relying on a single
spinning bit of metal inside a metal case inside a computer um oh yeah that could just go down randomly at any point and
you know you'd be faced with either just loss of it or paying large sums of money to attempt to
recover it yep the other thing is um this is a little bit orthogonal but i had a friend who uh
um lives in berkeley and you know was uh went on facebook and told everyone he's so excited to go on vacation,
went on vacation, and then was robbed while he was out of town.
And that person, they took all his electronics.
And so things he had on Dropbox he could recover,
but even if he had backed it up on an external hard drive, it's still gone, right?
Yeah.
So I also use CrashPlan,
which I think they changed their name now.
I'd have to look.
Oh, really?
Which is a backup service that I pay for as well
to backup my stuff to their servers.
And people use some of the Amazon AWS EC2,s ec2 glacier one of those acronyms at
amazon to back up their data to the amazon thing so same idea same idea sort of as backing it up
to the dropbox servers although i think there's some risk there that because it's not really meant
purely for backup that if your file somehow got accidentally deleted it could get deleted
and dropbox this thing too and it may be a little harder to get it back although i think they have
ways of doing it um yeah i was gonna say if you like long term there's a there's a dot i think
it's like dot archive folder in your dropbox that has files you've deleted they actually get moved
there and i think they get that gets purged every few months or something so yeah yeah but like you know it's not really like i always feel better when something is designed for
that purpose you know like yep totally for backing up um and there's other ones too i think carbonite
is another one i hear about i have not tried it uh crash plan didn't change its name it's still
crash plan okay but something that is an actual backup service who kind of are staking their
reputation on like and i and to be fair i don't think I've needed but once in the three or four years I've had it.
Like one time I needed to recover a couple files and it worked great.
And other than that, I've not needed it.
So in that way, it's kind of just insurance.
But it helps me sleep better at night.
Yeah, another thing that's really important is to back up in the other direction too
from the cloud so uh i have a friend she was uh uh she's a reporter for i think the verge
she's a reporter for some tech uh newspaper and um some hackers got access to her gmail account
and they went on her gmail and literally all of her email, all of her photos, everything.
Just gone.
I don't know if she ever got it back.
I don't know if she was able to recover that by contacting Google over the phone.
I'm not sure how that ended.
But definitely, like, I have a Thunderbird instance on my desktop
that just fetches all of my Gmail, you know, using IMAP.
And that way, if something like that does happen, at least I have, you know, a local copy of it.
Yep. Although I often wonder, like, if all my emails just got really deleted,
I might be better off, but it's a separate topic.
Yeah. She actually never called Google and she was much happier and reached Nirvana.
Another thing that's related is two-factor authentication um you definitely want to have that turned on that's good psa within the psa me i've only vaguely know about this i
mean i have it but so typically you have a password which is some alphanumeric code but then it's good to also
have something that is on you or that you have so sometimes it's like your fingerprint which is
not as great as you might think because there's no way to really change it and it turns out it's
more hackable than you think but then there's also like uh various ways of doing two-factor
the second factor is normally like a one-time password.
So a lot of people, you see like the RSA key chains for banks, which have like a little LCD
on screen on them with a six digit number that changes and it changes in a known way
to an algorithm if you have a secret. But if you don't know the secret, then the pattern is unpredictable.
And so it prevents people, even if they get your password, which doesn't change, they won't know this other one-time password that either changes every time you use it or changes based on a time-based schedule.
And that gives you an additional layer of security that people need both um and then there are even more secure ones that do stuff a little slightly differently if you are really
really paranoid about it um and i i've enabled the otp for both me and my wife because it it
turns out it's actually really easy um and it isn't that much of a hassle because you can turn
it on for a computer and it
just stays on that computer for some number of days you don't need to keep doing it that's right
and that is somewhat of a security risk but i i personally make the belief that uh you're more
likely to be hacked from a anonymous drive-by hacking where something is going on then someone coming and sitting down
your computer and you know getting on your stuff like that's possible too or stealing your computer
or whatever and you can try to go in and revoke it and hopefully you have recovery stuff um but
it's it's worth it to not have that hassle of needing to get a text message or use an app or use your rsa key every time
right i mean the odds that you know someone steals your laptop and somehow it's not password
protected or or they stole it before it was locked and they're not just in the business of selling it
they're in the business of logging in as you like like all of these things are just like when you
add them up like the the joint probability distribution like looks very narrow i mean uh it's just highly unlikely right
so yeah but as patrick said most if it's very important stuff people you know out on the
internet getting your password yeah and if it's very important like if you do conduct business
email like you probably want that secured more than your personal email they could be tragic if you lost early love emails between you and your girlfriend but like
i don't know is that a thing i don't know anyways uh but like it's not really the end of the world
right right like but if you lost you know important business contacts like that would be worse right
yeah exactly uh okay yep the other thing i'll say back onto the
topic of backing up oh and uh is for your phone like my wife uh lost her phone and it turns out
we got it back but we thought it was gone forever and so we did the remote wipe thing and she lost
since her last backup you know that she did previously you know i lost some number of
pictures and since then we realized it's really important to have for us to additionally on our
phones like jason was saying using the phone app to back up your pictures or like google photos
has a thing i think facebook photos will do the same thing where it's automatically uploading pictures at some resolution so that if you lose your device, it's not the best version, but at least it's something.
So you still have those pictures. And so that can count as a form of backup as well.
One thing to keep in mind, if you're on iOS, iOS doesn't allow services. So, so all these,
like all these programs like BitTorrent sync on iOS iOS, Google Photos, you have to run them periodically yourself.
If you're on Android, they'll run you every day or something.
But keep that in mind.
So I tell my wife, I remind my wife every now and then that she has to go in and run the BitTorrent Sync.
And it's pretty cool.
It brings up a little status bar,
shows you it's transferring,
and it'll try to be clever about
finding... If you're at home,
it'll send it to your home
computer first, knowing that your phone
is more bandwidth constrained.
Send it from your
phone to your computer at your house, and then
it'll send it to another computer
or what have you.
Oh, I recently made the obvious realization that i was thinking between my kind of like server computer and my desktop for pictures and everything and i was i was like so happy with myself because
i finally had wired connections instead of wireless and i was like whoa i'm getting eight
megabytes a second sync speed this is pretty pretty good or whatever. It goes so fast.
And then I realized, oh, you know,
I think I used an old 10100 switch instead of a gigabit switch.
So I switched it.
Oh man, too many switches.
To a gigabit switch.
And I was getting like,
I think 24 megabits per second
or megabytes per second.
I was just like, yay!
Like, this is even so much faster.
Because I had one, but I just like, you you know had to use some old one laying around not thinking like oh it'll it's just so
much faster than wireless anyways right right oh yeah no you realize you like hit another order of
magnitude yeah so i think and we'll just we'll move on from this but uh the other cool thing
about the bit torrent sync is it provides an easy way to access your photos on your desktop.
My wife, she's tech savvy and everything.
But even a tech savvy person, getting photos from your phone to your desktop, especially if your desktop is running Windows and you have an iPhone or something, it can be a little complicated. With this BitTorrent Sync, if you have it set up correctly, you just open the Sync app
and wait, and then the photos are just there in the folder on your desktop.
I mean, you don't have to do anything.
It's really nice that way.
You sound like a sales pitch for BitTorrent Sync.
Before you leave the topic completely, I'll also say another strategies people employ which is valid they used to burn dvds but now i think storage is so big it's hard
to do dvds or even blu-rays i don't know but now hard drives or ssds or you know usb sticks are big
enough i guess a valid strategy would still be to download onto a usb drive and mail that to your parents
or put it in a safety deposit box.
And then the other thing I was going to say is that
you could also ray-to-ray your hard drives.
That's another valid backup strategy because it helps, again,
protect against a single hard drive having a problem.
But there you're having multiple hard drives
and not getting the full capacity of each
because some of it is sacrificed to protect against errors.
Yeah, so just to tell everyone real quick about RAID,
the way RAID works, there's a couple of primitive versions of RAID.
There's several versions.
The first version is what's...
I don't even know what it is.
It's called striping, I think.
No, the first version is just where it just takes your...
If you have two 1TB hard drives, it just concatenates them.
So now you have a 2TB drive.
A 2TB logical drive.
Right, but it's actually these two 1TB drives.
And if you write to the sector, you know, N over 2 plus 1,
you're writing to the beginning of the second drive right um there's also mirroring and they don't have to be the
same size or like really the same in any way really right there's also mirroring in the case
of mirroring they do have to be the same size and you want them to be the same performance or you'll
get the performance of the worst one yep and every time you write a bit to one of the hard drives it writes it to both so it's it's as it's just like a mirror um it mirrors
everything on the left hand with the right hand um but then it turns out you know you really
let's say you have three hard drives sure you could do mirroring and i have three copies of
everything um but statistically that's kind of overkill.
So if you kind of do some probability theory,
you can get 95% redundancy
or you can guarantee that two or more drives
have to fail within a few minutes.
You can make that guarantee um without having to
sacrifice so much of your disk space and so that's where these sort of raid five and uh i think
there's other ones but raid five is the most common yeah so what you're saying is the chances
are most of the time you'll fail because a single drive starts to have a problem and as long as if
if you use three drives you can get the most of the capacity of two drives, I think is how it works out.
Right.
And the third drive is used for kind of error checking the first two.
And then as long as if only one drive has an issue, you get to keep all your data.
You can take away the bad, you know, sick hard drive and put in a new one and it'll essentially
rebuild it and then you'll be back to full protection exactly if you lose two hard drives
though you have a problem but the chances of that happening are you know far less and even if you
had them fully mirrored just two you would be in the same. And if you had three fully mirrored, well, that's great,
but you have three hard drives,
but only one third the space, right?
Exactly.
That's an inefficient system.
So yeah, I have fully mirrored.
I only have two drives.
I'm thinking actually about buying another two drives.
And so in that case, maybe I'll go to a RAID 5.
It's actually kind of hard once you pick a RAID,
you know, to switch to another one.
I think you have to just, you know,
like purge all of the data and then bring it all back.
But yeah, that's definitely,
that protects you from hard drive failure.
There are also, I know Linux has some file system stuff
I was reading about recently
that tries to handle some of this
for kind of like network attached storage reasons
where it's not handled at the per se,
just like the array might want to be handled
at the hardware layer
and OS actually just sees a single drive,
but actually try to handle it at like the file system layer.
But like where you have a disk pool,
something is used for parity
and they try to kind of be smart about where they stick where
so that you can kind of just add or take away drives without having issues.
Kind of like a Hadoop file system or like a Google file system
or something like that, but only on one computer.
This sounds really formal, but I'll take an action item to look into that
and maybe try to get us better information next time.
It's just speculation. An action. action cool or we'll distribute it someone out there has to know about this maybe
they can write in and tell us yeah if someone knows about some type of like you know hadoop
file system like thing where you can literally just pop in a hard drive and your your file system
magically gets bigger um let us know that'd be awesome um
that'd be that'd be really really fantastic yes cool um okay so time for book of the show
show my book of the show is uh kobolds ate my baby um it's really fun it's a uh it was out of print for a while they brought it
back really excited about that i actually i had pirated this because it was out of print and i
literally could not get a copy and i was well i mean yeah so as soon as it went back in print i
bought a copy i'm very satisfied uh it's it they call it a beer and pretzels rpg uh if you don't know like
there's there's video game rpgs but there's also true sort of role-playing games where
you all sit around at a table and there's sort of this set of rules and there's one person who
arbitrates um all of these rules and uh and everyone else has to sort of play these characters. And part of the rule sort of encourages you to, you know,
assume the persona or persona of various characters, right?
So this one in particular, every person is a kobold.
Wait, it's not just personas.
I think it's just personas.
It's personas?
Or it's persona?
Persona and personas.
Oh, it's personas?
Okay. Anyway. Sorry. No, it's personas okay anyway sorry so no it's fine learn something new uh so uh in this year of kobold um you have to sort of eat this baby uh it's very hard to eat the baby
you always end up failing in just hilarious ways um but you know hopefully you get closer to the baby
than anybody else um and uh uh along the way there's a bunch of little rules that make it
kind of fun to play especially people who aren't might not be into rpgs um there's one where
um anytime someone says king torg everyone has to say all hail king torg if you don't you die your
character dies um and so you just use that in funny ways to get people killed and things like
that um it's just a bunch of like kind of like funny things like that they've all rolled up into
one game uh highly recommended very nice i don't think i've actually ever played a pen and paper rpg before
i've really tried to do it once or twice like i got like a star wars beginner's guide many years
ago when they had like an rpg and tried to play it like with my brother and like we never really
understood or did it right so yeah i i played dnd a a little bit, and then we were playing it in school, and the school actually banned it.
We only played it twice.
There was, like, a hysteria.
Yeah, but it was that time where it was, like, associated with witchcraft and all sorts of craziness.
So it got banned.
To be honest, I never really enjoyed it, the D&D.
I only really like pen and paper RPGs that are are satirical and and and funny and and and
sort of tongue-in-cheek um like cobalt date my baby is one of these paranoia rpgs another one
but but any of the pen and paper rpgs that are serious i just can't get into it
so yeah i just never played any of them oh you should try this i guess i'm missing out like it
yeah but you have to have the problem with all this you can't just be one person or even want two people really like it really needs
to be a group of people that's right yeah yeah i don't have that many friends okay anyways moving
on my my book of the show is firefight by brandon sanderson this is the sequel to uh oh no oh no i just it dropped out of my head i have to
look it up anyways it's a sequel to his previous uh book that is called steelheart there we go
thank you amazon and steelheart is the first in this i guess universe uh i think there is a series
they're calling it the reckoners and it's kind of a superhero universe there are people with
superpowers but it's not like marvel or dc superpowers they and it's an interesting take on
what superpowers are and what it means and uh these superpowers kind of you know like do people
necessarily have to change by having superpowers anyways it's a pretty light read it's it's lots
of fun um you should
obviously probably read the first one steelheart first and if you which was a previous recommendation
if you read that one this is a psycho on firefight i also really enjoyed it um a little different
uh kind of book than the first one but very fun nonetheless uh and this is a good opportunity
to show for a plug that uh uh, if you would like to
help support the podcast, uh, you can listen to firefight on audible by going to audible
trial.com slash programming throw down, and you can get a free month at audible, which
means you get a credit.
And for one credit, you can download like any of the many, many books they have.
I actually pay for audible on my own and listen to it on my commute because
my commute stinks.
And I like to listen to sci-fi.
So I make it through a lot of sci-fi books and I listened to them on audible.
I really enjoy it.
You can get a one month subscription for free after that.
They'll charge you.
But if you don't want it to be charged,
just cancel after your first book and you can get to keep it because even if you like jason said if
you don't like paying month to month which i also don't like being committed to the nice thing is
you still get to keep all your books um that you've bought with your credit so you don't have
to keep paying um and the paying for me works out month to month cheaper than you know buying it straight up or whatever
yeah audio is very expensive yeah they really can be which makes sense i mean if you think about
like a movie is well i guess it's a lot more production just like two hours three hours but
an audio book can easily be 10 20 30 hours so the book i'm listening to now is three books in one and it's 65 hours.
Oh, wow.
Wow.
So that's like a week of commuting.
Right.
No, that's.
Oh, wait. Go to that math.
Wait, 60 hours.
That's probably a month of commuting, right?
Yeah.
Yeah.
No, even more than that.
Because if you say there's like 20 work days.
Oh, right.
Yeah, only at work.
Anyways.
Cool.
It's a lot.
I enjoy it.
It helps me pass the time.
Yep.
I'm just saying it helps me pass the time.
We're also on Patreon, which is pretty cool.
If you want to support the show, you can donate to our Patreon and
every time we produce a show
I will kind of automatically make a donation
which is like a pretty cool setup they have there
so
definitely check that out we definitely
appreciate your donations that's how
we keep the lights on
yeah and you guys have been really good
about supporting us and
embracing our stuff
a couple people have written in and like hey like what's the deal but you know like if you don't
want to don't like it's fine like we don't require you to do that we're not gonna charge people to
download the podcast yeah a couple people said you know they want to support the show but they
they they you know don't uh uh you know they're not in a position financially to do that
and things like that and don't worry about it man i mean we're gonna we're gonna do this show
and if you can support that's great and if not um you know if this show helps you uh that's really
what what what it means you know that's really what we're doing it for is to is to help people
out and uh i don't feel like there's any pressure or anything like that you
know and if you don't like an episode just download it and then turn it off and you can
feel good about really pressing that delete button really hard yeah that's right you can use the what
is it on the new iphone the force touch oh the force touch and just like if you press it hard
enough uh one of us will get punched. Delete with a grudge.
Oh, man.
It's the time for Tool of the Show.
My tool of the show is Qt.
I'm sure a lot of people know what this is.
It is a cross-platform GUI framework.
It does more than GUI.
It does like threading and things like that, but basically You know C++
Has a lot of sort of native thing. I mean if you want to do
Linux you're doing some kind of GTK kind of thing if you're on Windows you're using
I don't even know I guess Microsoft foundation classes or whatever they have now. I get some kind of dotnet thing
If you're on if you're on Mac, you're using Cocoa or Carbon.
There's a bunch of different platform specific things.
And so if you want to make a cool desktop app,
like if you take any of these cross platform desktop apps,
like Steam for example, Steam uses QT.
So that way they can write the code once
and it runs on Linux, it runs on Mac, it runs on Windows,
and in all three of them, it looks reasonable.
Qt differs from WXWidgets, which is one I recommended
earlier in an earlier episode.
WXWidgets actually takes your code
and transforms it into something native.
So in other words, you build some form in WX widgets,
and when you compile your code for OS X,
you end up with Cocoa code.
So it feels like you built a native app.
Qt is different.
Qt sort of has a layer in between,
and Qt's goal is to try to give a uniform experience
across all the different platforms so that's the difference like wx which wants you to give a
native but different experience on each platform and qt tries to give you a uniform experience
on each platform but it doesn't feel native it turns out in my opinion Qt is way better.
The reason is I've used WX widgets, it sounds great in theory, the idea that people think
you built the app just for them or just for their OS, but in practice people know.
You'll end up with a button where on Linux the button doesn't fit right but you don't
have time to adjust it for all the different OSs.
Or on OS X, you use a pull-down menu in a weird way
where you wouldn't have done that.
And so I feel like it's almost an uncanny valley
where it's using native widgets,
but it's not laying them out in a way that that that makes sense or there's some
weird word wrapping and actually it's actually worse than than just doing qt and people know
up front that this is going to be a different experience than than a native app um i think
it's great highly recommend you guys check it out if you're doing any kind of c++ gui work
which i just generally try to avoid yeah yeah I mean if you're gonna do
it's necessary this necessary and I appreciate the people who do it I just yeah yeah if you're
gonna do a quick GUI for some small project use like R or something or IPython notebook
but if you really have to build a GUI use Qt my tool of the show surprise is a game this one is an ios game i i keep i
should look up every time but i always forget whether there's an android version of it or not
um i'll check yep and so this game is called wayward souls it's a roguelike and it uh is very
much kind of like if we've talked about i think spelunky before um it is on android as well
on the google play store yep so in the kind of theme of spelunky or they're saying mage gauntlet
but basically it's procedurally generated dungeon levels and you have you can kind of choose what
character you want to play as you kind of go into the level you fight some bad guys and you die a
lot but then like you kind of get better as like a
player you learn what you're supposed to be doing and then like you also kind of get gold that you
can use to upgrade your characters and make them better equipped when they go back into the dungeon
um and so there's kind of that combination which i personally like where uh you find things in a
given playthrough that are making your character better,
some equipment that you lose when you die,
but then there are also some things that you don't lose when you die
and you kind of carry across.
And I like that aspect as well
because it helps me to feel like I'm making progress
even when the level is just unusually difficult.
Yeah, I've played this game as well.
I think it's great.
I like the idea that what you want is you want the suspense.
You want to feel such that when you die,
you lost significant time.
That's what creates the suspense and makes you cautious.
But at the same time, you don't want to not make any progress. i mean you don't want to to just never see the ending of the game and so
this sort of gives you the best of both worlds yes yep it's kind of like i think there's always
this debate like quick save in games like the ability to save anywhere in a game does fundamentally
change how you play a game right and in some ways knowing you can just
go back to 30 seconds ago you act very differently than if you know you're going to lose an hour's
worth of work but at the same time based on where i am in my life like it's really hard to sit down
and know i'm gonna be able to play for an hour and not not quite make it to the next save point
and then lose that hour have to do it again next time
yeah i mean for me it's okay because uh as you said there's you always make some
modicum of progress so you always make some mediocre amount of progress no matter what
and so eventually you'll you'll beat the game yeah well everyone's older but wayward souls i
like it's cool and it's you know it's
plays relatively quickly and it's not that some roguelikes are very in depth and this one isn't
like that and so that makes it enjoyable this is definitely a hack and slash roguelike yep cool
all right so we're gonna talk about to source control source control um yeah so basically Control. Source Control. Yeah, so
basically
Source
Control is
kind of about just keeping
they also call it version control.
It's about just keeping history
of some
kind of project. So it's not
only about backing up.
It's also about being able to go
back and forth in time and see sort of, oh, what did things look like, you know, a week ago? Or
I pushed out this build and my customers are really unhappy. Let me, you know, go back in
the past week and see what went wrong. so it's very different than backup it's
extremely important especially if you're working on some kind of project um there's really two
sort of strategies well wait sorry before you go on i also want to say that like i think that's
important we say source control because we're programmers but like you really could use it as
just straight version control for almost anything that has versions.
Now, some things aren't really great,
like binary files are hard,
but if you have a config file or...
I'm trying to think of a good example of something.
I'm too nerdy and programming-oriented to think of something at the moment.
Oh, if you're writing a book.
Yeah, there we go.
Yeah, you could source control your book,
version control your book.
And it's a little different there because I think in a book, you kind of always know you're making progress.
But maybe you would want to go back like, oh, I'm unhappy with the direction I took.
I want to go back to where I was before.
And the thing in code is, like Jason said, is you introduce a bug and you want to be able to go back.
Or specifically, you ship code to make a release
that goes to a customer and they have a problem with that you need the ability to go back to
exactly what your source code was at that time and know that you're have the same thing you sent out
and so if you make a fix you know what exactly you fixed rather than saying oh they called me a month after i did it and i've added
three features halfway and now like oh like crud i either need to try to finish these features and
hope i didn't introduce new bugs or what you the right thing to do is to be able to go back
to what you sent them and work on the bugs there and then make sure you bring them forward as well
or whatever your solution is but that is what the importance of version control is versus
backing up which is just saying I don't want to lose my work right and as I did
write a book with a bunch of other authors and we used version control and
as you said in the beginning you're just writing and so it doesn't really make
sense but at the end where you're kind of coalescing the book,
or even if you wrote the whole book by yourself,
you're going through rounds of edit,
possibly with several editors who have different opinions.
You'll often find yourself going back and forth
with certain parts of the book,
and having version control is extremely important.
You could have an editor that takes you in one direction,
and then the other editors decide, oh, that was a bad idea.
You need to be able to go backwards.
And so, as Patrick says, not just for programmers,
anyone who's doing something with source files,
and even artists, there's some specialized tools,
but they're extremely powerful for doing version control
on, you know, blender models and things like that, um, that handle sort of those binary files,
um, you know, that, that, that semantically understand how those files work and do
versioning that makes sense. Yep. It's also important both for a single file. Like I need
to roll this single file back where I need to roll all the files back together because especially with at least with source code right
like files depend on each other and so if you only roll one file back then the
other files won't it won't work anymore because the other files aren't
compatible at that point yep yeah exactly there's two sort of ways to do yeah there's two ways to do
version control one is lock and the other is merge the idea with lock is
this is mainly used for binary files for you know people are doing art and things
like that if Patrick and I are both making a bunch of art assets for some game, we just have a list of assets.
And I decide, okay, now I'm going to take grass.
I'm going to make all the grass for the game.
I could just lock the grass texture file.
When it's locked, Patrick, he could read the file,
but he'll know it's locked and it won't let him make any changes.
Then I can go in, I can paint all of my grass.
And then when I'm happy with it, I can unlock, I can update that file.
And that file will unlock, which means now somebody else can lock it.
And it now has my new content.
And that way, for an individual individual file only one person can edit
but you know i could be editing oh go ahead yeah no you could be editing lots of files but i was
saying the advantage here is it makes it very explicit what you're working on so that it
duplication of work is maybe easier to be avoided because i know jason's working on grass and if i
know we need we both knew grass need to be worked on, he got it to it first.
I know, oh, I should just wait on him to be done.
But in like a source control, in a source code scenario, it may be that like, hey, I just need you to add this other member variable to your class to track this thing.
But you're doing like an algorithm rewrite.
And like, you know, I want to an algorithm rewrite and like you know i want to
just go ahead and have you unlock it i'll make my change lock it back and then you can lock it back
but like if i want to make this small change i don't want to wait around for you
to make your gigantic change exactly yep
so so that yep go ahead oh no you go ahead i'll just say that so that's where the merge based
tools come into play is to say that you don't lock a file like everyone's working on their changes
and then basically whoever submits first that's great that's the new kind of current state of the
repository and then if you are also working on a file before that change then you need
to before you can fully have your change become the new standard you need to merge against any
shared files between the two changes so you know i edit main.c to add blink and led jason's working on main.c to add a log statement at boot uh i get my led change
in first he goes to add his print statement and it says oh the newest version is newer than the
version you based your change on you need to bring down the new version merge in your change and then
you can re-upload it and then it can become the new version. Exactly. So notice that like to do a merge-based system,
you must be able to decompose the file.
And so that means it's typically only used for text.
If you're doing some kind of binary asset,
you would use a lock-based system.
And many of the source control systems
are able to do much of that automatically, right?
Like, hey, I want to JSON modify line 5.
I modify line 33.
Like, we'll just go ahead and assume those two things are compatible as long as if both of them were able to build okay.
And we're not going to force you, the programmer, to take any action.
We'll just do it silently.
Or some tools are very explicit, like explicit like hey you need to resolve every change
like you need to improve them and even the ones that automatically try to do the right thing
after they've done the automatic emerge they give you an opportunity to make sure things
compile and things like that before you know the merge is committed right because you could change
two unrelated pieces of code.
Like I could delete a variable
that's not currently being used
and then Jason adds some code somewhere else
that uses that variable
and an auto merge could have run into a problem.
Right.
Because it thinks my deleting of the thing
is unrelated to his using it somewhere else.
But if you build before, you know, kind of doing your stuff,
you'll catch that like, oh, hey, this doesn't work anymore.
Yeah, exactly. Exactly.
And so definitely invest some time if you're going to use version control,
which hopefully we've convinced you to do that.
Take some time to get familiar with a good diff and merge tool.
I use MELD.
I think MELD is pretty great.
It's been up and down in terms of...
I've had issues with it in the past.
A lot of those issues have now been ironed out
now that they're on GTK3.
But yeah, I like MELD you know i'm not you know
married to it i'm sure there's there are others out there that are fantastic but whichever one
you pick uh get very good with it because you'll be doing a lot of that so it's also very important
to point out that like when you're in university setting or whatever it it is really kind of
optional to use versicontrol it's important to of optional to use version control it's important
to get used to it and it does actually have advantages but to be fair if you're just one guy
working on something or one gal working on something uh it's not a big but once you start
having two three four people uh it starts to become very important as a form of communication
right to say here's the current state of everything it's not you know oh joe's
computer is got the latest code so you need to go get copy his stuff bring it to your desk and like
make changes and then sally needs to come get it from you because you now have the latest version
that would break down really fast yep and even if you're working by yourself i've often been working
on things that were kind of prototypes that are very early stage and i come to a fork in the road
and it's sort of like okay i can do some kind of machine learning here to solve this problem
or i can just do a simple counting and i'm not really sure what to do. And so I say, okay, I'll do the counting thing.
And then I do the counting and about halfway through it, I feel like, oh, I start having
regrets like cold feet.
I started thinking, oh no, I need to really use an SVM here.
But I've already written half of the counting.
I'm just not, I just not, I'm not feeling comfortable with it, but I don't want to lose
that half in case I change my mind again.
Right? So this is exactly what branching is for right you would have you know a branching
one branch it just does you know simple accounting another branch it does some kind of svm and you
keep them going in parallel and so even if you're working by yourself what you don't want to do is
delete something because you're not sure if you're going to need
it right and so version control can can prevent that from happening but it does that overhead
and version control systems in my opinion are always somewhat complicated like it's not always
straightforward because they're trying to they all have a process that they're built around and
they kind of assume you're using their process. And often you aren't exactly.
Yeah.
And so then it becomes like friction between you and the way you do it.
The first time I used a get,
I really had that problem was I wasn't following the process.
They kind of assume.
And then it was friction because it didn't make sense to me.
I was just doing voodoo incantations to make it work.
Yep.
So, yep.
And then I think it's also important to point out
that as you do this,
that there's tools are optimized for different processes.
So like branching,
certain tools may be better at branching than others,
where branching here means,
like Jason illustrated illustrated you have two
divergent code paths and like a release you can do releases as version as branches so i make a
branch this is my release branch i'm going to send this out to the customer if there's bug fixes we're
going to fix them on that branch but we're going to start adding new features on the mainline code
and those two may diverge over time uh and then there may
be another branch for the next release the version 2 release but you could still add changes to the
version 1 uh because you have customers that need that uh but version 2 maybe people want to pay to
upgrade to that and get the newest features or whatever right you can have those handle as
branches but there are other ways of handling it too and then how like if what happens if you want to do a branch for experimental stuff and then
ultimately you want to merge it back into the main line like is that easy or hard different tools are
designed for different use cases and you run into certain things being easier and harder
depending on the tool you select that's very vague and abstract no it's true i mean i think
that it's the first time you try and use version control it's not going to feel very natural
that's that's perfectly normal um i definitely i've switched among many version control systems
and every time i change is very frustrating but every time i change change, I'm glad I did. When I first went to Git from Subversion,
I was just very frustrated.
But now I've kind of understood the workflow.
I'm very happy I switched over.
Yeah, so one way,
if you weren't going to use version control,
is like the classic, we were in college,
everyone's writing a
presentation and everyone has different like your group of three you're writing a presentation
everyone writes their own slides you all email it to one person before the deadline and they try to
like compile it all together but there are obviously some slides which are shared and then
a person is forced to kind of like manually go between and resolve any conflicts that's you know
one example but like that happens in source code too and source control just kind of makes that
that process very explicit which is good um you can also like as we already said uh go back in
time have branches have multiple versions and not have to like have you know main.c.v1 or main
right v1.c or you know what other naming schemes to handle it and even be able to apply bug fixes
to old code and still be able to send that to people also if you just like snapshot at your
directory every five minutes that potentially could work
for a lot of these cases too but that'll get really big unless you are only tracking the
differences but the source control is built with that in mind so they typically are pretty
efficient about storing only the differences as opposed to the whole files yep um so there are
some cons it's not uh version control doesn't solve all the problems
there's some use cases where it doesn't work um one thing to keep in mind version control keeps
the entire history um this can actually burn you pretty badly if you do something like accidentally
add a you know 100 megabyte binary file um to to the version control you try should try not to do
that um if that happens by accident you can use some you know voodoo black magic to delete the
file um you know you can't just delete the file because it's version control like the fact that
you deleted it is there and the history is there you actually have to do some black magic to to go back
in time and delete that file um what's that you need to purge it you need to purge it from history
right that's right there's different names depending on the source control but yeah
yeah yeah i think in git it's uh like a rebase you have to rebase and remove that commit.
It's not pretty.
But anyways, you have to keep the entire history of every file.
Now, it's compressed and all sorts of stuff, but at the end of the day, it's going to be pretty large.
So that's something to keep in mind.
Another thing is that it's not really designed for archiving. I mean, if you want to keep a backup of all of your pictures,
this is probably not the way to do it because there's just too much overhead in all of these processes
that you're never going to use
because you're just dumping pictures in there.
So for something like that,
you want to use the things we talked about in the beginning,
like SyncThing, BitTorrent Synrent sync all of that dropbox etc yep so we'll do a quick who's who's of uh
who's who who's who of uh source control systems you know that we've kind of used or heard about
talked about and we'll kind of go his you know kind of in chronological order uh so you'll have
heard some of these a lot of
people heard of cvs concurrent version systems there's rational clear case microsoft source safe
a lot of people's first experience that are of a certain age i don't know how to say that like if
you worked in software in a certain time that may have been your first encounter with it razor
uh yeah then we get to those were all you all things that were used in the 90s,
and most of them aren't used today.
I mean, it's possible, but...
And I say all of those are lock-based.
I don't think most of those aren't.
Merge-based is more recent
and has become more dominant recently.
Right, yeah.
I don't think it was as popular previously.
Yep, so in the 2000s, they had SharePoint,
which is also lock based but sharepoint targeted um
you know artists and things like that so microsoft documents yeah yeah that's right yeah yeah artists
uh editors writers um people are yeah creating that kind of content um and it's designed for
teams of people where um you know collaboration on a on a file level just isn't that important.
It's really more like if you and 10 people are writing a book, but you're each writing a different chapter.
That would be great.
SharePoint would be good for that.
The 2000s also introduced Subversion, which is very popular even today.
And that's where really people got into merging and branching and things like that.
Subversion today is considered kind of primitive.
The way you create a branch in Subversion is by copying the entire repository.
So it's a little bit primitive by today's standard, but still, as I said, very popular.
Then more recently we have like get Mercurial and these are interesting because they're both also distributed.
So instead of having a central server where everything is kind of held, it's in a distributed
fashion and only by convention does one of them become kind of the gold standard.
And every client kind of has their own thing.
You can work offline.
You can commit just locally and then upload to a remote, one host on a server.
But that's only, again, by convention that that is the one.
It doesn't have to be.
And so that's another difference is whether something's centralized or distributed, which has impact.
And so Git and Mercurial are two both versions of that.
There's also impact.
We didn't really talk about how you architect, like whether you have a project or repository or whatever you want to call it in the various version control systems.
But basically, at what level do you track stuff in one organized fashion or do you split it into
multiple ones and as you go to a really big team that starts to have a lot of impact too for
performance reasons right one thing to know about mercurial um mercurial actually has some pretty
cool functionality um where you can actually check out part of the repository.
In later versions of Subversion and in Git, you can't do that.
You get the entire repository.
And in fact, the way Git works under the hood, I don't think it even has a clear concept
internally of the directory structure and things
like that um but with mercurial you can actually uh set up access control on per directory basis
and things like that so i'm a big fan of of having one source control uh system for an entire company
wow that's pretty brave yeah i mean well a lot of companies are doing this i mean uh slack has this
um uh a pinterest is i believe works this way this is just from talking to friends
but uh um i'm a big fan of that i think that um you know you can really trust people are
administering stuff and there's still got to be some amount of permissions per directory, right?
Like you don't want one team accidentally just blowing away all your stuff one day.
Exactly.
So that's where Mercurial comes in.
You can get away with this.
You can use subtrees in Git and have sort of one repository,
but under the hood, it's really a bunch of repositories.
But to the user's perspective, it's just one.
But Mercurial natively just supports access control lists
on the directory level.
And so I'm trying to learn Mercurial.
I haven't learned it yet.
But yeah, as Patrick said, I mean, you can have, you know,
one version control project per team,
one project for the whole company.
There's many different ways to architect that.
They all have pros and cons.
And so that's definitely something that if you're interested
in more enterprise applications of source control
that you'd want to look into.
Yep.
And then also we didn't really talk about,
but all of them is also whether or not and how they integrate with your code review process or whether your company has a code review process.
It's not always a given.
So, yeah, you should definitely do code reviews.
I mean, I think it's very important to have another set of eyes looking at something.
And as you said, I mean, if you're using a merge-based system,
it seems natural to integrate the merge process with the code review process. And so that's what GitHub, GitLab, Stash,
a lot of these sort of source control management systems,
they say, okay, when you do the merge
someone has to approve your
merge before it goes through
and that kind of works like a code review then
yep
but yeah definitely
the moral of the story here is
don't be like us
we've lost things because we
didn't back up and
we had to redo work because we didn't have version control or didn't use it.
Since then, we've kind of learned from our mistakes.
Hopefully, you guys can learn the easy way through us.
Definitely use version control anytime you're writing source code.
One thing about Git, you don't need a server for Git because it's distributed, as Patrick said.
You can literally just type
Git init if you're on Linux or Mac. You probably already have Git installed by default. You can
just type Git init in any directory and now you have source control in that directory. It's that
easy. So definitely use it for your projects. It'll save you a ton of headache.
And definitely back up your photos.
Super important.
All right.
Well, that's a wrap.
Thanks, guys.
Cool.
One last kind of meta thing here.
Oh, so someone wrote in and told us that we're in the top 100 podcasts on iTunes.
This is in the US.
So I don't know what we are worldwide
or in other countries.
But thank you guys so much
for listening
and for your support.
And it's truly
kind of at a loss for words.
I mean, it's truly remarkable.
I don't know how often those change.
So by the time this comes out,
we may or may not be there. Yeah, we could be kicked off by then yeah we have we have screenshots so we'll
send them to you if you don't believe us yeah it's it's i mean like when we started we started
this what six years ago or something um just had no idea that i honestly didn't think anyone but my mom and my girlfriend at the time would
listen to this.
And it's just truly amazing that we've come just so far and we have so many listeners
and we just really appreciate you guys taking some time out of your day to listen to this
and we hope that we could provide a good service to you guys.
All right.
So thank you.
Thanks, everyone.
Bye.
The intro music is Axo by Binar Pilot.
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