Programming Throwdown - Ruby
Episode Date: October 12, 2015This show covers Ruby: a multipurpose interpreted language for rapid development. Book of the Show Jason: Paranoia RPG Player’s Handbook Patrick: Lock In ★ Support this podcast on Patr...eon ★
Transcript
Discussion (0)
programming throwdown episode 47 ruby take it away jason hey everybody. We have a cool episode coming up on Ruby. We also have a lot of
interesting questions
and feedback and
a lot of mail. Actually, the mail
has gone up by, what, maybe
a factor of five or something?
A lot.
There's a lot of new people out here.
We don't know where you came from, but welcome.
Actually, if you guys
just shoot us an email or post on facebook or g plus tell us where you found uh if you're if you're
new to the show let us know where you came from because we we got a ton of people uh uh in the
show very recently at least based on the emails and our very loose, hand-wavy statistics. And so, yeah, let us know.
We're curious.
So, cool.
So one of the emails we got is from Jaroslaw Piskorski.
Sorry if I messed that up.
So he's, I don't know if he's a statistician,
but he knows a lot more about statistics than Patrick and I do combined.
And he added a lot of information on r um one of the things about r that we didn't know is that
the r the syntax in r and for people who don't know r was the language we covered last month
episode 46 that's right so the c uh the the syntax of R is almost identical to the syntax in statistics textbooks.
So you can open up a statistics textbook, take some equations from that, and almost type them verbatim in R, which is pretty cool.
Also, he mentions a lot of things R does. There's a lot of the things, there's overlap
there with MATLAB
and with
NumPy and SciPy.
But they're worth mentioning. They're interesting.
And so
definitely go to ProgrammingThrowdown.com
Check out
our blog and go to the R episode.
He has a ton of information there.
If you're into R and you're a statistician especially.
Or did you post up his comment?
He posted it in a comment.
Okay.
Actually, we'll link to his comment from this show.
Ooh, that's meta.
Yeah, yeah, look out.
That's like Inception or something.
So, yeah, that's pretty cool. Definitely definitely check it out a lot of interesting stuff um another question we got this is from ash booth
and he was saying uh basically what's the difference between kind of doing projects in
school and uh working in industry um wow like where do we begin right there's no difference
yeah right so i mean i'll say a couple of things um when you're most of the projects that you do
in school are individual and so depending on the scope of the project if you're doing like a phd
dissertation that takes four years um then you probably have some kind of source control and things like that.
But even still, if you're developing by yourself or with one or two other people, you don't really have to document.
You don't have to write a lot of tests because hopefully both of you or the three of you have all most of the same assumptions
and and the code doesn't have to uh you know doesn't have to live for a very long time
um and so definitely when you're working in industry you have to program very defensively
because there's a lot of people on the team there's people on other teams who could break your code. And sometimes you write
tests to make sure that other people can't break your code. So that's something to think about is,
actually, someone put this really good in a really clever way. They said, if you're an industry,
your code has to be peer reviewed. So presumably one or two people have to look at your code.
So right off the bat, your code has been read three times more than it's been written.
It's been written once and read three times, and that's before it even gets committed.
And after that, it's just going to get read even more.
And so coding in that environment is
very different than than coding in school yep you pretty much summarized what i would say but
yeah i think the big difference between school and industry is your projects tend to be very
short-lived and you tend to almost never use existing code so you tend to almost never use existing code. So you tend to almost, what we call, I guess, greenfields,
like code where you're starting from scratch
versus an industry on the whole,
you're very rarely doing that.
And even at some point, even if you started that way,
after six months of working on something,
it's no longer that way.
And so you have a lot more maintenance,
a lot more digging into code bases you're unfamiliar
with or have been unmaintained uh and that's something that you don't really get experience
with in school at least not in my schooling when they never gave us like a huge code base and said
here go fix something or add a new feature uh the closest we got was for our operating systems class
we needed to add a feature to the bsd kernel oh that's cool yeah so we had to actually
dig through and understand it at some level to be able to add it and that was pretty representative
of the work you end up doing a lot also for me i didn't do graduate work so i got a master's degree
but uh you know it's mostly just normal classes i didn't do any research and so for me the projects
also tend to be much much smaller and i didn't work on research and so for me the projects also tend to be much much
smaller and i didn't work on them eight hours a day for literally months years yep which can be
very common at work yeah i mean you could work the same job for 10 years and you could literally be
staring at the same code uh you know 40 hours a week for 10 years so i mean i mean hopefully you
know it's you don't have to keep coming back to that code but but you'll be building on top of you know, 40 hours a week for 10 years. So, I mean, hopefully, you know,
you don't have to keep coming back to that code,
but you'll be building on top of that for years to come.
Or if not you, someone else will, right?
And then you said about peer review as a reason for writing it well or whatever.
But, I mean, that's something else that's a really big difference.
And many places have some form of peer review
or needing unit tests even.
And this is something I never did other than theoretically in school.
You may have to write unit tests for the unit test portion of some class,
but it wasn't something we did for realsies.
Yep.
But in work, I do it for realsies.
Yeah, yeah.
I mean, like I said, if I don't write, I mean, this has happened to me
where I don't write, I mean, this has happened to me where I don't write a unit test, and
then another team
that we're sharing the code base
just breaks my code.
And it's not that they're jerks or anything,
it's just that they
invalidated some of the assumptions I made,
and without unit tests,
there was no way for them to know they did
that, right?
Cool. So so our last question
Quang Nguyen
asked
basically what are our thoughts on
programming competitions
so Patrick and I have both
done programming competitions
one thing I can say it's
so the situation is like
this programming competition
in terms of your time, right?
I spent, I don't know, I spent maybe 2,000 or 3,000 hours working on programming competitions.
Like either practicing, going to competitions, doing online competitions.
I mean, I spent probably more than 3,000 hours.
If I had spent that much time doing work on open source projects
or modifying the BSD kernel or something like that,
it would have made me a better software engineer, right?
But the coding competitions make you a better interviewee.
And so both are, you know, you could argue about whether the interview process is broken because of that.
A lot of people say that.
And I don't disagree.
I don't really know what we could do better.
But the fact is, at least right now, you know, coding competitions will allow you to pass interviews that you would not
have otherwise passed. But again, taking that same time and putting it into working with a big team,
using source control and things like that would make you a better engineer. So yeah,
use that information however it best suits you yeah i don't remember the exact question so i
don't know if we're answering or not but on that topic it is uh true that i think there are two
aspects to coding competitions one is doing stuff at speed so like making a stab or guess or
you know doing the big order approximation big o approximation of a potential thing and
understanding what the impact of that will be off the cuff thinking of an algorithm and implementing
it sort of correct at least the first time like these things at speed are really great for
working on a programming interview the second part is like the algorithms like actually learning various algorithms and tricks and data structures and understanding like you know when you're in
grade school and they give you those word problems you have to learn that certain words mean addition
certain word subtraction certain multiplication like learning those keywords like how to take a
guess at what the data structure might be um I think those are two different parts, and the algorithms part
has some usefulness
outside, like learning what all these algorithms
are and when to apply them and how to apply them.
It's more generally useful
long term. The coding at speed
is really good up into a certain
point, and then the diminishing curve
kicks in really hard.
So once you can do it
fast and you're familiar with all
the standard libraries of the language you choose to use and you can sort of get done in in the
time frames that the competitions normally have getting much faster will make you do better in
the competition but not in real life right that makes sense even for a programming interview
i don't think it really matters you don't have to have super speed you just have to be quick but not fast yeah so maybe so maybe the best advice here is especially for
people in college and and things like that is is uh you know to be like decent at you know top
coder and these other sites but you don't have to be great maybe that's yeah i would think like
the way i would view it so so to use Topcoder specifically,
is I think it's valuable to get to the point
where, be honest with yourself,
like on the easier,
there's like an easier mode and a harder mode
or an easier level and a hard level.
It's like on the easier level,
you really should be solving the easy one,
correct the first time,
the easiest question.
The middle question,
you should be getting right in
the time frame and you should often get the hard one right uh and all of that within the time frame
that they set for you so you can do like practice competition or whatever yeah but it isn't important
you get it the absolute fastest well i don't know about you but i i so for me to do one of the hard
ones it it takes me about a full day on the easy one oh you're
talking about the division the easy division yeah yeah oh yeah right okay that makes sense
yeah sorry yeah so i think the hard division gets into competitiveness so you should be able to do
the easy one but the easy one on the hard one is typically oh that's so confusing the level two
easy one is typically the level one medium one yeah just to recap so
there's two divisions in top coder there's division two which is uh think of it like the minor leagues
and division two has has it's fine division two has easy medium and hard and they typically
although not always but they typically take the hard division two problem and make it the easy division one
problem and then now there's another medium and hard in division one i don't know too much about
division two but in division one the i've never gotten a hard problem right in the 90 minutes that
they give you um and i've only gotten hard problems right I mean the smallest the lowest
time has been something like five hours
for me to get a hard problem right so
there's definitely a
no but I'm saying I don't I would go further
so but you actually did so I did competition
too but you did a lot more than me but
I that's what I was saying like I don't actually think
division one is necessary at
all I think you need to be able to do
division two in the time frames they give you
as like a, are you doing well enough?
Yep.
I think that's sufficient.
We talked about this in our earlier episode, but one of the
things, kind of going back
against what I said earlier,
playing, I guess, devil's advocate against myself.
One of the things that
pro-game competitions
do give you is an ability to look at
problems and kind of eyeball
how difficult they are
yeah that's what I was trying to say maybe I said it
yeah yeah like like you see like
like like an approximate
estimate like just a swag
at it like yeah this is
really easy like a top coder it's
explicit like you just see this
problem and it might
like there's not true because sometimes like the hard one and the medium one are similar in
difficulty oh that's true that's and it's better to do the hard one first yeah well in div 2 that
might be a div 1 the hard one's almost always impossible like to do in 90 minutes it's like
always some math or statistics trick and you've either
memorized all the tricks the people i know who get the hard ones right um are people who have
just memorized a ton of number theory tricks and theorems and they just see it and they know okay
that's this theorem let me start coding and for the rest of us plebeians, it's like impossible.
But yeah, to Patrick's point,
you can look at a certain problem and say,
your boss can come to you and say,
okay, we need to get this access time down to 10 milliseconds.
Is there some kind of caching or something we could do? And you can look at that and say, yeah, that's doable.
Or that's going's doable or you know
that's going to take years and and it might not even happen right so um like uh like we could
like write some function to do that or there's a bunch of heuristics we need to you know do data
science and and and figure out if we can you know uh if there's some trick in the data or something
right so so yeah anyways that's sort of
long-winded answer the answer is yes they help but uh only to a point yeah only to a certain extent
but that's true of most things in life that's right it's it's uh it's actually an uncanny
valley if you are in the top maybe 50 people in the world on top coder then now you're like kind
of pseudo famous and that's great. If you're anywhere
between there and the bottom 50
percentile, it doesn't matter.
And then
anything from there to maybe the bottom 1 percentile
is better than nothing.
So, anyways,
your mileage may vary.
Although
I found that a lot of the nasty
tricks I learned in coding competition
helped me to be really fast at debugging code on the fly like just hacking print statements in or
whatever is necessary in in a loop to just get something out and you learn like how to make the
compiler be quiet and just like how do i force with the minimal lines of code to get it to do
what i want yeah that's a good point i think that uh and you would never code that way like i would never check
in code that way but when i'm writing test code or debugging something like i people always look
at me i'm like what you can do that it's like sure you can cast this thing that way you shouldn't
but you can yep yep yeah i think that uh there's it's sort of like those people
who work who actually worked in a newspaper who have to produce a newspaper every week
they just have a ton of tricks that if you just wanted to write an article yourself like they
could just they could write it 10 times faster and it's because they were put in a position where
they had to write an article in 30 minutes
and they just figured out how to get it done and it's usually things that go against your intuition
that you would think are kind of bad but they really work and it's the same with coding there's
just like hideous things they that never make it into the final product but are stepping stones to being very efficient yeah all right cool time for the news
news so first news article is something we talked about on uh last month last but uh but uh
it's uh this is a very this article goes into a lot of detail on it uh The title of the article is Amazon's $23.7 million book about flies. Basically,
this guy is, I think, a biologist or an ethnomologist. I know he studies insects. He wanted to buy
this book. The book typically retails for around forty dollars and these two sites they each
had it for three hundred dollars and he said that's kind of ridiculous and uh he went to send
the link to somebody else and by the time he sent it to them the book was worth on like four hundred
dollars and then that really kind of got his attention so sure enough uh after a month or so
the book was worth 24 you know 23 and a half million dollars and it's
just a 40 book and and at the very end it ends up being worth like 40 again but this is all about
sort of he actually deconstructed um the algorithm they were increasing by a set factor right so like one was under one was over like one was trying to be the cheapest by
some margin but only a little margin and the other was trying to be slightly more expensive than that
one yep yeah and so it just had this race condition well it's race conditions not the right
word but yeah it was like an unstable equilibrium so so yeah one of them increases the price 20 the other one increases
the price 19 and then the first one you know sees that increase and increases the price 20
it just keeps going until a book you know 40 book is worth 20 million yeah and eventually
someone realizes it's crazy and just manually resets the price lower yeah yeah they must have
humans in the loop that look at you know everything that's
retailing for more than 20 million and do something manual i mean so yeah i was trying to
think if there's a way to exploit this behavior but i don't think they're i mean you could make
people's prices be driven up but it doesn't really matter they just won't sell the book
well i i thought about this right what if you what if you lie to amazon and say you have
the book for a dollar wouldn't that make them lower the price yes except then if someone buys
it in that time period that's right yeah you have to that's the problem right you have to
say i have the book for a dollar hoping that there aren't that many people buying books on flies.
But then maybe they would buy your book.
Now you're kind of in trouble. Like the people who are selling the $23 million book would buy your book.
And there might be people out there, which I would not be surprised, but I've never heard of it,
who are like watching for, like they historically track books with enough,
like this one's probably rare enough where they don't,
but books with enough volume or just anything with enough volume and they look for used price
discrepancies and if it's a big enough discrepancy they buy it right and then you know essentially
try to sell it back like there are people on ebay that do that search for misspellings of words
yep it's like the or certain like old objects that people don't know what they are so they say like oh i found
this weird bottle opener and it turns out it's not a bottle opener it's an antique surgical
instrument right but if you search like weird iron bottle opener you find these really rare
collectible you know yeah yeah totally so so yeah i think the answer is yes you could take
advantage of it but you will probably get in trouble and get yourself in a
sticky situation so um especially if it's about flies so don't buy books about flies that's the
moral of that story right exactly uh so the next article is a regex1.com which is an interactive
tutorial for learning regular expressions online.
So Jason actually found this link, this article, and I find that this is going to be awesome. I
am going to try this tomorrow because I stink at regular expressions. I'm a big fan of the quote,
what is it? If there's a problem and you solve it with regular expressions, congratulations,
you now have two problems. Yeah, exactly. Yeah, so this is
actually a user, a listener
request. So
Nicholas Bailey sent
an email saying, hey, can you talk about
regular expressions? And so
this is for you, Nicholas. We're talking about regular expressions.
I'm also in the same boat
as Patrick here, where every time
I need to use regex, I always
have to fudge my way through it online
and I get it wrong nine
times and then on the tenth time it finally does what I
want
and it's one of
these things like I think it'd be good for me to just bite
the bullet and like dive into
regex for a week
and then get to the
point where I could just write the regex correct the
first time so yeah I'll also be trying this website.
Yeah, the next one is interesting.
Things I was unprepared for as a lead developer.
So, you know, most teams, the way they're structured is you have your team and you have a manager who typically manages maybe 10 or 15 people,
and then you have a tech lead who is in charge of maybe two or three people.
And the tech lead typically also writes code himself versus the manager typically just manages.
So this person moved from an established company to a startup um at the startup he was
lead developer and uh this is just sort of like a a uh a monologue um sort of like a diary about
his experiences as lead developer uh specifically things he didn't expect and i thought this was
really fascinating um so it's definitely worth reading
I won't spoil it but
no go ahead
well yeah I'll spoil it
the one that really stuck out
to me was
as lead developer
you obviously you're
in the trenches and so you spend a lot of time
with the developers
but at the same time you're given the trenches and so you spend a lot of time with the developers um but at the same time
you're given sort of a more high level vision and so in his case you know he's at the startup
and so he's learning things like you know if this product isn't successful or if it has severe bugs
then they're going to shut down the startup and so the people that he's managing like all of them
are just going to be out of a job and then one of his employees comes to him and asks him if he can
you know learn ruby on the side and and he wants to do that but in the back of mind he's thinking
like dude our startup's going to die in a month if we don't get this done and you're asking me if
you want to learn ruby on the side and but you know again his job as the lead developer is to insulate his team so
they don't have to worry about the startup going under or whatever right so so so part of that is
is is answering that question rationally um you know pretending like he doesn't feel all this
other gravity and then saying you know yeah go
ahead and learn ruby it's not a big impact on the team or no you can't learn ruby right now
not you know what are you doing the whole company's gonna die right so so i think that's sort of in a
nutshell is a lot of his issues is sort of walking this sort of double double life leading this
double life so it's definitely interesting. I highly recommend reading it.
So the next article I have is actually not that important.
It sounds weird.
Anyways, it's about the JetBrains developers of IDEs,
and they changed their licensing,
or originally changed their licensing and changed it back,
and they changed their mind.
Anyways, I want to use this as an opportunity to rant about why everything is
going to web-based subscription licenses so jet brains originally announced this so before you
could buy you know a license to the software for a flat fee then they were going to now you need to
pay a monthly subscription in order to have your software and if you stop paying it you don't own it anymore and the companies tend to
think this is good for you as an individual but in all the cases i tend to look at it it seems bad
to me so the problem is they're collecting subscription fees which is great and as far as
that like if i stop use if i only want to use it once in a while i can pay a
subscription fee and then stop using it and stop paying which is nice and it sounds cheaper up
front but then the fact that like long term i don't own it and if i stop paying i lose it uh is
it's not great for me and also if there's new versions of a software released the company needs
to and they don't constantly improve the version I have
because they're not really incentivized to.
So that's kind of bad.
But they're really incentivized to make it awesome for the next one
or I don't pay again.
And when you go to a subscription model,
it's a little loosey-goosey to me
as far as why would they continue to give updates at an awesome rate.
Because you're paying to use it you really like
it you need to keep using it and it's not like if you stop paying you just stop getting new features
you lose access right yeah i mean so a couple of things about this one uh bit torrent sync which i
had as a tool to show a while ago they had a subscription model for the pro version and i
never bought it because um there's something about subscription models.
It's sort of like I think it's a psychological thing, but you just actually I'll get to that later because there's a whole separate rant about that.
But they switched to a one time purchase model.
I think it's just 50 bucks now and i bought it immediately so i mean
they went from not getting anything from me and me doing everything i could to use the free version
and get the most out of it to like them just immediately getting 50 bucks um i see the other
side of it though which is they're basically never going to get money from me again so so that
who cares because like for bit torn sync they don't have a maintenance
cost so why should they continue to get money from you um that's that's true yeah so so presumably
now they should use all of these 50 investments to build another product that they're not who cares
well they have to keep their company going right sure i mean if they want to right
but they could just make a product and be done like that's okay too um yeah maybe i mean you
would like them to keep it updated right and they want to continue to make sales it probably is
worth it to them to keep it maintained because then people will keep buying the existing version
at least right but what i'm saying is like for people that run
a service or server and there's cost to it i understand right like you have costs to keep
this thing up i have to pay you because you have to pay for me to continue using it but for things
like photoshop or an ide right it's i'm using all my own resources. All you're doing is keeping a licensed server up.
Yeah. I mean, you're, you, you have to assume that they are spending a lot of money, like
improving the product. If they don't do that, then you're absolutely right. It's just,
you're throwing money away, but presumably you're, you know, $10 a month or whatever it is
goes to allows them to hire some engineers to work on it um but i guess costs
aren't typically that drastically different right like in the short term theoretically right because
the if i pay you a hundred dollars once and i buy your new software every year or i pay you ten
dollars every month like it's roughly equivalent.
Yeah, that's true.
That's true.
The big difference for me is just, like, if I stop paying,
I can't keep... If I'm happy with what I have for now,
I can't just continue to use it without paying.
Right.
But to be fair, there's a barrier of entry.
Like, if I try JetBrains and I don't like it,
I can cancel, and I only paid one month.
No, I understand.
Yeah, if I have to pay $300, then I might just never try it.
So yeah, they have to do some kind of
shareware version or something.
But there's a lot of, yeah, like 30-day trials, right?
Yeah, right.
That's a common thing.
Yeah, that's true.
Yeah, I mean, I'm definitely with you.
I mean, anything that's been a subscription,
I'm trying to think of anything.
I can't honestly think of anything
other than Netflix and Hulu that are and those don't even
really count those are more like utilities yeah video and music I do but I don't really I'd rather
I'm not sure if that's a great idea for me or not like I haven't I'm not fully sold that I feel like
those are those are basically like utilities I mean I mean the difference between you know say
Spotify and JetBrains is thatify is you know presumably putting out
new content all the time and you're paying for the content well man they're not responsible for
getting the content right like they're they have to sign but like the artists and stuff are making
the content they just have to make sure to keep doing the deals right right and the deals cost
money hence the hence the subscription like otherwise the point is like if i like if i
really like this ide and i pay every and again this this specific idea is really kind of irrelevant
i don't use it so maybe it's a bad thing to pick no i think it's good it's a good discussion is
that like if i really like where it's at and i don't just particularly want to pay for it right
now like i don't need to upgrade i'm happy where it is and i just want to keep at and I don't just particularly want to pay for it right now like I don't need to upgrade I'm happy
where it is and I just want to keep using it I don't
have that option that's true
yep that's true so like
this is what I do for some Adobe products like I have
Lightroom for my pictures but I'm not
on the newest one I'm on like several versions
ago yeah I have the same thing with
Illustrator like I'm happy with what it is right now like
I don't need to upgrade yeah
the whole adobe
creative cloud thing i just can't deal with it like like the idea that like because this is a
problem is i don't use illustrator often enough to make the monthly fee worth it like for for a
product that i'm going to use once every four months you know i can't justify spending fifty
dollars a month it's ridiculous but you could
justify buying i think it cost me like a hundred dollars when i bought it right yeah but i've used
it for two or three years yep yeah i bought illustrator before the whole cloud thing for i
think it was like two hundred dollars and the same thing i used it for i've been using it for i don't
know six years or something anyways anyway so uh the other thing last thing about that is uh
you know people think that so this is about the subscription thing people think oh if i
get this ide i'm gonna be paying for it forever um this goes to like a psychological thing
people generally feel like they don't change i don't know if you read this article but people feel like they change
way less than they actually do so they did this study they surveyed a bunch of 20 year olds
and said 10 years from now will you like the same style of music that you do now
and the majority said yes and then they interviewed a bunch of 30-year-olds and said, do you still like the same music you did 10 years ago?
And almost 90% of them said no.
And then they thought, okay, well, maybe 20-year-olds just don't get it, right?
So they did the same thing to 30-year-olds, 40-year-olds, 50-year-olds.
And every single generation did the same thing.
Every generation felt like even 60-year- olds felt like they wouldn't change when they
were 70 and they changed and so with respect to subscriptions yeah i always feel like i'm going
to be paying for this forever like bit torrent sync i feel like i'm gonna be paying you know
10 a month for the next 20 years or maybe not that extreme but But when really, like, so, like, what you actually pay versus what you get for subscription versus one-time fee, your brain doesn't process that correctly.
And so, that makes subscriptions an even worse idea.
Anyway, so, time for book of the show.
Book of the show. So, my book of the show book of the show so my book of the show is a kickstarter
um project so it hasn't materialized yet although i'm eagerly waiting it it's a remake of can we
still join or are you just teasing us with something we can't join a good question so i
asked the person running the project if people could still join because the project has already been funded and it's over from that perspective. But he said yes. He said just email me or message him through Kickstarter and give him some information and PayPal him 50 bucks and you can join so so basically even though you can't join through kickstarter
you can still uh get the book um so the book is uh paranoia rpg it's specifically it's a remake
so paranoia rpg is a book that came out a long time ago um it's a game book uh so it's kind of
like dungeons and dragons these other ones um but this one, the catch is you're sitting around at this table playing with these other people.
One of the person is a game master, so just like D&D.
But each person has a secret mission.
And the secret mission is always destructive.
Like my secret mission might be get Patrick killed as many times as possible.
Patrick's secret mission might be like fail this
one part of the mission. And so the way the game works is instead of rolling dice, well, you roll
dice too, but in addition to rolling dice, every time you take an action, everybody passes a card
to the game master. And most of the cards are empty. So you start off with a handful of cards.
Maybe 20 of them are empty,
but you have three of them that say
automatically fail,
whatever action you're doing right now.
And you have three of them that say automatically succeed.
And so
if Patrick is
trying to turn on
the shield generator, and my
mission is get Patrick killed as many times
as possible and he's under fire from enemies then i will pass my you know patrick fails this roll
card but because everyone's passing a card patrick doesn't know what i did he doesn't know it was me
who did that at least not right away and so um so that's kind of the whole point is like but one thing is like if
you fail the entire mission then everybody loses so it's sort of like you have to limp along through
the mission uh just stabbing each other in the back as many times as possible without going
overboard and losing the mission so it really takes the whole dnd experience and makes it like it makes it really exciting like
i played a little bit of dnd and i could never really get into it but this i just absolutely
loved um and um it's the thing is it's really dated especially being sort of a sci-fi theme
book it's definitely showing its age so this kickstarter is is a way to rewrite it you know for a modern audience and i'm really
looking forward to it my book was going to be red planet by kim stanley robinson that was the one i
was terribly foreshadowing last time by saying i wasn't that into it turned out the book ended and
i still wasn't that into it and so i've decided not to give you that
as a recommendation if you're interested in a really long form dry discussion of terraforming
on mars and economics of that and hey there's water there's water on mars so we could do that
now which is something this book talks about oh great and elon musk talking about nuclear bombing
mars as a way to to kickstart terraforming
is also something kind of they talk about in the book.
Okay.
So the book is, I mean, it's accurate and interesting in that regard.
It's just a pretty long book for that.
Got it.
So instead, I'm not finished with the book.
I'm about halfway through it, but I'm really enjoying it thus far.
And that's John Scalzi's relatively new book lock in and uh this book is about a near future where people
get a flu or flu-like virus that alters their brain and makes them paralyzed and kind of like
there's a whole portion of society that becomes locked in where they can't
move and they have to do everything kind of virtually or like through the use of like
android robots oh wow so that's not spoiling that's like literally like the first five pages
of the book no yeah yeah so that makes sense that's anyways it's really interesting and i'm
actually listening to this book on Audible.
And if you're interested in trying Audible,
which a lot of people have been doing,
so send us in what you are listening to with your Audible free book.
And you can go to audibletrial.com
slash programmingthrowdown,
all one word, lowercase for programmingthrowdown.
So that's audibletrial.com slash programmingthrowdown.
You can get a free book. And we get a little bit of something to help us keep the show running
and you get a book for free that you get to keep even if you cancel your subscription i have one
book a month that i get uh and i always find something awesome to listen to they have tons
and tons and tons of books even if some of them are real like losers like red planet red
mars yeah i mean you don't have if you really like it it's just it but yeah it's okay very cool it
was better than sitting listening to music again on my drive into work yeah right there's only told
only so many chiptunes on spotify hey you listen to that channel too yeah i love that channel i
wouldn't what's the new one I got?
It was something very strange.
I'll have to think of what it was.
Oh, okay.
It's like Disco EDM or something.
Really? Okay.
Yeah, I was like, oh, okay.
Yeah, yeah.
Okay, time for tool of the show.
Tool of the show.
So my tool of the show, there's a pair of tools.
What? That's not fair.
I know, totally cheating. the first is image magic now this is image magic like the british version so it's m-a-g-i-c-k uh image magic um and it is a library for working with images and uh it has a
billion different bindings i haven't checked but I'm pretty
sure there is a
ruby binding let me check right now
oh yes there is there is our magic
yes so there's actually two so
so yeah there's image magic is ubiquitous
just everyone uses image magic
if you're doing things with images it's great
also
FFmpeg
it's it's
in the same vein as image magic
for videos
despite the name it does way more than mpeg
it does wmv, it does avi
it does mp4
which I said is mpeg
but it does everything
and it's ubiquitous
it's bindings for every language
so if you need to work with images
or you need to work with video or you need to work with video,
you're going to be using ImageMagick or FFmpeg.
They're just brutally difficult to compile yourself.
I remember one time I spent almost a month getting FFmpeg to even build on Windows.
Hopefully a lot of that is better now
I have experience with FFmpeg
there's like a zip of executables
you can download
yeah that's right so definitely
they're huge monolithic projects
don't try and build it yourself
if you don't have to
fortunately most people don't have to
because there are just bindings for everything.
So check them out. They're great.
I've used them for so many different projects.
We had a thing recently where we were doing some machine learning on videos,
and we wanted to sort of put some instrumentation,
just draw some instrumentation on the video,
like annotate the video,
and we used FFmpeg to do that,
and it came out really nicely.
The other thing, two things I use FFmpeg for
are taking a video and converting it to stills,
so like every frame to its own file,
and also I took, it's really weird and cheesy, but whatever, and converting it to stills, so like every frame to its own file.
And also I took, it's really weird and cheesy, but whatever.
I take a time lapse of putting up the Christmas tree each year,
and I just take it with my SLR camera because this is what I'm used to now,
although now I'll probably do it with my phone since I've added this feature.
I typically take it as a whole bunch of still images,
and then I use FFmpeg to smash them all into a video file yep that makes sense and it's just really super easy and straightforward much easier than like trying to open a whole bunch of high megapixel
images in uh you know like a video editor or something they tend to bog down yeah i mean
that would be just brutally painful to do that because it's kind of
silly because a 1080p video is what it like a mega no two megapixels per frame or whatever
but like an slr yeah like eight megapixel or 12 megapixel images so yeah yeah is it um is it is it you get better quality if you down sample
a something with high optical quality does that does that so i don't know the videos for me turn
out really good and i which i i guess maybe i should try to figure out my phone the reason
why i do it my camera is i can put it in fully manual mode, which means the focus stays constant and the settings
stay constant.
Yeah, right.
And so then you don't get like weird effects like some frames being focus changing or when
someone walks nearer or farther to the camera, they may go in or out of focus slightly, but
at least the whole focus isn't shifting forward and back, which distorts the view slightly.
Yeah.
I mean, I guess, so if you have a camera that's taking a certain resolution,
what that means are like photons are hitting
these cells and the cell buckets
have a certain size.
So if you have a higher
megapixel, assuming like
the aperture size is the same,
then you have more smaller
buckets, but then you're just
averaging those buckets when you downsample.
I guess i don't
know i just don't know enough about optics to know like if you take your slr and down sample
it versus just taking pictures with your iphone assuming there was some manual mode on your iphone
i don't know which one's better the other thing is like the you know i typically take it over the
course of like a long period of time or two long periods of time and i find phones work great for when you just want to like take a short video but like time lapses and stuff you want to take a long period of time or two long periods of time and i find phones work great for when you
just want to like take a short video but like time lapses and stuff you want to take a long one i want
to adjust the speed i may want to speed up some parts and slow down others and i've just never
gotten in the knack of being able to do that on my phone yeah yeah i agree cool all right very cool
my tool of the show is personal capital i don't know if you were you
were talking about no you talked about something else on another show i was thinking i talked about
wealth front but i don't think i've ever talked about this so personal capital is a combination
of wealth front and mint ah so um i don't use they so they run both a robo advisor is what they
call it which is like a way for you to invest money with them
and recommended ETFs at low rates or whatever.
Okay, but I'm not interested in that part of what they do.
But they run also a service that's similar to Mint
on top of Yodlee, is it,
which is the API backend for connecting to financial services,
which is not what Mint uses.
Mint rolls their own
so the connectivity is actually a little better in personal capital than mint and mint is really
good for like day-to-day spending and kind of not so good in my opinion for like investment so if
you have any sort of like money in stocks or a you know 401k or whatever personal capital does
a much better job of like explain like tracking that And it'll also give you like you are currently invested in too many bonds or too much cash or too much whatever, right?
According to like, you know, where you should be at your age based on some recommendation, which you may or may not agree with.
But it does analysis that I find interesting to see and helpful.
And so I recommend that this week.
How does this company stay alive? like where do they make their money because they can recommend you services
right like same thing as mint they're selling at some level which yes you may or may not be
comfortable with um but for them one thing is that they try to get you to which i've i didn't
feel like the push is very hard or at least i haven't had it but for
using their you know advisory fund thing in which they get some small percentage once you use a
certain amount of money same thing as wealth front right like after so many thousand dollars they get
a percent yeah right right not a whole percent but some fraction of a percent right right but the it
doesn't look like these guys do the mint thing in a sense like
they don't do they actually connect to your bank and stuff like that yeah oh they do that okay yeah
and your credit card like they connect to your credit card okay because it's from the front page
it sounds like it's all about just your investments not really your day-to-day no it does both but
the cool thing like the day-to-day isn't as good right like mint is better for that in my opinion right right um but this is better for the investments so it's
worth using and the day-to-day you kind of have to the day-to-day you have to look at yourself
anyways right like mint could tell you some things but really you should just look at
your your expenses and just say okay that that's a mistake or you need to cut down well
i'm really like using mint for having i have you know several credit cards or whatever for different
purposes and like it will accumulate them all together for me wait hold on a second why do you
have several credit cards so i have a high rewards this is so personal whatever i have a high like a
reward because i've only ever had one credit card ever since i was
like 16 years old it's been the same there's a couple good reasons if you're if you can control
it and are this is not this is so off topic for the podcast okay yeah but anyways basically like
a rewards card but it's an american express which isn't accepted everywhere so then you need to oh
got it but in general it's also good to make sure you could have a debit card in a credit card but you should have at least two some things in
case you know one of them has a problem or you know gets used somewhere else and they have to
lock your account you know temporarily that's true there have been a handful of times where
um my there's been an issue with my credit card and i yeah i had no backup so that's a good point
yes so it is good anyways and sorry for that
i don't think personal capital works for all of our listeners who aren't in the u.s and all those
people who may be like what i would like a job and now you're talking about how to invest money but
yeah one day we can all aspire that we have enough money to invest and worry about so i mean one
thing everyone can agree on is that uh they wish they had done better
like they'd known more about this when they started because that's when it matters the most
and that's when you know the least absolutely and that's where i feel like i'm at and that's
why i guess i try to be you see those graphs of like every dollar you invest when you're under 30
is worth you know hundreds of dollars you invest when you're 50 right right i actually didn't i
didn't the first two or three years i didn't max right right i actually didn't i didn't the first
two or three years i didn't max out my 401k just because i didn't really understand what it meant
or anything um so yeah don't do that kids if you if you can max out your 401k yeah anyway
so let's talk about ruby you sound like a really old guy now like yeah young whippersnappers yeah it wasn't that long
ago guys i'm not that old but but uh uh but yeah there was a couple of years i've been working
if you tuned in this is a programming podcast we promise i've been in industry what 11 years
and and the first two or three years i didn't max my 401k so don't do that um how long have
you been in industry and then we'll talk about ruby i'm
just curious i think i'm at eight years okay maybe i'm not at 11 then maybe i'm at 10 i don't know
anyway i did it right after undergrad i started working because i did my master's degree while
i was working okay got it got it yep anyways again so off topic so rub Ruby. So I have a quote.
I want to read this quote.
Okay, go for it.
This is related to sort of like background for Ruby.
And this is by the inventor, designer, creator,
the head honcho guy for Ruby, Matsumoto.
Probably saying it wrong.
He's Japanese.
That's where Ruby comes from.
And here's this quote.
I really like this.
I hope to see Ruby help every programmer in the world to be productive and to enjoy programming and to be happy that is the primary
purpose of the ruby language that's awesome he wants us to be happy yeah i mean it's way better
than fortran which wanted missile simulation to be more accurate ruby they want you to be more accurate. Ruby, they want you to be happy.
I like that.
I like that.
I thought that was nice.
It's very prophetic.
Wait, I don't know about it.
But anyway, yeah.
So anyways, that's some background.
So to give you the direction Ruby is coming from,
it's supposed to be a happy and productive environment.
Yeah, that makes sense.
I do think there's a lot of,
and this, I promise, is the last rant rant but there's a lot of connection between being happy and being productive
and like a lot of people say oh i really want my kids to be happy or my spouse to be happy and
it's actually kind of hard to make somebody happy but you can definitely make someone productive or
at least not make but you could definitely it's much easier to give
people like advice and direction that makes them more productive and if that leads to happiness
then there's a much easier way to make people happy than to try to make them happy directly
anyway uh okay so uh yeah so ruby is uh people don't know, who've never seen Ruby or know anything about Ruby, it's similar to Python.
You know, they're both interpreted.
Would you say that's its closest competitor?
I would say Python is definitely the closest competitor.
What was the other one you said?
No, I was going to say, I was just rephrasing, like, closest competitor.
I think Python is probably more popular than Ruby, so.
Yeah, I think they're popular and different. Like, Ruby probably more popular than ruby so yeah i think they're they're popular and different like ruby's more popular for web um like python has the django which is you know
similar to ruby on rails but you know not anywhere near as popular um and when it comes like
scientific stuff python is just way way more popular so um they both have their sort of niches but they're both interpreted Ruby was actually number 5 in the RedMonk
programming language rankings which is pretty cool
these guys they take
the number of comments
on Stack Overflow and the number of GitHub projects
and kind of throw it all together in some
algorithm and then spit out the top 21 languages.
And Python was number four,
and Ruby was actually tied for number five with C++ and C Sharp.
I don't really know how you can be tied when they take in so many things.
But yeah, Ruby is definitely up there.
So it's a popular language.
It's a good one to know about.
But programming language number eight is CSS.
I don't know.
What?
What's wrong with that?
There's a lot of CSS out there.
No, I...
Yeah.
Yeah.
No, I'm going to...
Never mind.
Let's just move on.
Okay.
I mean, yeah. So... There is a lot of CSS out there. That was not where I'm going to, never mind. Let's just move on. Okay. I mean, yeah.
There is a lot of CSS out there.
That was not where I was going to go.
You're thinking CSS is more like content than a language?
I know if I look up, is CSS Turing complete, the answer is going to be yes.
Of course, of course.
But I think to your point, there's a lot of CSS that is just describing things.
That's really not source code.
It's really output, right?
I mean, in fact, it literally can be output because there's LESS and SAS and other programming languages that compile to CSS.
And in fact, not that many professional developers write CSS, like raw CSS anymore.
It's sort of like saying, oh, the most popular programming language is machine language.
But anyway, so one of the things that made Ruby so popular is Ruby on Rails, which is
a sort of model view controller web framework written in Ruby.
And so I'll kind of talk about that briefly.
So MVC framework, model view controller framework,
has sort of three components.
There's the model.
The model usually starts out auto-generated.
This is called a object relational Model, or ORM.
You can actually do something in Ruby on Rails called scaffolding
and say you're writing some very small metadata file
which just says things as simple as, like,
I have a person, and a person has an age,
and a person has a list of phone numbers.
You write in this very compact dsl
and then from that it turns into an entire database and also a bunch of code to do primitive
things with that database like if i want to fetch a person or write a person things like that
so the model is a lot of it is auto-generated you may want to do you know more specific things
in that you may want to say get all the people that have updated their profile in the past day
so that's not going to be auto-generated for you you'll have to write that that would be part of
the model the view is all just HTML and templates.
So the idea is view might be something like open tag, header, close tag, hello, and then in brackets, person name, close brackets.
And then the controller, which is the third piece, it's responsible for filling in all those brackets. It's responsible for knowing what
person name means. It uses the functions
you wrote in the model to go and fetch people and then tell the view
this is the information you need.
So I don't know if Ruby on Rails was the first MVC
framework, but it's definitely the most popular by far.
There's a ton of tutorials and other references, which we'll talk about at the end.
And it also, it's pretty cool.
With the scaffolding, it actually supports different databases, which is pretty awesome.
You can actually prototype your website using SQLite.
You're just running on your machine without any
database service
and then copy your
Ruby on Rails
project over to your server
which is running MySQL
and run the exact same
code on that server
and it just magically works, it's pretty cool
magically
it's the magic of
scaffolding so uh ruby on rails totally awesome uh it might be a bit dated now i don't know how
well it's maintained i haven't i definitely don't hear about it as much as i used to
um but uh it's i've used it for a few projects it's phenomenal
um i think also it got promoted to...
Ruby on Rails was really pushed a lot by the...
Oh, why did the name just escape me?
Oh, no.
Brain meltdown.
Oh, well.
One of the things that Ruby, I think, is popular because of
is also it supports a lot of different ways of programming.
So Python also has this as an advantage.
Like you can do scripting in Python or you can write object-oriented stuff in Python.
Yep.
And Ruby has a similar thing where it really does support lots of different ways.
It just tries to get out of your way and allow you to do lots of stuff in a very flexible manner so that you can write in Ruby different coding styles for different problems.
Yeah, and this is one place where Ruby does better than Python.
In Python, a class is handled in a really goofy way.
Basically, a class is just a collection of functions.
I'm not going to get this right because it's very nuanced but
under the hood in Python
a class is
just like kind of an afterthought
and it's kind of hacked on there but in Ruby
classes
are totally kind of their own entity
and they're handled in a much more elegant
way.
Another thing with Ruby is you could do really elegant meta
programming so in other words if you have if you have a if you have a class
and the class is a list of methods and you want to get you know the method
names of the class of actual function names you know you can do that pretty
easily like you enumerate all of the methods for the actual function names, you know, you can do that pretty easily. Like, you can enumerate
all of the methods
for a given object and things like that.
You know, you could do this in Python.
Any object has a
dot underscore underscore
dict underscore underscore
object or property.
And using that property, you can
fetch, you know, you can do metaprogramming
in Python, but it's definitely, as I said before, it's definitely kind of an afterthought or some hacky thing that, you know, probably wasn't intended in the beginning to be a big part of Python.
But in Ruby, that's kind of like a first class citizen in the sense like they kind of thought about that from the beginning.
And that's one of the reasons why Ruby is so good for domain specific languages um which we did have a request to talk about and we will in the future
yep yeah definitely but briefly it's like a new language you define but you're not trying to do
everything like you're not really writing a whole language well you are but you're not writing a
language to do everything not a general purpose language a very domain specific something for a specific niche a specific application um so like scripting
an ai in a video game right like you may want to have a configuration language for doing that
that actually gets executed but it doesn't need to necessarily be turing complete or does
it need to be a from it may look a lot like ruby um and ruby supports that really well it has a lot
of them because of this really good meta programming reflection introspection yep i mean you might want
a dsl that's very specific so that you can make a lot of assumptions about the DSL. For example, in Ruby on Rails, there's a DSL for defining your model.
They make a lot of assumptions, and based on those assumptions, they can
turn your model into SQL commands. They can't just turn generic Ruby code into SQL commands.
That would be too hard so
the DSL tightens the assumptions
on the language and
because of that lets you do really cool things
one of the cons about Ruby
it's
again it's a double edged sword here so
take con with a grain of salt but it's
dynamically typed and it's interpreted
and so what that means is
if you spell something wrong, you know, variable name wrong,
if you change a function to, you know, accept a string
instead of a number and you didn't change all the places that use that function,
you're not going to find out about that until you run the code.
So if, you know, if you're talking about, say, Homebrew, which is the Mac package manager that's written in Ruby, where you just hit some command and then after a minute it's done, that doesn't really matter.
It's like now you found out about the bug after 50 seconds instead of two seconds or something.
So it's not that big a deal. But if you're building a website,
there might be bugs that you don't find out about
for a month and then they just start crashing.
You don't know why.
There's a really interesting Stack Overflow
question about why
Twitter switched
from Ruby to Scala.
And the
short answer is just that.
They ran into too many problems where everything looks
good and then at two in the morning, some code path gets executed that hadn't been before and
things just start crashing. And so with Scala, if someone fat fingers a variable and spells it
wrong, or if they change a function without letting everybody know uh you know scala just tells you right away before you deploy that code so are they still using scala
i don't actually know i know they were yeah i know they were using for trying to use it for a
fair amount of stuff before but are they using it for everything are they still um good question so
i used to talk to a lot of people at Twitter.
A lot of those people now aren't at Twitter anymore.
So it's hard for me to really know.
You know, definitely as of a year ago,
or as of two years ago,
they were definitely using Scala for almost everything.
I heard actually, so I did hear
sort of friend of a friend kind of thing.
So take this with a grain of salt.
But I did hear that they were moving away from Scala
I don't know why
but maybe
there's performance issues or something I don't know
I do know Scala takes a very long time to compile
so I don't know if that was why
but yeah
I'm sure there's still a ton of code there written in Scala
also Ruby just really never got adoption
in scientific uses which is something
Python got like huge adoption for use
so there's a lot of really good examples and libraries
for doing scientific computation, high precision math
that kind of stuff in Python
I'm sure there's no reason
you couldn't do it in Ruby, but you're just not
going to be going down
the path of least resistance as far
as having other people who have already done it.
Yep.
If you're going to do something scientific,
just write up Python
web service and
have Ruby call it.
Don't try and do scientific
stuff in Ruby. It's just going to be painful.
Just for people
who don't know, a lot of these scientific
matrix operations
and things like that,
they really have to be done in C
or even Fortran.
And so Python just has a bunch
of bindings to those languages.
And really the cool part about NumPy, SciPy, these libraries,
are all of the C code that you don't have to write.
So you can't just take the scientific libraries in Python
and import them to Ruby.
It won't be that easy.
So yeah, that's definitely one area that wouldn't be fun to do in Ruby. It won't be that easy. That's definitely one area
that wouldn't be fun
to do in Ruby.
You don't have to. You could definitely use both of these
languages together.
A great
learning resource, which I think both Jason and I
did, I never finished it, but I did do a fair
amount of it, was the Rails for Zombies.
We're terrible people.
All these MOOCs, which I guess isn't exactly a MOOC, but sort of similar. amount of it was the rails for zombies but i did about terrible people all these moops which i
guess isn't exactly a mook but sort of similar rails for zombies.org um and this is an interactive
online uh tutorial which i was one of the very first ones i saw done like this now i see them
all the time but very first ones i remember distinctly saying was this one and it takes you through all
of the kind of steps of bringing up a ruby on rails website and it has a kind of funny theme
with zombies and it's just it was a fun time and it's also educational for what would a ruby on
what is developing a ruby on rails app look like yeah i also did about half of it I thought it was great definitely check
why did you finish I'm just teasing I'm just he's no I mean I'm thinking about
it I don't really know I'm calling the kettle black actually okay I know I
didn't finish I remember it's because I got halfway through and I learned as
much as I needed to know to build the site.
And then I just started doing real work.
That's what happened.
So it's actually, I would say it was a win for them. Like they got me to the point where I was productive.
Nice.
Yeah, so definitely check it out.
If you want to be productive in Rails, you have two people people here who who who took this class and then
and then and then did some cool rail stuff so uh yeah check it out well thanks for listening
yeah um just a couple of meta things oh first let's let's recap for people who skip to the end
uh book of the show probably a good idea there was a lot of ranting this episode yeah book of the show is paranoia rpg uh and patrick's is lock-in uh tool this show i did
image magic ffm peg and patrick did personal capital um so yeah so one thing uh we've had uh
we're still like kind of dealing with some hosting provider issues and things like that
we changed hosting providers
and
some people in Russia
I got an email from someone in Russia
who can't access it because the hosting
provider is banned in Russia
I have no idea why
I'm pretty sure it has nothing to do with us
because all those nasty things we said
about the Russian government no we did nasty things we said about the Russian government.
No, we did not say anything bad about the Russian government.
Yeah, all those Vladimir Putin jokes we've been making.
Stop.
I don't know.
So I'm sure it has something to do more with the domain, the top-level domain,
and nothing to do with programming throwdown.
But nonetheless, we're banned in Russia, which is kind of cool.
Yeah, go us. I am going to host
the podcast
like an alternate place on S3.
I did a lot of
research into RSS. There's actually no
way in the RSS feed
for me to specify two sites.
No one ever thought of that
as a reasonable use case.
I actually cannot
fix the iTunes
or the RSS or any of that.
The best I can do is provide
just a
download link on
www.programmingthrowdown.com
So that's what I'll do.
If you can't access the podcast
and you're not in Russia, let us
know. As far as I know, Russia is the
only country in which we're banned.
But there could be others.
So if your buddy is telling you what a great episode
and you can't listen to it,
your buddy should let us know.
Your buddy should just send you the file.
Yeah, and let us know.
Yeah, but basically you can go to the website.
I'm going to have alternate download links as soon as possible.
All right, I think that's a wrap.
Cool.
All right, guys, have a good one, and keep sending us those emails.
They're awesome.
Thanks for all of your support on Patreon.
Actually, the Patreon is growing.
Let me see what it's at the Patreon
is at
$22 an episode
so thank you guys
that is awesome
thanks for supporting us on Patreon
we really appreciate that
that's awesome
and thanks for checking out the books
that we recommend and all that good stuff
send us lots of email thanks for checking out the books that we recommend and all that good stuff. Send us lots of email.
Thanks for Yaroslav, Ashbooth, and Quang Nguyen for the questions and comments.
And we'll catch you guys next month.
The intro music is Axo by Binar Pilot.
Programming Throwdown is distributed under a Creative Commons Attribution Sharealike 2.0 license.
You're free to share, copy, distribute,
transmit the work, to remix, adapt the work,
but you must provide attribution to Patrick and I
and sharealike in kind.