Programming Throwdown - Go
Episode Date: September 6, 2012This show covers Go, an interpreted, low-level language that has native coroutine support. News:100000 DPI printer, Joyent Cloud ending lifetime support, Apple buys fingerprint company, Twitt...er caps 3rd party apps. ★ 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.
Episode 18, go.
Take it away, Patrick.
So I had my parents visiting, and we went to, being in the Bay Area,
we went to try to do some of the touristy attractions.
And we went to the infamous Alcatraz, which sits in San Francisco Bay.
And you can kind of see it from over there.
It's this ominous old building, kind of like a lot of run-down skeletons
of buildings that used to be there.
No, not actual skeletons.
I love you.
Did you take the picture from behind the bars or whatever?
No, actually I didn't.
Oh, okay.
But it was kind of interesting, so try to keep this semi-relative
or at least maybe interesting to people.
So you see like movies and stuff growing up,
at least here in the States, about Alcatraz,
this prison for hardcore mobsters in like the 30s.
And I guess it was around that time, like the 30s.
And even before then, there was like a military base there or whatever.
But this is where they sent all the really bad people.
And there's several famous escape attempts
and various famous prisoners are held there.
And then eventually the prison kind of closed
because it was like really horrible.
And also people in San Francisco were kind of like realized
it was maybe a bad idea to take all the worst criminals from the country
and stick them just a few miles offshore from like a really big city.
Although like that bay is really dangerous
and filled with all sorts of ways to die,
you know, it's still maybe a bad idea.
Did you know during the summer they have a swim, a duathlon,
where they swim from Alcatraz to San Francisco and then run a marathon?
Yeah, I did see that.
And the tour guide was quick to point out that those people do it in a wetsuit.
Actually, they have some people who do it without a wetsuit.
I happen to work next to somebody who's going to do it without a wetsuit.
That's crazy.
And, yeah, I thought, I just thought people died doing that.
Like, I didn't think that it was safe.
Yeah, I mean, I guess it's different if you're, like, trying to do it in cover of darkness
and disoriented and not coordinated, right?
Like, this could be really bad.
Versus, like, middle of the day, you know what you're doing.
But, okay, so anyway, so we go to the prison, which is cool.
You know, if you're around and you haven't done it, you should do it.
But I thought it was interesting because having seen it all this time,
I really thought there was, like, all these different buildings
and, like, rows and rows and rows of jail cells.
It was this massive thing.
And it's really not.
I mean, a lot of prisoners were held there,
but it was a pretty small area where they were held.
I think it was in the hundreds, right?
I don't remember the exact number, but yeah, just not a lot.
And it really fits.
There's three levels, so it's really high.
But they're open air.
Like, it's just the cells are stacked in three levels.
It's not like three floors, and you can see from top to bottom.
But just to see how small it was.
And so they've done something really creative.
I guess it's like social engineering, let's call it.
So you get there, and then you take this boat ride over, which is cool because you're going San Francisco Bay on this boat.
And then you get there, and then they give you a little speech for like 10, 15 minutes about all the stuff you're going to do.
And then they direct you to walk up this long hill to where the prison is.
And then they give everybody headphones and this little device which gives you an audio tour.
Yep, complimentary.
Yeah, included.
Oh, that's true.
You have to pay for the ticket to get there, right?
Right.
So then they give you this thing.
But the point is that everyone has one because they're free at that point.
Yes, once you're there.
If you can get there, you get these for free.
Yep.
And so then you're touring around.
So I noticed a couple things.
One is that at one point I took my headphones off and was just, I don't remember, taking pictures or something.
And I paused it.
And you look around and you just see, you know, hundreds of people like wandering this jail like zombies.
Yeah, because they're all going in the same direction.
The same path.
But like overlapping each other.
Yeah.
And like not paying attention to people around them and bumping into each other and just, like, completely mindless.
It was really creepy and weird.
It was so awesome.
And, like, I don't know, just it was very, very strange.
And you could tell, like, what part people were on and, like, what they were doing.
And so that was kind of creepy.
But the second thing is the social engineering part I was getting at is that because it's so small, you would be very disappointed having paid, I don't know was an extraordinary amount, like $30, $20 or something to take this boat ride there.
But to go and like you would look around and you'd be done in like an hour and leave.
And like you'd be like, oh, that's kind of like disappointing.
But instead they give you this audio tour, which most places charge for you to take the audio tour.
And they even have like guided tours.
And so it makes you take a lot longer and they take you on an inefficient path
and kind of have you looping over yourself and revisiting the same
places but with kind of different story or different view or looking at something on the
wall a slightly different way and it really makes you feel like you got your money's worth and i
felt kind of bad having pointed out to my family after this tour like oh wow that was kind of like
not that good like you know the story was Like, this audio was a good thing.
But, like, it was really not that interesting or big if you really think about it.
It's sort of like The Matrix.
And you're outside of The Matrix because you didn't have your headphones on.
And everyone else is sort of, like, just really entertained by something which is really actually in the grand scheme of things.
Like, very tiny and, like, completely controlled by this like audio program and so you're outside of it and you're like realizing these people are walking between
like four or five rooms but like to them they're just spending hours in this massive like it's kind
of good so take it it's worth going now we've polluted it i guess now like you're gonna feel
bad doing it but yeah but well i mean i think it's okay i do it once if you had to pick between
Alcatraz and Golden Gate Park
you should pick Golden Gate Park
and the west side and see the bridge
and stuff like that or go on the bridge
it was worth doing
I don't mean to talk down about it but it was just this
aspect of this audio tape thing
which is very intriguing to me
that people are so easy to
tune out everything around them.
Yeah, yeah, definitely.
So, interesting.
Now I'm going to be more attentive when I go to touristy places to see how they're manipulating me.
It's obvious, like, Disney is very into this, right?
Yeah, they're pros.
Like, controlling everything, like, how you experience this Disney magic and what they do to do that.
Yep.
Yeah, so.
All right, on to tech news articles.
All right. Speaking of being in jail
how do you come from that i don't know a group of researchers uh used a interesting technique of i
guess what you call it nano fabrication to reach the ultimate resolution of color printing so i
read this story a couple times before i figured out what was going on but what they did was essentially were able to
manufacture these metal dots spaced very very close together but all the dots are
the same color they don't have pigment to them they're very very tiny and
they're all just metallic but based on their spacing they're spaced about half
the wavelength of light apart and by altering very slightly the distance
between the dots,
they're able to generate color based
on what waves can get through between the dots, like the
posts, and which ones can't.
And what they're saying is basically that by doing this
and making this color picture, which is fairly tiny right now,
it's only like five micrometers by five micrometers,
which I guess humans can only see down to about 10.
But making it this small,
you cannot make a color picture that is of more resolution
because if you put the dots closer together,
they'll just blur together and won't have the color aspect of it.
Because your eye isn't sharp enough?
No, because of the actual physical properties of light.
So light has a wavelength, right?
So if you make something two dots closer together than that wavelength,
the wave can't resolve it.
It can't tell the two things apart.
It looks like one thing.
So it's like the classic story of, I guess you hear this in physics,
if you try to figure out what object is in this room by shooting first beach balls at it
and then baseballs at it and then like baseballs at it and then
you know like tiny bb's at it and you what gets through and what doesn't depends on the size so
this is like trying to see it would be like at the point of where they reach to be trying to see
you know what a i don't know like a can of soda with a beach ball like it's just too big like you
can't you can't tell that it's there maybe that's a bad analogy anyways
no i see what you're saying yeah i got yeah so it's a 10 you know 100 000 dots per inch which
doesn't seem that high because like printers do 10 000 dpi it's only 10 times more resolution
than that um oh yeah you're right so it's not incredibly high but but it's the maximum yeah
it's not possible to do more.
That's insane.
It's cool because these people got there first, and they win.
Like nobody can.
Yeah, there's no more race.
Like they finished.
So it's so funny you mentioned this because I just saw a TED Talk today
on a trillion FPS camera.
So a camera that could record a trillion FPS.
And it can record so many frames for a second that they actually like um fired like a small beam of light and you could actually see like
the beam of light like enter this piece of glass and like fragment through the glass
so you could actually like slowly like it was like a slow motion like a video of light
whoa yeah yeah i have will take that video post
both links but yeah it's amazing like what are the chances that uh to like
huge milestones in terms of like you know dots per inch in terms of pictures
or frames per second we're both you know reported in the same day so close yeah
that's pretty awesome that's kind of cool.
The next article I had here was about this company called JointCloud.
And JointCloud did something which a lot of people are upset about but I thought would
be an interesting topic to discuss which was when they were first beginning and they actually
had a different name previously.
They offered people who spent and I believe it was like on the order of $500 or something,
they would get a small hosting account.
So this is a website host,
but they're slightly different.
They're like a infrastructure as a service kind of thing.
Oh, I see.
So, you know, think more kind of like EC2, I guess.
Amazon's a kind of equivalent thing.
And so they were offering for $500.
If you paid them this $500 in about 2006, I think it was,
that they would give you a lifetime of hosting,
shared hosting plan for a lifetime.
And they were a very young company,
so giving them a lot of money up front
for something that they may go bankrupt in a year or two,
that was pretty risky.
So people gave them this money,
and they used that money to help fund their startup or whatever.
So now turn 2012, what, like six, seven years later, and they've sent out emails to all
of the people who have this account and said, basically, we're ending your account.
We're no longer, this is a legacy account.
We're no longer going to provide it.
We're going to give you a year free of you know our new equivalent plan and we're
going to enter a plan um is that reasonable for them to do is that unreasonable yeah i don't know
it's a tough call right because they took this gamble and they sort of like they want to have
their cake and eat it too right like they took this gamble getting their initial following
by by providing this amazing service.
And then now it's sort of like they want to cash in on those people but also cash in on their support that they gave back when they were new.
So it's really, I don't know.
One thing, it must be a large segment of their population, right?
Otherwise they wouldn't have spent the social capital to do this, right?
Okay, interesting.
I mean, I don't know.
It's one of those things where it could be that they're a small percentage, but a large expense.
So that the servers are on. So I was reading an article that was related to, I think, United did something similar where they offered for the sum of like $300,000.
It was like a lot of money.
You could buy like lifetime tickets, basically basically where you go anywhere in the world
on, I think it was on United, anywhere in the
world, anytime you want, and you could buy a
companion one for some additional fee.
People spent what
amounted to a lot of their savings to buy this
saying that for years when we retire we'll be able to
just travel around the world.
It's like, this is
cool. But it turned out United kind of crunched
the numbers when they were having some bank problems that these people who paid, you know, like $300,000 are costing us on average like a couple million dollars a year.
Yeah.
And like taking up seats.
And they got all sorts of like priority service.
And then there's all these accusations of fraud.
Like, oh, instead of, you know, a person and their spouse flying, the person would just book a ticket but book the seat next to them to them for you know under a fake name just so they wouldn't have to sit next to somebody
doing things like this and so there's just like he said she said between united and the customers
where they're trying to revoke these lifetime tickets because of this abuse um and but yet
people paid a very large sum of money and if it turns out united didn't crunch the numbers
correctly whose fault is that yeah yeah i mean it's hard to say right one one kind of interesting a very large sum of money. And if it turns out United didn't crunch the numbers correctly,
whose fault is that? Yeah. Yeah. I mean, it's hard to say, right? One, one kind of interesting
thing that I thought about was I've been reading this book called The Lean Startup. And it's kind
of, it's a really interesting book. I haven't read enough of it to like talk about it in any
depth or anything, but the chapter I'm on now is what's called the minimum viable product and the idea is sort of
like you cut any corners you do anything you can to like get something out the door that like people
will want and so this is sort of an example of this where these guys they didn't really have a
plan of like how their pricing model was going to work or anything like that so he's just like the
bare minimum that they knew everyone would love, got it out the door.
But then like,
and so like we've really worked for them.
But then I feel like,
you know, that's an investment.
And so they're sort of like,
they're defaulting on their investment
in these people, you know.
But it's kind of sad that this has become,
and some people are even saying like,
shame on the people who bought this for assuming it actually be, you know, kind of a lifetime.
Well.
Because, I mean, this has happened over and over again, right?
Yeah.
You used to have unlimited data.
And it turns out, oh, yeah, yeah, no, no, no, it's not actually unlimited.
So it turns out, so I guess people are just not going to trust, you know.
Yeah, so in general, now you just can't trust when people say unlimited or lifetime or any of this stuff, right?
It's just not true, right?
We have a bunch of those forever stamps.
And I think it's just a matter of time before they're like, well, the forever has come.
Yeah, well, it's interesting because the forever stamps the post office offers says if you buy this and then we increase the cost of a stamp we'll just you can use the forever stamps right but it actually they have
some incentive to keep doing it because then they don't have to keep changing
print runs for the new amount so they can print a lot of these forever stamps
and just essentially sell them for whatever they want right and they don't
have to keep printing new stamps with a new number on them right right is
somewhat in their advantage to keep doing that which is a safety as a
consumer that they'll want to keep honoring it because there's like a cost savings for them
to keep doing these yeah that makes sense so which is different than a company offering you know a
completely unlimited or you know lifetime style membership yeah that's fair yeah i mean realistically
the price of a stamp let's say it goes up 10 times right that's not as bad as
these lifetime memberships where it's probably hundreds or thousands of times
you know value yeah and so you can say we'll give them back the money they they
gave but the thing is like well the people don't want back the money because
it's like your point the service is worth more than the money they gave yeah
now in hindsight it seemed it's a really great deal that they made but at the
time it was risky yeah so you need need to give them back in proportion to the risk they took.
But on the same hand, if these people are costing too much money
and it would drive the company out of business,
what's the right thing for the business to do?
Yeah, I mean, why should the company have to fold and then reinvent itself
just because it made a promise it can't keep?
It's hard to say, but they should because they made a promise it can't keep it's hard to say but they should
because they made a promise so like they should have to keep that but if the company goes you know
goes away because this is too expensive these people are going to lose their plan yeah it's
basically the same it's the same thing so it's the same outcome for them so yeah it's a really hard
thing so just be careful if you're starting a, just plan for it to not like plan to go on.
Right. Don't plan that like, oh, we'll go away in a few years.
So this isn't a hard promise to keep.
And in general, I've noticed that I've become really suspicious of temporary anything.
So in other words, like like cable companies are notorious for this.
It's like, you know, I used to have cable TV and every year they I would get like half off my cable bill and it would last for a year.
And at 11 months, I would call the cable company and say I'm canceling.
And they're like, oh, we'll extend your special offer.
And so it turns out like everybody I worked with, everyone in the office is on the special offer.
Like it wasn't really that special, you know, but like but just things like that, like scream, like, like scummy and like be careful, you know what I mean? So it's like anytime you see like unlimited or, you know, half off for the next year or whatever, it's always like makes you, for example, I was getting ady. They were having like half off for the first year and they wouldn't,
it was very hard to find out what it was the second year.
And it turns out it was this ridiculous price.
Like it was like 3X what I could get somewhere else
for the second year.
And so just things like that,
just be careful for like temporary things
or unlimited things because, you know,
it's never going to last.
Yeah.
So basically you can't trust everything you read on the internet yeah shocking so the next news article is on
Apple buying a fingerprint company and yeah I saw this story actually and I
thought it was kind of interesting I'm not quite sure what does article say
what they plan on doing with it well it's Apple no yeah yeah yeah so there's a company who made fingerprint scanners and had a lot of technology.
And they had to make an SEC filing because I believe they're a public company is why.
And so they have to disclose that Apple is trying to buy them and that they're entering into negotiations.
And then somebody has to go and approve it, I guess.
So Apple, they've disclosed that Apple had been trying to make a negotiation to license some technology related to 2D fingerprint scanning and that now Apple wants to buy them.
And so people are speculating that either in the, that they're in a hurry, that it seems like everything is very rushed versus normal.
So that it might be as early as this year's new iPhone or iPad that might be coming out that they might have some sort of fingerprint scanning as a two-factor authentication or something
like that so so two-factor authentication is something you know and
something you have is a typical two-factor yeah there's three factor
right there's yeah I think that adds like something you are but something you
have and something you are seem kind of the same to me but I may be getting that wrong all right so first
factor is like username and password so those are not considered two-factor
although if you want some interesting reads go read about Microsoft you know
not that I want to rag on Microsoft but they had interesting post about whether
or not they were gonna add two-factor authentication to their new outlook.com
and they consider username and password two factors but the reason that's not two factors is because that's two things you know.
So it's the same.
So if somebody figured them out via the same means, they could hack you, right?
Yep.
So just to recap, so a username, a password, something that's sort of in your head that
you can just blurt out onto a machine or device, that's one factor.
Yeah.
So those are the same factor right username and password
because they're both something that's in your head right but they're also something that if an
attacker like was able to hack a database they would have both of those right so versus when
you add two factor typically that next factor is something you have so this is like world of
warcraft has rsa keys which are little uh pieces of plastic world of warcraft yeah i think you
could for like certain world of Warcraft people, they get...
Yeah, I'm pretty sure.
Oh, that's interesting.
Or other online, or banks do this, or many companies do this for their VPNs.
So it basically amounts to a physical device that you have,
a little piece of plastic that has a number on it,
and that number changes every so often.
Right.
And so the interesting thing about that is you have to type it in.
But even if somebody managed to steal the number that you typed in,
it was only good for 10 seconds, 30 seconds, a minute, 5 minutes, whatever,
however frequently that number changes.
And once it changes, they no longer have access to your account
because they don't have that object.
Right, and even if they have a sequence of numbers,
a lot of these number generators are algorithmically designed
where you need thousands or millions of numbers in sequence to guess the next one.
Ideally, nobody would be able to guess it if they knew one number, then the next number, then the next.
They shouldn't be able to figure it out.
Right.
But yet, it's not random.
It's not like a random number generator, although it looks like it.
It's not because the person on the server needs to be able to also know what the number is supposed to be.
So that's typical like the two-factor thing. thing well but something you have could also be your fingerprint so
interestingly this article yeah so i'm gonna pretend like i know the reality is i'm totally
cheating for those of you at home and reading wikipedia but but the third factor is something
you are and so a fingerprint or something which like is actually physically part
like like right that cannot be rough like you could give ways yeah you can
give the RSA key to somebody else but you can't give them your finger so I
think that's the okay so it could be two-factor could be like password and
fingerprint right or three-factor we give password fingerprint and I say yep
you know or OTP, one time password.
There's various names for these things.
And so it's interesting that the iPhone might have this.
Or maybe that's how you log into a device.
You have to hold your finger down.
And it's a secure thing.
And people have lots of issues with fingerprints because
fingerprints are pretty easy.
They're not considered as safe as some people think they are
if you get someone's fingerprint.
Now it's hard because you have to know the person but like if you touch a mug and then i get that
mug i can actually lift your fingerprint off the mug and then put it on like it's pretty easy for
me to fool most fingerprint scanners but in reality that's still far more secure than an
iphone which just normally isn't even locked so your data is not protected at all yep um so and
i mean a password like uh i think
they have password crackers and things like that yeah or somebody can just sit there and guess them
or look at the smudges on your screen or you know there's like all sorts of like an expert phone
cracker here in the audience that's genius but you're totally right like let's say you had
someone's phone and you're some kind of digital forensics expert you needed to get in you could
probably measure the amount of wear on the different parts of the phone.
And I would give you some guess as to.
Yeah, and like a super comp.
But, I mean, even just looking at the smudge pattern.
Or, I mean, most people think they're going to be birthdays, anniversary years.
So if you really know the person, you're going to guess.
Or I bet a lot of them are 0, 0, 0, 1, 2, 3, 4, 9, 9, 9, 9.
Right? I bet a lot of them are 0, 0, 0, 1, 2, 3, 4, 9, 9, 9, 9, right? I mean, just try the first 20 things, and you're probably going to hack 50, 60, 75% of phones out there.
But a fingerprint is nice because, you know, it should be easy to do.
You just set it on if it works really well, right, and this is great.
So interesting.
Nobody knows, right?
It's Apple.
It's secretive.
They don't say anything but that would be very curious to see if it comes to their mobile devices or whether
it's something more mundane like being on the laptop which other companies have done before
yeah i know that like one thing that apple seems to boast in their smartphone uh you know like
propaganda or like commercials or whatever is that uh is how fast it unlocks um like that seems to be
like a like a feature like always says like oh you can
be like from phone in your pocket
to using your phone like faster than any
other phone that's like one of their
key features and so like
adding a fingerprint where you don't have to type in a code
no no actually
it's going to make it go faster
because I mean it's much faster to just put your thumb on something
than to punch in four digits
so my thing is another thing Apple should work and be simple, right?
Yeah.
And fast, right?
I mean, it's the kind of thing.
But fingerprint scanners, I don't know if you've ever used them, but all the ones I use tend to just be terrible.
So they had one at my university to get into the gym.
They used fingerprint scanners.
And it actually worked really well.
Oh, okay.
But I will say that i've seen other people
have probably so so so basically either it works or it doesn't like it seems like it works for you
it works really well yeah if you're one of the eight percent or three percent or whatever because
i've seen people just sit there at the fingerprint scanner and it just doesn't work yeah i mean so
like if you're the fbi you probably you know do some image detection on a fingerprint and you
have to match 15 distinctive features on the fingerprint or whatever.
But I mean, for some of these fingerprint scanners, maybe they only have to detect two or three features.
And then that's enough to just a random person having the same fingerprint match on two or three points.
It's probably fairly low.
It's not unique as we think of fingerprints, but it's a one in 100,000 chance that just picking up a random person's phone, you're going to have a close enough match to get that.
Yeah.
You can increase reliability that way.
Yep.
I mean, you think about it.
If somebody takes your phone, chances are that phone's going to go through maybe 10 people's hands.
Like someone will steal your phone.
That person might try to get in, might not.
Who knows?
If they can't get in, they'll probably try to sell your phone onbay or something so so your phone will go to a third a second a third person but it's not going to cross
more than like 50 people yeah so so if the scanner can be good enough to where the 51st person happens
to have a close enough fingerprint that's okay yeah yeah so that means all the statistics game
this is a common thing right false positive versus false negative. So the person
whose phone it is wants to get in every single time,
but everybody else in the world should not
be able to get in. Yeah, exactly.
It's a hard thing to balance.
Yeah, yeah, totally.
That's a good article. Talking about
companies that change
what they're doing in life,
Twitter has been in the news a lot.
So Twitter made a lot of waves when they went from kind of being focused on the
web to start I think their first thing was they made their own client and
people got a little worried but then they started buying some big clients I
might getting in the history exactly wrong no I think you're right but now
they're making even bigger ways where they're telling third-party clients so
if you are trying to make a website or a piece of software that connects to Twitter
And displays tweets on your own, but you're not Twitter
You're gonna be limited to a hundred thousand didn't say a hundred thousand users
Yeah, so no more than a hundred thousand people can use your service. That's kind of weird
Like why would you this is your arbitrary number right but but even the that's weird that, like, we're limiting you cannot become popular.
That's basically what they're saying.
Yeah, that's right.
No matter how great you are, you cannot become popular.
Not any other, like, it seems like a lot of other ways to limit it.
I don't know, but that just seems weird.
And I guess for existing, they're doubling it.
So, like, you can have 200,000.
So, this is kind of weird.
I know there's, like, limits on how many, or there sometimes are limits on like if you're a third party client per username you have, you can only make so many requests.
Right.
To help try to prevent like denial of service attacks, these kinds of things.
Maybe they're worried of people like maybe they've had people just scrape the entire Twitter corpus.
But I mean, it used to be one of the things where they would provide that to people.
Yeah.
Like provide the stream.
Right. But, I mean, it used to be one of the things where they would provide that to people. Yeah. Like, provide the stream, right?
And that was interesting because people did all this analysis about, you know, what all the tweets were about and sentiment analysis.
Yeah.
Trying to see if people were happy or sad.
Did you see that?
Did you read that article on this guy could, within, like, 100 meters, figure out where you lived based on like your tweets and your friends tweets etc
yeah so you think about it it's like what what it did was it tried to it sort of like searched you
and your friend network etc and tried to find like one or two people that had a good bearing on like
somebody says for example uh i just went to the san francisco giants game right so it knows that
person's in San Fran.
And then it kind of used this inference diffusion algorithm.
But within 100 meters.
100 meters is really good. But the other thing is some people have location data attached.
So that makes it even stronger.
Oh, that's true.
Some people will have location data.
Some people will mention things that are like definite unique locations.
And then even once you have that, you can kind of start like oh I went to McDonald's
well you probably went to McDonald's close to
where all these other things are so now I
can start to get even better and
closer yeah yeah
that's crazy so Twitter is very
valuable but now they're making
it's kind of an interesting thing they have all these third party
and that's how they got big again they use
these third party clients people weren't
going to Twitter.com a lot they were using all these other twitter clients and now
they're basically getting rid of those and it you know people say well why and i mean we did one
thing we discussed when we brought up this article before we started recording which i think is
interesting is that these people are accessing twitter through an api so twitter's value is in
these 140 character tweets tweets that you're following
or whatever. But that means if all they're saying is like, I issue Twitter server requests to say,
give me Jason's tweets and his friends tweets, right? It sends me back these 140 character
texts. That's the response I expect. But how do you advertise through that? Well, you can inject
fake stuff like here's a sponsored tweet but that's pretty easy to either
just filter out right because you know that's not in the person's list of friends or you know just
show but it's not a big deal but you can't i can't give you like an image to show like hey you need
to show this ad as well you'll be interesting is if you had to create a session so in other words
like you had you you asked twitter you said hey i want to open up a new session in your API.
And then that session gave you, let's say,
like 100 tweets an hour, let's say.
I don't know, I'm making that number up.
But it gave you X tweets an hour.
But then if you wanted another tweet in that session,
they gave you an ad that you had to show.
I guess there's no way to know that you showed it.
To know that you actually showed the ad.
Yeah.
This is a complicated thing.
I mean, the other thing is that they could charge you per access or something, right?
Yeah.
So then that third parties would have to, you know, give that cost on.
Right.
So either you pay a one-time fee and they hope you don't, you know, spend more than that.
I mean, there's all sorts of weird ways I guess they could try,
but they've just decided I guess this is the way they're going to do it.
Yeah. I mean, the problem with this is that there's no path forward.
Like, let's say you had an app that had, you know, hundreds of thousands of Twitter users and was very popular and highly monetizable.
You know, I guess you could contact Twitter directly and negotiate with them.
But I mean, this policy doesn't just kills your business.
Well, it just prevents the businesses from ever starting right right now you won't start
a Twitter business now yeah right but this is interesting because I guess
other people like you know Facebook or even like a Google Plus or other places
that they start that way right nobody can access their data right and then no
there are no third-party clients and then slowly they kind of sometimes let out a little bit of an api to do that twitter kind of started the other way like
oh we're gonna make this available for you and then now they're kind of becoming more like just
facebook or google plus yeah but that kind of i don't know that kind of ruins it like then it's
not different anymore yeah another social network it's just one where you can't post as much.
Yeah, you can't post the picture.
You have to post a link to the picture.
Do you have a Twitter account?
I do have a Twitter account.
So I actually have a Twitter account that other than getting hacked,
I haven't done anything with it.
So apparently I've made tons of posts, but none of them intentional.
But I just never understood it.
And maybe you could explain it to me,
but it seems like Twitter is just like a subset
of what you could do with Facebook.
I didn't quite understand the Twitter concept.
So things have changed, right, the environment.
But when it originally came out for me,
the draw was I could follow.
It was asymmetrical, which Facebook wasn't.
So Facebook was symmetrical.
If you were my friend, I was your friend. so that mean if you're a celebrity right and i was your friend you got to
you could see all of my stupid posts that you didn't care about because you're a celebrity
gotcha and then i could see all of your posts you know like all of them so in twitter the difference
was first of all it was public so anybody could see any post you had so there was no expectation
of privacy and then there was this asymmetric part so you didn't post things there that you didn't want
everybody to see so that was good and for me like being aggravated at facebook for how they deceive
people about privacy i like the fact that it was just easy everything is visible it's all public
right but then there was this asymmetric thing if you're a celebrity i could follow you you could
post something and i could see it but you didn't necessarily have to see everything that I posted.
You could have a different set of people that you followed as a celebrity and you would only see their information.
Now I get it.
And then Google Plus kind of did the best of both worlds in a way, I guess.
But there's not as many people there, but it doesn't seem like anyways.
But this best of both worlds.
I think just about everyone on Google Plus is a programming throwdown follower so we have we have a few hundred followers it's about right
but you know the google plus is both like right like i can do asymmetric following right but if
it knows that we're both in a circle like i can share stuff to this group specifically versus
having to make it all public right exactly yeah so yeah i guess i can see it now i mean
definitely like so twitter is is commonly used in like nbc for example say you know check our
twitter and it like now now it makes sense because it's public because it makes sense for them to be
like hashtag olympic gold or whatever they think they put at the bottom of the screen on during
the olympics nbc you know or when they do that, they can boast like,
oh, we had 100,000 people use our thing, right?
And that's measurable for them.
If you did that on Facebook, you would have to, like, friend them.
They wouldn't necessarily have access to, like, everything that you were posting related to that.
Yeah, that makes sense.
Oh, I mean, the NBC Olympics would get me on a huge terror.
Yeah, let's not get into that. Patrick gaverick gave me this like he knows how upset i am that like i don't we haven't even talked about it
but i know how upset i was i know how upset everybody else i knew was yeah so i like let's
not even we have to proxy through europe to watch the olympics anyway so so um tool of the bi week
anyways actually i have an olymp prediction, but I'll tell it later.
What prediction?
I have an Olympic prediction.
Olympic?
We'll do it real quick.
All right, go for it.
Before, pre-Tool of the Bi-Week.
So last Olympics, I made a prediction that I was going to be able to watch the Olympics.
In 2008.
In 2008.
In 2012, I was going to be able to watch the Olympics, like, either on YouTube or on something like YouTube.
All of it.
And that came true if you were not an American.
If you're in one of the 97 countries or whatever that...
You were not in a, like, first world, like a large developed country.
So it seemed like...
No, England was on the list.
Was it?
But that's because everybody's a BBC subscriber already. They already all for bbc whether they like to or not oh if you haven't i think
the way it works now i'm probably getting this wrong in the uk if you have a tv you have to pay
for bbc ah you already have to pay a subscription i didn't know that right it's like included i
don't know if it's like a tax or a license or a fee you pay okay so like they don't have cable
providers like we do so that was my
prediction and that sort of came true okay my prediction for the next olympics is okay wait
so i messed it up is this the 2014 olympics or the 2016 olympics oh you mean the winter rio or winter
i think i'll say rio give myself an extra two years buffer okay by then definitely any followers
i forgot so so but maybe you remember. No.
So the prediction is that either using peer-to-peer technology
or someone like Microsoft or Google buying the exclusive rights themselves,
one of those two things will happen,
and you will be able to for free watch the Olympics online.
That's my prediction.
I would agree with you,
except NBC has already bought the rights i
think through 2018 or 2020 so regardless they like you would have to pay and you'd have to either a
buy nbc which owns nbc devastating you'd have to buy the company to get the rights or you would
have to pay them to agree to give you the rights like you would have to sub license from them if
they're even allowed to sub license that's that just crushes my spirit well that that actually so that eliminates option number two we still have
peer-to-peer video streaming so well i assume you meant legally oh well
well if you say illegal you could watch this one for free yeah okay but it's not very accessible right like my grandma can't watch
it for free easily they're they're okay i mean she has like change your dns and all this stuff
right yes yes so uh there will be some peer-to-peer technology which is like unshutdownable and you
there's also other websites that had olympic content and you'd go
to it the next day like day two of the olympics and just an fbi logo and like the fbi just sees
that website wow yeah yeah you must go to different websites than i do no literally like i just yeah
yeah they did this to this other no i'm just kidding so um yeah so interesting prediction
that's my predictions so the biggest problem i had oh, we want to use all this social networking,
but you had to stay off of every social network.
So even if you get over the air free NBC channel, like their one channel,
that only broadcasts some of the things that were only based.
So in America, they only broadcast things that they thought Americans would be interested in.
It basically turned it into a reality show.
Yeah, that's true. About certain turned it into a reality show about certain athletes
as opposed to certain sports or certain, just whatever, very strange.
There's virtually no team sports.
And I'm pretty sure that's on purpose.
Well, there were, but regardless.
I mean, they're in the minority.
Yeah.
So even if you watch the thing, you have to stay offline
because they didn't show it until many hours later.
So if you went online, you would see who won this thing.
Yeah, it would ruin it.
It would just be everywhere.
And so then when you watched it 16 hours later, like, yeah, that was the part that killed me is I couldn't go on anything or I would accidentally see who won.
Yeah.
Even the sports NBC was showing or I knew was going to show that I might be interested in, I didn't have to worry if I went online.
Yeah.
Yeah, I totally had that happen.
I went online to see
what sports they would show
and now it's ruined.
Yeah, now Google News will show you who won.
Yeah, exactly.
I implied that you used Google. I had no idea.
Maybe you're a Bing user.
Yeah, Bing News showed me who won, but fortunately
they were wrong.
No, I'm just kidding.
Tool of the buy week.
So my tool is GNU Cache.
Is it GNU or GNU?
I never know.
Is it GNU or GNU?
Do you pronounce the G?
I'm not going to pronounce it.
All right, maybe you can look that up.
I'm not going to fall victim.
I think it's GNU Cache.
But anyways, it's G-N-U-C-A-S-H, GNU Cache.
And the idea here is...
Two syllables, GNU.
Oh, it is GNU.
That's what Wikipedia's pronunciation key says.
Wow, I learn something new every day.
So GNU Cache is, like many programs, there's GNU Chess, there's GNU Go,
there's GNU CC, the C++ compiler.
And the GNU Foundation manages a bunch of open source platforms.
And GNU Cache is one of these open source programs.
And so what you can do is you can go into like your bank or your credit card or other financial institutions that you're a member of.
And you can export to any format you want actually like GNU cash will take like Microsoft money or
quicken or the QuickBooks the new quicken they'll take any of these formats
so you export your data it's like for February you export your you know credit
card your bank statements etc then you go into GNU cash and you import these
things and it will do
the job of sort of matching up. So in other words, if you used your checking account to
pay your credit card, it'll match those two transactions together and like create a, what's
that called? A double logging or something? Anyways.
Accounting, the accounting thing?
Yeah, when like, when you match the two. Anyways, so so um guru cash will do all that for you
and it'll try to intelligently and it gets better at this the more you use it guess at the
categorization of your entries yeah yeah so so in the beginning it actually starts knowing nothing
so like for example you on your credit card you paid for shell gas so shell will show up
and uh so you put on there gas but but then through fuzzy string matching, it over time starts
to learn.
So now it's at the point where it's kind of trained.
We've been using it for a few months, and it knows most of our expenses.
Like this is video games, this is gas.
And the other cool thing it does is it shows you every month, or you can pick a range of
months, it'll show you pie charts and bar charts showing like how you're doing
and what your biggest expenses are.
And I cry a little every month when I see like,
was like a hundred plus dollars a month going to cell phone bill.
Excuse me.
But yeah, it's good to sort of be aware of your expenses.
And we were talking about this before the show.
Neither Patrick nor I have like a set budget,
like, oh, our expenses are going to be X dollars a month.
But the better thing is to sort of have this adaptive budget.
So, you know, if over time you see,
oh, my video game expenses keep going up and up
and, you know, I'm getting addicted to like buying things on Steam
and not playing them or whatever.
Guilty.
Guilty. So you could say, oh say oh i'm gonna tone this down i'm not i'm only gonna buy one thing on steam
this week and so it allows you to sort of self-regulate yeah this is a common like mind
hacking thing is that if you want to help make something better if you just make it visible
so it's not exactly visible where your money is going each month and people tend to have problems spending less than they make yeah which is you
should be doing that spend less than you make it's important definitely and if
you make it visible though right like you see how much you're spending in
various things you begin to be conscientious of about it so even if
you're not trying to make it go down you will make it go down yes typically
totally just like this when they put up a speed limit sign that tells you how fast you're going,
even though that sign doesn't send you a ticket or anything for the most part,
just showing you your speed, people automatically slow down because they feel bad.
And like, oh, other people are seeing me, right?
Like I need to go slower.
Or efficiency of your car, like depending on how fast you're going
or how fast you accelerate, your car is depending on how fast you're going or how fast you accelerate your cars different levels of efficient but even if you don't care
about miles per gallon if you put a meter on there that shows mile per
gallon studies show that you will make your miles per gallon go up yeah just
it's human like you want to make it better yeah I mean anytime you see a
number you want to make it go either I noticed that there's a community center
that I play volleyball at where the speed limit signs are all prime numbers and like yeah like in the
in the uh like actual place where you park like in the in the specific place where you're passing
all the spots the speed limit is seven and then when you're getting ready to like exit on that
sort of main atrium it's 19 and i just I just thought that like, that really caught my attention.
And so I thought that was pretty clever.
It's probably not prime,
it's probably trying to make it something
that you have to actually try for.
So if you make it like 15 or 20,
people kind of confuse the hash marks, right?
Like on the car and-
Oh.
So like making it a weird number,
you have to like count the hashes and be like,
oh, I need to stick it here.
Yeah, or at least you think about it.
Yeah.
Like you don't see a lot of sevens or 19s.
That's the first time I've ever seen 19s.
So just making it something different
gets you out of, what do they call that, like blindness.
So there's the term called X-blindness.
So it'd be like, in this case, speed limit blindness,
where you pass by so many speed limit signs every day
that you just become blind to them.
Just subconscious.
Yeah, yeah.
So this time, it's like you see a 19, and you're like, whoa.
You immediately start paying attention.
So GNU Cache does this.
Yeah, it is helpful.
Yeah, GNU Cache keeps you from broke blindness.
Spending blindness.
So what's your tool of the buy week?
My tool of the buy week is 7-Zip.
So 7-Zip is an open source Windows tool
for meeting all your compression and decompression needs.
And being the guy who always pretends to do four tools,
but it's really for different OSes,
I'll add P7-Zip, which does this for OS X and Linux.
Oh, okay. All right, all right.
So 7-Zip, so I mean, how many times you go on a, you know, form somewhere or see something and people are like, how do I unzip this or how do I do this? So it's like, so get 7-zip. It'll do all your stuff. So people, it used to be like WinRAR or what was, I forget, the WinZip or whatever. It was one of Windows. But now it's just like 7-zip. I have it installed, what they call it, shell extension, so you can right click on an archive
and then just say extract a folder, extract.
First of all, 7-Zip's really fast, so it's nice.
You don't even normally need to bring up the GUI.
It has a GUI, but I hardly ever bring it up.
And then it just works, right?
It's nice.
You don't have to think about it.
It's just the tool to get.
And it's not like WinRAR used to be.
It's like, what is that called? Pesterware or something. Yeah, youware or something yeah like that pop-up but like you're supposed to pay a certain
amount of time if you don't nag where okay yeah and you know kind of like but seven zip's not
like that you just install it it just works they have their own compression format yeah i think
like dot 7z yep it's lzma is the type is the uh is the the algorithm? Okay. Yeah, but it works for RAR files.
It works for zip files.
It works for tar.gz files that you get from Linux stuff
if you ever need something that's that.
It just works.
I think it even works on ISO files.
I think an ISO container, you can unzip the ISO into its component files.
Of course, some ISOs can contain stuff like boot sectors and things,
so I'm sure it probably just ditches those.
Yeah, probably.
But all the files that are there, it'll extract.
So it's really useful.
And 7-Zip is the best compression you're going to get
without knowing the media.
Like an MP3 will always beat 7-Zip because it's lossy.
Yeah, it's lossy. That's cheating.
Yeah.
But if you don't know what you're zipping or you just want a general utility, 7-Zip will give you the best compression out there.
So, yeah, I recommend that.
Yeah, yeah, it's great.
Multi-threaded, too, so it runs pretty fast.
Yeah, it's good stuff.
Definitely get that.
All right.
So on to our programming language of the week.
I don't even know if we announced it.
I guess we did announce it at the we're covering go yes go go maybe
they you know gadget if you did if you didn't know you might think that i was just telling you to
start talking like episode 18 go and then you start talking yeah patrick loved the building. So, yeah, so Go is a,
Go is actually an imperative language that was invented at Google.
But it has sort of a lot of nice,
like sort of functional characteristics.
So it's pretty new, right?
Yeah, so.
About two years ago now?
Something like that.
I mean, Go 1.0 came out, what, March?
So that's, what is it now, August?
So yeah, just about six months ago, the 1.0, like the official version came out.
Before that, they had sort of like these release candidates that had varying levels of functionality.
Like batteries, like as far from included as possible.
Even like, I remember when it first came out a couple years ago you needed to download um a
library just to print to the screen like you had to go on the internet and get like another package
for for printing and i was like this is ridiculous yeah um but now you know they have a lot of those
things included like file io and printing and all that stuff uh is uh is all totally in there so the
thing that i remember when i first started hearing the press releases about Go
and people talking about it, as people tend to do any time Google says anything,
was this, it was built for multiprocessor environment.
Like, you know, now there are computers with many cores and that kind of stuff.
And that it was going to be, it's not multi-threaded.
I remember it wasn't.
But people said that it was built for things that have multiple cores and multiple processors.
So what did they use to handle concurrency?
Right.
So they use goroutines.
And goroutines is sort of a play on words.
It's a play on coroutines, which I think we've talked about, actually, on the show.
But I'll just recap quickly.
So let's just go through the layers.
You have processes. And so if you ever go to like your task manager in Windows
or you type top in Linux or on the Mac,
you go to the, what's it called, activity monitor,
you can see a list of your processes.
Like I have Chrome, I have Firefox,
I have, you know, Adium, Instant Messenger, et cetera.
That's like the highest level of granularity.
And so starting up a process is pretty time
consuming and you're not supposed to have thousands of processes running or hundreds of thousands
right you're supposed to have just not unless you're effective with malware yeah that's right
our parents probably have well maybe not your parents your parents are pretty tech savvy but
sure my parents have thousands of processes but anyways so so you're intended to have, you know, 20, 30, as many as you
have programs running, right? Then the next level down, a process can create multiple threads.
And so threads can sort of allow you to do two things at exactly the same time. And you can have
different threads running on different cores of your machine. And so get you know n-way parallelism. So
let's say you wanted to, let's say the 7-zip for example. So 7-zip will take,
let's say 7-zip knows you have four cores on your computer. Well
they'll take your file, split it into four chunks, and do the compression on
each chunk on a different thread on a different core.
And so once it's done, all those threads will come back together and merge the chunks.
So that's threads.
But in many environments, you actually want... So along with processes, you can't have that many threads.
You can actually only have a few hundred threads total.
Some operating systems, I mean, if you have enough memory and things,
you can get to a thousand or even 2000. It's extremely rare. If you're making an application
for everyday users, you can't really feasibly go over a hundred threads safely. So, but you might
want to do a thousand things at the same time, right? Like that might make your program easier to write, easier to understand. Maybe if you're doing like disk kind of stuff, you know, you might
only have like 90 of these that need the computer, the CPU at one time, but you have the other like
900 waiting on the network, right? So to do that, they invented coroutines. And the idea is
coroutines is something that sits on top of a thread pool.
So you might have, let's say, your application might have 10 threads that are all just kind of
sitting there waiting for work. And you might have 10,000 coroutines. And the coroutine says,
hey, I have stuff to do. Give me a thread that's available. And so you have up to, let's say,
four coroutines that can do that. And then once they're like, oh, I'm waiting for the hard drive, you know, this thread can work on another coroutine.
So coroutines have been awesome.
Stackless Python is one of the first programming languages that had coroutines.
Now Ruby has them.
But for people who have heard of EVE Online, the MMO, that whole thing runs on a few machines that have stackless python and every ai is running
its own co-routine so if you imagine there's like millions of computer opponents in the game
and each one of them has a co-routine that's sort of running at its own pace
well one of the many interesting things about is that as opposed to most massively multiplayer online
games where there's essentially parallel worlds where if you exist in one world you only exist
in that world and it's not easy to travel to another world and all player activity doesn't
exist in just one world but EVE Online every player logged in and every all exists in one
common shared world. Yeah yeah exactly and so one of the reasons why they were able to do that
is because they picked a technology that scales so well.
So, I mean, it wouldn't be possible to have...
I mean, a lot of these like World of Warcraft and things like that,
they might do like a thread for every zone AI.
Like each zone will have like for all the AI running in that zone one thread.
And so if you follow that logic, you can only have a few hundred or a thousand zones.
Right. And then you have to use a new machine.
So Go, you know, understood that that coroutines are awesome and that we want to sort of like take advantage of that.
But they also understood that a lot of people who need this kind of tech aren't python and ruby programmers they're guys who do like low level um you know
like networking or like this back end for world of warcraft like heavy data processing and things
like that so they created a language that was very similar to c or c plus plus but with this
coroutine support looking at go code it really does look a lot like C. You can almost just read it like it's C.
Yeah, it has the option of being strong or weakly typed.
You can actually do like X colon equals and then anything.
So if you change the return value of the function,
now X's type changes.
But you can also be explicit and say like, you know.
Integer. Yeah, it's actually backwards.
It's really confusing when you see it for the first time. It's like x int equals, which is like
really throws you off. But yeah, you can say effectively like x is an integer and it's equal
to the output of this function. And if the function output changes, you'll get a compiler error.
So it gives you that safety that you often need when you're doing these like critical back end,
you know, like if you think about it, you can have a front-end in JavaScript as most, you know, browser
front-ends are, and if something crashes, your program will keep running. Like let's say you're
using Gmail or Yahoo Mail or something. You go to open a mail and your JavaScript crashes. You'll
just try to open another mail and you're okay you know or you'll reload the page
and the whole javascript engine will refresh um if your back-end crashes you're in big trouble
like if the thing that writes the database crashes then like everybody's host that's when the server
goes down yeah when you say that the website's down yeah then then everybody on using your
service gets the screen with like a team of monkeys has been dispatched to fix the problem or the whale with all the balloons oh i haven't seen that one the fail whale
that's awesome what is that oh yeah that's the twitter one right oh all i know is the youtube
one the team of monkeys has been dispatched but um actually there's the crying robot too
um on gmail but anyways so um so yeah so a go is an attempt to sort of give you
that safety that c c++ gives you a strong type and everything and even give you more safety because
go has a garbage collection and safe pointers so you don't have to worry about
pointer math yep well actually the crazy C operations.
No, you're right.
It's memory safe.
It can be type safe.
You can do crazy, like you can add pointers, but if you ever go out of bounds,
you'll get a runtime error.
As opposed to in C where it'll just
let you do crazy things.
Depending on if you do something bad or not.
Yeah, yeah. If you have some kind of static
thing, it'll...
In C, you can allocate a huge array
and then have smaller arrays inside of it and do all sorts of funky things with memory you can't do
that with go but um but they try to still as opposed they try to give you some ability to
kind of lay out memory and control more how memory is done so that it still stays efficient because
you can have more control over how things are done because you know what it should act like.
As opposed to just, I think the way Java more approaches it
is like, doesn't really give you any control over that.
Like look, we know what we're doing,
you just write your code and we'll handle everything else.
But sometimes you can impart knowledge.
Like hey, let me give you this hint.
Hey, put these things next to each other
because I'm going to keep using them over and over again.
Yeah, totally.
Go gives you sort of that flexibility that lets you do that, which is awesome.
So Go works, as we mentioned, with Go routines.
And the way that these routines talk to each other is through channels.
And so the idea is if you've ever used a concurrent queue in Java,
you know what a channel is.
It's exactly that.
So what a concurrent queue is, first let's talk about a queue.
A queue is a, I always get this mixed up.
First in, first out.
Is that, yes, that's a queue.
I always get those two mixed up.
For some reason, like.
A queue is is like
is like literally like a pipe like the or like a line when you queue up to get your starbucks or
your mcdonald's or whatever the first person who gets there is the first person who gets served and
everybody who comes next if there's somebody in front of them has to wait behind that person in
front of them right but like in the case of a stack which is last in first out right
most recent person to get there is the most is the first person to be served see i know i found
out now why i get it confused because i think let's say you have a bunch of things already in
the stack and you put a thing in the stack i think that that's sometimes i could think that that's
the first thing because it's like the thing you just put in.
But that's totally wrong.
So just to clear it, the thing you just put onto the structure
is the last thing.
Yes.
And so when the first thing goes out.
The most recent timestamp.
Yeah, that's a good way of looking at it.
Yeah.
That's the last thing.
And so, yeah, so a queue is a first in, first out.
And you can use these channels, which are queues, to talk amongst goroutines.
And the interesting thing is it can be blocking.
It doesn't have to be, but it can be.
So, for example, you could create 10 goroutines.
Let's say you were implementing 7-zip, for example, you could create 10 go routines. Let's say you were implementing 7-zip, for example.
You could create 10 go routines that would compute 10, you know, that would compress 10 chunks of memory, you know, one each.
And then would pass the compressed chunks through one of these channels.
Then in your main program, you would say would say you know go and then the first
function go space second function go space there and then at the end of the 10 functions are in a
for loop at the end of that you could have another for loop from 1 to 10 where you just read from the
channel you block so even if channel 5 finishes before channel 1 you won't look at it because
you're waiting for channel 1 oh so you can actually do both okay you can actually block in
order to where like the first channel the first go routine has to answer first
or you can just block and say once any of these ten finishes then like you know
do something with the data and then wait so in the case of sevens if you'd be
interested in having an order right as you need to write it out order to the
file typically right right but in other something you may not care right exactly first thing is don't let me know because I want to write it out ordered to the file typically. Right, right. But in other something, you may not care.
Right, exactly.
First thing that gets done, let me know because I want to start doing work again.
Yep.
And so there's some things that make this really great.
So we'll talk about some of the strengths.
One strength is that to turn something from a function call, which is synchronous.
So let's say you laid out your program as if you had written it in C and it just said for i equals 0 to 10
compress chunk i and then for i equals 0 to 10 like write chunk i. But you could
write that in C and it would just like use one thread in one routine and it
would just execute in parallel or in sequence. And if you had any bugs, you would find them and things like that.
If you wrote it in Go, or if you wanted to change it into using more than one core,
all you have to do is put the word Go in front of the function.
Well, and you have to do the channel stuff, right?
But the idea here is the channels will work, and the functions will work without Go.
So if you don't put the word go
it'll only use one core and everything will run in sequence which is great for debugging and you
know your channels will you know obviously like your channel will completely fill up before you
get to that stage where it empties because it'll do all 10 and blocking right but it's cool because
you can test it and you can see if there are any bugs, things like that.
Then all you do is you go in your code,
and you add go, go, go,
and as long as you've done it right,
all of a sudden now your program's using
all the cores on your machine,
and it's running super fast.
But most of the time when you get to that stage,
it's already well tested.
And so that whole pipeline of development
I've found to be really nice nice yeah that's nice and the other thing is because they're co-routines and not threads
you don't have to worry about using too many of them so i mean let's say um you broke your file
up into one meg chunks and each chunk you tried to process in parallel well if you use threads
and i gave you like a 10 gigabyte file
and you tried to create 10,000 threads, you'd crash the OS.
And yeah, it'd be a nightmare, right?
But in Go, you can create 10,000 Go routines.
And they know like the 9,998 of them would know you only have two cores
not to, you know, waste your time.
And so they just sit there.
So you talked about, I mean, maybe skipping ahead a little bit,
you're just kind of getting to the strengths.
So this, and I even brought it up, this concurrency is kind of baked in.
It's pretty nice.
People seem to like it.
It's lightweight, like it's not a big chore to get it set up and working
like it can be in some languages.
And then you don't really have to worry about all this thread
I need to start up a thread pool and then I need to have a
queue and threads need to service the queue
and all that kind of stuff is just
taken care of which is really nice because now
that processors aren't really getting
any faster but we're getting more of them
even like phones now
are going to have I think like four processors
in them. And now they have those
64 core desktop processors.
It's just insane.
So those are strengths, but with strengths come weaknesses.
Yeah, that's right.
So one of the weaknesses is there's no generics.
So it's hard to write something that operates.
Generics is what the Java name is, and C++ is called templates.
So this is like you write one function,
and it kind of knows how to operate on all sorts of different types that are passed in.
And then the other thing is it's still pretty new.
And as with anything, if you're going to try to use this at work,
I'm not going to vouch for it.
Google might vouch for it, but I'm not going to vouch for how reliable this is or how great it is or that it'll work so if you're trying to
go to your boss and like hey i want to write this our entire startup company we want to make it like
you know like that that might be you might be a genius five years from now or you might ruin your
startup and have to rewrite all their when they have to rewrite all their code, just because it doesn't have that
track record, that history.
But it is good for using, like we always encourage people to
find that little project or that little tool that you need
to write and implement it in Go.
And then one day, it will have that track record, or it will
pass by the wayside.
But everything starts at some point, right? I mean, C++ used to be brand new
and people laughed at it
and said, no, we don't ever use that.
Now it's like,
what did we do before C++?
Or, you know,
Java's becoming that same way.
You know, so C,
or C, so Go,
you know, maybe one day
people will look back and be like,
back when I was a kid,
Go was a young ripper snapper.
Yeah, exactly. I mean mean but it's interesting that you
mentioned c++ because you know just think how hard this stuff is so so remember the the people
that go the go language is going after in my opinion are the c c++ really low level and to
do this kind of stuff in c++ is super hard, right? I mean, even just threading.
Like, I don't know about you, but any time I've had to do multi-threading,
I've had to use Boost Thread because, like, Boost Thread has all this code
which, like, wraps around this.
Like, it'll say, oh, I'm in Windows.
I need to use, what is it called, the threading library in Windows?
Not Winsock.
But anyways, it uses something.
If you're in Linux, it uses Pthread.
Or Mac uses Pthread.
You know, so then if you want to do thread pools,
you have to write the thread pool code yourself and handle that
and, like, make sure all the threads are, like, busy.
Like, you have to do all that yourself.
It's just insane.
And so Go gives you all of that for free
and still gives you a lot of the constructs in C and C++ that low-level programmers really like.
Yeah, I guess my point is, like I was saying, it's a track record thing, right?
Yeah, totally.
Don't be surprised if your boss isn't gung-ho about it.
Yeah, exactly.
You know, if you're in university, you know, writing a research paper in Go, it might be great, and there might be a lot of stuff to study, but the problem is in 10 years from now,
if your plan is to have that research paper be worse in 10 years,
you'd rather build on something that has people kind of,
it's trusted, it's well-known.
You know it's going to be there,
and the compiler will exist for future machines.
Right, yeah, like C++, I mean,
even if people stop writing code in it,
there's just so much code that is written in it.
Support somewhere by somebody seems like it would just have to continue, right?
Yeah, and I mean, that's why C++ is so ubiquitous
that the Android has the native development kit.
I think iPhone has something.
Actually, iPhone C++ just works natively.
So, yeah, I mean, these languages have stood the test of time long enough to where,
you know, you could write something in C++ and someone could use it on Android, right?
I mean, right now, that's not true with Go and it might never be true.
I mean, it doesn't have its place, it's just not ready yet.
Yeah. Yeah. And there's also along those lines, there's not a lot of bindings for Go. So,
in other words, let's say you wanted to use, let's say 7-zip, for example. Let's say you wanted to use uh let's seven zip for example let's say you wanted to
use seven zip inside your program and you're writing so seven seven zip source code uh part
or library yeah right right so seven zip is written in in c++ but uh if you wanted to use it in java
um there's a binding for it which means means that the 7-Zip people, or maybe somebody else, some hobbyist, has gone in and written the glue code to access 7-Zip C++ libraries from
Java.
And so Java's a ton of these bindings to other libraries, but Go doesn't have any of this
yet.
Yeah.
So as far as tools go, there's two different compilers for Go?
So many!
Yeah, I mean, you know, I think this is common, right?
Because C++ was the same way.
There was a number of different compilers.
Remember when there was, like, Turbo C++?
There still are.
There are many.
I mean, you've got, like, the Microsoft compilers.
You've got GCC.
I mean, there are typically, got like the Microsoft compilers. You've got GCC. I mean, there are typically multiple compilers.
And it's interesting that though one person, you know, essentially Google is developing Go and they've still thought to release two compilers.
Yeah.
Yeah.
So in this case, but actually the two compilers have different sort of use cases, I guess you could say, or different sort of applications.
The regular Go compiler
has a really fast compile time, but it has a really slow, not really slow, but it's a slower runtime. And
so there's also a version called GCC Go, and what this does is it runs like a Go
preprocessor on the code. And so for people who don't know gcc is more than just a c
compiler it also does c plus plus obviously the g plus plus but it there's a there's gcj for java
there's um everything basically exists for like yeah there's language i'm trying to think i can't
come up with another one but i know know there is at least almost every language
There's GCD for decompiling so anyways so so all of them compiled down to this intermediary code Which I don't know has some name and so there's a front end so you can have a different front end
Like you're saying I could precompile it that yeah produces this output file of a certain format right that
Represents kind of the programming structure as
opposed to the specific language right exactly and then there's the gcc back end which can take
things from gcj gcc g plus plus it can take output from all from all of these because they're all in
the same format and just do a ton of like optimization crazy like research-based optimization
yeah like oh this for loop could be unfurled or unrolled.
This one can't.
And there's some crazy branching we can do here to try both branches, et cetera.
So GCC Go has a Go front end with a GCC back end.
And because it's doing all this crazy, funky stuff, it takes longer to compile.
But then it should, in theory, run faster.
So you can, when you're doing the interactive, like, try something, run it, try something, run it. it takes longer to compile but then it should in theory run faster so so you
can when you're doing the interactive like try something run it try something
run it you can do the fast compile times you don't waste a lot of your time yeah
but then when you're ready to kind of like you know start testing performance
or tuning that then you can switch over to the GCC yeah totally totally yeah
another cool tool is uh this is more of, I guess, a doc than a tool,
but it's organizing Go code.
I found this really useful.
I've been writing Go for the past few weeks.
And I found this kind of useful
in sort of laying out,
understanding what is a package
and what's a package supposed to contain.
Because in languages like C++ and Go,
the package, and even in java actually like i never
quite understood like like you know oh i have 20 files should i try to group these files in
different packages like what's the limit you know and so uh it tries to address some of those like
i guess like philosophical or maybe architectural questions so uh yeah those are some pretty good some pretty good tools to get
people started yeah I think we've got some so so you know go it's it's new but
it's cool it's good for a lot of like low-level systems for you like we're
talking about applications back and stuff you know watch where it goes you
know yeah I mean think about if you write a server and go you know typically
the way server works is you have some kind of thread pool
and then people access your server, like somebody hits your website, and it looks for an open thread
to service like that web request, right? So pretty much everything you do on the web that's server
side or anything you do that has to service a lot of customers relies on some kind of thread pool.
And as we mentioned, you know, in C++, there is no thread pool.
You have to write that yourself.
So this stuff in Go becomes very easy.
Like if somebody hits your website and it has a Go backend, you just kick off a Go routine.
And you don't worry about, oh, if a million people hit my website at the same time, I'll kill the operating system.
You might go really slow.
Yeah. I mean, you know, that person, that millionth person hit the website,
you know, they might not get service.
Their request, like their browser might tell them that this website is not available.
You know, and there's, you can actually, before kicking off the go routine,
you could check and things like that.
But the important thing is that you're doing something really low level,
but you don't run the risk of blowing up the operating system right i mean that's sort of the nice thing about
it yeah we've gotten some awesome feedback about our java episode people yeah people had some
comments and we read them all we don't always reply or at least not expediently to all of our
stuff we do read them we are listening we're paying attention some new languages people have
yeah and asked for.
The queue is growing.
It's not first and first.
I guess maybe it's a priority queue.
Yeah, that's right.
But the languages are growing faster than we're actually recording them.
Yeah, we definitely are going to spend the next few episodes getting back to some of those requests.
Yep, but thanks for all the feedback.
As always, you can find us on our Google Plus page or email us at programmingthrowdown at gmail.com.
Yeah, if you write any cool programs in Go,
definitely post us a link or something.
Tell us about them.
All right, well, until next time.
See you guys later.
The intro music is Axo by Binar Pilot.
Programming Throwdown is distributed under a Creative Commons Attribution
Share Alike 2.0 license.
You're free to share, copy,
distribute, transmit the work, to
remix, adapt the work, but you
must provide attribution
to Patrick and I
and share alike
in kind.
