Programming Throwdown - Haskell
Episode Date: August 1, 2014This show covers Haskell, a statically-typed functional language. Tools of the show: Jason: Uber Patrick: Store Coupon Apps. Books of the show: Jason: Start With Why http://amzn.to/1uNg61I Pa...trick: Childhood's End http://amzn.to/1s8Fmv ★ Support this podcast on Patreon ★
Transcript
Discussion (0)
Hosting provided by Host Tornado. They offer website hosting packages, dedicated servers, and VPS solutions.
HostT.net
Programming Throwdown, episode 35, Haskell. Take it away, Patrick.
Welcome to another episode of Programming Throwdown, here late at night on the shores of
Lake Michigan. You know, if we average one episode a month, we're close to the three-year mark.
We used to do more than one episode a month, but now we've been pretty regular at once a month.
Yeah, but then we had that break too, so I don't know. Yeah, I don't know what the average span is.
I think we did 14 each in our first couple years years or something so i think we're actually on like the fourth calendar year that we've been doing this
or something man that's actually a co-worker of mine uh watched the or listened to the first
episode and uh he was he was telling me oh i started using your tool of the show and i had
no idea what he was talking about because it's been so long that was four years ago yes uh we we didn't even live in the same states that we do now so that's true it's
a long time ago all right well first i want to start off with a shout out to the player fm team
they sent us a nice email talking to us or showing us actually a picture of google io and they were
demoing an application they made.
You can check it out.
That allows you to listen to podcasts.
And they featured programming-related podcasts
and specifically Programming Throwdown at Google I.O.
So if you're at I.O. and you saw our picture,
why did you not also send us that picture?
That would have been cool.
But anyways, some of you may be listening for the
first time from that, although that was a little while ago, so you probably already listened.
But thank you to the Player FM team for that honor. Yeah, definitely. We appreciate it. I was
totally unexpected, and it was really a privilege to be at Google I.O. Do you care what your job
title is?
Yeah, I don't know.
I mean, this is one of these tough questions. So I actually got asked this a few times.
Once on Quora, somebody asked me to answer it.
And then coincidentally, twice in real life,
two different people asked me.
And basically the gist of it is, you know,
it comes along the same lines.
Like, you know, I'm applying, you know, one company gave me job title X, the other company gave me job title Y.
And it's not like one is, well, and so the idea there is, it's not like one is like chemist and the other is computer programmer, right?
I mean, they're all kind of programming related it might just be one is
like a senior and the other isn't or or you're like senior staff engineer at a company of four
people but you're just regular engineer like a huge company you know and or you're data scientist
for a software engineer and uh the reason why uh uh the reason I've heard of reasons why it actually does matter is for visa.
It's kind of unexpected, but I have a colleague who's going for his, I guess they call it the E1A visa,
which there's many different visas that you can get to work in the U.S.,
and the E1A stands for exceptional.
And it's for people who have just a lot of publications or Nobel Prize, you know, people contributed to Nobel Prize, you know, projects or things like that.
And so this person felt like, you know, getting the scientist title would sort of help his visa situation but you
know outside of that i mean that could be true i'm personally of the mindset that it doesn't
really matter but what's your take on it yeah i mean if you have well extenuating circumstances
maybe sounds bad but uh yeah unless the visa thing i don't know anything about that but as
a general rule for me personally no i don't think it matters um the problem is every company defines them differently and different companies have
different expectations so if you're cto of a your own startup or you know ceo and cto of your own
startup that means something different than if you're a cto of facebook um right so like they're
not even in the same class and those are are obviously an extreme example. But being a senior engineer at one place or not senior engineer at another, you know, it just depends if it's a newer company versus a more legacy company, depending on what field it's in and, you know, what kind of mapping they do or want to be able to say we have this many senior software engineers working on something.
Right.
And they can skew and play games with it.
And ultimately that's something that's actually really hard to find out before
you accept a job at a company.
It's not something that you're going to be able to ask a question like,
what is the number of years of industry experience a person with this title
typically has in your company?
Right.
They're going to be like,
either that's not like that's personal or like like or protected to the company or they don't know
and so it's really hard once you're in a company you have a feel but before you join a company
i don't know i think you i don't know that has any correlation to your responsibility or your pay so
the things that really show a company how much a company cares about you is
how much they offer you um and like the perks and the kinds of things and then what kind of role
they describe having a vision for you and depending on the company that role may or may not
be something you actually end up doing but um i think that's how a company so to play devil's
advocate though right like if you if you have a higher title than, like, you know, if you're, let's say you're applying,
let's say you want to change jobs, right?
So the recruiter, you know, on day one, they don't have as much to go off of.
If you're like, you know, really like senior staff software engineer versus if you're like
level one software engineer the recruiter
is going to kind of put you on a different path right i i don't i mean i guess it depends on
sure maybe a bad recruiter no i mean you should because some places just have software engineer
right like that's just it or especially if you work at a place that isn't a software engineering firm, right? Like, they mostly do something else.
You may just be a software engineer.
And you need, it's up to you to describe your role, right?
Like, I manage a team or I'm an individual contributor or, and people always kind of
lie on their resume a little.
But I think part of the interview process should hopefully be them trying to figure
out, like, what level of responsibility you have at your current company
yeah that makes sense makes sense yeah i also agree that it doesn't it doesn't really matter
i mean it sounds like this visa thing has some carry some weight because you know your your visa
packet goes to somebody who probably knows nothing about the industry yeah you know whatever industry
you're in um i would say so so that makes sense
but yeah it doesn't matter but it does matter it does sound nice so why do you think it's a good
title it sounds nice right like it it's like oh like i'm gonna get called a better title right
like that's nice maybe it has that psychological like you know because you have a better title
you go in with like more brav. Yeah, I don't know.
That could happen.
I think it's just too complicated.
It could go either way.
So the variance of what it means is too high.
Whether it means a little or a lot depends on so many things that you just can't weigh it properly.
Yeah, that makes sense i mean i would think that some of the like larger companies probably have
some kind of matrix where it's like okay if this person comes from intel and they have title x
and we'll like you know start off assuming that there'll be title y at microsoft or whatever you
know there's probably that at the very like large scale so if you're going from one huge company to
another but like uh yeah in general but why does it why do they care about and this goes back and It's probably that at the very large scale. So if you're going from one huge company to another.
But like, yeah, in general.
But why do they care about, and this goes back, and this isn't, you know, I don't think you should take a job just based on salary. But the reason that I've ever heard of recruiting or managers hiring people ever care about what level to place them is always because they're trying to get to a target salary.
And typically, the salary you're able to put someone at
is based on the position at your company.
So by moving them up one title, you can give them more salary.
And so the only reason they've ever wanted to move people up
is because they want to make them a more competitive offer,
not because they thought they were a more skilled worker.
But that's dependent on the company.
So that's why I said the actual revealing bit of information is your salary offer not the title but then on the flip side right if
you don't reveal your salary when you're negotiating your future job then they still
have your title unless you don't reveal that either yeah so i guess like they could try to
infer your current salary from your title but then maybe that just means you should't reveal that either that's true yeah so i guess like they could try to infer your current
salary from your title but then maybe that just means you should never reveal either yeah you
probably shouldn't reveal either i think we talked about this in the actually you know we had an
interviewing show but we never had a salary negotiation show that's a that sounds like a
stressful show yeah that that would be that would uh that would stress me out i don't want to give people advice there so i i watched i managed to watch the final game i tuned in just at the right
time to watch the conclusion of the international which sounds like a movie but it's actually the
dota defense defense of the asians ancients defense of the ancients i think that's what it stands for
yeah valve a game video game we're talking
about video games by valve uh and the world champions or what ship is called the international
and it made a bunch of press this year because um the prize pool was 10 million dollars and i think
the winning team got just over five million dollars and there's five people on a team
so it became instant millionaires each which is pretty cool um and one interesting thing is that uh valve didn't put in the prize
pool themselves people bought items in game in order to increase the prize pool for the other
competitors yeah this is totally genius so valve came out with dota defense of the ancients 2 or
dota 2 and they had a you know they didn't want to unbalance the game like there's a game that came out called battlefield heroes uh where you could uh it was free to play but you could buy
like a better gun or whatever right and and it wasn't very popular it was reasonably popular but
wasn't that popular and and the big thing is you know the more competitive you are and and most
people who play dota 2 are just have a competitive nature uh the more like you
don't want things that you don't want money to influence the game pay to win yeah exactly
pay to win that's right but uh so what these guys did is they took a page out of the korean mmo
handbook and said okay we're just gonna sell like funny hats and sweatshirts and weapons that don't
actually do damage like any more than
those different looks and so just yeah we'll sell looks and i remember kind of thinking this is
ridiculous and i remember thinking like okay one of these days i'll spend you know some money and
buy a hat just because i like the game but uh it ended up not happening but then what they did was
they added this um this donation thing so now it's like not only. But then what they did was they added this donation thing.
So now it's like not only is there a donation aspect of it
where part of it will go to these top-notch players,
but then also they added an achievement kind of system.
The point is they finally hit the formula
on how to get money from people without affecting the game yeah and
there was something more complicated too like i think as they cross certain like almost like a
kickstarter campaign as well like as if you bought it and then enough other people bought it you got
more benefit from having bought it or whatever yeah there's a pyramid scheme basically yeah not
exactly yeah something like that was more complicated anyways but whatever got a lot
of press attention for them i wonder how many new people like played the game i mean i never i'd
heard the game i've never played it still haven't played it but i actually know how it's played now
uh versus i didn't and they had a bunch of simultaneous streams going so like you know
different languages but then also like if you've never played the game like a new and it's confusing
because the team that won is called newbie oh spoiler alert um but then they
had a newbie channel like a new player channel which like if you've never played before instead
of just using the weird acronyms and slang they would try to explain what was going on
um which of course it was still happening in real time so they didn't fall behind
which made it hard like okay hang on we'll come back to that because this is what's happening now
but yeah i thought that was nice and it was cool to watch a video game we actually had real announcers they had like fireworks when
the team finally won uh you know and um it was really you know i i can't say that i'm a big fan
of watching video games i've never really watched them before like live or anything but um you know
it was kind of interesting to watch you know i'll try it i've never watched
video games live either but uh but i've been hearing a lot about it is it still going on
so it's done i think league of legends is currently in some sort of tournament now which
is the other big moba but um this one is done the team won a team new team newbie from china
um when i think actually two teams from china were in the um finals and yeah so the thing was that you know you watch it and because this game is actually
really quite complicated and hard to explain and very fast like your actions per minute really
matter um it makes it for a little bit of a weird thing so like this attack happens and just kind of
like finishes very quickly it's like you kind of don't know what happened uh and they also it's you know a big map and they move around the map very quickly
to show you different things happening in different places so it's it was a little hard to watch it
wasn't as nice as say you know watching a football game or a basketball game where there's nice breaks
in the action where they can show you an instant replay and yeah and there's only one ball and only
one really center of action and yeah this is just kind of
crazy wow yeah i'll have to check this i'm sure i can watch uh archive oh i'm sure yeah yeah yeah
yeah um but i was you know i was on i watched some of it on twitch. is it twitch.tv i don't
know on twitch oh yeah twitch is yeah so it was actually really cool and it was crazy to see the
number of people watching like when i tuned in you know towards the end there was on just the stream i was on which was like the mainstream whatever i think i want to say there was
up up to almost like 300 000 people watching it simultaneously like when i was watching oh my god
um and that was just one channel that was live it was like middle of the day west coast time i don't
know what time it was other parts of the world um but yeah that was like one game one channel
one time like that's actually you know it's not a football game can probably generate you know millions and millions of views even for
a non-championship game but still like 300 000 is a lot of people to just watch a video game right
like yeah i would argue most football games that aren't playoff games won't have that kind of
attendance i think i mean that's hard to say because some football stadiums are like oh like
100 000 almost 100 000 people in them just live yeah but that's a third of think i mean that's hard to say because some football stadiums are like oh like a hundred thousand almost a hundred thousand people in them just live yeah but that's
a third of yeah i guess that's true but the uh um the other thing uh that i was gonna say is twitch
tv is is actually amazing like right now they're focused on games but i don't really see why twitch
tv can't just do anything like anytime someone wants to stream anything you know like
twitch tv could could do that i mean like i i think it's just a matter of time before they branch out
to just doing streaming video for everyone yeah it seems really popular with the uh certain groups
of people but yeah check it out yeah i guess it's true it's like they have a good niche uh but it just seems like i mean
everyone should just uh i guess there aren't that many things though that you would stream right
because like you you still have to be on your home internet unless they support cell phone i mean i
think this is a big market already for them like between you know these these battle games like
minecraft has a lot of live streaming i saw people streaming even like
the world of warcraft card game uh what is it hearthstone oh yeah i've been playing that a
little on my ipad i should have made that my tool yeah it's pretty fun um i've been playing it on
the ipad as well yeah so i really like that game um and there's people who live stream playing that
game i think i guess from their pc um right but yeah it's like people stream what i would consider maybe strange stuff but uh
yeah i mean i would love to live stream my hikes like like just strap a cell phone in my arm or
something or my head oh yeah that's right yeah maybe google glass will uh will do but google
glass doesn't do streaming right i mean they do hangouts yeah you can do a hangout don't do
but but that's different right this is like like i don't think you can have a thousand people in your hangouts on air man
that's what people stream to youtube but i don't know if you can do that for me i have no idea
oh anyways it's just software man just software all right all right it's just software next time
yeah next time so there's uh so typescript which is actually, we talked about this before the show, we're going to definitely do an episode on all of these JavaScript compiled to JavaScript languages like TypeScript and CoffeeScript and things like that.
But there's a short story on this is, the JavaScript VM is the only VM that's in all popular browsers.
And so if you want to write code that works on someone else's computer, which it's most likely going to run on their browser,
and so it's most likely going to be in JavaScript.
With that said, JavaScript isn't really designed for writing like very complex, or let me just step back javascript is one language and
as we know from watching this from listening to this show uh you know there's many different
languages and each one kind of serves their purpose so uh you'd like to do other languages
but you have javascript so there's a lot of these languages such as typescript which compile to
javascript so you can write in something, but still run on other people's browsers.
And TypeScript is actually made by Microsoft.
Actually, it was made by a company that was bought by Microsoft.
But the compiler has been open sourced,
but it really hasn't built a lot of community around it.
And now there's CoffeeScript, and there's other competitors that are pretty good.
So they decided to move to GitHub
to get sort of that community aspect of GitHub,
and they rewrote the compiler, which is pretty cool.
It's got a lot of improvements.
But in general, GitHub is another one of those things,
like Twitch TV, that has just really amazed me
at how it's just kind of changed the whole ecosystem of programming.
It's like the Craigslist of source control.
Like the Craig? Let me think about that.
I don't know what that means.
I just thought it sounded really deep.
It did sound deep.
Yeah, I can't quite comprehend that.
No, just because everybody says, like,
Craigslist killed the newspaper classifieds,
which is where newspapers made a lot of their money and so like github like kind of killed like a lot of people trying to charge for
essentially the same service that's not really a good analogy because it didn't really it mostly
just made it better as opposed to doing the same thing cheaper terrible analogy i'm sorry i apologize
the thing github did that that that i think really is what took them to the top
is the way that different users could interact with each other's branches,
like with each other's repositories.
The idea that somebody could create a branch of my repository
and then ask me to merge it back in.
That was, in my opinion like the big
innovation there like i i uh put hyper neat which is my phd dissertation source code on uh github
and it has like a ton of forks and somebody went off and made like an arcade or sorry an atari
like uh emulator AI.
And a ton of crazy things have been forked from it.
And I can actually go back and look at what's been forked, even though I don't know any of those people.
I think that that is something pretty amazing that GitHub did.
I'm a terrible person.
I've been using Git recently.
I've been trying to learn it more.
It's just not clicking
with me i've just not found the right explanation or way to grok it in my head and i just nothing
nothing but git but git itself it's just not like it does not mesh with my way i've been doing
source control so i since i didn't start off doing it i'm trying to figure out like how to adapt and
i think that's the wrong approach and so i've i gotta work it but right now you know i'm not impressed i don't i don't care for
yeah so git it took me a long time also to learn git and i kind of uh thought that git was just it
was just kind of ridiculous and it didn't make sense for a long time one of the a couple of
things that really helped me early on was git stash i don't know if you've used that but but
yeah like i so i used to think
that like you had to just commit all your changes before you could switch branches and that was kind
of frustrating because i'd have two branches that were halfway done and i couldn't figure out how to
switch but git stash lets you do that and you'd also stash and then update a branch and then unstash
and it kind of so i should correct git works fine for me locally
but you know ultimately your the idea of git is to like share with other people
that and that's where it starts to fall down for me i start to have problems
um oh yeah but maybe it's specifically the collaboration tools that that the team i'm
on has been using but yeah the that's possible. Anyways. Yeah. Mesh networks are pretty cool.
And I read an article about,
I don't know.
I'm trying to say deep things.
I don't know if it's working.
Mesh networks are meshy.
Totally.
Mesh like a sieve.
This guy's wearing a pink shirt.
Oakland.
This guy's wearing a pink shirt
and his name is Valentine.
That should make you look at this.
Okay.
So Oakland is a city near where Jason and I live
sort of in the Bay Area of California near San Francisco and it's known for its San Francisco
it's known to be kind of quirky and Oakland is even more quirky I don't know the right is that
true wow I did not know that yeah so Oakland. So you hear a lot about like protests and stuff from Oakland and in a similar vein, I guess.
One of the things that Oakland.
So they've had some problems with trying to organize awareness events, let's call them.
And the various authorities deciding to like shut down cell towers or Wi-Fi connectivity.
And this has been a continuing problem for them.
And also being near such tech-minded people,
they've decided that internet is a basic right
and that they would like to have
uninterrupted network connections.
So they've decided to build a mesh network,
both to provide kind of guaranteed access
and also to get around any potential censorship.
So trying to avoid if someone decides to censor something,
try to get around it.
And so it's basically just about a group of people
trying to work against the man to build a mesh network.
But it's kind of interesting.
And they're talking about, I guess,
the group of people trying to establish this in Oakland
studied one that was used in New York State when a hurricane hit and did a pretty good job surviving.
It actually was used for some of the people right after the hurricane, and it was the only form of connectivity it had, even when cell towers and stuff were down.
And so that is a great idea.
People always say about ham radio operators and how it's really useful to be a ham radio operator right after an emergency and how much help you can be.
And this is also something that I think would be great to get involved with, even if you don't really agree with the dissident nature of it, perhaps, or like, a hurricane, what it may be, making sure that people have another way of getting on
that isn't controlled by kind of just a couple people
and maybe at risk to single-point failures.
Yeah, that makes sense.
I remember there was a lot of research on mesh networks
and all sorts of graph theory
and what's the lowest power way to get internet to everybody
and all of that and uh yeah but i didn't see too much beyond that so it's cool that someone's
actually building a real one instead of just theorizing all right so my article is on uh
oh no good you're good uh sorry my article is on the raspberry pi basically there's a new version of
the raspberry pi and uh it's pretty cool i actually have never owned a raspberry pi but um i did have
a gumsticks which is kind of a similar idea uh but it was kind of a little bit more niche i think
raspberry pi is much more mainstream i think it was going to be niche but it hit mainstream or
maybe it wasn't it was like the first thing to end up becoming mainstream yeah that's right it's definitely mainstream by accident because they
have such a huge backlog or maybe maybe people did it on purpose right like people always intend
to be mainstream it just never works out maybe yeah um um but yeah so check it out if you're a
raspberry pi fan this one has a bunch of it fixed a lot of nits people were having i also don't own one but i keep telling myself i'm gonna
get one and then i'm gonna have all these projects to use it for but i never quite have like oh i'm
ready to start this project that needs it and order it and so i've just i don't want to just
buy one and have it sit around i have too much of that kind of stuff yeah that's the thing like i
hit my critical mass of things that just sit around and collecting dust so including me
yeah i sit around already collect dust yeah all right time for book of the show
my book of the show is start with y by simon sinek so i actually uh was got back into watching
ted talks um which is pretty epic i just love them them. And I can't believe it's been so long since I saw them.
Actually, TED Talks were kind of on the decline in the sense that,
well, they started the TEDx, like the franchise TED Talks.
And then they started in the stream, like, mingling the TED with the TEDx Talks.
And so the quality basically went down.
Yeah, I stopped watching because it was like most of these are not good yeah I mean I watched like 10 talks in a row from TEDx women and I mean you
know women are great uh they make up half of the world and they have a lot of great things to say
but like TEDx women was geared for like a specific genre of talk it was it was a lot about like feminism and things like
that and and it was just it was too niche right and to get and i got 10 in a row of those and i
was like okay you know i'm kind of done and so uh they started doing that but now they're back
um you know the the past like 10 or 11 ted talks on on the YouTube stream have all been from the main TED conference.
And they've been amazing.
I'll have to check it out.
And one of them was from Simon Sinek.
I was so impressed with his talk, I got his book and I've been going through it.
Wait, like Dead Tree version?
No, I got the Kindle version.
Yeah, so I'm saving saving some trees hurting some
bits those bits are like just burning at the stake um so basically the book is about uh
um different companies and actually it really kind of uh covers this idea of company culture
and sort of what that means and and how to
sort of have a strong culture like internally and externally and it has a
bunch of great examples it goes over a variety of different companies but but
one of the things to really take away is this they say you know when you're
pitching something don't start with what They say like companies that start with what end up
becoming commodities. So for example, if you say we're Intel, we make a processor that's,
you know, 1.2 times as fast, you know, it's 20% faster than the other processor. So if you start
with what, you become a commodity, like you're only as good as your 20 improvement and if the other
company comes with like a 30 improvement then people just go with that right but if you start
with why like uh uh you know let me think of let me pick on a company here um tesla like uh tesla
we believe and i don't know what tesla. I'm just making this up, right?
But it's like, Tesla, you know, nobody should have to, you know, put fuel in their tank again.
Or Tesla, like, why are we...
Saving the world, one tank at a time.
Yeah, but it's not only about...
So saving the world is also a what, right?
So you have to ask, like, why save the world? Wait, you have to say why save the world is also a what, right? So you have to ask, like, why save the world?
Wait, you have to say why save the world?
Yeah, of course.
Or more specifically, why, you know, why what Tesla is doing is saving the world more than other things.
You know what I mean?
I'm going to watch this talk.
I'm intrigued.
Yeah, I'm not doing a good job because i'm not simon sinek and and the reason why i like this book so much is because
it's uh it really he does an amazing job explaining something that is pretty innate
and biological and he actually goes into biology and chemistry of the brain and things like that
and he's done a lot of research and he explains
something which is uh you know like you often like get these kind of feelings like i remember
when i got my first ipod um the way that you could endlessly scroll through your music because it had
the wheel right the little touch sensitive wheel and instead of having instead of having a like the
the zoom had the thing that you slid
with your thumb and you had to bring your thumb
back to the starting position and slide it again
but the idea that you could just slide
forever with your thumb
there's something kind of innately
cool about that. It's sort of like when you watch
Plinko in The Price is Right
there's some neurons that
fire and you get a kick out of watching the little
disc bounce on those pegs.
We are totally like so deep in analogy in this in this show.
Yeah, I've gone too far.
Saving the world is like a Plinko board.
Yeah, but there's there's many of these things where they're innate to our biology.
Like we get a kick out of it and we don't really know why. It's not a
logical thing. And he goes into
a lot of that when he talks about
sort of how to
both sell a company and
how to build identity
at a company or at any type of
organization or family or what have you.
And I'm only about halfway
through it, so I still have quite a bit to read.
But I'm very impressed. And definitely, if you don'm only about halfway through it, so I still have quite a bit to read. But I'm
very impressed. And definitely, if you don't want to read the book,
at least check out... Wait, so you don't know the ending yet?
You can't recommend it without knowing the ending.
He has two
TED Talks, and they're both great.
So, you know, the TED Talks take
a total of, what, maybe 40 minutes,
and the book would take, you know,
a few hours. So watch the TED
Talks. If you like them, read the book. I've know you know a few hours so watch the ted talks if you like them read the book i've done both well half of half of one and all of the other and i'm a big fan
all right my book of the week is a science fiction book childhood and childhoods and
arthur c clark classic science fiction book next is it a classic in the sense like is it from the
uh i don't know exactly when it was from
but it's definitely retro because the the technology the futuristic technology is
really like uh not chuckle worthy but just kind of like like oh interesting that's right they
didn't have like computer screens um yeah right or stuff like that right like oh you would use a you know it's like if
someone said using the telegraph to talk to a satellite it's like what yeah um no yeah so yeah
it's it's amazing watching like watching or reading like science fiction material that's old because
uh like there's one of them i read maybe uh okay like in snow crash they uh which you know snow crash isn't that
old neil stevenson but it uh it um they they describe this thing that is basically second life
but uh you know just at the time it's just so crazy and outlandish because it's pre-internet
you know so yeah i don't talk a lot about the book because i never know what to say without
spoiling a fiction book but uh it's interesting it's intriguing it's kind of weird but like weird in a way that makes you
think so you should check it out if you've never read it before yeah definitely all right so now
tool of the show my tool of the show is uber i used uber for the first time for people who don't
know what it is it is a phone app where you make
an account you associate it with your credit card or some kind of payment system i think they're
accepting like paypal and things like that now and then uh and then it does a taxi service and
it's actually pretty amazing so i'll tell you my experience quickly. My car broke and my wife, we towed the
car to the dealership. Oh no, wait, sorry. My car broke, but it didn't, we also had to tow it to the
dealership a month ago, but the last time it broke, we, a different car, we drove it to the dealership,
dropped it off, and then my wife drove me to work. They had it fixed, you know, at the end of the day,
and so I had to get back to the car dealership
by myself.
So I took Uber.
So first things first, you go into the program, because of your phone's GPS, location and
services, it knows where you are, uses that information and it gives you a little map
and basically says, here's where I think you are. Do you want to be picked up here? Then it shows you what kind of car, it gives you a list of car choices.
And you can put in if you need a baby seat and things like that.
I just need a regular Uber, right?
So then it says, okay, cool.
Where do you want to go?
You find your destination on the map, which works just like, I think it uses Google Maps, but it just it's very intuitive right tap on your destination um you can also search for it and then um it'll give you an
estimate of the price which in my case ended up being right on they gave me a range and ended up
being right in the middle and um and then it tells you it will tell you how long before the driver
gets there and and so on and so forth then as soon as you accept, it shows you the driver before he's even gotten to you on the
map.
So you can sit there on your phone and sort of passively watch this little Pac-Man game
being played out where the driver makes his way over to where you are.
It also shows you a picture of the driver so you know it's like an uber the guy picking you up and not some psycho killer
unless the psycho killer has a mask
then
the guy picks you up
takes you to wherever your destination is
and you just walk out
like the payment's already done
you don't have to deal with tip
you don't have to fumble around in your wallet
for dollar bills or anything
you just walk out
I thought the whole thing was awesome and I highly recommend it You don't have that awkwardness. You don't have to fumble around in your wallet for dollar bills or anything. You just walk out.
I thought the whole thing was awesome and highly recommend it.
Nice.
My tool of the show are store coupon apps.
Save money.
Don't be embarrassed.
Don't have to worry about printing out before you leave.
Just look it up while you're standing in line waiting.
Done.
Store coupon apps. Yeah, download apps for a store you shop at on your phone and get the
coupons like what's an example if you go to target target as an app you just download the target app
and they got coupons or home depot i was at home depot i was standing in line saying hi i wonder
if there's a coupon i downloaded the home depot app it's like sure enough here's a coupon i just
click it and the person scans it and i save money holy cow i did not know so i spend i find that stores here can get very busy especially if you
go right after work because everybody else has the same idea and so stand in line and while i'm
standing in line i just cruise for coupons i did not know that the so i've never installed a store
i just saved you money i did not know that they had coupons.
Oh, my gosh.
You should check every store you go to.
Yeah, I should.
I should just have a page on my phone.
Or right when you get to the store, you're in the parking lot.
Just pull it up in advance and be like, here's the things I need.
I wonder if there's anything.
Oh, yeah, look there.
Oh, man, that is amazing.
Wow.
Okay, cool.
That was very generic, nonspecific, but I'm glad this has such an impact on you.
I will definitely do that.
I will definitely get the Target app and the Whole Foods app.
Yeah, so, like, the grocery store, Safeway, has one, too.
And different ones have, like, you know, sometimes they, like, you know, have, like, not, a not like a rewards program per se but kind of where like they they'll when you scan it they know what you you can have like various coupons
collapsed into kind of one scan and you just scan it and all the coupons that apply it just takes
them off and then it recommends new ones for you that are related right so that's their way to get
you back to the store but yeah they tend to be pretty helpful and it's a store i already go to
typically so i don't really mind yeah no that's
awesome i'll definitely check it out so now we're on to haskell so haskell is a functional
programming language so jason yeah real quick sorry to interject but before we before we before
we dive into haskell i just want to give a shout out explanation no sorry the uh i know we said
we'd do swift we'll definitely do swift. We'll definitely do Swift, but we got
several requests over the week.
We got a ton of requests, actually, over the week to do
Haskell a lot.
Yeah, well, every week. Especially this week,
we got blasted to do Haskell.
Ironically, we got requests to do Swift
after we had decided we were going to
abandon Swift for Haskell this week.
It's sort of like, I don't know if people are messing
with us, but anyways, that's why we're doing Haskell this week. So it's sort of like, I don't know if people are messing with us.
Yes.
But anyways, so that's why we're doing Haskell.
Brace yourselves.
Swift is coming.
Swift is coming swiftly.
Yes.
You completely botched my train.
I had, like, an awesome transition, too.
It was epic.
Sorry.
No, it's okay.
So Haskell is a functional programming language. So Jason,
why don't you start us off by telling us something about functions in Haskell?
Okay. So one thing about Haskell's functions, they're first-class citizens. And a lot of people
don't know what first-class citizens, what that really means. Like it's a term that you hear,
but nobody ever really defines it, at least not to
me. Which probably means we have wrong definitions. Yeah, so when that happens, you usually figure
like, oh, it means that I have this vague, nebulous idea of what that means. But all that means,
there's just a handful of things that you need to be a first-class citizen in a programming
language. One is being able to be passed as a parameter. So in other words, like a function should be able to take this
thing as an argument. It should be able to be returned from a function, which is
very similar, and it should be able to be assigned to a variable. So if
the particular construct you're talking about can can do those three things it's a first-class citizen. That's why for example in Java classes the actual class
definition is a first-class citizen because you can actually pass the class
type as a function parameter to some function that like needs that for for
something very specific right but in C++, for example, classes are not first-class citizens.
I mean, classes are, but class definitions are not first-class citizens.
That's right.
But a class definition, like the names of the methods and things like that,
are removed by the compiler.
And so it cannot be a first-class citizen.
So, yep, in Haskell, functions are first-class citizens,
which allows you to build interesting things, right?
So one thing where I've used functions as first-class citizens before
is, or just even, you know, kind of using functions in an interesting way,
is several times I've implemented kind of like a state machine.
And, you know, a state machine, kind of naively,
people tend to, you know, kind of like the first way you ever implement it,
and sometimes it's the right way, is you just have like an enumeration,
and the enumeration has all your states.
And then the thing that gets called each update or whatever
gets passed in what the current conditions are
and whether you should transition a state
is just a big switch case statement, right? So on the state and you have various cases to handle moving from
one to the other um and it gets really messy right another way to do it is to have separate files or
classes to represent each of the states and then you essentially hold a pointer a variable that
you know points to the class as the function that should be called. So,
hey, here's the update that should be called. This is maybe not a completely great example of, like,
all that effort being a first class citizen entails. But if you think about, you know,
pointing to the function itself, and then you may pass in, hey, here's the function,
like a callback function, I want you to call when you're done changing your state or whatever.
And that's how you kind of link the series of events
to handle the state machine
without having to have like a giant switch case statement.
And it allows you to dynamically change the behavior
so you can reconfigure what state transitions to which else
based on something different.
And it allows you to build up something really complex
without having like really nasty spaghetti code.
Yeah, yeah, definitely.
So another thing about Haskell, it's pure.
What that means is each function will do exactly the same thing given the same set of parameters.
There's no global memory that you can mess with or anything or anything or anything like that like if you call a function
with xyz it will return abc every single time where yeah yeah yep that was confusing because
at first i thought you meant variable named xyz oh no so yeah if you call a function with a certain
uh set of inputs you will get exactly the same output every time.
Well, provided that it's not based on time or something like that.
But there's definitely no other variables that can affect your function.
So even the notion, and I find this a little difficult, and I'm not even barely scratching the surface of functional programming.
I still have a lot to go, and I'm always trying to learn a little bit more because i think it's helpful in reasoning about
other stuff but is that even the variable name can be confusing in a pure language because it's
not really variable if you say x is equal to five um x always needs to be equal to five or else
you're a liar um and so you can't change what x is equal to later on if you say it said it's five it needs to always
be five um and so oh so you're saying why call it a variable yes it's not variable variable means it
varies yeah it can't vary so people say the variable x is equal but it's well it's not a
variable it can't vary um uh well what if x is equal to a function that was based on input from a file or something?
Maybe if x is equal to a function, then it could vary, right?
But if you say x is equal to the function addition, it needs to always be equal to the addition function.
Even if it does different addition, it still has to do addition.
Oh, you're right.
That makes sense.
So it does turn it up on its... So the alternative to functional programming is typically called imperative programming. different addition it still has to do addition oh you're right yeah but one of the one so it
does turn it up on its so the alternative functional programming is typically called
imperative programming um you know things execute line one then line two then line three
and so one of the things that turns on its head is the fact that you have to think about things
differently when you can't just change the state willy-nilly as we'll say um and when things don't
just go around changing what other things are,
you have to kind of think about it differently if you first learned imperative.
And there seems to be a debate about which one's easier to learn first.
Is it hard to learn functional programming,
or is it just because we mostly learn non-functional languages
and then try to learn functional later?
Yeah, I read this interesting article that talked about
functional languages uh as using excel spreadsheets as an example what yeah if you look at an excel
spreadsheet like excel is a functional language because if you look at an excel spreadsheet
each of the cells contains a function of the other cells but there's no um order so it's not
imperative right so you're not saying you know compute this cell and then compute that cell
you're just saying this cell is based on these other cells and then you're relying on excel to
to realize the value of the cells in an order that makes sense and like i think i wonder what
happens if you create a loop in excel it probably just oh just yeah everything that's it can't
it can't evaluate it puts like a special flag it basically says something's wrong like does not
because you could say like a1 equals b1 plus c1 and b1 equals a1 plus c1 or something and then
just like the whole world falls apart or
just a equals b and b equals a if you just put that in you get all errors i guess but at any
rate so so excel is a perfect example of a functional language that everybody has used
maybe not everybody but you don't think i mean like again this this is like debatable but what do you constitute as
everybody i would consider i mean because you think about it i'm sure our parents use x no i i
was okay yeah you have a fair point i i was just being pedantic i i think i know but i mean it's
interesting i wonder what percentage of say americans or or let's say westerners we'll say
people listening to this
podcast probably have a pretty high chance of using some short oh yeah people listening to
this podcast is probably close to 100 but yes but anyways so the uh so so if you think about excel
and how it works that is sort of a good introduction to a functional language because you just put a
bunch of functions all over the place and then you just
let excel take care of everything and one of the happy benefits or one of the reasons why you would
want to have this pureness where so getting uh the where things don't change right you can say that
if x is equal to five it's always equal to five if i pass in some value there's no side effect so if i
have the function addition and i pass in one and two i
will always get three is it allows you to do things that you can't always do without a very large set
of restrictions in another language which are kind of reasoning about a program so if i validate that
one plus one equal always equals two in haskell uh one plus one equals two ones right like i don't
need to keep checking it
with varying other states of the program because it's just not a thing. So you can say something
about the correctness of a function and the compiler can reason about what stuff will be
and what's safe to change or not change versus if you're referencing a global variable, for instance,
it has to believe that global variable could change at any time. And so it can't reason about
the interaction of that global variable to the rest of the function
that may have nothing to do with that global variable directly.
That's right.
So you can actually, in Haskell, you don't have to define the type of most of the variables,
maybe even all of the variables.
I think there's actually some very specific cases,
which you'll almost never run into in practice, where you have to of the variables. I think there's actually some very specific cases which you'll almost never run into in practice where you have to specify the type.
But in general, you don't have to specify
the type for anything because Haskell can evaluate
the code and figure out what type it should be. And that's a good transition into one of
the strengths of Haskell, which is this type system.
Yeah, I mean most of these, if you think about Lisp or Prolog
or other functional languages, they're all weakly typed.
And in general, weakly typed languages like Lisp and Python, it's just
very hard to scale those, right? Because what will happen is you'll end up with
compile time errors that you won't catch until runtime.
And whenever you have that situation, you're inherently less productive.
Because you have to actually deploy something or run some kind of very in-depth simulation
to find an error that a language with a stronger compiler would tell you immediately.
So one of the beauties about Haskell is it's a functional language,
but it has a strong type system that will catch a lot of these errors
and let you be more productive.
Yeah, and so the type system allows static typing
so that when you compile your program,
the compiler can reason about the type of an object
and do type checking for you so you can catch a lot of errors at compile time. You'll hear this fancy term. So there's a lot of
research around Haskell. It seems to be like kind of like a running joke that, you know, Haskell is
only used by researchers. I can't. Yeah, like programming language compiler. Yeah. So one of the things you hear this Hindley Milner type inference,
and you can go read about like what that is in very, very specifics.
But it kind of gives you two things.
One is it basically is a way, a method for defining what types a given expression can have.
And then algorithm for computing the type of a given expression
and so these things together are really powerful and you hear about like i hear about this a lot
that you know oh the type system in haskell is really strong and really powerful and without
you know really getting into it it's hard to know what that means but essentially it's a way of
allowing you to write functions and do function overloading so like in c++ you would have to do templated
programming um to kind of handle generic types so haskell allows you kind of ways of saying i have
an item a and is an input to this function and the output is a list of type a's um you know a set of
type uh you know more than one of type a's together and allows you to do stuff like that and do checking,
which is something you can do in other languages,
but it just happens to be the specific way
that it's implemented and you're able to define stuff
in Haskell that you can do very interesting things.
And just in my opinion, that just like in C++,
you can get into a lot of problems
with templated programming.
You can get into some really deep weeds with
playing with the type system
and doing really complex things in a type system in
Haskell. Haskell
can be sometimes hard to read
for people who aren't familiar with it,
or even sometimes are,
but the type system especially
seems just like a lot of it. I look at it
and I'm just like, I don't even know what this is saying.
It's something to be careful about i uh i looked at you know a couple people on the my team at the last place i worked wrote a bunch of haskell and sadly we ended up throwing it away
because nobody else knew haskell and we ended up having to rewrite it all which is which is
actually pretty sad because it kind of hurt their feelings anyways um but uh but yeah i mean that was one of
the big things was that it was just very hard to understand what the program was doing but i think
that you know it was also very hard to use unix but now everyone's using unix like windows has a
bunch of unix in it osx is built on bsd right so so you know, it might be that Haskell is just
before its time, like,
isn't that the phrase? Maybe, yeah, but
I think some of it also is
people, so this is the same problem,
so this is my issue with Perl,
is I have no problem with Perl
specifically, like, you know, I don't
have strong feelings either way,
but a lot of times people try to do
crazy stuff in Perl to kind of show off.
So like, oh, I can do this in one line in Perl, right?
And you get the classic Perl one-liners.
But they're impossible to understand.
Like, that's great if you're doing something once, one time,
like you're trying to clean up some input text
and no one will ever try to do it again.
You're just going to store that result somewhere
and everybody else will use the cleaned result.
Like, sure, great, fine, show off. but if you're going to like be submitting code that's
going to be maintained like it's better to be a little bit more verbose and write it out and
you know some people argue back so this is a constant debate i was having recently on my team
is that some people say oh no it's better to do these i call them clever things uh People a lot of times do it to try to show off like using things which aren't always
commonly used.
And it's not always immediately obvious what they're doing because it reduces line of code
count.
And the reason they say is because every line of code is a potential bug.
So the less lines of code you write, the less bugs you might you will have.
I guess that I don't know, like maybe.
Well, yeah, I think you have to think about bug density, right?
Yeah, so that's the problem is like,
I can't reason about your code quickly.
If you wrote it out more verbosely
and I can reason about it quickly,
I'm more likely to help you catch errors.
I'm more likely to either reject or gloss over
if you write some line of code
that I'm not exactly sure what it's doing.
I would like to say that I reject it, but reality is sometimes you're pressed for time
and you've got a lot of stuff to go through.
And so sometimes you let something slip through and it's like, if you had known what they
were trying to do, you wouldn't have let it, like you would have realized it was a problem.
Yeah.
Yeah.
So this is not a conversation on Haskell.
This is a little bit of a sidetrack.
Yeah. No, but to your point though, I think functional languages in general require a lot more documentation.
Because they make the claim that they're much less verbose than they are. whereas in java maybe you know a comment per uh file is okay in haskell where a you know like
100 lines could actually be doing quite a lot you should definitely be very verbose in your
commenting so i kind of have so and this is always like something that's a little hard to pin down
but um people try to explain concepts and sometimes try to show off by how like uh detailed or complicated the
process is but i actually think that's kind of like i don't personally care for that style i
prefer that if you could explain it to me shortly and in a way that like my grandma could understand
it right like then you've done a better job than a person who can use more buzzwords um and so and
i think sometimes that you know as an as an industry, yeah, there might
be uses for Haskell, but sometimes you get people who are just fanatic about it and they like the
fact that it's very exclusive and that, you know, it, you know, they can go through kind of the pain
of doing it, but that's not always the case. Sometimes it is, it is really a good tool for
the job. And like I said, one of the benefits I've gotten from learning functional, trying to learn
functional programming more and more, I won't say I have learned it, is a new way of thinking about things.
And sometimes, like we were talking about, you know, the way of doing different state machines.
Sometimes you don't implement it in a functional programming language, but you take some concept with you.
That's really helpful.
Exactly.
Yeah, I mean, you can get a lot of functional ideas into other languages. Like with Java, you could have classes where the class implements some interface,
and the interface only has one function in it.
And now you basically have function pointers in Java.
So one thing to take away is that every language you learn
sort of helps you holistically become a better programmer.
Yep, yep, yep, yep.
Cool, so can you explain what a monad is? Otherwise, you aren't a true programmer. Yep. Cool. So can you explain
what a monad is? Otherwise you aren't a true
Haskellite. No, I'm not a true Haskellite.
I failed that test.
I think it's hard to explain
what monads are because it's a
complicated concept.
But I will try one
way that I've begun to think about it.
And I'm by no means, no I won't even say,
I'm not even a monad beginner. And so there's probably people who could give us a better explanation.
If you have a great explanation that you can send us that short, send it to us and we'll read it on
air and give you credit. And if my grandma, if I can reach to my grandma and she understands it,
uh, you will probably win some sort of Nobel prize. I'm not sure in what. So if you think about a function, right, like a function is
some way of doing computation, a notation for how to define like this thing is going to take some
input, produce some output, and here's what it will do. And in Haskell, you can't have any side
effects in your traditional functions. So if you think about a function being
very strict in scope, and you think about something that's more general than a function,
that can have notation that says other things besides I have an input, some code you're going
to execute in an output, and here's maybe the types, but like you want to be able to have
kind of almost other tags or syntactic sugar or things that you want to be able to have kind of almost other tags or syntactic sugar
or things that you want to be able to say more about a function than just those things. Like
you may want to say this thing does input or output. This has, this could raise an exception
that it sometimes doesn't produce any result at all. If you want to say things at a higher level
than just take some input, do some computation, produce want to say things at a higher level than just take some input do some
computation produce some output and and reason at a higher level about what the function is going to
do that's kind of what monads are are able to do for you okay this probably i i think that's that's
how i'm currently understanding it so the classic one in haskell is is for input and output so if
you want to write to the screen,
you can't do that in a normal function.
So you have a monad, which allows you to say,
hey, I have some code that's going to run.
If I'm also going to do other stuff,
like I'm going to have input and output,
I'm going to write to the screen.
I might pause, things like that.
And so that informs the compiler that, like hey something different than the rest of
the program is going to happen here uh and things that interact with it it knows how to kind of
think about those oh i see what you're saying so it's a it's a it's a way yeah i still gotta wrap
my head around and i haven't fully either and i think there's many things it can be used for um but you know
it's kind of a way of calling out that here is something that is going to have a side effect
without just making the whole program basically say might have side effects so you're saying
here's things which can produce side effects but the other things don't right like so gotcha
anyways that's probably a poor explanation but i tried okay no i
i think it makes sense i mean it's one of these things where i think i have to like have it
explained to me many times and then each time i'll pick a little facet of the yeah i'm in the same
boat and i'm still beginning my journey of understanding it so lazy evaluation so yeah another thing has to has is lazy evaluation and so
again just think about say the excel example right let's say there's some cells that are way
off the table like like your screen is like you're looking at cells a to g and rows 1 to 10
or 1 to 30 on your screen but if you were to scroll way down to you know row 15 million
there would be some data there right but obviously you know if you tell excel like add columns a and
b it's not going to add the infinite number of rows of a and b together right like it's going
to probably just add what you have on your screen and maybe like some of
the border and as you scroll around excel will will start filling in cells that it didn't know
before right like it still knows how to compute them but it's not going to compute them because
you're not looking at them yep right and it knows how it may have to compute some of them because
you may have a cell on your screen that references some of them and so it'll go compute those but the
ones that you don't care about have no reference reference to right now, it won't do.
Exactly.
There's got to be some way to really screw with Excel.
I'm sure people have done this, like crazy Excel hacks where it just locks your computer.
You open a spreadsheet and your whole computer locks up or something.
Anyway, so this is lazy evaluation.
Haskell does this
as well. So if
they might define
a function or a set of functions over
a space, but they're not
going to instantiate every possible
one of them. They're going to
at runtime start realizing
the values of
the outputs of functions as you need. Which leads you to
weird things like infinite lists,
which, okay, and church encodings,
which I tried to understand and I still don't understand.
I've never heard of, I'll have to research that one.
This is the story of my Haskell life,
like researching one thing after another.
But like I said, you learn.
So we have some resources for getting started real quick.
Learn You a Haskell for Great Good.
This is a very interesting approach
to a programming language book uh and it's you can either buy the dead tree version or
read it online um and it's pretty good i didn't make it all the way through i kind of
it's one of those things like haskell's uh complexity curve is very exponential
so you read early and it's like oh it's too slow too slow too slow so you just kind of start
skipping and you're like oh wow i have no idea what's going on it's like, oh, it's too slow, too slow, too slow. So you just kind of start skipping and you're like, oh, wow, I have no idea what's going on.
It's definitely not like linear.
So there's also learn Haskell fast and hard, which has an interactive component to it, which I was playing with earlier today in preparation.
So I think I'm gonna have to check that out a little more, too.
Oh, cool. Very cool.
Yeah, this is awesome. So definitely check it out.
Haskell, it's getting a lot of popularity, and it's very forward-thinking.
Right now, programming language geeks like it,
but as you said, Unix geeks were the only people who liked Unix,
and now everyone's running it in some form or another.
So yeah, it was great doing the show on Haskell.
It's been long overdue,
and we look forward to doing some Swift next time.
Alright, until next time.
See you later.
The intro music is Axo by
Binar Pilot. Programming Throwdown
is distributed under a Creative Commons
Attribution Sharealike
2.0 license. You're free
to share, copy, distribute, transmit
the work, to remix, adapt the work,
but you must provide attribution to Patrick and I and share alike in kind.