Programming Throwdown - PHP and Hack
Episode Date: January 24, 2017On this show we discuss PHP and Hack, an language that extends PHP. Show notes: http://www.programmingthrowdown.com/2017/01/episode-62-php-and-hack.html ★ Support this podcast on Patreon... ★
Transcript
Discussion (0)
programming throwdown episode 62 php and hack take it away jason
hey everyone uh welcome back first uh podcast of the year year unless you're on the Chinese New Year
and I think this is like nearing the end of your year right is that true I think yes I think it
starts like next week oh really oh well depends on when this is released oh yeah good point t-shirt um january 28th beginning of the
year oh interest says yeah this will this may be the beginning of the year for for everybody
uh for all for both calendars of which i'm fully aware um so we have our t-shirt winners uh josh
p and sam are uh two patreon subscribers that I drew at random.
And actually, this is kind of, I don't know, funny or sad or whatever.
I was going to use the Patreon API and write a Python script and do all this stuff.
And then I realized Patreon just lets me download a CSV with all the names and email addresses of people who have subscribed.
So I put that CSV into Excel and then addresses of people who have subscribed.
So I put that CSV into Excel, and then I just randomized the rows.
After telling everyone I was going to learn the Patreon API,
it turns out I didn't even have to do that.
I used trusty-dusty Excel.
But yeah, after that random function, Josh P. and Sam R. were at the top of the list,
and they both will be getting some pretty epic t-shirts.
I'm probably going to send them out later on this week, this week being the week we record.
So by the time you listen to this, I would have already sent out the shirts.
But congrats to you two, and I hope you really like your shirts. And thank you to all of our patreon subscribers and to all
of our listeners whether or not you support us we thank you yeah definitely and we'll probably do
this again i don't know really the cadence or things like that but uh we'll definitely do this
again and and do more giveaways like this so uh thank you for subscribing following us uh you know
getting uh following
our link to audible uh checking out the books we recommend and things like that that's really sort
of what keeps sort of the whole show and all the expenses covered and keeps kind of everything
together and if you're interested in a t-shirt uh there's a link to it on programmingthrowdown.com
on where you can get those that's right it's pretty cool there's a regular t-shirt and there's a ringer T-shirt, which are those are actually my favorite.
The ringer T-shirts are the ones where the you know, what do you call it?
The end of the sleeve like that.
Cuff.
I guess that ring.
Yeah.
The sleeve cuff is like kind of like a thicker material and a different color.
So it kind of like grabs your arm.
I don't know.
I kind of like those shirts.
But yeah, they're both available.
And I think there's even a hoodie available
if you're interested in that.
Well, I want to rant about online television.
All right.
I feel this is one of those things we can talk about.
And then five years from now,
then we'll look back and realize how crazy it was
when this was a problem,
like whether or not to buy a smartphone or other classic examples. And this is, I don't have very
good reception in my house. So I try to put up an antenna. It doesn't work. Cable's too expensive.
I don't, maybe that's just me being cheap, but I feel like for how much value I get out of it,
actually paying for the normal cable subscription,
they want to add all this extra stuff and it's too expensive.
But I have been happy.
Yeah, I agree, totally.
Okay, yeah.
And this is increasingly common from what I understand.
I think lots of people are cutting cable.
But there's a lot of services, Sling TV, the PlayStation View,
in America at least.
And now there's like a
direct TV one.
But one of the issues is there's still all
these weird things that happen.
We wanted to watch, my wife and I wanted to
watch the Golden Globes
on Sunday night. And
we just assumed it would be on the
PlayStation View, which is the one we currently use.
And we
the guide said it was going to come on i
could set it to be recorded we sat down and then it was you know just a kind of a message screen
saying the rights to this are blocked by the network and it was like no really yeah so apparently
even though in kind of every other way our subscription acts kind of like a cable subscription.
There was some rights conflict between NBC and the kind of Golden Globes themselves about online streaming permissions.
And there was basically no legal way to stream the Golden Globes online.
This is like a huge mess i mean i have this problem with the olympics where it's it's i feel
like it actually i think we talked about this last olympics we talked about how this olympics would
be totally on the internet and then that didn't happen but um i feel like every olympics and and
this is true for the world cup as well the rules are different like the technology
seems to be the same and we could have streamed even eight or twelve years ago the olympics but
but the policy is completely different like i think two olympics ago you could see everything
and then the last olympics they had kind of highlights and i think this olympics is the
same as the last one where you could get highlights but if you want to you know just watch it as if it was a tv station you had to have cable it's just
kind of I don't know I feel like this is just like a house of cards you know basically you know
they've built up all of these different policies around when you could show and how you can show
and the advertisers you know what they get and what they don't get and what your commitment to them. And all it takes is really someone just kind of
cracking this egg, like someone just getting a deal with the NBA, the NFL and a few other networks.
And the whole thing will just fall apart. I don't know that that will happen, though,
because one of the issues is they negotiate really long contracts
and so i think part of the issue is like some of these it's like for the next five or ten years
and so those contracts may or may not talk about streaming streaming will change dramatically in
five years and they don't come up at the same time and then also i think there's other issues in our consideration but but for me it's just
I'm pretty happy with my I first I had um the sling tv that was pretty good I actually like
the playstation view much better this isn't a pitch for them I don't get paid by them
I wish you had the roku at one point right I still now I'm using the amazon fire tv I think
that one's pretty good but I did did have a Roku before. Yeah.
And it works really well.
I really like it.
But then you run into these weird things like what happened.
I should have been able to watch it.
I was at the right time. It wasn't even an issue of recording it or not recording it.
But there was just no way for me to watch it.
And that was really frustrating.
You know, I wonder like, I mean, so Golden Globes. So this is this is gonna sound terrible but i don't
even know what the golden globes are i think it's for the best movies right oh no that's the oscars
no it's similar yeah similar and this isn't a pitch i actually don't care that much about the
golden globes it was more just like we'd seen some stuff about it we weren't there was nothing
else we were planning on watching and it's just something was like oh well let's sit down and
watch that and then when you couldn't it was like oh now i'm
bummed yeah right it's a forbidden fruit now right yeah but i didn't even care that much about it
like if i had just known i wouldn't be able to stream it i wouldn't have cared
i've started you know i have a bunch of youtube uh subscriptions and that's just become my sorts of entertainment, like YouTube and various kind
of funny, you know, pages on Facebook and the funny subreddit on Reddit. I just, you know,
I mean, to be fair, I didn't grow up with television. I actually never had cable TV
until I met my wife and we moved in together.
So my parents just never really had it.
And so for me, it's not that unnatural
to just be completely oblivious,
like almost anything TV related, even really movies.
I actually only recently saw the Star Wars,
like the original movies.
And so for me, it's all just youtube and internet and i feel as if
that's just going to become more and more popular and eventually like even if the contracts are are
for a long period of time just the economics will collapse but maybe that's not true i mean maybe
our people are just really set i know for like sports for example you know the nfl channel is
always going to be popular like nothing's going to know the nfl channel is always going to be
popular like nothing's gonna change that you know they're not going to make a new set of teams or
anything and a youtube only nfl yeah could you imagine i mean it's i guess it's totally possible
right there's nothing well the problem is you need to build the stadiums right i don't know and some people say the
e-gaming or e-sports but i just find those to be complicated in a way that isn't enjoyable in the
same and i'm not a big sports fan but when i sit down and try to watch like streaming league of
legends on twitch it just confuses me oh yeah i actually like um there's people who play games on Twitch and they just kind of tell jokes and just like they have raffles for prizes and stuff while they're playing.
And I find that to be like pretty good background noise.
OK, yeah, that could be interesting, like a person.
But I mean, like watching the tournaments, I guess I don't play football, but I understand watching football and I understand the game.
Maybe just because I always have. But like sitting down and watching league of legends yeah i think we've talked about
that before but yeah it just seems so fast moving and fast paced it it just seems it isn't really
conducive to sitting back and just watching yeah i think the problem with these games is you can't
like zooming out doesn't really work
like like football it works because you're zoomed out like if i was on the field i wouldn't be able
to see everything would be just a blur and they're moving so fast and they're so strong like i was
blown away i actually got an opportunity to go to levi stadium which people don't know that's the
where the san francisco 49ers play well where the san francisco 49ers lose actually again i don't follow but i i heard that they're they did really like
the worst team in the league but yeah um but yeah actually i got to go on the field which is really
cool um but i had no idea like how big it is and it's one of these things like okay you know it's 100 yards
it's very obvious but like unless you really go on the field it doesn't really make sense like
you're you know like the idea that like these players they get tackled and sometimes they fall
four yards I mean it's like an insane it's 12 feet like the person someone fell like two heights of a person in length, right?
And so my point is like, you know, those people are moving really fast and it's totally insane.
But when you zoom up really far and you're looking from a blimp or from a stadium seat,
it just looks like little ants moving really slowly.
And so you can watch football and kind of get an idea of what's going on.
But for e-gamingaming it doesn't really work like you're seeing the same screen as the person playing and it's just it's just a total blur right hmm maybe they need a special view for spectators
you know where it's zoomed out but then you wouldn't be able to really make anything out
you know or maybe just there's a out, but then you wouldn't be able to really make anything out, you know.
Or maybe just... There's a reason why football fields are very bland looking, right?
Yeah, and I guess it's been around for longer, right?
That football, there are lots of kinds of sports that aren't televised.
I assume so, I don't know.
Or failed sports that nobody even plays anymore
just because they're not conducive, not interesting, whatever.
So that's kind of a self-fulfilling thing.
Football was interesting to people and it made good TV,
which meant people were invested in tweaking it to make good TV.
So eventually we'll come across a game that's both fun to play
and very suitable for streaming.
And then it'll catch on.
Yeah.
I think, though, there's actually, like,
I think there's definitely something to making, like,
basically two views of a game.
So there's the person who's playing gets one view,
but then if you're watching, you know,
if you're a spectator watching professionals play,
the graphics will just change for you
in other words like all the details of like the trees all that stuff kind of becomes
very bland so that you could understand what's going on like almost like cheating but uh but
the actual people playing don't get that luxury you know well for the starcraft competitions i
know they like remove the fog of war so that you know you can kind of
see the ambush about to happen and stuff so that's similar to what you're saying yeah that's right
yep cool um but yeah i agree i think it's it's a total mess it's like it's everything is a surprise
like you go to watch olympics like surprise you know you need a Comcast account right and
I don't know I think I see your point that it probably won't get fixed either it's kind of
sad but on the flip side there's a lot of really awesome entertainment on YouTube and other sources
um okay so on to news um this is pretty cool. This is one of these security things I don't really know, don't have a strong background in, but it's actually okay because this link kind of, it's a presentation from a team called Team Pangu. team pangu and they're the team that has um jail done the jailbreak on the most recent iphones
and so they actually walk step by step through um how to jailbreak um you know an ios 7 and they
actually walk you through how to do it to your own phone but they walk through like specifically
in terms of like the firmware and the software and the buffers and like exactly
what is happening when you jailbreak your phone and they describe sort of the arms race uh between
them and apple so they say you know oh look ios 7 we did this and then apple countered with this
and then ios 8 we did that and uh you know it it's a PowerPoint presentation so it's meant to be delivered to like a lay audience not super technical but
it's really cool the other thing I didn't realize these people who do the
jailbreaks are all Chinese which which is pretty cool I had no idea that it was
like a team out of China.
I think it's awesome.
And they kind of did a really good job kind of explaining who they are, what they've done.
And it's part of a, they actually run a mobile security conference called Mosec.
You can go to mosec.org and check it out and actually that's in shanghai so if you're a
you know security expert and you want to check out shanghai you could get your boss to yeah to
get you to go to this conference um but yeah i thought it was super cool and interesting i always
kind of wonder how these hacks actually work and uh and so they explain in pretty good detail
so is there any i mean particular reason why it's a group out of china like and so they explain in pretty good detail so is there any i mean particular
reason why it's a group out of china like what do they explain the motivation or just they happen
to be the people most interested in it um yeah it's a good question like it's obviously a lot
of work you know i guess if you're a security researcher maybe it's paid work to do that but
that's one of the things that always interests me is, are people just that generous with their free time and that's what
they want to work on? Well, this is definitely a company where they're getting paid somehow.
Okay. My guess is, yeah, like who would pay to have a jailbreak for iPhone?
I mean, obviously users, but no single user would pay enough money to justify it.
And they're not really crowdfunding it.
Yeah, it's a great question, right?
Like, you know, where's like follow the money, right?
I don't know.
Yeah, I mean, if anybody out out there knows any of our listeners know
like just in general security firms uh that do like commercial hacking like hack the ps4
hack the iphone hack the android like sort of like who really funds those i assume some of the
hat many of the hacks are done by people trying to get money right so I'm
trying to hack your account so I can use as a botnet to make you click on my ads or click on
the ads of my competitor whatever it is that botnets do so there's that kind of hacking and
so there's security researchers who spend a lot of time researching that so they can kind of show how like in white papers how
smart they are that people will pay them to check out their stuff to make sure it's correct
so it's like a proof of work i guess because they can't talk about that makes sense can't talk about
i i went to jace jason co and found 20 flaws and fixed them because Jason co doesn't want to admit that
it had any flaws. And so you have to do it in like this way where you can kind of show your prowess.
That makes sense. I mean, the other thing is if I, if I knew a group of people who are all very
reputable in the security realm, and I was a giant company like a Google or a Microsoft or something, then
maybe I would fund it.
You know, in other words, like like they did, Microsoft has like gives all their employees,
I'm sure, Windows phones.
And so if there's an exploit in the Windows phone, then like that means someone can read
Microsoft employee emails and Microsoft so big they they could afford to you know pay one of these
teams to try to hack their phone just to prevent that right there's also bounties some companies
do if you find a flaw they'll give you you know decent sized monetary rewards yep yep um interesting Yep. Interesting. My next news article or link is to godbolt.org, G-O-D-B-O-L-T.org.
And I don't, I mean, I guess I don't, that doesn't explain what it is at all.
But what it is, is a place for you, it's a compiler explorer for C++. It may support other
stuff, but that was mostly how I came across it. and it's a way of typing in source code in one panel
of the website and on the other panel is the assembly output from gcc targeting various
processors but i think mostly intel maybe only intel and it will show you what the assembly
instructions generated by the compiler for your source code are.
And they have a little example.
Oh, that's cool.
That it starts off with.
It's not really that interesting, but you can kind of see it pushing onto the stack and kind of the rudimentary stuff.
But where it really starts getting interesting is where you put in a little more elaborate code
or you start adding compiler optimizations like turning on optimization level three.
So that's dash O three for GCC.
And then watching kind of what it does with the code
as a result of that.
So in the kind of-
Whoa, that's cool.
Yeah.
I just did it.
And it went from like 10 instructions to four.
Yeah, exactly.
So in the kind of naive non-optimized way,
it's doing a lot more so you can see what's happening. But when you start turning on optimizations in the kind of naive, non-optimized way, it's doing a lot more so you can see what's happening.
But when you start turning on optimizations in the compiler, the code gets much more compact.
You could also do like OS for optimize for size.
Oh, apparently I typed big S. It's a little less.
Yeah, they work now. I have three.
And so you can start to play with examples and see what happens
even if you don't understand the assembly just to kind of see how it interacts is interesting
but then as you start to do the uh will it do the uh um what's it called the sim d like if you have
a for loop will it it will do unrolling it will do some unrolling but i don't know if it'll do sim d
i don't you maybe it will i i would assume it does if you
know what the inch the flag for it is oh right yeah cool this is awesome um it was just really
interesting to me so typing it in playing it with myself by myself was sort of interesting
but then going online and seeing examples other people had of interesting results was really cool too.
So in some cases, kind of writing two equivalent expressions will produce vastly different
results, like the difference between a one line function and a hundred line function
because of how the optimizations in the compiler work.
It was able to kind of detect an equivalency for one example, but not for the other.
And so it just sort of
unexpected corner cases of compiler optimization are interesting and you see
a lot of those online from people who have played around with it I'm gonna try
I'm gonna try I've always wondered this I've always wondered if it mattered if
you did post fix or prefix incrementer inside of the for loop.
And I'm going to prove it to myself one way or the other right now.
Or at least for GCC version 6.3.
So for GCC version 6.3.
No optimization.
Wait, should I do optimization?
Do it without.
I feel like I should do it without starting.
Okay, I'll do without and I'll do with.
Oh, this is
such a lot with good live uh podcasting but but while jason does that he'll come back with his
results in a minute oh there he goes i can tell you right now it's 16 it's 15 instructions if i
do a plus plus if i do plus plus a it's exactly the same uh so yeah so it turns out this is something that i i think i told the audience
like a year ago that it doesn't matter well for a primitive for a primitive in the for loop where
you're not using the result that's right yeah it doesn't it doesn't matter if it's as you said like
an int like if it's if it's you know object said, like an int. Like if it's, you know, object plus plus
and you've defined the prefix operator
to be way more efficient, then yeah, all bets are off.
But yeah, this is totally cool.
I mean, this is already useful.
So for people,
Jason's going to go prove a bunch of coworkers wrong.
So for people who are interested about assembly
or want to poke around with this,
this is actually very informative.
Even without kind of knowing what all the Intel instructions are you
can start to get a feel for it just by playing around with really simple
instructions and seeing what's the same and what's different yeah that's awesome
so yeah my news is JSON logic this is one of these things that's like,
I have yet to think of a way this could be really useful,
but it's just so interesting.
I feel like there's got to be something useful in this.
The idea is, as it suggests,
it's effectively a programming language in JSON,
where you write JSON.
So JSON is this, you know,
container format. So it's like XML and these other container formats. And so, you know,
typically JSON would hold, you know, a document with a bunch of fields like name, colon, JSON, age, colon, blah, blah, blah, right?
And JSON can hold objects, it can hold arrays, it can have arrays of objects of arrays, et cetera, et cetera.
And it has a really nice representation for storing data.
The question always becomes, let's say you're trying to describe a topology of a neural network,
or you're trying to describe some kind of process, like which function should I be using.
You could have JSON and you could have a bunch of C++ code that looks at your JSON and then,
you know, invokes the right object or looks at your JSON and then adds those two arguments
together. This JSON logic actually lets you write code in JSON. You can add numbers in JSON.
You can have arbitrary equations in JSON. And then you can compile it with this or interpret it, I suppose, or interpreter.
And so a good example of this would be if you have sort of a bunch of parameters, like one parameter kind of makes your website kind of slower in this way, but faster for images.
And you have another parameter that kind of tweaks your website in some other way.
And you want to sort of play with these parameters
based on sort of what's happening.
Like, oh, if a lot of people are getting images,
I want to like boost my image stuff.
So it's almost like you want this sort of equation,
but you want to be able to hot swap it.
You want to be able to say, oh, I need my, you know,
I want this parameter plus that parameter
is equal to that parameter.
And like, I want to make that change right away.
This will let you do that. And so it looks kind of cool. As soon as I find a project that can use it, parameter is equal to that parameter and like i want to make that change right away um this will
let you do that and so it looks kind of cool as soon as i find a project that can use it i will
give it a shot and let you know how it goes my next link is to a collection of interesting bitwise
operators and tricks uh also an opportunity to talk about bitwise operators. But on this website, there are just, I don't, I didn't, they're not numbered and I didn't count them, but dozens of bitwise operations and what they do.
And it's nothing complicated, just like how to calculate two to the end.
Well, that one's a little obvious, I guess, you know, using left shift.
Checking whether a number is a power of two.
Then there's some more interesting stuff
like averaging two numbers using bitwise operators
trying to find some other good ones
set the rightmost zero bit to one
turns out it's actually pretty easy
fast inverse square root
one of those is famous
before the show we were talking about John Carmack
one of those is famous because John before the show talking about John Carmack one of those is famous
Because John Carmack used it in quake
Is it inverse square root? I?
Think I think he did these square root that might be but uh
I'll look it up. No, it's fast inverse square root. Yep. It's Carmack
and so
The it's just a list
Yeah, so there's just a list. Yeah.
So there's just a list of kind of interesting operators.
I don't know that there's a particular great reason to use these normally.
I mean, they're really interesting.
Your code is probably better off writing it all the way out
than kind of using these condensed forms.
But if you write really fast code.
This has the advantage where it's very hard to get fired if you used a lot of these
because you've made yourself absolutely critical.
I'm just kidding.
Yeah, I mean, yeah, I don't really see any reason for using these.
Again, I think the compiler would do the optimization for you.
So if you're really trying to get code size down
or really trying to get something accomplished fast, these are really cool.
They're also really awesome for just thinking about this.
And what I do want to call this out as part of it is I've talked to various people who are kind of, you know, what are things to be ready for in preparing for an interview?
And one of the things is bitwise operations come up a lot.
And depending on where you are in the stack
you maybe get away without it but for most people you know kind of understanding how computers work
is sort of a given and part of how computers work is how bitwise operators work and so being prepared
to kind of talk about binary forms of numbers and manipulating those is something that's pretty important.
So if you don't know that
and you're kind of doing anything
except for super, super high level work,
that's something worth thinking about.
And a page like this,
although you may not remember them
and you probably shouldn't use them,
will get you thinking about those
and kind of being a puzzle.
See if you can figure out
or at least looking at it, understand why it works um even if you couldn't yeah that's a
really good point i think that's also a lot of these have references like it's not just here's
a line of code it actually have a link to a document explaining exactly what it's doing
yep and so um this is something i'd recommend for any of you who are kind of trying to interview or
just interested in low-level code um to kind of brush up on bitwise operators there's there's
lots of links like this this is just one i happened to run across that i thought was
had some kind of nifty operators in there yeah this is really cool i actually sat on an interview
years ago where the the candidate was interviewing
for a firmware engineer job and uh there was all sorts of questions like this like there was
a bunch of numbers that were packed into three bits each uh you know so as is uh each number
was packed into three bits and you had to sort of unpack them and things like that
time for book of the show Each number was packed into three bits. And you had to sort of unpack them and things like that.
Time for book of the show.
Book of the show.
My book of the show is Richard Dawkins is the author.
The book is The Selfish Gene.
This is, I mean, I don't know if you'd call this controversial or not, but this is absolutely.
So Richard Dawkins is an evolutionary biologist.
And so, you know, the whole book is explaining a facet of evolution.
But the idea is, you know, there's evolution, there's survival of the fittest, and there's a lot of these terms that Charles Darwin and others have sort of coined that have become part of common core, like what most people understand.
But then there's this idea, like, there's sort of this number of things that sort of are, you know, a little counterintuitive. Like,
for example, you know, cancer can kill almost anyone. There's some viruses that are incredibly
powerful. And so why is humanity getting more and more complicated? Or why is just nature getting
more and more complicated? You know, even those simple things seem to be very efficient and very
powerful. You know, it doesn't seem to fit with the survival of the fittest, right? And so that
concept is called the arrow of complexity. The idea that just complexity in the universe keeps
increasing, we don't really know why. There's another idea, which is if you believe in survival of the fittest kind of on an individual level, then a lot of these systems like ecological systems become unstable if you were to model them in this way.
In other words, if all the lions are trying to kill and eat as many zebra as possible, then what happens is all the lions eat all the zebra and then everyone
starves you know and so uh um you know people had kind of wondered oh maybe there's enough
zebras that are faster than the lions that they live to an old age and stuff like that but even
then it's like a very unstable equilibrium and it didn't
seem very likely um richard dawkins tackles a lot of these issues in the selfish gene which is
i think super interesting um uh you know i mean just not to do too much of a spoiler
but basically the idea is that the genetic code is the thing being selfish, not the individual. And so in
other words, you know, a lion will not kill 10 zebras if it can only eat one. It will kill the
one zebra and it will eat it. And it'll take us so much time to eat it that the other nine zebra
get away, even if they're all slower. And so the idea is like richard dawkins makes this this
conjecture that that you know the genetic code is selfish what that means is even if the lion can
kill 10 zebras it just won't um because the zebras and the lions are sharing much of the same
genetic code and that code is trying to be as diverse as possible so if for whatever
reason lions can't survive anymore the genes themselves get to live on in the zebras or the
fish right or whatever so the book covers a ton of things i mean this is just one of them and he's
also written several other books but i just think these things are fascinating.
I was very fortunate to have been able to ask Richard Dawkins a question.
He was a keynote speaker at a conference and he also took questions.
And our team kind of submitted a question, which he answered.
You know, we were kind of asking about this era of complexity and uh um you know we asked like how this was actually before i think he actually ended up
writing about it later but this was you know back like 2004 um he actually explained kind of what he
thought um about that era of complexity and he thought that it was um trying to get new food
that basically you know effectively like trees are trying to get new food.
That basically, you know, effectively like trees are trying to find new ways to keep the food away from us or make it harder to reach
and animals are trying to find new ways to get that food
and that sort of arms race is sort of what's making things more and more complex.
But yeah, I think it's a super interesting read.
Highly recommend it my book of the show is Abaddon's Gate
by James S.A. Corey
which is a pen name for actually two authors
but this is the third book in the Expanse series
and I can't say much about it since it's the third book
obviously I read books one and two.
It's a nine to the third.
And I'm, you know, so I guess the test for a series like that is whether you're going to read the next book.
And so I think I'll probably read book four.
So I guess that's a recommendation for book three.
Why would they do a pen name?
Do you know?
So I think just because it's a little easier to sell rather than having two authors names on you know so people i don't that's a good question they probably have
answered it um there's several interviews with the two authors i'm sorry i'm not saying their
names right now i don't remember what they were um but they kind of write as this person they can
kind of give this person their own character i guess and and then write that way and the series is pretty good
and one of the things is i i didn't actually kind of realize that the tv version on the sci-fi
channel sifi channel i don't know how you say that that oh yeah they changed it sifi or something
yeah and so on that channel i watched the first couple episodes of the Expanse TV series. And although it's not kind of accurate to page by page in the book, they have very much the same feel and very much the same themes. And I found it, although it's a little, it's pretty dark. It's overall the series itself is kind of dark um and so the the tv show was pretty dark but i found myself enjoying it and
i saw a brief interview with the two authors who consult heavily the authors i can tell you the
names are daniel abraham and ty frank okay thank you the internet it's so useful um and so they
were interviewing them about the expanse tv show and one of the
things they were saying is that they don't they're writers of the book and they consult and kind of
give ideas but ultimately there are people who understand writing for tv choosing what themes
to pull forward and what parts of the story to modify to make it make sense for tv so they're
not what they call those like screenwriters, I guess. Those people, and they consult with the two authors,
but they're trying to have a relationship
so that it doesn't have to be true to the book
at the expense of bad TV,
but not great TV and leave just,
it's just inspired by the book.
So it strikes a good middle ground.
Yeah, it's similar to The Walking Dead.
You know, like The Walking Dead, you know, at first I read all the comics.
And then when the show came out, I was like, hey, Linz, to my wife, I was like, hey, you should check out this show.
And I kind of was pretty sure she wasn't going to like it because the book is sort of very kind of tactical and it talks a lot about
you know surviving in the zombie apocalypse and and it's also kind of gruesome and there's just
not a lot of like touchy-feely or like emotion type stuff in in the comic um and and uh when we
watched it we we both realized that like they actually kind of made it into more of a drama to fit sort of the TV medium.
And as a result, we both now really like it.
Yeah, so The Expanse is good.
If you aren't really a book reader, but you do watch TV, I'd recommend checking out the TV series.
And if you've read the book and you haven't checked out the TV series, do that as well, because you'll kind of know what's you don't know what's about to happen, but you kind of know what's going to happen, if that makes sense.
So eventually the things you know are going to happen are going to happen, but they may happen sort of differently than you expect.
Yep.
So it's still worth watching is what I'm saying.
Cool. And what is that's on? Oh, it's on SIFI. So I guess you'd get that through like Hulu,
Netflix, or that other thing that we don't pay attention to.
Well, they're streaming TV as well. If you have TV that streams SIFI. Yeah,
there's lots of ways to get it. I'm not going to go through them all.
Gotcha. Depending on your will. Yeah. Anyways. And I actually listened to that on Audible because I have a long commute and that's how I do most of my reading. I just call it reading. Maybe that's unethical, immoral.
I think it's reading. No, I think you're of sci-fi. And then they were kind of like looked at me and I'm like, okay, well, I don't read it.
I listened to it.
And they were like, what?
And I was like in the car because I commute
and then I just listened to it.
And they were saying how they couldn't do it.
But for me, it's really good
because it allows me to kind of do something I enjoy,
which is reading these books.
But I don't have a lot of time to sit down
and actually you know do
page turning yeah exactly do you like have you ever um you know started like i mean have you
ever got so lost in that world that you just show up at work and you're just like what happened yes
like i feel like that's that would happen to me almost every day it does happen to me sometimes
and it's really scary.
And I don't know whether I actually was paying attention on the road and then my brain just didn't bother to record it.
A slew of just carnage behind you.
Yeah.
But anyways, so this is also Audible is a sponsor of this show.
And so if you've never tried Audible before.
Not anymore.
Oh, dear.
I'm just kidding.
Anyways, if you're interested,
they have a thing where they'll give you the first book free
as like a part of a trial.
And then after you get that book,
you're welcome to cancel the subscription.
And what they do,
the typical thing is you get one book a month,
one credit a month, which is good.
I've never found a book that was more than a credit,
but I guess it could happen.
And so you can go to audibletrial.com slash programmingthrowdown.
I really like Audible.
I still pay for my own subscription, and I really enjoy the books I get on there.
And kind of making my commute that much easier, well, it's still pretty crappy.
But at least it's a little less crappy.
Yeah.
Actually, maybe next month's news, someone did this awesome visualization of traffic in the Bay Area.
And I'll make that news next month if I remember.
So I'm going to create a new slogan for Audible, making Patrick's commute a little less crappy.
There you go.
I'll send that to them. We're also on Patreon.
So you should go to patreon.com slash programmingthrowdown
and
that's how those
that's how Josh P
and Sam R got their free t-shirts
they were lucky, Patreon subscribers
but that really
kind of helps us out, it goes straight to the show
we have an account for it
it's not like going into our pockets or anything like that.
All of it gets redistributed back to help the show in some form or another.
So thanks for that.
And it's time for Tool of the Show.
So my mission, every year I set a mission.
I don't really call it a resolution because like I feel like resolution implies that there's a problem that you want to resolve.
This is more just like a goal.
And if I meet it, it's great.
If not, my life doesn't really change that much.
It's always kind of something small.
Like one year, I was look people in the eyes when I talk to them.
Another year was just I think it was like
something about being more polite. There was another, I don't know, it's, it's, it's, I've
been doing this for a long time. Sometimes they're kind of technical. This year it's about organization.
So I found when I was kind of reflecting back on the past few months that when I was kind of
more organized at work, just, I got a lot more organized at work, just I got a lot more
done.
The people around me got a lot more done.
And I could actually just see this almost perfect correlation as I was kind of walking
through the past few months, this perfect correlation between when I was organized and
our sort of velocity and my velocity.
Now, part of that is there's like a chicken and an egg there.
Like part of it was,
I was disorganized because it was a disorganized time
in the project.
And so, you know,
I don't think that it's solely because of that, right?
But it's still something I wanna work on.
And it's not only getting more organized,
but it's also being more efficient with the organizing.
Like I want to be
able to, you know, take notes, write to-dos, set deadlines for myself, get notified when it's close
to those deadlines, check the box when I'm done with them. And I want to do all of this really
quickly so I don't have to waste a lot of time. And so my tool of the show is this thing called Emacs Org Mode, org for organization.
So for people who aren't Emacs users, Emacs has major modes.
So the idea is if you're editing a C++ file, you're in C++ mode.
If you're editing an HTML file, you're in web mode.
And the mode, you know, there's like a massive amount of logic behind each mode, right?
So the syntax highlighting is totally different, things like that. you know there's like a massive amount of logic behind each mode right so the
syntax highlighting is totally different things like that org mode is just a
completely different environment inside Emacs where you have like a calendar you
have like to-do lists and you have all these different ways to stay organized
it's incredibly complicated I actually what I downloaded it and all that that was very
straightforward and I was like oh let me check out
the manual I was expecting you know maybe an 8
page manual there's like a 300
page manual on org mode
which makes
me think like maybe
the only people left using emacs
are people who
like don't do that much
coding anymore I don't know like the median age of emacs are people who like like don't do that much coding anymore i don't know like the median age of
emacs users maybe now is like 40 or something but uh um but you know it looks awesome i'm just
getting into it um and uh that's my tool of the show so far i've i can say that you know you can
very quickly get up to speed and do some simple things with org mode very nice my tool is cpp lint.py which i is a c++ linter by i think this one's actually made
by google so it's for the google style guide but i also simultaneously would recommend uh there's an llvm or i guess a clang
linter as well that will do more than just the google style guide it actually can do other style
guides anyway so linters are my tool of the show and the reason why is because i find that if you
have a style guide for whatever code you're writing in whatever
language that is super useful and i'm not a big proponent of nitpicking to death people but keeping
everything consistent and the easiest way i know to do that is to have a linter that just every
time someone makes a change just kind of already will tell them when they're not matching the
expected style and I'm not much one I'm not one for getting into debating
whether use Google has a C++ style guide I think there's a Linux C style guide
there's which isn't C++ but then there's other versions and other people have
style and someone you know kind of the other day was arguing for some new code to use this other kind of style that they preferred.
And one of the things I asked them was, you know, is there a linter or have you kind of a lint rules for some linter for that?
You're kind of your way you're saying that it should be done.
And they were kind of like, well, no. And I was like, to me, that's a huge negative where I don't want to adopt your way, not because
I particularly think it's bad, but if you don't have a linter for it, to me, that's really
frustrating because it doesn't keep everyone honest and it doesn't allow, it allows people
to kind of get away when they don't really want to do it or they don't particularly, you know,
they don't agree with it. It's just messy messy and so i think just having everybody agree and then having a linter
is a kind of way to not have conflict yeah and just to explain i mean we've covered this in
other shows but but a linter is just something where it will look at your source code and tell
you when you've violated the style guide like it'll actually scan your whole source code and say, hey, at line 46, you have an extra space.
You're on line 48, you just new line
doesn't need to be there.
And then there's also a formatter.
Like there's like Clang has a linter
and also Clang format.
Oh, I guess the Clang linter is part of Clang format.
Right, yeah.
And so it will just, it can also just fix almost all the lint
errors for you um cool and i'm not i'm also i'm sorry go ahead oh i was gonna say i'm the same
way like i don't enforce the rules um in code reviews and things like that but i do think that you need a system that annoys people
who have lint errors in other words like like there's a system every place i've worked has
had a system in place where you know if you put if you don't put a space somewhere it gives you
a little warning when you try and submit your code and then as long as that system exists i
i leave the rest up to the you know leave, leave it to the honor system, like let people fix their own issues.
But if that system doesn't exist, then it's just like the Wild West.
Like you have to enforce it, you know, personally, like socially.
And nobody wants to do that.
Yes.
This is sort of similar to what I was going to say, which is I don't make the linter a hard fail.
Some people do. But in my opinion, there are certain times when you should be allowed to kind of break it
if you think there's a really good reason for it.
And I'm not going to care.
But as you said, I've been on teams before that had nothing.
And then somebody just forgets or whatever in a code review.
And then you start having a bunch of code that doesn't comply.
And then it's a's essential to change it.
And I think just having an agreed-upon style guide
keeps the code easy to read.
Yep, totally.
So linters are my tool of the show.
That's awesome.
Yeah, so, all right, PHP and hack.
So first, shout out to Cyrus.
We won't spoil your last name,
but Cyrus emailed us and said,
hey guys, you haven't done PHP.
Why don't you talk about PHP and WordPress?
And so because you emailed us,
this is exactly what we're going to do.
PHP is a huge language in terms of user base.
Tons of people use it.
It's amazing we haven't covered it.
I actually had to do a double check to make sure we haven't covered it in the past.
And, you know, to kind of motivate PHP, you know, everyone's kind of done templating, right?
Like, for example, if you do printf you do printf my name
is percent s and then comma and then your name right you can even do all sorts of crazy logic
after the comma it could be whatever c code you want but then at the end it's some string
and then that percent s you know the the what you put in after that comma gets substituted into the percent s.
And you could be really complicated.
You could have percent 2d, and it puts a number there with two decimal places and everything, right?
If you use Python, they have the format function, does the same thing.
It even has the same syntax.
You know, almost every language has some type of substitution, some way of doing substitution like that.
And that's called templating. So PHP, at least when it started, is effectively a way to
do templating with HTML. So you could write a bunch of HTML and then, a little
different than printf, in the case of printf you do all these percent S's and
then all of your arguments come afterwards, in the case of printf, you do all these percent S's, and then all of your arguments come afterwards.
On the case of PHP, you write all this HTML,
and then in the HTML itself, you do like a PHP bracket,
and you have some PHP code.
But at the end of the day, it's still kind of templating,
like printf kind of stuff, right?
Now, why is this important?
So put yourself back to the 1990s
right like um browsers were just crazy you know like the iphone wasn't out yet smartphones weren't
really out yet really at all and uh and the web browsers there's just not really any compatibility.
Like, you would be lucky if they all rendered the HTML even remotely the same way.
JavaScript, forget it.
Like, if you had a bunch of complicated JavaScript or even simple JavaScript, you know, there's no way you could guarantee that even 90% of browsers would render it correctly.
And so what that means is you have to do everything on the server side.
So someone, you know, clicks a checkbox, you have to actually go to the server, you know, re-render the entire HTML, like what the whole universe looks like now that that checkbox has been checked, and send that over to the client.
The client's going to refresh the whole browser.
And I mean, if you've ever seen old websites,
like maybe like your hospital doctor website still works this way or something.
But like that's just, that's how the whole internet worked.
And everything was done on the server.
And so, you know, that made these server templating libraries
like php really popular php like a lot of people do like to rag on it i think because it's like
any beginner programming language a lot of people kind of did it as one of their first programming
languages and when you do that i think it opens it up to a lot of criticism or hate as a inferior
language and also just quirkiness. But, you know, it does have a lot of libraries. PHP has been
around for a while. There's a lot of support for it. There's a lot of different tools to get done
what you need to get done and do the things you're trying to do in it. And there's also a ton of
tutorials because it's such a popular beginner's, or has been a popular beginners language, then you get a lot of people
writing about it and answering a lot of common problems that beginners tend to have. And a lot
of code examples, a lot of legacy code that you can look at to kind of understand how to do stuff.
Yep, one thing PHP does really well, I mean mean not the language itself but the the maintainers do
really well is uh the documentation like if you were to like type php printf and you actually go
to the php site and look at the printf documentation um they have it's almost like a wiki
type style like there's the official documentation and then
there's all this user contributed content and that they keep that from version to version
so um so it's pretty cool like if you look up even just printf uh php printf you'll see all
these things like people say oh here's some hack for this here's some way to do that if you want
to print an object here's some code and it's Here's some way to do that. If you want to print an object, here's some code.
And it's just become, it's almost like a living manual of PHP, which I thought was kind of clever.
And it also helps with the beginner aspect.
Just to kind of breeze through some of the details of PHP, it's a weekly type language.
So you just say, you know, I equals three.
And then later on on if you want
to say i equals jim you can do that it's fine um it's all of the arrays so php only has uh object
um which is kind of like a class and uh well it's it's basically php only has arrays but
they're associative arrays.
And so even objects and classes are kind of represented using these associative arrays.
But it kind of begs the question, like, what if I just want an array of 10 numbers and I want to index into it?
You can actually do that.
You can create what we would traditionally call in C or C++ an array.
And what PHP does is under the hood, it's still an associative array,
but PHP will let you iterate over it.
And when you ask for item one, it still works.
But under the hood, everything is effectively a map in PHP.
It's either a primitive number, like a double or a string,
a primitive variable, like a double or a string, a primitive variable like a double
or a string, or it's a map.
In PHP 3 they added classes, which is kind of syntactic sugar, but obviously very useful.
So you have classes with properties and all of that.
The biggest advance came from Facebook.
So Facebook wrote a language called Hack.
Hack is completely backwards compatible with PHP.
So in other words, you can take WordPress, which is a very know, library or tool.
You can actually take that and run it in Hack.
So anything that's built in PHP will work with Hack.
But you can also add, there's some more keywords
and some more things you can do in Hack
that you can't do in PHP, which is pretty cool too.
One of the other things is it can be compiled so
instead of being interpreted as traditionally you can compile it and then run it on the hhvm
virtual machine and that allows the code to be faster because as we were talking about earlier
in the one of the news sites was the godbolt and compiler optimizations and how it does that.
And so by doing even just a little bit of compilation, you get the ability to kind of optimize things, shift stuff around.
And that's awesome because it allows the programmer to still write something that's very readable without sacrificing speed.
Yep. Yeah, totally.
So just to kind of dive into some of the things Hack adds,
one is it adds types, which is very similar to TypeScript. So you know you can take just a
regular JavaScript file and rename it.ts instead of js and it's now TypeScript and it works fine.
But once you've done that and you're using the TypeScript compiler, now you can actually go and add like int a equals three,
instead of just a equals three, right?
Or like this function takes an int x and a float y, right?
So hack is the same way.
And you can slowly over time add types to your code base.
And hack will understand if it doesn't see a type,
that that type could be anything. But if it does see a type, it can call out a compiler error.
Hack adds generics, which are super useful, right? I mean, if you want a set data structure,
but you want it to be a set of anything,
you can do that with Hack.
And it works similar to C++.
You do set, angle bracket, string, angle bracket,
and now you have a set of strings.
It's got collections.
So you don't even have to write the set.
It's already done for you.
It has set, has hash set, hash map.
A lot of these common collections that you'd see in Java and other languages. It has lambda functions which
now we have in Java 8. Those are just if you remember they're just functions as first class
citizens. So I could say f equals some function and then pass f to another function or another object and that object can
hold on to f and call it whenever it wants it also has async support which is super important right
like if you um you can actually call a function uh and then uh pass it a callback and it'll execute
that callback kind of whenever it returns. So just
this asynchronous kind of mode of programming, which we talked a lot about in the Node.js episode.
So you're asking yourself, I'm starting a new project. Should I use PHP? I don't think it's
the language du jour, or I don't, that sounds too fancy pants. It's not the kind of language of the moment.
It's not the hot language, but I mean, my understanding, it's still pretty commonly
used even for kind of new stuff, because there's a lot of people have been doing it for a long
time.
And so they're really good at it.
They know how to do it.
It gets the job done.
And often that's very important.
But there's also a lot of legacy stuff written in PHP. And so if you kind of join
a project or team that has that, you could very well find yourself maintaining PHP code. But I
wouldn't say it's probably the number one choice most people have for the problems on the web. I
think there's a lot of other kind of new JavaScript solutions to that or Node.js on the server
to kind of accomplish some of the same ideas.
And so I wouldn't say it's commonly chosen today,
but there are probably some areas where it is.
And for people who have been doing it,
I mean, it obviously will be a kind of something at hand
for them to choose.
And then, you know, that legacy code just doesn't go away.
There's a lot of time invested in that.
And so I would say there's still probably a lot of people's days
are spent still writing in PHP.
Yep.
So just to, like, put it in perspective,
so they actually just released this, the T-I-O-B-E.
I don't know if I'm supposed to spell that out or not, T-O-B-E. I don't know if I'm supposed to spell that out or not, Tiob. But the Tiob index,
sort of, they use GitHub and a bunch of other metrics to try to predict or to demonstrate
sort of which language is the most popular. And PHP dropped from 6th to 10th between January 2016 and January 2017.
And I think a lot of that is just because, you know, a combination of Python, Node.js, and some of these other languages are just kind of, you know, picking up more steam.
But, I mean, the fact that it's 10th is still very powerful.
I mean, as Patrick said, there's tons of people using it.
But also, I think measures like that, I'm not familiar with that exact one and the methodology.
But I think measures like that where you're kind of looking on GitHub and stuff, that's probably a lot of new public development.
But, you know, a lot of lines of code get written in legacy systems, not just maintenance, but new features being added.
And so, you know, I think those metrics probably skew to new starts.
Like there's a weighting to the languages that new projects are started in.
Yeah, yeah, it's a really good point.
Yeah, I mean, PHP is just insanely popular.
So where is PHP used?
Wow, so many apps, especially open source apps, are built in PHP.
You know, WordPress is probably the most common.
PHP BB, which is a forum.
The reason why it's BB, it's from the the phrase bulletin board right um did you ever go on
bulletin boards no oh yeah me neither i have friends who have like like really awesome stories
about things they did on bulletin boards like rpgs that they played using message passing but
i think i should invent a past history where I did.
So you could regale us with your bulletin board stories. When I was a kid.
Back in my day, we passed punch cards back and forth.
PHP My Admin.
If you have a MySQL instance, this is the web interface to that that's extremely popular.
I've used all of these.
Gallery, Drupal, MediaWiki, like Wikipedia itself is all written in PHP and is open source.
Joomla, which is a super popular content management system.
So just a ton of really powerful apps have been written in PHP.
And they're so extensible.
People have written so many.
It's almost like Emacs or VI, right?
People have written so many extensions to these apps that it's just very hard to make them obsolete.
And I'm sure they'll be around for the next 10 years.
So yeah, so that's PHP in a nutshell.
I mean, as Patrick said, I also wouldn't really recommend
using it for a new project.
I think Node.js, Python, these other ones are kind of,
even like Ruby to a lesser extent,
are kind of, even like Ruby to a lesser extent, are kind of making PHP
obsolete. But it's still important language to learn. If you're looking for a job, there's a
good chance, you know, there'll be some PHP involved. And yeah, and let us know what you
think. If you've built anything amazing in PHPp that you have on github or somewhere else let us know and we'll we'll uh we'll talk about on that show so to wrap it up we'll repeat the
kind of tools and books we mentioned in the middle of the show so that this is easily you can scrub
to this part easily uh and that was the the selfish gene abedin Gate. Those were the two books. And then Jason recommended Emacs Org Mode as a tool of the show.
And I recommended Linters.
I don't know that that's really actually helpful to say I recommended Linters.
No, I think, you know, people should use Linters.
Well, no, I think Linters is actually a great tool because it's one of these things that it takes a little bit of work and a lot of people don't want to put in myself included don't really want to put in the time to uh to integrate it into
your workflow but then we're always so glad we did and so hopefully we can pass that yeah of
knowledge linters are definitely useful i meant repeating linters at the end for people to look up
oh all right sorry never mind Never mind. That's awesome.
But thanks, everyone,
for all our listeners
and sticking with us.
Jason and I were just regaling each other
with stories of yore
from the podcast of old.
Wow, that sounded awesome.
And we've been doing this a while,
but we enjoy it
and we always enjoy hearing
from everyone out there
in listener land.
Yeah, one thing,
if someone bought a t-shirt,
you know, so I bought a t-shirt, uh, uh, you know, just to make sure that the, it wasn't going to be,
you know, that it was going to be good quality and all of that. Um, uh, and I, I feel like it's,
it's good. I mean, I like it. Uh, I wear it to work sometimes, which is super cheesy what no i know i know self-promotion i know it's kind of cheesy but uh uh but no if if
you bought a shirt i know a few people have bought a shirt uh actually many people have bought a
shirt um and if you have let me know send us an email uh if you think the logo is too big too
small if you think t-shirt's amazing
let us know what you think um you know the t-shirt is still a rather new part of the show
and so uh we're looking for your feedback yeah i mean i guess we don't need to know we already
know if you buy it because we know but oh yeah don't just tell us you bought it yeah but send
us like a picture or hashtag us or tweet us or whatever the cool kids do these days
about um you know a picture of you wearing it somewhere cool that would be awesome oh that's
a great idea yeah if you uh have yourself wearing this shirt anywhere uh but if it's on like the
grand canyon or something that'd be even more epic wait why the grand canyon because that's like
nothing to do with our show i feel like wearing it to a computer history museum
or wearing it in front of your awesome you know vi themed editor or you know whatever something
yeah yeah you're totally right yeah it needs to be like something you like
would next to a wax statue of richard stallman or something um If you have that picture or any others wearing your
t-shirt, post it
and
do at programming throwdown
or in the case of Twitter,
at neural nets for life.
We will
retweet you and reshare you
and embarrass you
if you want us to.
No, we won't embarrass you. If you embarrass yourself,. No, we won't embarrass you.
If you embarrass yourself, we'll just do the honor
of promoting that.
That's true. We'll amplify your
embarrassment.
That'd be really cool, actually. It's a great idea.
Either way, let us know what you think of the shirts.
Alright, until next time.
See you later.
The intro music is Axo by Binar Pilot. See you later.