Programming Throwdown - Deploying Software
Episode Date: October 31, 2016How to distribute software so it works on other people's computers. Show notes: http://www.programmingthrowdown.com/2016/10/episode-59-deploying-software.html ★ Support this podcast on P...atreon ★
Transcript
Discussion (0)
programming throwdown episode 59 deploying software take it away jason hey everyone
i have some pretty cool news so i've done some digging into T-shirts.
I found out something kind of interesting.
So there's two ways to get T-shirts printed.
The first way is ink printing.
And that looks, you know, okay.
Like, I don't really want to, like, bash it too much.
But it's not what you expect.
Like, when you see a T-shirt, like a professional t-shirt someone's wearing, this is not that.
Like, this is just, like, it looks, like, kind of stained.
Then they have screen printing, and that's, like, the real deal.
So I found a place that will do screen printing, but the caveat is we have to put in our order in advance.
So they just print it all. Like I said,
they have to set up some equipment. They print it all and then they kind of tear down the equipment.
It's not really like quite an on-demand thing. So I set up a straw poll. I'm going to post a
straw poll in the show notes and also on Facebook, Google+, all of those social media channels. And go on the straw poll and vote your size.
If you want to buy two, vote twice.
So I've set it up so that you can do that.
And put in your votes, and then we will bulk order the T-shirts.
And I'll try and figure out some way to get it to everyone.
But put in the order now and then also send Patrick and I an email.
So we have your email address.
So you put in the order, like the vote.
That way we kind of have an idea of how many people are interested and things like that.
Also email us and let us know what size you want. That
way we have a way of getting back to you. And yeah, let's make some awesome t-shirts. I'm really
excited. The design looks awesome. And I think this is going to be pretty killer. So that's the
intro. Let's do news and links. So my news item, first news item is Keras, and specifically it's Keras.js. So Keras is a neural
net library. The idea is you have a neural network which is a sort of nonlinear composition of
functions that's meant to sort of learn some mapping. So for example, let's say you have a bunch of weather data. You have the day
of the year, like is it February 14th of whatever year, and what the weather is. And you want to
build some model that says what tomorrow's weather is going to be. You could run it all through a
neural net, and it will approximate, it will kind of interpolate based on the averaging
and all that, what the weather is going to be like. So neural nets are very, very popular for
doing machine learning. Keras is a pretty cool library. The reason why I mentioned this is they
made something called Keras JS, which is pretty cool. The idea is you can take a model that's trained. So you
could take, you know, your weather model that you trained with Keras and you can actually run it in
the browser. So someone can actually have your model running in their browser and play with the
days and get different weather forecasts and things like that. So I thought, you know, especially for building tools and just for visualization, it's kind of kind of cool. So I guess to kind of
elaborate more or whatever, because I don't I know a lot of people get a lot of people are curious
about machine learning, but I don't always exactly understand how it is when you say they run the
model. What you're saying is you've trained it previously in some other way, but they can actually take a given set of inputs
and get the results without kind of training or changing the underlying model that's already been
trained or the weights that have been given. Yeah, that's exactly right. And the reason why
this is kind of really interesting and hard is they actually run it on your GPU. So, you know, these models, you know, obviously
training it is very difficult, but even executing the model, if it's really big, like imagine if
the model is doing some kind of crazy image processing where it's, you know, taking your
face and like putting a dog face on it something, like overlaying a dog tongue on your face like what Snapchat does.
Those kind of models are really complicated.
You can download a model which does that so you don't have to train it yourself.
They've trained it on a bunch of people's faces.
But even just running that model in the browser,
it just would run way too slow unless it used your graphics card.
And so I don't even know how they did this, but somehow I guess there's a JavaScript library for
accessing your graphics card. Oh, it's probably WebGL, right? Well, it's open source, so we can
look at the source and figure it out. That's right. So they're probably like, they probably
did some crazy web gl hacking
or something i have no idea how they did this but it's fascinating and uh they even have some
sample models which is pretty cool there's a model that where you can draw on the screen
and it'll tell you what number you drew like if you drew a three or a four um so yeah check it
out if nothing else check it out as like a cool toy to play with
um but if you're into doing machine learning uh check it out for realsies because it's pretty cool
i should also say uh snapchat is probably not using a neural network model for or a machine
learning model at all for applying a tongue to a face really yeah you have to detect your face
right so i well maybe but i mean you could do things like detect features of the face like
through sift or some other kind of features and tracking and putting it on i mean do you think
they're evaluating like they may have like a eye detector that is a model but you think they really
have a apply tongue to face thing oh no no you're
totally right so yeah they have like the neural net says an eyeball is here a nose is here and
then from there they kind of guess or maybe they have a neural net that figures out where the
corners of your mouth are or something yeah right or even just more traditional image processing for
doing those things i mean i don't know what state of the art is or how well it works i've never used that feature to be fair yeah so so so people used to
do a lot with like sift and these kind of like they're called unsupervised methods the idea is
you know sift is just like it's a way to just say look this part of an image is interesting
and someone has taken so many images um over such a long period of time that they have
this kind of interesting detector um a lot of people are moving from that to neural nets where
they um have labeled data and they say you know i want a corner of mouth detector um so that's
kind of the state of the art you're right though. Snapchat could probably get away with just using SIFT.
The accuracy would be like a little less, but it'd probably be fine for most things.
I mean, most people are looking right at the camera.
Well, also, they need to be able to do it, you know, kind of they're probably willing
to accept less accuracy for something that runs more quickly on a bunch of devices.
Yeah, that's a good point.
Yeah, great point.
But those are the kinds of things you have to think about. There's some trade off there. Yeah, I mean, you know,
in general, like neural nets are, I mean, they're super old, but they weren't that popular until
maybe five years ago or something. And so, you know, now like phone companies are starting to
catch up and things like that. But there's still a lot of, as Patrick said, a lot of devices where, you know, you could run SIFT pretty easily, but you can't run a neural net.
So the next news article we have is called More Interesting Mazes.
And it's on, I don't actually know how you would pronounce the name of this website, but it's been around forever, Gamasutra.
I call it Gamas sutra but yeah you're
probably right it could be yeah so this is you know you've probably seen them before if you've
hung out anywhere i don't even know how far back they go but they run a lot of articles about
technology behind making games game development uh they host like post-mortems for failed games
and so there's an article i read a few days ago about generating
interesting mazes and this is at first i thought it was going to be about you know the maze that
you did when you were well maybe you still do them but where you have an entry point on one
side and an exit point on another uh and you're trying to go through the maze but i guess it's
all it's kind of just talking about more generally a maze being a mathematical term where there are
rooms and walls and there is only a single path between any two rooms so kind of like doom like
the levels and do exactly right so talking about like levels for a game although i mean you could
have multiple paths there isn't anything wrong with that but if you restrict yourself to trying to have a unique path between two different points and
then kind of going about how an algorithm would generate a maze and there's like a lot of naive
ways of doing it but then if you kind of start adding coloring to the various you can think of
it as like a grid into the various nodes on the grid adds different coloring and run the algorithm.
You can kind of generate and it has a,
if nothing else,
you can just go through and look at all the pictures.
They're kind of cool where they generate slanted mazes and,
you know,
circular mazes,
recursive mazes,
and just talking about all the different ways to generate.
And I,
you know,
it doesn't kind of call it out,
but this is very similar to kind of procedurally generated, or i feel like this is sort of similar where you're kind of taking a
notion or description of how to do something and then kind of applying that to a whole area
yeah totally and so they're producing what looks like really interesting designs and patterns from
relatively simple rules yeah this is awesome this reminds me
of uh and i think we talked about this years ago that cellular automata that made cave
cave mazes oh yeah yeah yeah this is so cool i wonder you know i mean you could make a maze app
for kids or you know they have to draw from one side to the other and it could just keep generating mazes it would never stop yeah cool but i mean i guess this is an interesting thing
where you can make many valid mazes but if you don't kind of teach the computer what is an
interesting maze then the maze could be really boring yeah right or super super hard right if
there's only one path or something yeah and there's
like ways of measuring that for mazes but people talk about the same thing for like sudoku that
you know there's like the ratings on the puzzle and there's kind of a way to quantify how hard it
is but then there's an argument where people say oh humans create better sudoku puzzles because
they kind of craft an experience through the solution versus the computer doesn't but over time the computer can be taught to do the same thing um and so
it it doesn't work anymore there's a thing that still floats around i was reading some about it
with the recent alpha go where people for a while the best chess the west best way to play chess
was a you run a bunch of computers
and then a human makes judgment call about which computers kind of giving the best answer
and this kind of hybrid human and computer approach. And for a while that was like
considered better than either humans or computers. And so a lot of people actually,
that became kind of like a, a notion that a lot of people still think is true, even though now computers far surpass like if you a human gets involved, it'll just make it worse.
And so actually what you're describing is kind of interesting because there's a surge in a new method.
There's a ton of research papers that came out this year on this method called generative adversarial networks.
And it's exactly what you described,
except instead of a human, it's another algorithm. So basically, you have one algorithm or many
that generate solutions, let's say,
and then you have another algorithm
that kind of gives you a thumbs up or a thumbs down.
And the algorithms that got a thumbs down on their solution, they are disappointed. They kind of changed
the way that their function works. And the ones that got a thumbs up, they're reinforced.
They want to do that again. And so the idea is they actually used it for generating art.
So they built this one algorithm.
All it does is it looks at a bunch of fine works of art and a bunch of random images,
and it learns to distinguish one from the other.
And then they have a bunch of other algorithms that try to generate fine art.
And this first one tells them how good they're doing.
And it turned out if you do this enough,
you can actually make your own art generator
where you kind of seed it with,
like you could seed it with a picture of a robot
and a Van Gogh painting,
and it'll find some way to integrate those two together
that makes the fine art algorithm happy
oh interesting yeah yeah we'll make that a news next next month but yeah so anyways more
interesting mazes that was a little bit of a side stroll but yeah no that's totally awesome
check it out has a bunch of really cool pictures of mazes very compelling makes you want to solve
them all um uh i guess you can't though right because they
don't have well you could if you because any two rooms are only connected in one way if you put a
random start and a random finish anywhere there you go it'll be valid i think i didn't i didn't
think all the way through that but yeah um all right my news is something pretty cool. It's called MyPy. It's static typing for Python 3.
So you see a lot of languages that have this,
like with dynamically typed languages,
like they do this goofy thing with the annotations
right at the top of the function.
You do like at sign, int,
and it just feels so like ugly
and kind of hacky and crafted.
This is not that.
This is finally statically typed Python that looks nice.
So, like, for example, in the, you know, function parameters,
it works just like, you know, hack did to PHP.
So in the function parameters, you just put the name of the parameter, colon, the type.
And if you don't put a type, it works just like Python.
But if you put, you know, colon type, then mypy can do something, you know,
do something clever with that.
So, you know, if you, if your function is, you know, x colon int,
and someone passes in john to your function, the mypy checker,
it's not a compiler really, because the Python compiler handles that. This just checks it
and says, you know, no, you did something that's not legit. This is super, super important because
of, you know, code aging and because of many people working on the same code base.
I mean, if I have a function that takes two ints and a string
and I decide that the middle int, I don't want it anymore,
so I just delete it and people are calling into my function,
Python will, well, depending on how the person calls into the function,
Python might actually accept that.
Like if I have an args component at the end or something.
And it'll just, the program will behave in a very strange way and no one will know why.
So this static checker catches those things.
And I can't tell you how many times this has saved me in languages that have this like TypeScript and Hack and things like that.
I mean, I've been, I constantly advocate for, you know, strong typed languages. And this kind of
brings it to Python, which I think is pretty awesome. There seems to be the current trend is
away from untyped or dynamically typed, I guess not untyped, but dynamically typed languages.
The pendulum seems to have swung back
to adding types or having types yeah i mean now that they have the uh what's it called um
like haskell and scala the type inferencing now that they have the type inferencing where
most of the time you don't need a type but but some of the times you do. Like, for example, if you have a function, the parameters need to be typed because there's no information to be gleaned there, right?
But if you have, you know, x equals 1, you don't need a type because it's just right there in front of you.
And so, you know, type inferencing has allowed, you know, programming language designers to only, you know uh have you put a type when it's
really needed and i think that has made strongly typed languages just you know much more like all
the value is still there and the penalty is not so much well that's if you're very aggressive in
using auto in c++ it's it's sort of the same way. A lot of times, auto is a shortcut
for a very specific type
and the type cannot change
and it can only be one type.
But the compiler will figure it out
instead of you needing to write it out.
Yeah, exactly.
I don't know.
Does your editor do this?
If you go over,
if you mouse over a variable,
so I haven't done C++ in a long time.
If you mouse over a variable that's auto, will it tell you the type?
I use Eclipse and it won't.
It will tell you if you got it wrong.
Like if you have auto foo equals some constructor,
and then you do foo dot, it knows the type of foo but if you hover over foo
it just gives you the line where you defined it oh i see maybe it's just a ui change but for scala
for scala whenever you hover over a variable eclipse tells you the type it's super valuable Yeah. Well, talking about C++, the 2016 CppCon just concluded and I had previously leading up to it.
I guess I've never really traveled to a convention like CppCon or visited or attended.
Seems like it would be cool. Yeah, just never gone.
We should go. I mean, I feel like we're doing ourselves a disservice.
There you go
we'll have a boondoggle i mean business trip um yeah that's right what's the next one in hawaii
yeah exactly i was thinking the same thing but there are several topics i caught my eye or i'd
come across them in google searches um and the nice thing is after cpp con they do release all
the videos just on YouTube.
And so it's not really a news article, but a helpful link is if you go to the uploads portion of the CppCon channel, which will link in the show notes, or you can just type
CppCon, one word, into YouTube, you will see a list of the 2016 talks.
I don't know if they're all up yet, but they have a whole bunch up now. It looks like they stopped uploading a couple of the 2016 talks i don't know if they're all up yet but they have a whole bunch up
now it looks like they stopped uploading a couple days ago so they must be almost done or done
yeah there's hours and hours and hours of talks there are and there are some really good ones in
here like i don't want to name any because i know i'll mess some up but and also i'll butcher some of the speak many all the speakers names
but herb sutter has some good ones in here about kind of how modern c++ should work and how you
should use pointers and memory ownership and transfer um that's really enlightening because
a lot of people still develop c++ as they did a long time ago and c++ is well
you can't i don't know if you can say it has changed i mean it has changed but you can still
do all the old things but there are kind of newer ways that are mostly just strictly better
yep um and so if you're not writing modern c++ most of the time you're probably missing out
there are probably rare occasions
where you shouldn't or can't, you don't have a compiler which supports modern C++.
But there's a lot to offer and kind of the modern way of doing it.
Yeah, absolutely. Yeah. I mean, think about how many wasted, like how much wasted code is,
you know, for int i equals zero or for some iterator you have to define it and
increment it and you know and with auto i mean yeah there's a ton of new stuff it's really cool
and so there's a lot of stuff in here i think even about proposals for i guess what will be 17 c++
17 um and yeah i would all the talks i've watched or watched part of have seemed
really well put together and I really liked what they were
saying but I assume there's also stuff
in here that's considered controversial
or just someone's opinion about the best way to
do stuff I've seen like a
lot of convention drama
recently there was a
I can't remember I think it was Ruby on Rails
there was a convention where a guy got kicked out.
I guess he was making some rude jokes or something.
But like, oh no, it wasn't Ruby on Rails.
It was Node.js.
There's a Node.js conference and this guy made a couple of rude jokes.
I didn't think they were that rude.
They were kind of rude.
And like they kicked him out.
Like he was supposed to speak again the
next day they kicked him out and then someone got kicked out of another conference a couple weeks
later so yeah don't be rude at conferences i i was also wondering like what it takes to
present at such a conference like i mean i know you apply and you you kind of send in what you
would like to talk about but i feel i would be feel very i mean we do this podcast but i would still feel very intimidated to
get up at a you know cp c++ conference and present something c++ related uh personally i just find
that like super scary yeah but they're i think they're all developers like you know they're all
c++ so it's probably
a pretty tight-knit community i would do my guess yeah if you went to them you probably wouldn't be
i guess because i've never listened to a conference the thought of presenting at one
seems really intimidating yeah i mean it it uh the thing about it is is the audience of c++
obviously enormous but like the developer base I don't know how many people
do you think you know have written more than a thousand lines of the C++ compiler probably not
that many maybe I see what you're saying so you're saying it isn't people who write C++ you're saying
it's people who are kind of nerd out on the language itself yeah exactly so it's not c++ users but when you say c++ developers you mean
people working on clang and gcc and yeah like libraries they might be you know hundreds of
thousands of c++ developers who watch the talk but who actually go to the conference you know
it's probably just a core group of people i guess i should have done more research for my news article
i don't know what the intended audience for the conference yeah actually i'm just i mean i'm just
speculating i don't know either i assumed it was probably a c++ users conference um maybe yeah i
wonder it's okay well there's so the videos have been up for six days and they have a thousand views.
So yeah, I mean, it's probably, I mean, it's probably is for users, but hardcore ones like
you.
What?
Oh, wait, that's a compliment.
Nope.
An insult.
I'm not sure.
No, it's definitely a compliment.
All right.
Well, time for book of the show.
Book of the show.
My book of the show is a bit of a cop out um
this is a website bayesian methods for hackers um we've covered this before yes it's a website
as the website before yeah and this is a book so the website was so popular um they printed it out
i'm sure in in no small part because of us.
And maybe because it was on the front page of hacker news for months and months. But, uh, uh, you know, the website was so unbelievably popular and so enamoring that, uh, they printed a book.
Um, the book is literally the website, um, you know, in a, in a nice format. Um, but I think
it's awesome. I'm going to pick it up.
It's a great reference material.
The thing about this Bayesian, it's really,
a lot of it is about explaining uncertainty.
And this is something that I honestly feel like
everyone with a CS degree needs to know.
Like, let's say you do make, it's a good example. feel like everyone with a CS degree needs to know.
Let's say you do make... That's a good example. Let's say you want to make an AI to play
Risk. Well, Risk has a lot of chance, right? I mean, you roll the die,
sometimes you win, but then there's...
Forget about making an amazing player, but even just making
a basic player, there's risk, but you have to kind of make decisions in a domain where you have this uncertainty and you have to be able to adapt to the uncertainty and kind of model that.
And I definitely, when I got my degree, I had no idea how to do that. And I even, you know, I knew a lot of AI machine learning, but everything I knew was
what's called frequentist, which means you don't model the uncertainty. You know, if you flip a
coin once and you get heads, you just say that coin can never be tails because I've never seen it.
And so this is the heads coin. And you you could get you know far with that but i think
whether you're doing machine learning or not you know every all of us who write software have to
deal with uncertainty and uh for that reason i love this book because it caters for people with
the cs degree and kind of walks you through how to deal with with you know these kind of walks you through how to deal with, with, you know, these kinds of circumstances. And if you ever played,
you know,
civilization or any of these games,
and you think like,
how does the AI do this?
I mean,
there's all this chance,
like how does the AI,
how can it plan for that?
This book is,
is for you.
It's,
it's a really good read.
It's not hard,
not too heavy and check it out.
I read,
which is not my book of the show, but I will mention it.
Maybe I'll make it a future one.
Is The Signal and the Noise?
Oh, I've heard good things.
Well, it's a, what would you call that, a popular book?
No, it is popular, but it's written for a general audience.
And so he does in there discuss exactly what you were talking about the
difference between bayesian and frequentist views of the world and has some kind of cogent examples
and talks about how predictions which is kind of like the the main subject of the book is about
like bayesian thinking is about making predictions and evaluating if you got your
prediction right or wrong yeah um and so how that in general we should be moving to that because it
kind of better fits the world uh yeah i mean it's very hard uh just to like let people know why
everything is in bayesian the problem is um instead of thinking about things in terms of numbers,
you think about things in terms of distributions, kind of like the Schrodinger's cat. It's like
this coin, you know, it isn't heads, it isn't tails, it's, you know, 50-50. And the problem is,
the world is more entangled than we can understand.
And not we as in human beings, but it's very hard to make a machine understand
the entangled nature of the world.
Like, for example,
if you have a feature in your model called day of week,
it can't be Monday and Tuesday at the same time, right?
Like, if it's Monday, you know
it's not Tuesday. But, you know, for the model to learn that, it has to see all the pairs of
features. I mean, if you tell it explicitly, then sure, right? But in general, the model has to look
at all the interactions of all the variables to figure out which ones are sort of entangled.
And that is super, super hard and it requires an unbelievable amount of data.
So for these reasons, it's very hard to get Bayesian stuff to work when it gets really complicated.
And that's why when everything was complicated in the 60 the 60s and 70s people couldn't couldn't
you know get there right but now it's starting to become more popular so i yeah that maybe i'll
talk about in the future but he has a lot of case studies about kind of failures of prediction um
anyways yeah yeah we should definitely uh do that because i've heard good things i haven't
read it yet i'll read it there you've already read it and we'll talk about club our yeah uh so my actual book of the show which
seems anticlimactic at this point is a zero to one by peter teal and i hope i'm saying that last
name correct yeah and okay good and this is his view on startups on a broad ranging set of topics i guess and it is mostly about the
difficulty exactly what the book describes of going from nothing to something which is as opposed to
what most companies do which is once you already have something trying to improve that something
which is like from one to two,
for instance.
Right.
And so going one to two is a very,
very different problem than going zero to one and how that confusing the two
is never going to really work for you.
You're going to have problems.
That makes sense.
It sounds really obvious when you say it that way.
It's also him just kind of talking through some of the stuff behind what he's done,
a little bit of a biography, I guess,
with his work in PayPal.
And then some notes about how,
when he runs a venture capital firm,
how interestingly, if you try to go for the companies
you think have the highest probability of success
and you build a portfolio out of them, your portfolio will probably not do very well what you actually want to do to some
extent is increase the variance looking for companies that have a great idea but a very low
chance of success but what you need is for them to go zero to one and return you know a hundred
thousand times your investment and then
it'll more than make up for all the other money you invested in the other companies and i see or
and this is probably my opinion on kind of his his thinking there but the way i kind of take that away
is when you hear people saying why in the world would people invest in this company that seems silly?
If it's silly because it's a radical idea,
then it's probably very much merited,
even if it's almost guaranteed to fail.
But if you hear about a venture capital firm investing in something that has a very low chance
of returning 100,000x on,
even if it's successful, it's not going to move the market,
then that actually might
be a venture capital firm that isn't of the same caliber of what Peter Thiel is advocating
is kind of the right way to do that investment.
Oh, that makes sense.
This sounds like there's something called novelty search and it works like this.
You, so the idea is you have kind of some function you can give it inputs you can get an
output and the way novelty search works is novelty search if you give it a certain set of inputs you
win but you don't really know what those are so with a regular type of search you know you would
start with something random and then you'd start with something a little different and you'd see
kind of did it get better or worse this is called hill climbing and as you just keep tweaking things tweaking things you get better better better
better better and at some point you get to the point where no matter what you change it gets
worse that's called a local optimum and you just say okay i'm done um novelty search is kind of
interesting you feed in a set of inputs and then you feed in, you know, a different set of inputs.
And if you get the same answer, that's bad.
So if I feed in, you know, the second thing and I got the same answer, like, you know,
I want to stay away from that part of the input space.
So if I feed in, you know, if I change the second variable just a little bit and I get
a totally different answer, then I know, aha, the second variable, that's where all the interesting, that's where all the variance is.
And so it's kind of like you don't even care about the answer you get.
You just care that it's different from the other answers you've seen before um and so that's it's interesting like peter deal is basically advocating
novelty search when you're investing which sounds super dangerous but i mean it makes sense i guess
i mean if they find that if that one thing they find is that valuable then it makes sense he also
has thoughts about monopolies which is interesting and how monopolies can be good and you really
want to invest in them uh but you know kind of like what are the downfalls of it but you know
he talks about a lot of people kind of think they have monopoly but they don't and then you just end
up in a market that's a race to the bottom um i see and then how like he has some thoughts about
is google a monopoly and like why or why not?
Or like a de facto monopoly?
You know, anyways, it's interesting.
I don't want to, you know, spoil it all or give my interpretation, which is probably not right.
So go listen to him tell it.
And I will totally, totally check that out.
Although I guess now he's gotten into like some political stuff.
So people might not like this suggestion of mine.
Oh, yeah.
This is not in regards to that. This is just in regards to the book and him talking about startups that's why we were like
racing each other to give that disclaimer i mean i don't want to get involved this is uh this has
nothing to do with politics at all this is peter thiel talking about his companies he has a lot of
interesting political views as well and that some of those are in this book but not his really recent ones because this book's a little bit old i don't remember when it
was released and uh so you know we this is a portion of show where we get to plug some stuff
and i actually did listen to this book and all the books i listened to because i have a long
commute on audible and we do have a affiliate link with audible and if you go to that link you can get a
free credit which is good for basically any book that they have in their library of which they have
many many many books and if you go through our link then we get a little bit you can help the
show and get a free book and then you can cancel after you get the book or if you don't then you'll
just get a monthly subscription and get a book every month, which is what I have.
And actually, my wife started listening.
I don't know if we can say that on air.
Oh, well, my wife shares my account.
And so it lets us do that.
That's fine.
People won't judge.
I hear everybody talk about HBO all the time.
Apparently, there's like only one HBO login in the whole world.
With Hulu, I think it's, no, sorry, not Hulu.
With Spotify, they crack down.
I know, yeah, like Hulu and Netflix,
like there's a limit to how many streams.
Anyways, this is off topic.
So, you know, now my wife's actually gotten some books
and so she's been, she's like,
wow, this really actually is good.
I enjoy listening to these books while I'm in the car
where I would otherwise just listen to the same songs again or whatever.
Yeah, I need to do this.
You know, I've been reading books on the bus.
And lately I've been like,
lately I've had to work a lot of overtime.
And I've been reading books.
I feel like, you know, doing slow but permanent damage to my eyes.
Like maybe, you know, listening to books, even though I'm on a bus,
you know, just closing my eyes or looking out the window
and listening to books would probably be much healthier.
I knew someone who listened to books while they were working.
I can't do that.
Like it's too distracting.
Yeah.
But while I'm in the car or whenever, like, yeah, I do it.
I mean, you can also listen to podcasts like this fine podcast.
That's right. Don't get an an audible subscription if you have to choose between audible and our podcast but if you have the luxury of doing both which you should because we're only on once a
month then uh check out audible you go to audibletrial.com slash programming throwdown
all one word um we also have patreon so patreon is a is a pretty cool service
you can actually download the episodes from patreon i know some of our russian friends can't
can't get the episodes from their source i'm still looking into like a better way to to handle that
but at the moment you can download mp3s from our website or from
patreon which has a really high high speed connection um if you're a patreon subscriber
um you go to patreon.com slash programming throwdown um it's as little as i think a dollar
is the minimum a dollar a month i don't know if you can donate it's an episode right it's per
episode yeah i mean we keep the episodes once a month we're not going to like accidentally we're not going to
purposely shill you and put 10 episodes a month or something i don't think we can even do that
episode part one episode part two yeah right um but yeah anything you give helps out the show
it goes to things like uh you know designing this t-shirt. So we appreciate all of your donations.
So being the last episode before the election,
I have to make one joke based on what you said about,
which you are right, several people have written in
that they can't download from Russia,
but they can read all of our politicians' emails.
They can't listen to this podcast.
That's our problem.
We didn't have our rss
feed on wikileaks so we just need julian assange to decide that this is controversial and then
everyone can get a chance to listen to it yes julian if you're hearing this uh i'm sure he
listens yes i'm sure he listens hack my computer and take all my programming through episodes, but please leave my credit cards intact.
Please no one do that to any of my stuff.
Yeah, I mean, yeah, joking aside, don't ruin my life, please.
I know some people out there are good enough to do that,
Uber hackers, and that would make my life hard.
Tool of the show.
Tool of the show.
My tool of the show is, how show my tool of the show is how do you say the term meter
why is every meter oh sorry i won't interrupt you oh just termiter which is supposed to be
like thermometer or something i don't know but the idea so i uh um the way i work is I write a lot of kind of scripty tool kind of things, prototypes, things like that.
And I want to work very quickly.
And usually the code I write has to be rewritten.
Like once, you know, the target keeps moving, we're learning a lot.
And then we say, OK, this model works now.
Rewrite it.
So for this reason, like I need to work fast.
And usually, you know, I'm writing all this code.
I have a bunch of prints.
It's in Python.
I'm like printing a bunch of things.
And then I kind of have to look through and I see, okay, here's a print saying, you know,
iteration two and then some data and then iteration three and then some data.
And I have to like in my head kind of get the average of all these iterations.
And it's just kind of a mess
and it's and sometimes i'm just wrong like i just misread it or i think the average is this just
from eyeballing it and when i go further down it's really something else and basically what i need
is a way to go from prints in python to a graph but i need it to be just very, very easy. If it takes more than 10 minutes, it's not worth it.
I could just eyeball it.
And Termitor does this.
It's amazing.
Basically, it uses Unix pipes to stream in data.
If you don't know what this is, check out our Unix commands
episode.
But you could stream in numbers to this termiter
and it will turn it into a plot right there in your terminal so so you could say like print and
then do like asdf asdf asdf and then some data then you know you're going to get all this prints
with all these different things you could do a grep for that asdf so on so now you only have those lines that have those numbers that you want
and you can you know cut out those numbers pipe them to termiter and you have a graph so um
it's super super powerful i've been using it a lot it's a lot of fun i actually wrote my own before someone told me about this um the one i wrote actually does png so i think i'll keep mine but uh uh but this
is this is totally awesome and it's uh um it's right there on github now i'm distracted because
the movie of the example is this website asciCII Cinema. And so they have a whole bunch of ASCII art movies.
Now I'm distracted by clicking on random ASCII art movies.
So if nothing else, go to this GitHub page.
I really encourage you to get it.
But if you don't, check out the ASCII art movie.
And then, yeah, follow all of the other ones on that website.
Nice. So my tool is, unfortunately, this is only, as far as I know, on the iPhone.
But they have an equivalent on Android as well.
And that is Motion Stills.
And so this is a product that was released by Google.
And then I don't think it got a lot of traction.
But they did integrate the technology that was a part of it into Google Photos.
So I think this is how you can get to it in Google Photos.
But I will say if you have an iPhone, it's worth checking out, even though it's if you also already have Google Photos, which is awesome.
And you should get Google Photos. I do recommend Google Photos.
Yeah, me too.
And so what this will do is on your iphone if you take a live photo
or you take a movie it will do uh i guess essentially image stabilization on the kind of
movie that you have so that the things that are actually moving in the scene kind of pop out to a
greater extent and oh is that what it's doing i was wondering what it was
doing right and so the reason you think oh that's not that big of a deal except that when you have
the looping happen and you manage to before i had kind of live photos turned off and i thought it
was just a waste of space uh but now i've turned it on almost exclusively because of this most of
the time it kind of is just like,
oh, that's silly or it doesn't work.
But occasionally you just manage to capture something
where if you're handholding the phone,
it moves just enough that you've ruined the effect.
But if you run it through the motion stills
and you get the live photo
where it's just like a person moving
or turning to face the camera as you tell them,
you know, smile.
And then you take the picture
that you get this really cool you know much more artistic effect yeah it's like the whole world is
frozen except for your friend well it looks yeah more like a cinema or a movie where you have a
stabilized camera uh but when you're hand-holding you almost always get some vibration in the movie
yeah this is so so cool yeah i uh i didn't know but so wait so if
you have google photos you already have this is that right i believe that for movies i don't know
i assume for live photos isn't a thing in android but if you have a movie i would assume that google
photos either at least has an op is what i read has an option to do this or we'll do it automatically
for your movies cool where it'll try youtube has
that as well where it'll try to motion stabilize the movies very cool i'll try this out that was
you should just go watch the videos on search motion stills and watch the videos because i'm
sure my description of it was butchering it no no i thought it was solid it makes sense cool um okay so now we're the topic of the show the topic which is
distribution you deploying software you wouldn't think that this would be hard it is it's one of
these things that kind of creeps up on you um as a developer you don't really expect this to be a
problem um like where do we? I guess we start with applications
that's kind of the most straightforward
the most obvious question is, I built this thing, it works on my computer
why don't I just zip it up and email it to someone?
I mean that seems very logical
if you try this, here's what will happen
you and possibly your friends,
it will run no problem. But for most people, it won't work. And the reason why is
everyone's operating system is in a different state. I mean, you might have developer tools
that most people don't have installed.
You might even have just, you know, a slightly different version of Windows. Like it's still
Windows 10 or XP or whatever you're running. But it's just, you have a couple of security patches
or a couple of updates that other people don't have. And when it goes to their computer it just blows up, it ends badly
so basically
don't zip up your program and send it to someone
you can do that if it's your friend
and if it doesn't work it's ok
but don't zip your program up and email it to your whole school
it's just not going to work
I guess surprisingly
it actually is shocking that it
does work sometimes like if you think about all the chances for it to go wrong different
processors different whatever but it actually has a non-zero chance of working and that actually is
kind of amazing in itself is that you can't true. You can't email, you know, you can't email random, like stuff from Windows to Linux,
like that won't ever work because of kind of how the syscalls work between the different
operating systems.
But if you email it to, you know, your friends and family, there is actually a chance of
where, and that's actually kind of cool because of how, and that's one of the purposes of
the operating system itself is to make it so that you don't have to be specific to the exact processor you're on
or to the exact configuration of everything but then like jason said there's also a lot of things
that can go wrong uh and so one of those things that can go wrong are your dependencies which is
the stuff that your programmer lies on that you may not realize at first which
is uh you know if i install and it depends on what language you're in how obvious your dependencies
are but in python for instance if you've just you know pip installed something on your computer and
you send your python script to someone else and they try to run it and they're like it won't work
right that's not sending a binary i guess but sending that script and it doesn't work is
because you installed something and they didn't. Yep. That's right. But even for something like
C++, if I use, uh, for instance, direct X and I, well, I guess this isn't true. It is included now,
I think, but if I sent it to Jason and Jason didn't have the same version of DirectX installed as me. Yeah, if you used OpenAL or something.
Right.
Then I'm depending on some code that isn't shipped with the source code that I compiled.
And that would happen if I'm using specifically a shared library, which is some binary that's compiled that isn't an executable but is on my computer.
And on Windows, those would be dlls or sos on linux
and even like you know no matter how even the most professional software development studios
still have this issue to deal with like that's why when you install a game on steam
you get that little box saying you know checking for direct x installing direct x
it's because nobody can guarantee that you have it so everyone just makes you know, checking for DirectX, installing DirectX. It's because nobody can
guarantee that you have it. So everyone just makes you at least check for it. Right. And so part of
distribution is making sure that the shared libraries that are expected on your system are
there and that they have a compatible version because maybe the person has an older one or
a newer one that is incompatible with your version.
And so sometimes you end up with it must be greater than and sometimes must be between and sometimes must be equal to the version of that library.
That's right.
And even if sometimes you don't have shared dependencies or shared libraries, but sometimes there are static libraries where the library is compiled into your binary itself.
And that's one way to avoid having to check for it
on someone's system is to just include it in yours
when you send it.
The problem there is that that's duplicate code.
So it makes your binary bigger
because you have to ship with all of the code you use
instead of everyone being able to share the same code that is the same.
That's right.
And also, some people won't give you a static library.
Like DirectX, I don't believe they have static libraries.
That's a good point.
Also, it's a little bit of a trap.
Sometimes a static library will refer to a shared library,
and you won't even know
that now you're depending on some shared library that you didn't know about. So yeah, there's a
bunch of gotchas. There's certain like low-level tricks you can do. Like there's this thing called
dependency walker, but you don't want to do any of this. You want an installer that will do this
for you. This is kind of like writing your own compiler.
You don't want to do this.
I mean, unless that's your expertise.
So there's a bunch of installers.
For Windows, there's something called NSYS,
which is a null-soft scriptable install system.
On OS X, there's Sparkle, which is very popular.
And on Linux, there's PPA, Personal Package Archives.
They all sort of have kind of different procedures
for building your package and deploying it and things like that.
One thing I strongly recommend,
if you're planning on deploying software to customers or to strangers
or to any large group of people, get VirtualBox and get a version of
Windows, a vanilla version of Windows, maybe even two different versions of Windows and a version
of Linux or what have you, and make sure that you can install your program on that machine,
that virtual machine that doesn't have anything else installed
chances are the first time you try nine times out of ten you know you'll run your program and it'll
pop up an error saying oops you know you don't have you know visual studio developer files or
something like that and you'll have to add that to your installer so it's also worth pointing out for large projects and large programs that doing the installer and
distribution and checking compatibility on the platforms is a job for people or people's unto
itself but for a small team or program you know a person is probably doing this along with doing
other stuff yeah and it's very time consuming um you know when i release maim hub um i mean especially now that maim hub's been around for
so many years i mean i spend more time on the installer than anything else to this day i mean
the past maybe three years every year i've spent more time having maintenance issues on the installer than anything else.
Another way, I mean, people have obviously gotten sick of building installers and definitely zipping their binary.
So they have app stores.
You could consider Steam as an app store, right?
Windows has an app store.
Apple, obviously, with iOS and OS X, they have the app stores. They're called app store. Apple, obviously, you know, with iOS and OS X, they have the app stores.
They're called App Store.
Android has the Play Store.
And basically, along with the store, there's also, like, developer support.
So if you want to make a Windows app for the Windows App Store,
they've made it as simple as possible where you hit some button and it does everything it needs to do so that when someone gets that app from the store that
it will work on their computer. They provide pretty good guarantees for that.
Yeah. So there's a way to package and describe the needs of your app
in a consistent way so that it works for everyone.
Exactly.
I guess Steam's a little bit different there because i don't think steam has the same level of integration with that
um does it i actually have no idea how steam works i mean i'm assuming that there is steam
i'm assuming that steam integrates with visual studios somehow uh but uh But I don't know.
It's a good question.
But the continuous, sorry, the way that Steam is kind of different
is that Steam has a wide variety.
It has DOS programs.
It really has to support a much broader base than something like iOS,
where you know everyone's running Xcode.
Or not everyone, but most people are using some variant of Xcode or Xcode build.
So yeah, Steam, actually, it's really interesting.
If you work for Valve and you're listening right now, write in.
And we're super interested how Steam actually works from the developer side.
So related to this topic, but not quite what we've been talking about, so change of topics lately, is continuous delivery.
And we'll talk about continuous deployment. And this is talking about you write the source code as a developer and then assume you have a system that produces the installer
that describes the dependencies, that packages it up and ships it.
How does the process of when that happens occur?
And I think this is a topic of interest to a lot of people.
The traditional way that it used to be done i guess almost everywhere
was people would essentially write code or if you're a small team you know you will write code
at some point people will begin to say oh this is we're ready to kind of build this and ship it
you'll kind of compile it all package it up install it on a few computers virtual box make
sure it works and then when it does you'll
kind of ship it to someone and then you'll probably freeze that code and then you know start kind of
making changes against it and if there's a problem that your customer has or your friends have you
would edit that frozen version and try to like apply bug fixes and that that that's kind of a
very traditional way of deploying software and the
software process then nowadays you start to hear a lot of talk about continuous delivery or continuous
deployment we'll talk about the difference in a second and this is more once i integrate code
into the repository a series of automated steps begins to occur where it builds my code, it runs my unit tests,
it builds the installer, it, you know, maybe run some integration level tests,
checks for problems. And that happens in a system and you'll hear stuff like Jenkins,
which is what will kind of monitor for those events and perform some scripted set of actions.
And continuous delivery is about doing that
on a very regular basis, like every night or day,
or even with every change,
doing some set of those tests and integration
and making sure that the code is ready
to be deployed at any point.
Any code you have, it always builds,
it always is ready it's passes all the
tests but then it might go through a step of like human qa or evaluation quality assurance
or evaluation or testing before it's kind of promoted to this is a good release or a release
candidate but you still have kind of you might hear like nightly or different people have different words
for it but you'll have still installers or versions of the executable for a much more granular fine
grain uh thing yeah and that that this is uh this is one of the things that makes this possible is
um you know thrift and protocol buffers and these kind of like very backwards
compatible information kind of representation. Like if you have so many different versions,
if you're literally putting out a new version every night and you're sort of tweaking the way
that data is saved, you need something like Thrift or protocol buffers. So someone on version 800 can migrate to
version 802 without having to start from scratch. That's right. And you begin to see there might be
some problems, which is how do you check code into the code base for people to be able to review,
but you don't want it kind of running yet, or it's incompatible with some other version.
And this is where you start having feature flags come in. So portions of your code are active or
not active. And then for continuous deployment is like another step above continuous delivery,
where in continuous deployment, you really are, after all of the automated steps complete,
you're kind of saying to other people who would use your code,
you can now use this. You wouldn't really, I guess, see that in something shipping to consumers. I
would think that would be really weird. But for teams where you're producing a library that another
team in your company consumes, they may have this where, you know, every night, there's a new version of your library produced, and their build
system just picks that up into theirs. And so you better make sure that your code, and you have the
tests and the automation to check that every single one of your changes could have that happen to it,
because you don't know when it's going to be created at any time. Yeah, actually, it made me
think of something kind of interesting.
I wonder how many, I wonder for an average software, for average company that develops
software, how much of the software you think is used internally?
My guess is a lot.
I mean, my guess is probably 50% when you include it and and everything so so more than half of the software you write
or your company writes will be consumed only by your company well i guess it's hard so if you
talk about like a micro services architecture even just a regular distributed system you know
you might have the amazon front page or home or search page or whatever there's a whole
bunch of services that are behind the application that is really kind of driving most of that are
those things internal or not like it's hard to say oh good point i guess internal is a little fuzzy
i guess internal means the binary doesn't leave your servers oh okay but then like every
website is internal only that's right that's true what we're talking about a second but i do want to
say that uh you know for like microservice i said library but also if you're running a service you
could redeploy that service with every code change or every night um and make sure that you're always
on the freshest release. That's right.
Yeah.
I mean, one thing maybe people don't know unless they do web development or just this
kind of like service-based architecture is it's designed to be very, very modular.
And so, for example, if you're making like a funny meme site that has like the funniest
memes and people can comment about memes, things like that, you might have a service like a funny meme site that has like the funniest memes
and people can comment about memes, things like that.
You might have a service that all it does is write the meme text onto the image.
And it's just standalone.
It's maybe in a Docker container or something.
And so that team, you don't want to have this monolithic binary
where if anything is wrong with any part of it,
nobody can ship their updates. So the team that's doing the write the text onto the image,
they're doing continuous deployment and they are, you know, with some degree of certainty,
like failing, you know, maybe once a year they blow up the build or something, but it's okay
because there's redundancy and we'll talk about that more later. But yeah, I mean, failing you know maybe once a year they blow up the build or something but it's okay um because
there's redundancy and we'll talk about that more later but yeah i mean imagine you when you build
something for school you usually build this one huge binary um it's got like your project and
maybe you keep adding on to it throughout the year but uh but in industry there's there's just
thousands and thousands of services well depending on the size of your company.
But there's many, many services.
And they're all kind of communicating to each other and all updating, you know, almost at least nightly, if not more often.
Or at least not in a coordinated way.
What's that?
Yeah.
There isn't a coordinated, okay, everybody roll out now.
Exactly.
Yeah.
So, yeah, we could jump into web development. So
maybe the first thing I'll talk about is sort of how do you update the website? And then I'll go
into, you know, the database. So, you know, the database is just a recap database that holds all
of your information. You know, if you're doing this meme website, the database is holding all of those images and your user accounts and all of that stuff.
And then the website is where all of your logic is, which says it'll hold some data, but it's meant to be very transient.
Someone uploads a new meme.
It has to go somewhere.
It doesn't go straight to the database.
So actually, it does if you listen to last month's talk with HyperDev.
But generally, you know, it goes to some web server.
We're not that cool yet.
It goes to some web server.
That web server kind of accepts it, you know, and says, OK, this user made this meme and then puts that information in the database.
So you can hot swap this. So what that means is if you have a new version, maybe that version
is faster. Maybe when you upload the meme, it turns it into a JPEG or something. No matter
how you uploaded it, you could upload a PNG, it turns into a JPEG.
So you want to make this change. Well, the database doesn't have to change. It's just
storing these images. So what you can do is you might have the most popular meme site ever. So
you have thousands and thousands of machines and they're all just super busy making your website
work. So you can say, I'm going to change one of these
machines to do this JPEG conversion thing and then you can actually see, you
know, if you have the right logging infrastructure you can see like okay I
have more JPEGs now than I did yesterday and this machine is pretty much a JPEG
and it's sane and everything. And then you say okay I've done one machine and
it looks good let's do ten machines next day next day let's do 100 machines
okay let's do all thousand machines
and so in this way you're kind of
transitioning people
from one version of your site to the other
another thing you can do which is what Patrick mentioned
is if
you might have a flag
which will change all the machines at once or maybe some
of the machines but it's controlled at runtime so instead of you saying I'm
going to replace the code in this machine and not the other ones you say
I'm going to replace the code in all the machines but only the ones that have
this flag set will do something different. The rest of the machines will all continue doing the same thing they were doing before.
So you're kind of trusting yourself to use those flags appropriately
and not actually change something on all the machines.
And that flag approach is what you have to do if you need to change the database.
So let's say I'm storing these memes and my site's getting so popular that
I actually have to use a new database that can only hold JPEGs, but it can do an amazing
job and it will save my company a whole bunch of money because of the way it handles the
JPEG.
So you keep the old database around and you start bringing
up the new database and you actually do duplicate writes. So in other words you
say I'm going to write you know the PNG file to the old database and I'm going
to write the JPEG file to the new database but when I read I'm going to
read from the old database. And then you start monitoring and what you should hope is that these databases start to
look the same over time. That, you know, eventually they should have the same
data in them. And when that happens then you start having machines start reading
from the new database. Like, okay, I'm writing everything twice and I'm
verifying
that when I write twice, they're in both databases and it looks solid. Let's have a few machines
start reading from the new one. And then you keep monitoring. And then when that looks good,
then you kind of switch everyone over. So it's this very gradual process, but as a person who's
using the website, it's completely opaque to you.
I mean, it's kind of remarkable that, you know, you could have an Amazon page and then leave it on your browser, refresh three days later.
And you're probably looking at like the code that's servicing your page is completely different, but they make it look exactly the same, which is pretty awesome.
Well, I think that's all we got for deploying software that was kind of three vaguely related discussions yeah i mean and this should
kind of tell people uh you know it's hard it's domain specific it's not a science um um there's
there's a lot of nuance a lot of cruft that's developed over the years and it's become this
sort of craft there are some people who are like, you know, deployment craftsmen.
What, what did we call them?
Oh, I don't like when people say it's an art, but I think that's good.
I'm going to use that. It's a craft.
Yeah. Like we have a production engineers, um, where I work and, and, uh,
um, they do more than this, but this is one of their expertise.
Yeah. Craft. I'm going to use that. They do more than this, but this is one of their expertise. Yeah, a craft.
They craft an installer that actually installs correctly.
So just to repeat, to sort of recap, the tools of the show were Termitor and MotionStills.
The books of the show were Bayesian Methods for hackers and zero to one by peter thiel um you
can check it out on our show notes get links to all of that which are on facebook apparently and
on programmingthrowdown.com that's right we're on facebook someone asked me to start posting them on
that's right patrick is are you boycotting actively or are you just no i think i do have
an account i just i don't know i'm not a social person i'm a terrible human being so i'm not a
social person so i don't find interest i i think did i talk about this last episode i checked out
instagram and it was like no i don't read the comments i just look at the pictures and i'm like
oh i can get behind this it's like pictures from people i think but like no words right i don't like to, like people say things and I'm just, it makes me mad or frustrated or,
you know, anyways.
Yeah.
No, I don't do Facebook.
Not just Facebook, but, you know, if we're on Facebook, we're on Twitter, we're on G+,
and we're on LinkedIn.
Someone asked me to start posting them on LinkedIn.
So I said, sure.
And some people actually respond on LinkedInin which is kind of cool um uh it's a little sad that there isn't
one continuous thread of comments that go across all of these networks uh it's almost like like
every time i add a network it kind of fragments but i think it actually doesn't fragment it just
grows the amount of communication but i
just wish that someone there's a startup to take that from zero to one that's right let's get peter
theil on this um so you know hey check follow us on all of them then you can see all the discussions
going on in parallel maybe a human can like copy all of the comments across and keep them all in sync yeah no don't don't
that just sounds miserable no oh yeah definitely don't uh don't volunteer yourself for that that
sounds terrible well thank you all for during another episode yeah thanks a lot um uh let me
know about the t-shirts um we have a straw poll vote and send us an email
with your name
and what t-shirt you want
and if we get enough
orders we will put in the
bulk order I think we need 25
we'll put in the bulk order
and I'm
sure we're going to get 25
but
definitely let us know so that we can get you a shirt well there's
you and me and our moms so we got that's right we got four 21 slots left that's right till next time
see you later the intro music is axo by biner pilot
programming throwdown is distributed under a creative commons attribution share alike 2.0 our pilot.