Programming Throwdown - 167: Desktop User Interfaces
Episode Date: October 23, 2023Intro topic: Jogging MetricsNews/Links:Unholy LLMhttps://huggingface.co/Undi95/Unholy-v1-12L-13B The reverse red herring  https://www.blameless.com/blog/the-reverse-red-herringThe "ens–t...ification" of TikTokhttps://www.wired.com/story/tiktok-platforms-cory-doctorow/ Response letter to Godot is not the new Unityhttps://sampruden.github.io/posts/godot-is-not-the-new-unity/https://gist.github.com/reduz/cb05fe96079e46785f08a79ec3b0ef21Book of the ShowPatrick:Math Games with Bad Drawings by Ben Orlinhttps://amzn.to/48qlg9AJason: The Invisible Hook: The Hidden Economics of Pirateshttps://amzn.to/3LChBffPatreon Plug https://www.patreon.com/programmingthrowdown?ty=hTool of the ShowPatrick: Factorio (Desktop Game)Jason:AI Hero (iOS and Android)Topic: Desktop user interfacesWhat is a user interface?Web and Mobile UI toolkitsDesktop optionsQtCross platform, custom UI elementsQt creator, code generatorWxWidgetsCross platform, uses native UI elements WxFormDesigner, code generationCan look different on different operating systemsElectronLocal nodejs webserverHtml/JavaScript technologyRequires interprocess communication to use other languages  Jupyter notebooksMathematica-like notebook Not for distribution StreamlitPython to web compilerGame EnginesUnity, Godot, UnrealTips for building desktop UIUI is slow (startup time, interaction time)Separate the UI from the engine & business logic ★ Support this podcast on Patreon ★
Transcript
Discussion (0)
programming throwdown episode 167 desktop user interfaces take it away patrick
as a true nerd figured out a way to make
even the things I never thought I would do nerdy. So I guess I should, this sounds like a brag,
like true nerd. I don't know what that means. I'm not gatekeeping. Everyone could be a nerd.
If you're listening to the show, you're a nerd. Yeah, that's right. You're all honorary nerds,
even if you just started. I did some amount of physical fitness stuff, you know, in high school, be on some sports
teams. And then it sort of just languished when I became an adult. I know a lot of people like
play pickup basketball and stuff, which is great. What sports did you play? I played basketball,
but I was never very good at it, to be honest. Yeah, same here. I played basketball. And despite
being very tall, I was also absolutely terrible at basketball like it's the was that the hundred
thousand hour ten thousand hour thing i just wasn't willing to put in the like i would go
to practices but i never like played on the weekends or it wasn't it wasn't a passion
yeah i mean my thing was i was and i realize this now watching my kids play sports like i
just don't want to touch anybody else physically touch anybody else.
And so I would see like,
how could I play,
you know,
this sport,
whether it's basketball or soccer or whatever,
in a way where like,
I don't have to even inadvertently like touch anybody ever.
And,
uh,
and of course you just can't,
can't really play most sports that way.
I ended up finding my niche in volleyball,
but every other sport pretty much can't work that way. ended up finding my niche in volleyball but every other okay all right pretty
much can't work that way so i uh this all started i guess for a variety of reasons a family of
member member of mine uh started jogging running um a while ago like years and years ago now i was
like man okay that's good um so i was visiting with them recently and then it was like kind of
feeling bad they were getting up to go for their morning run and i was like enjoy i'm gonna just sit here on my phone um and
then then i was uh you don't have you know you get these smart watches i have you have an apple
watch or whatever um but i think other ones do the same thing and so it gives you this estimate
of your body's like aerobic capacity so-called vo2 max i don't know that much about it you
actually get it measured you go to a you know gym and they give you like a face mask that you have to wear and it measures
like oxygen and carbon dioxide i don't know something like that while running on a treadmill
and it has to do with your body's like ability to process and you know handle high amounts of
physical activity or whatever so so they estimate it on a variety of other factors that are correlated
with it and they give you the score and it says your cardio fitness is below average. Now, I'm not
like the healthiest person. I'm not going to lie. But like in general, you know, I like to consider
myself healthy-ish. I mean, it hurts when you see that, you know, it hurts. So I have a scale that
tells me my body fat is not what it should be and a watch
that tells me my cardio fitness so all this piled up to say okay i'm gonna do something about this
i'm i'm getting up in age uh you know it's not gonna get any better right so i was like i'm
gonna start running but of course it's not you can't just run like oh i have tennis shoes i'm
gonna no no no no no like that was not how i approached it so i gotta like figure out i'm
gonna do a program oh there's an app oh there's an app is gonna tell me exactly what i have to run each day uh and like go up by
a set amount you know each week so this amount of run followed by walk run walk and then each
week it's gonna get better and then you'll be able to run a 5k which is sort of like the shortest
distance that has common races you can run like a mile or 100 yard dash or whatever but like as
an adult i don't know how you go find a place where you run 100 yard dash or 100 meter dash. But 5k's are pretty common.
You can just Google it. There's probably one in your city every week, certain times of the year,
probably. So I was going to like, okay, I'm gonna run a 5k. Then I realized, oh, my watch can give
me all these running metrics. And then not only like per run, can you find stuff like how many
times your feet are moving per minute?
And there's an optimal range that you should be in for that.
And cues to make sure your like body is biomechanically efficient and studies to back that up.
But then aggregating them across days.
What is your training load like?
Are you getting enough rest?
What is the math behind it?
Oh, there's this set of people has a study.
This other set of people has a study.
They have different ways of calculating.
You can bounce back and forth.
And then you get into the traditional tech stuff.
Everyone tries to lock your data up.
So then you have all these ways of like exporting it to like more open source platforms or cross
platform stuff or just more free platforms.
And there's like, oh, are you in the Apple ecosystem or the Garmin ecosystem or the Polar
ecosystem or the Kuros ecosystem?
And there's like all this lock-in.
And it's just endlessly fascinating that people have.
So I was talking to this family member of mine and sort of saying, oh, you know, I'm doing this.
So I run on my Apple Watch, but I instantly grab all the data and push it up to this other platform.
It's called Runalyze.
Runalyze just runs this like free agnostic input source you know running all
these algorithms on whatever it comes from um maybe they'll eventually charge they're not
really open source but it's sort of at least free for now and so i just grab all my data and put up
there and he's like yeah but i've been using and he's using garmin or whatever i've been using
garmin for like 11 years all my data is there and i'm just like locked in because of all this
history of run so um you know so i so I've been running still pretty early.
Yeah, what's the effect?
Like, did you, like, is the data helping you along?
So it's keeping me engaged.
I will say like, it's like the base level metrics
that are improving.
So like resting heart rate is trending down.
That's good.
This VO2 max estimated is ticking up.
I'm still below average.
But I've been doing it sort of eight weeks.
And, you know, it's just, I guess.
So the thing that is encouraging, well, discouraging, but encouraging is some of them will give you
like how ready you are to run a marathon.
And then it tells me 3%.
And so I'm like, okay, well, clearly there's headroom here.
And so I find it very encouraging to be able to look at a description of all this stuff.
People say that you got to write it down.
Write down your metrics tracking because you're more likely to stick with it.
Writing it down sounds very tedious.
So instead, you just shove it all up in the cloud and you get a bunch of graphs that show you just how slow you actually are uh and then you you know so this uh once you sort of get into it
you start seeing times of like professional elite racers like people who do it as a career
in the olympics or whatever and you see their time compared to your time and the interesting
thing is like if you were to play basketball and say a professional basketball player was going to play basketball, you're not really playing the same game.
The strategies, dunking, the kinds of three-pointers they do, it's clear you're not doing the same thing.
Running is not like that.
When Ilyad Chogy runs a marathon at world record pace and you run a marathon at abysmal pace, you roughly look like
you're doing the same thing. Like the body mechanics look similar. Like if you don't have
a context, the speed could even look the same. It's not. But you know, it's sort of, you're just,
they're doing the same thing as you just like faster. And so there's almost this like motivation.
You don't have to learn a new skill. You just have to do more of it. Like, oh, I just have to get a
little faster, a little faster. And of course there's some power law distribution
right like eventually moving down a minute is incredibly hard versus for me moving down a minute
and pace is trivial but you know it doesn't you get diminishing returns there but there's this
the pros and me do the same thing we just go and run and so it's sort of been interesting and
motivating and the metrics
seeing you know this direct one-to-one comparison i run a mile and x minutes they run a mile and y
minutes versus you can't compare yourself to you know a football player or soccer player or
basketball player like they do what and you do why in a number to number comparison i don't know of
a number to do that yeah that makes that makes sense. Um, yeah,
because there's basically an arms race, you know, like there's a whole bunch of strategies that
might work at the high school level, but then by college, everyone's learned those strategies,
you know, in basketball or something. And so you have to, you have to do something different.
Um, but, uh, yeah, that's awesome. I mean, the most I've ever done in that is, uh, I do have a, uh, Fitbit that keeps track
of my heart rate and I try to keep my heart rate in a certain zone.
So if it's not in that zone, then I'll slow down or even walk and I'll just try and keep
it at that number.
Um, but yeah, I mean, that's just scratching the surface.
Yeah.
It's interesting if you really dive in and then we'll leave this alone.
But even the various, why does that zone training work?
What are the ways of picking the range?
How do you tell?
And then there's, you know, the sort of how you feel way of tracking it.
There's like a mathematical formula to track it.
And then there's the actual like getting at, I go run on a treadmill and prick my finger
and measure like how much of various hormones and lactate are in my blood. And it
tells you like, you know, your various thresholds. So it's kind of an interesting range of, you know,
philosophies for ultimately, but just amounts to like going and running, which you've been doing
for however old you are, minus, you know, three or four years, I guess, we've all been running for
years and years and years. But to kind of try to hone it is uh it's a kind of another endeavor yeah i had a buddy who
would run on the treadmill and he was extremely athletic and he'd run a treadmill at high
velocity and um and then also play final fantasy 7 and try to like optimize it at the same time
like while he's running and i remember
one time thinking yeah this is probably what like a human like this is probably what the matrix looks
like you know like your your brain power and your physical power are just being kind of like
maximally exerted uh on this station all right well with that we'll go to uh news of the show
news of the show so uh yeah both of my news are foul and you know obviously folks know we don't
swear on the show we've never sworn on the show uh at least i don't think we've literally never
sworn on the show but you know sometimes do, we bleep it out.
But I just happened to, just coincidentally, I have two somewhat foul news articles.
I'll do my first one.
Now, I'll give a bit of backstory to this. So I'm always trying to create different experiences, games and toys and stuff like that.
And so I wanted to make, and it sounds kind of silly but but hear
me out i wanted to make a uh engineering manager simulator or maybe just more generic like a manager
simulator and so you would mediate conflicts with people and you'd have to kind of place bets on
different areas and and just the parts that are kind of strategically fun about being a manager i wanted to just distill
that down and make manager simulator and so i wanted chat gbt to be you know kind of a big
part of this where you know there would be discussions among different chat gbt agents
who have been given different different goals and you know you would you would you know see all this information and all this intra-office diplomacy.
And ChatGPT is extremely strict on negativity.
I even tried something like write a mean letter to this person about some project that they
messed up.
And ChatGPT is like, I'm sorry, I can't write mean things
or I will not disparage anyone.
And it was just like, I literally couldn't finagle,
even like a polite but direct negative message.
And I don't know, maybe it's like a situation that's in flux.
But when I went to ChatGP a few weeks ago, or a week ago, like I literally couldn't get it to do it.
As three laws of robotics here.
That's right.
Human.
And so when when I'm and this is speaks a little bit to my psyche, when someone tells me or some system tells me I can't do something i immediately think there's a business
opportunity here like like if you can't do something then uh maybe there's some value there
and the only way you're going to extract it is by somehow subverting the system and and so that
might take an idea from being like uh the pet rock idea where literally anyone could do it to an idea where like maybe only you could do it.
And so there's a chance to be like a real innovator.
So I started poking around and I found something called the unholy LLM on Hugging Face.
And so this is a Lama 2 model.
So Lama 2 is a large language model that comes from facebook
so it started out as that but then it's been fine-tuned it's been trained on i actually don't
even know what it's been trained on but whatever it is it's it's completely uncensored i don't
think it's been trained on like purposely the worst parts of the internet or anything um and the reason i i
don't think that is because you know i started off you know just saying like uh you know tell me a
joke about about this this company or tell me a joke about elon musk or you know tell me 10 books
i should read and i got all like very normal answers um but if you tell it to write a nasty letter it will write
a nasty letter and it will drop f-bombs it will do everything and it is actually hilarious um
i've been showing off to uh um we had some family friends in town uh and i was showing them um you
know and then we were all getting a really big kick out of it. Um, and I guess like kind of two takeaways, one, um, you know, yeah, it is actually really hard
to say kind of anything negative on any of these or, you know, generative AI things.
Uh, but two, um, you can almost trivially download these. I was running it on my laptop cpu uh the laptop has it's a macbook
but it's too old and so i couldn't use the metal accelerator uh whatever that is so so it's
literally running on on the cpu and it was still able to generate like several tokens per second
and so you ask a question and you get an answer in 10 15 seconds um um and this is with
a 13 billion parameter model so um overall i was just incredibly impressed with how far the open
source has gotten um there's a hugging face has a leaderboard which is how i found this unholy
model i basically i was going down the leaderboard it's like you know chat gbt metas
llama i know both of those are extremely strict um you know and then there was a few others i think
you have to pay for or i just didn't know much about and then this one came up i was like all
right let's do it um so so yeah it was a really fun experience uh you know again you know you
shouldn't spend a whole bunch of time doing rude things. But now if I want to have
this sort of intra-office
conflict among these AI agents,
I could do it
without any
worry of the system
just becoming unplayable.
Yeah, I guess
the one level
more morality problem is you could end up with an AI or LLM that goes from just sort of hilariously in context dropping F-bombs to something that's actually traumatic sounding or describing a really bad scene or something that...
Uncensored, it's not like a binary thing like you're either censored
or uncensored i guess it can be but there's like it's like a gradient and you could go really
really far down like somehow it actually learned something about you and then it's saying stuff
about you personally and like it sort of jumps the boundary breaks the third wall whatever and like
you run into people just really really turned off or upset or even like, you know, someone damaged or, you know, really messed up by this thing.
So I hear you.
But I also could see why, you know, businesses don't want...
That's always what happens.
You know, these get unleashed and then someone convinces it to say something really bad or, you know, something that's socially considered a very bad faux pas to talk about. And, uh, you know, write an article, Oh, this is, this is the worst thing ever. But
yeah, I mean, there was one that I skipped over, which was, I can't remember the name.
I was trying to look it up just now, but it said it was literally trained on this forum called
4chan. And I was like, okay, I know enough. I know what that word means that
I'm going to skip this one. And so, yeah, I think you're right. I think that there's a spectrum here.
You know, I literally wanted to write a professional letter where one employee
felt like another one should get fired in my game. And I couldn't do that. And then there's,
you know, as said there's there's
many many layers to that onion and yeah i would also recommend people just you know for your own
insanity just yeah don't don't don't go down that rabbit hole but but you know if you want something
if you if you even for my you know if folks remember i released this generativefiction.com i released this uh this text adventure with uh with chat gpt
where you know as you meet different npcs you ask them questions and chat gpt generates answers
i was i was just looking at some of the stats that i was collecting on that and a significant
percentage of people's questions were blocked and you know almost none of those
questions were foul like somebody asked uh one of these in-game characters um you know like like uh
have you ever been on a cruise ship that sank so the premise of the story is you're on a cruise ship
and uh you know it's it's there's a there's like a murder on the cruise ship and it's a murder
mystery um and so someone asked you have you ever been on a cruise ship that sank to one of the NPCs?
And ChatGBT blocked that question.
So it is very strict.
But yeah, also don't go down that rabbit hole too far.
Don't look into the black mirror or whatever.
Look into the abyss.
Yeah, I think I said break the third wall, but I was thinking break the fourth wall.
I don't know.
I don't understand the indexing scheme.
Zero versus one indexing, we'll call it.
You don't know what LLM thought about that metaphor.
No, no, no, no, I don't.
I really don't.
All right, so my next article is from a blog
from a person who was dealing with an incident.
This is on the Blameless blog.
I've never read it before. We'll have a link in the show notes.
But this concept was pretty interesting. The story itself was, I feel like, full of a few mistakes in dealing with this incident. But this reverse red herring was kind of interesting.
So most folks know what a red herring is. And if you're debugging something or a problem goes and
someone just gets really fixated on this
thing that just feels very, very obvious, but it turns out to be a red herring, it's just
not worth considering. You should just move on and you're really wasting your time.
And so the reverse red herring is opposite. It's something that actually probably should
be standing out, but you kind of skip it or ignore it, or for some reason you discount it
and you don't spend enough time looking at it. You proceed through your processing of information,
your incidents, trying to do an analysis of what's going on. And then someone has an idea,
wait a minute, what about that thing we stopped considering? And all of a sudden,
it just bubbles right back up to the top again. And so I thought that was a sort of interesting phenomenon to name something reverse red herring uh sort of an interesting
i guess almost a double negative it just means interesting but it's been discounted for some
reason uh yeah the one i could think of that came up recently was um we had some code where there
had accidentally been a new line inserted, but the code still ran.
And so the second part of that line was, if you just look at it in isolation, it basically does nothing.
It's kind of like saying zero or something.
So you could put a zero semicolon in C++, it just won't do anything.
I think so. But,
um,
um,
but yeah,
this was one of those,
but actually ended up being a really serious issue because that,
that,
that second part of that first line was meant to do something really
important.
Yeah.
Yeah.
And it would be in this case,
just to finish off the story,
I guess they had rolled out a new binary to their an endpoint and the sort of
circumstances were that the effect was it looked like everybody else was uh had gotten a sort of
like pad configuration was ddossing their service um and in actuality it was that their new deployment
had a bug in it that was giving a bad response, which was... And then the clients were said,
if you get a bad response,
basically turn around and ask again
because something as bad as happening.
So they were DDoSing themselves.
And originally, they were like,
oh, no, it can't be this new deployment.
This is not how it would manifest itself.
And actually, it was.
And it feels like a bad deployment.
You just rolled something out
and then everything bad happens. That feels like it should probably bad deployment like you just rolled something out and then everything bad
happens that feels like it should probably be the first thing you consider but they tossed it out as
a red herring because they thought they had done it due diligence but uh they hadn't and it could
it could have been coincidental in this case it wasn't very cool um my second article is, and again, it has a cuss word in it, so I'm going to rephrase this.
It's the hoopification of TikTok.
But the important thing is actually the subtitle, which says, How Exactly Platforms Die.
This is an amazing article.
It really, you know, it's one of these things that I've always kind of felt, but I haven't really seen anyone put it in writing.
And this person puts it in writing extremely eloquently.
Basically, the thesis here is, and they use Amazon, I think these Instagram and these TikTok as examples.
I'm not actually on Instagram or TikTok.
Are you on Instagram, Patrick?
I think I have an account. I think a lot of these, I have an account and that's about the extent of
my being on. Okay. Um, so the, what they talk about here, which I've definitely seen is, is,
you know, in the beginning, you're trying to spin up this platform. So you have this cold start
problem, you know, like how do you get good content on TikTok?
How do you get the first hundred people on TikTok? And so what they do is they set up a bunch of
really friendly deals and they really focus on content creation. They give great tools.
They do rev share with content creators. They get famous content creators on and they give them money up front, et cetera, et cetera.
And so it becomes a great place for content creators.
So they go there.
A lot of these platforms, I mean, Amazon is notable for this.
You know, if you're exclusive on Amazon, you know, they would they would actually subsidize your your content so you could actually sell you know a beach ball on amazon for 14
dollars because for every beach ball you sell amazon will literally give you an extra dollar
so they were running this is in the 90s amazon was running everything at a huge loss um and all
of it was in service of creators so a bunch of creators flock to the platform sign all sorts of exclusivity deals um and then
the platform kind of gets the creators and they say look like we kind of have these people now
so now you know we could just kind of exploit them and let's focus on um um right? And so Amazon now says, okay, you know, forget about creators,
we have all the creators, let's focus on basically, you know, getting as many, you know,
people to buy as many things as possible, or in the case of TikTok, get as many people to watch
as many videos as possible, etc, etc. And so they go down that rabbit hole and at some point they get kind of a lion's share
of the people and that becomes saturated there's actually a third element which is the advertising
so amazon if you look at it now they'll actually a lot of the search results are sponsored which
is really weird if you think about it it's like someone's paying for the opportunity to sell you a beach ball, right? It's kind of weird. And whether you buy
it or not, that person's out that money. This is really the opposite of what it was when it started
where sort of Amazon paying the beach ball company and subsidizing their products. Now,
the beach ball company has to subsidize Amazon to like, you know, to make their beach ball show up at the
top. And the thing about, you know, advertising, especially like in the case of Amazon, where
there's not an advertiser, it's just Amazon, is you're you end up basically squeezing both of
those people. And, and you can just squeeze them as much as you, you know, as much as you're willing
to tolerate them sort of leaving your platform.
And so invariably, because of short-term thinking,
platforms squeeze too hard, people leave,
and then the platform becomes desolate.
I mean, it hasn't happened in the case of Amazon,
but with Instagram and TikTok,
all the metrics are trending downward.
I thought it was amazing
the way that this person really laid it out i think
there's a ton of truth to it is it written by cory doctorow that's what it looks like
uh yeah is that a famous person i have no idea who that is yes it's okay who is that like what
are they known for oh they i mean they've written a lot of things they've written i think fiction
books as well but they do a lot of writing
and introspection of the tech industry.
Oh, interesting.
Okay.
Yeah, I'm not very good at...
I probably should be better
at when I read a really good article
noting the author,
but I haven't really...
It's always been kind of a blind spot.
He was the one who ran Boing Boing
for a long time,
if you ever ended up on that site.
Yeah.
Yeah, I try not to attack social media
because I don't participate.
So I feel like it's an easy target for me to cast stones.
But I think this cycle is very hard, right?
You want to build something up.
How do you maintain it?
It goes by a lot of names and a lot of cycles,
but this is a very difficult trade-off.
Like long-term metrics is what you want, right?
How do you keep users engaged for one, two, three, four years?
But by definition, those are very hard to actually know
what a user is going to do two years from now
when you're 90 days into a project.
And so you end up optimizing for results uh but whose results is uh i think that was an accurate arc of uh choosing who you're going to optimize for yeah totally uh i guess in a similar vein
um there's been and not gonna you know sort to fully go into it, but there's been some controversy with Unity, which we've talked about on the show before, a game engine, and changing some of their pricing practices.
And there's another game engine, Godot.
And Godot is open source.
So, of course, it doesn't have any costs associated with it, at least any monetary costs you have to pay out initially.
And so a lot of people have been talking about,
oh, now's the time you really should move to Godot.
Godot's gotten a lot better.
You see a little bit the same thing with Blender.
Blender's really come into its own
despite being actually a very old project.
But you see a lot of new stuff
getting poured into Blender recently,
or at least I have.
It's become part of the zeitgeist
and just really a mature product.
And so people were talking about, and then there was couple famous you know kind of like live streams of independent game
developers porting their games from you know unity to godot and this you know start everyone got
really excited um and so someone wrote an article that was sort of like you know basically that this
is not true that there are some functions in inot around ray tracing. They're just really, really bad.
And you should not move to Godot.
Godot is not ready.
It's not mature.
It's not whatever.
And the, I guess, benevolent dictator for life, BDFL, this is like a commenter.
Anyways, he runs the Sam Pruden, I guess is, I don't know that much about the Godot project.
So if I'm messing this up, I apologize.
But I guess he's the benevolent dictator for life of Godot.
So he's sort of like the person in charge.
And so he wrote a response to this person's article about, you know, Godot is not a replacement
for unity.
And actually, as weird as this sounds, the reason I bring it up here is for two reasons.
It has almost nothing to do with any of the stuff I've talked about so far.
And so the two reasons I think that
this article is worth a link, you should check it out, is one, the way the diplomacy that Sam
handles this response is incredible. So someone has basically penned an article, pointed out some
flaws in a project he's worked on and put enormous amounts of time
in. And he gives them every benefit of the doubt over and over again. Now, I don't know the person
who wrote the first article. I don't know anything about Godot. But some analysis says, or even just
a simple reading and looking at Sam's responses, it's very likely that they cherry picked some
worst case numbers, and then some other worst case
stuff and then got like, you know, basically something that made Godot look very bad performance
wise. But the diplomacy is Sam responding in a public manner, but being just very restrained
and saying, look, maybe they just, you know, happen to pick an idiomatic case here where like,
it's not actually the normal case most of our stuff
doesn't fall to this problem but they are right this one thing for legacy reasons hasn't been
refactored and does suffer performance problems so they give credit where credit is due that yes
this is bad yes we should fix this give benefit of the doubt just so i guess like refreshing to
read someone handle something without like saying it's my job to just flame out
and scream at everyone
and just tell them these people are stupid
and our project is better
and instead just handle it very gracefully.
That's sort of thing one.
It's going to be really dense.
Thing two, it actually goes into a pretty awesome description
of how if you want to write a core game engine,
as an example,
but you want hooks for a scripting language,
so Godot has a scripting language,
but it also has hooks for other languages,
C++ or Python or whatever, and you want these hooks,
you have to think a lot about how other bindings
are going to call into your core library
and the languages it's developed in.
And so there's a discussion about this.
I called it ABI, Application Binary Interface, which is how actual, you know, parameters get pushed into a
set of contiguous memory to be passed from one program, one part of the program to another,
right? So in Python, you got to kind of set some specific bytes in a certain way so that you can
pass it into Godot and then Godot knows what to do. And this is normally accomplished by some sort of API, right? Which is like the sort of human readable description
of the function. Like this is a function that takes in an integer as a parameter. But of course,
like once you sort of compile it, you don't actually need that anymore. As long as if your
assembly language puts an integer in the right spot, jumps to some other correct location of the program,
and knows how to go grab that data that you put there, you don't need to know what the parameter
names are. They're not used intrinsically by the program. And so there's a description that goes
through that, which I just thought was actually really well done, pointing out something that you
don't normally think about, which is they have some primitive types. And then what they tried to do, except in some edge cases, is make sure that all of their functions adhere to the same
few types. So if you're writing a wrapper, you don't have to make arbitrary data structures.
Instead, your data structures are composed of all of these primitive types. And then you,
by composition, get a full featured API and sort of facilitate this wrapper thing. And then
internally, they make sure that they sort of use those primitives as much as they can. So you don't
have to do this unpacking, repacking, conversion, and the code just is sort of compiled away,
right? It just becomes a no op that the data just flows. And it doesn't have to be parsed or,
you know, are mangled in some way or unmangled.
And so I just thought, actually, that was a very interesting read from a technical aspect
of what someone building, in this case, it's a game engine, but any application where you're
expecting people to interact with it from other languages.
Just a really fascinating sort of read there.
I would encourage people, it's not super long, despite I probably spent more time talking
about it,
but definitely check it out.
Very interesting.
Yeah, so I think, you know,
there's the Sam Pruden article
and then there's a response from the Godot lead dev,
which is linked to from that article.
And I think a lot of the binding stuff,
well, no, I think it's just one click away.
So you want to read what Sam wrote
and then check out the response.
And in the response, there's code samples, and they dive in really deep on this.
You're right.
I'm sorry.
Yeah, so I messed that up.
So Sam is the person who wrote the original article that we'll have both linked.
Yeah.
And then, yeah, but I have the names mixed up.
Protecting the innocent, Jason.
It was on purpose. Well, actually, this gentleman who wrote the response to Sam,
he also had a really insightful tweet that I happened to stumble upon
where he said, you know, regardless of what you think of Godot,
the fact that Godot exists is the reason,
or at least one of the chief reasons,
why Unity walked back that pricing plan.
So it's sort of like the idea is that open source is ultimately a moat
that protects you from the potential of a monopoly or commercial monopoly.
Very cool.
Yeah, kind of a little bit of foreshadowing here but uh we'll talk about
Godot a little bit later on in the show and in our tool of the show but for now we have oh go ahead
oh sorry so just make it clear it's yeah so it should have been one one is the benevolent
dictator for life of Godot so one is the one I was I was talking about responding to Sam so
I apologize there for the name mix-ups hopefully uh didn't confuse anyone yeah i told him so now it's time for book of the show what's your book of the show patrick
my book of the show you have to listen carefully is math games with bad drawings by ben orlin so
uh last duo episode i had math with bad drawings by Orlin. And this is math games.
And so this is a pretty interesting read.
It takes a lot of games.
You probably know about tic-tac-toe,
the boxes game where you draw dots everywhere
and you draw one line at a time and you take turns.
It just kind of goes in depth about like,
what kind of mathematical areas do these touch on?
What are some variations of these games?
Like, are the games themselves
interesting or not interesting at the start? And then how do you sort of like propel them forward?
So in the example of, is it called dots and boxes? I don't remember. Anyways, we have the dots.
Yeah, that's right.
You draw lines and you make a square and then you get to go a bonus turn. And so he goes through
some of the strategies, which most people probably stumble upon. But then he gives some other games that sound really similar. And some are sort of a dual, like they're equivalent. And so it's just the same
game in a different disguise. But then some are actually sort of fundamentally different. So as
an example, you may not think it's a major change, but it actually becomes a fundamentally different
problem, which is instead of drawing between two dots up, down, left, right,
what happens if you can draw an arbitrary length line up, down, or left, right? How does the game
change? And so it feels like this very subtle difference, but in practice, if you can draw,
start, and then draw to the right, you know, sort of arbitrary length, the entire dynamics of the
game shift around. Wow, really cool. i bought the math with bad drawings um after
patrick mentioned it on that episode and it's been very entertaining um you know it has has great it
does have great well uh entertaining bad drawings and yeah i've been really entertained i think it's
uh it's been it's been good.
Definitely not an audio book.
Oh, yeah, it wouldn't be a good audio book.
Well, yeah, I think I'll grab this one too, probably.
Anything with games that I'm kind of a sucker,
I have to open the wallet.
Amazon's had me figured out.
They subsidize this?
Yeah, that's right.
All right, my book is The Invisible Hook, The Hidden Economics of Pirates.
So I always wondered this, like, you know, if you're a pirate, you know, let's say you take over and this is like literally not a software pirate or whatever, but literally
a buccaneer pirate, you know, in the 1600s or whatever, you know, if you're a pirate and you take over a ship, like what really happens
after that? I mean, could you just sell that ship at a port? I mean, wouldn't they know that you
stole the ship? I mean, it just, I mean, like imagine in the real world, I guess the equivalent
would be like a car thief or something, but, but those those people they have like chop shops that chop the car up i
thought you were gonna say nft oh yeah oh my gosh there's there's still people in my social network
really pushing nft hard and i'm like dude it's over come on i mean just throw in the towel um
but yeah like you know what happens with this giant ship?
I mean, you steal this ship.
It has like tons and tons of spices in it.
You know, like, how do you really get away with that?
How is this profitable?
How does that actually work?
It's really, really interesting.
You know, the way that you can fence an entire ship fence means to, you know, sell something,
you know, kind uh that doesn't belong
to you um the way you can fence an entire ship or the way that pirates ultimately got spices that
they stole and sold them to like you know individual towns and stuff really really interesting
stuff one thing i i didn't know about was the extent of these uh they call them letters of marquee so basically
the difference between a buccaneer and a pirate is a buccaneer has the authority of at least one
country so you know like you might go to the english governor or king or i don't know who but
it goes some english authority and he will give you a
letter of marquee which basically says you know for example if england's at war with france
or spain or what have you you can sink as many or capture as many french boats as you want
and the english will in fact they'll reward you for it and so a lot of pirates were actually buccaneers
so they would fly like a british flag they would take spanish ships hostage and then they could go
to any british or english uh town and sell the ship and sell the stuff right because they have
that authority and so that's how it worked for a lot of people but then you know some of the most notorious pirates they basically had their own you know kind of uh totally unstructured nation
so there would be pirate islands where you could you know sell a boat and they would figure out
what to do with it of course they'd like charge you um you know premium for that but they would
they would figure out a way to make money off that um the whole thing was really interesting i mean i know it's kind of a weird rabbit hole to go down but it i heard
i read a lot of things that really surprised me awesome all right that actually sounds really
interesting now that you got me now i'm now i'm curious because i feel like it's one of those
everyone knows what a pirate is but then if you think like you said one level deeper wait a minute
you know hang on what
do you actually do with an entire boat that needs a crew like how do you put people on it and sail
it to where you want it to go and you need to damage it to to take it over but not damage it
so much that like you can't sell it yeah exactly exactly um and uh yeah the whole thing is really is really interesting um another thing that really
shocked me was just like how much like physical gold was was was uh transported from south america
to europe like it's an unbelievable amount just it had this thing called the treasure fleet it was literally like a huge fleet of giant
ships and these were pretty much like no pirate would at least i haven't read of any pirate that
would ever challenge this it's just like an enormous juggernaut of a fleet of of like uh
you know privateers and all these like boats but they would just transport an unbelievable amount of gold um across the
atlantic ocean um so yeah the whole thing is really interesting and yeah it's definitely worth
the read oh very good this is time for tool of the show all right what's your tool of the show
so mine is a game sticking with uh my classic but this is one i i we don't spend a ton of time on it
i think everyone knows what uh this game is or or i we don't spend a ton of time on it i think everyone
knows what uh this game is or or if they haven't they're about to lose hours and hours and hours
of the life and i apologize in advance um but this game is factorio so factorio i think really
almost kicked off a genre i think there was like games that preceded it of course but now there's
a lot of follow-on satisfactory dyson sphere program i'm sure there's a dozen others um but
factorio the reason why i recently got into it i wasn't sure i would like it the graphics were follow on satisfactory Dyson sphere program. I'm sure there's a dozen others. But Factorio,
the reason why I recently got into it,
I wasn't sure I would like it.
The graphics were kind of meh.
So I played a demo and then I realized I spent more time playing the demo
than I probably like have played most video games that I own.
And so I realized that I probably should just buy it and play it.
But the reason why I started getting into it is they recently did a bunch of
work to support controllers. I was able to play it on my Steam deck i started getting into it is they uh recently did a bunch of work
to support controllers i was able to play it on my steam deck so they have on steam i think they
have it on switch now um was is sort of why they added controller support um but this is the reason
why i sort of picked it i always knew you need mouse and keyboard and just time with in front
of mouse and keyboard after a long day of doing it for work didn't really appeal to me but we
talked on the show before i got a steam deck now now. So I've been playing Factorio.
I have no idea, to be clear.
I know the rabbit hole.
I know how people...
I don't know what happens in later levels,
I'm sure, or later stages.
I'm sure your Steam Deck will bog down.
But for just picking up and playing,
I've played a lot already,
and I've never really sort of said,
oh man, this is running, this is unbearable.
This is too slow.
Yeah, you know, the thing that Factorio and its descendants have done really well is put you in control of the pace of the game.
So if you look at something like civilization, you know, you move your units and then you click and turn and then you have to kind of wait for everybody else and so you know maybe in the beginning of the game when there's a lot or maybe the end of the
game in civilization where there's a lot of things going on there's units all over the map then
the pace like really slows down um and at the beginning of the game it just feels like
the game is taking forever right um you know factorio has this beautiful dynamic where
you know as soon as you get the the factories like the beginning factory you're kind of then
limited by your own creativity you know you can you can end up with you know even with just the
initial factory you can end up with a massive sprawling base or you could have just three factories and you build everything by hand and and so the pace
like you your your aptitude is kind of controlling the pace of the game and it never feels like the
game kind of gets away from you or is boring yeah we didn't actually say what the game is so i guess
for the for the few people who don't know this this is, I guess, a factory simulator. So the rough idea is there are resources out in the world of various types. And then there's ways of, you know, building things to extract resources and then a chain to sort of finished goods. iron ore into iron plates and iron plates into steel beams or into gears or sprockets.
And so you sort of have these chains of dependency and you want to build better and better factories
that are faster and conveyor belts. But to do that, you need sort of more high tier products,
which have levels below them. So eight stages of inputs to get to the item you need to construct
your, you know, whatever you're building at the end. And so you build up these longer, longer
chains, like Jason said, I guess a lot of analogy for code, you can, you have to debug it when
something's going into the wrong, wrong input, you got to like, you can have spaghetti code,
you can have a very modularized and everyone sort of takes their own, own bent to it. And
it sounds horrible.
I know it really does.
But it's just one of those things to like Jason said,
kind of zone out and you just monkey around.
And there's no real exact winning and losing.
You're just trying to get better and better.
Yep.
Yeah, it's really satisfying.
Cool.
All right. My tool of the show is AI Hero, which is a game that I made. I've been working
on this game for years and years, just a tiny bit of time here and there. And basically,
I set a goal for myself many years ago that I wanted to teach AI, but I wanted to teach in a
way that had no words. And I felt like that was a succinct way of kind of explaining
you know you know that i wanted to to teach to demonstrate ai but without having to tell people
like you know turn to page 569 of this conference proceedings right so um it's pretty ambitious
goal and it took me a really long time to kind of find the fun so to speak so um the premise of the
of the game and you can get it on ios and android it's totally free there's no ads there's no in-app
purchases or none of that stuff um yeah the premise of it is you have to set these control
points in a way that creates certain curves or certain circles or other shapes.
And those shapes have to kind of separate clusters of labels. So you're on this graph grid,
and there's sort of a cluster of green points and a cluster of red points. And you have to,
by using your finger and moving these control points, you know, find that curve that separates those points. And then as it gets harder, you end up with four, five, six, seven different categories.
And so you have to have these sort of intersecting shapes that can allow you to separate all these
different classes. So it turns out, you know, with maybe two shapes, you can actually separate,
you know, four or five, six different classes if you like bend one shape around another and stuff.
So, you know, it did kind of accomplish that thing I set out to do.
You know, originally the plan was for it to be an educational game.
What I found is it really appealed to people of all ages.
You know, my kids played it, thought it was pretty fun, but a lot of adults were finding it fun. And so I just ended up releasing it as kind of an AI themed puzzle game for all ages. But it's written in Godot, so kind of a throwback to 10-15 minutes ago. I don't have to worry about Unity coming after me for my free game or anything like that.
But I did find Godot to be very pleasant to work with.
It is a 2D game, so it's not a huge technical achievement.
And so I wouldn't say I stressed Godot in any big way. But I found the feedback loop to be really nice.
One of the things that Unity and Godot do which i think is really interesting is they let you basically play you know like a module of the game like for
example um in godot they're called scenes i don't know what they're called in unity but you know
like you could have a scene which is uh mario right and you could have another scene which is you know level
three or something and you can actually just play the mario scene just by itself as a game and you
could just be mario and just jump around in an empty world um and so that way you can test like
certain pieces of the game without having to test the whole thing. I found that really useful as I was developing.
But yeah, check it out. It's totally free.
Hopefully you'll find it pretty fun.
Awesome.
Alright, I think it's time to talk about
desktop user interfaces.
Yeah, so Patrick, what is a user interface?
It is an interface a user uses.
All right. That's the end of the show. Everyone, Patreon, subscribe.
No, I mean, I think this is something everyone bumps into or starts out into, which is,
you know, have some cool functions, some application. Jason was just talking about his
game. But ultimately, we need a way of displaying that
to the the user so of course uh you know currently a lot of that could be web you could build a
website with you know javascript or another another language that that gives you that ability
um it could be a command line interface it could be hey i'm prompting the user and in sort of a
text adventure game could be a user interface there but i still want to have options displaying inventory and stuff but the one i think we're going to talk
about today is when you're on a you know desktop so windows or mac os or linux or dot dot dot dot
i'm not going to try to list them all because someone's going to write us in that we left
theirs off and you want to you want to have a way for a user to interact with a running program uh and you need to write code to do that yeah
that's right and so um you know i don't know if we've ever done an episode on command line
interfaces maybe that needs to be the next episode but um you know there's there's a lot uh around
you know making a good command line interface and you know terminal uh you can there's a whole
bunch of really interesting programs there. But by and
large, when most people think of a user interface for the desktop, they're thinking about something
that opens some kind of window and has a point and click interface and all of that. It's worth
calling out that this is a lot more complicated than web and mobile. I mean, mobile, the UI is really front and center to the whole experience.
A lot of mobile apps are just veneer around business logic that runs somewhere else.
Like imagine your banking app, for example.
When you go to pay somebody in your banking app or pay a bill,
your phone doesn't literally pay the bill.
Your phone just sends a request to some server
that does all of that.
Similarly, on the website,
your browser isn't literally calling some API
to move money around.
All of those are going to the server.
So using, let's say, Chase Bank, for example.
So your browser goes to the chase server and the
chase server does server to server communication so all the business logic lives there um
conversely the desktop is sort of the opposite where if you want to do business logic if you
need a good debugger if um you want to build a analysis tool and things like that.
It's great, but for graphical user interfaces,
the desktop is challenging.
And often it could be hard to know even where to get started there.
I feel like...
Yeah, go ahead.
A few years ago, I think the story was much more around
per operating system building it know, building it.
So you would, you know, if you're building a Windows, you would go into Visual Studio and you would, you know, kind of do the very Windows specific way.
If you're doing Linux, maybe you would do something, something else.
And everybody sort of had their own sort of way of developing this, you know, so-called native, native looking apps.
And I think as you were kind of mentioning, I think that's where the phones have an expected feel.
Like how things work on Android is actually different
than how things are expected to work on iOS.
So if you have an iOS app,
people expect certain functionalities and behaviors
around like swipes or around dragging up or down
or like certain things that's like very pre-canned.
Whereas I feel there was more differences historically
between like how something would work in linux versus windows versus mac os how buttons would
look and how interactions would be set but there's also more diversity just within a platform so like
you mentioned in windows or whatever like or or whatever there there could be you know a ui popping
up that has i guess what you would call like a normal desktop app but to be clear you could also
pop open a game and have a ui and a window as well and have a HUD and, you know,
have like buttons that are graphical and they look very different. And so there's all these,
you know, different ones. But I think today, a number of like platforms have come to also allow
people to develop across multiple, you know, sort of targeted desktop OS environments and sort of
really capture this. They really sort of come into os environments and sort of really capture this
they really sort of come into their own around hey this is like a good way of doing this
development strategy yeah that makes a ton of sense another thing too is you know in the case
of mobile um in the case of web the web is extremely uniform people have done an amazing
job of of setting up things
so that you can have relatively common experience.
It doesn't matter whether you're on the phone or the desktop.
And there's all sorts of ways to do these reactive websites
where if the column width is shorter, then it doesn't do a sidebar.
And all of that is really easy to do.
I mean, even programmingthrowdown.com,
if you look at it at a phone
or if you shrink the browser window on your desktop
to be really thin,
you know, things will start collapsing
and things that were just always visible
become little hamburger menus.
And I didn't code any of that myself.
I mean, all of that is just built into the web tools
that I was using.
On mobile, you know, there's really only two big players, right?
There's iOS and Android.
And because mobile is so important, most companies or even most developers will create two copies of their code.
So you'll have an iOS app app you'll have an android app and they'll you know you can use flutter and some of these things but most people i would say the vast majority are right
are building two separate apps and you never have to worry then about like oh like what if i need to
do something that is you know not supported by flutter or i need to use this ios plugin and
interop and all of that um conversely on desktop you know i don't know what the market
share numbers are like but i always feel like i need to support at least mac and windows
um but um if not if not also linux but um i'm usually in much more of a hurry when i'm building
a desktop app right because usually it's an app for developers.
It's an internal tool or it's something like that.
And so I don't want to have three different versions.
Like I don't want to spend that time.
And so you're kind of caught with the situation where you have to be really quick, but you're
using a, you know, you're in a place that isn't very well-traveled,
so it's a difficult position to be in.
So I have a few different options here.
I'll kind of list them in no particular order.
I've actually really enjoyed Qt.
Have you ever used Qt, Patrick, as a developer?
Only a little bit. I think Qt does one of those, like predating a lot of the sort of modern,
more portable coding practices. So in C++, I feel like, you know, Qt was a big influence there.
So we have like Qt and Boost, but then the standard library coming along and getting a
lot better. But they had to introduce a lot of the more high-level modules
really early to make UI programming work.
And so I feel like, yeah, I did interact with it and sort of,
we'll talk about later, but like asynchronous or, you know,
threading and these kinds of things, which had very poor
sort of out-of-the-box support.
And then Qt sort of stepped up and did that.
So not only has it got the UI stuff,
but it has a lot of C++ modules that, you know, came along later in other forms,
but they were pretty early to the game
in helping like level up the sophistication
of C++ developers.
Oh, very cool.
Yeah, I've actually only used PyQt
or I think now it's called Qt for Python,
which is like a, you know, a wrapper around the C++ code.
And so I could definitely see the C++ influence
when I look at Qt for Python,
just the way that objects are kind of passed into other objects.
It doesn't feel really that Pythonic.
But the things that really stood out,
so Qt, the idea with qt is that you know it's not a
native looking app so if you were to build an app in qt on your windows machine and you were to
build an app using the visual studio um you know a designer they're gonna look totally different
so qt has their own kind of buttons, their own text boxes that they
have designed themselves. And so, you know, at some point, like way down in the Qt code, like
they're rendering like raw pixels. So they've like, you know, they have total control over the
canvas and the window, you know, you're obviously abstracted from all of that. But you know, it has
this nice, like side effect where, you know, if you have a qt app on mac or on
windows or on linux you know it should look more or less the same i couldn't say it would be exactly
pixel for pixel but but you know it's the it's it's going to be very consistent um conversely
if you were to use wx widgets which which is another option, that's a very interesting
tool. The way it works is you write your WX widgets code and then it kind of on the fly,
I guess it's like a transpiler, although it's not really compiling, but like on the fly,
it's mapping your function calls
to the low-level thing.
So for example, you tell WXWidgets, draw a text box.
And if it has some check, it says, oh, am I on Windows?
Oh, I am.
OK, call this native Windows function to draw a text box.
Oh, I'm on Linux.
OK, call this native Linux function.
And so you get a native UI. At the time, this was like WX widgets is very, very dated, or it's not data is very modern, kept up to date, but it's started a long time ago. You know, and at the time, you know, people were much more in tune with what a desktop app should look like on Windows. And so WX widgets, you know, targeting, you know,
resolving down to these native desktop widgets, you know, was kind of a nice look and feel.
It has the downside that, you know, if, for example, a text box is taller in Linux than it
is in Windows, well, then it's going to look taller. And so if you run the
same app, and you expected the text box to be, you know, 60 pixels high, and now Linux, it's 70
pixels high now, now, like maybe part of your app, you know, fell off the bottom of the page,
and you can't get to it. And there's just a bunch of visual inconsistencies like this. So you really
have to, you know, run your app and all these different OSs all the time and make sure that it looks good in all of them. So that's kind of the trade off
there. I feel like Qt is probably a better bet now. I mean, people, Qt has taken like such a
large market share that people kind of have a spot in their brain for the qt ui you know so i don't
think you're shocking people anymore and you know you have the you don't have the other downsides
you brought up an interesting point there if you go back i don't know exactly when wx widgets i
guess we're looking up but if you go back 10 15 years ago 15 years ago people probably i mean
that's some folks listening are like uh what no i'm not going back
there i don't remember what's going on uh but when i was a newborn when you go back 15 years though
like most folks didn't know how to use a if they said i know how to use a computer they meant like
i know how to use windows and i know how to use like these apps in windows uh they probably didn't
really bump into other operating systems or if they were on,
you know, OSX at the time, I guess, like, you know, they knew or Linux, they knew one thing.
But now in our guests and a little bit in our modern lives, I think it's much more common for
people like most of the folks I know and work with, you know, they'll have a phone that runs
some operating system, Android or iOS, they probably have an operating system with apps
on their TV that's different. They have one on, you know, their desktop is something, but they
might have a gaming desktop and a laptop for work and their laptop may be a MacBook, but their
desktop is a Windows gaming machine. So I feel like people are much more likely to have encountered
and be proficient at various operating systems.
Yeah, that makes a ton of sense. And on the, you know, coming at it from the other direction,
operating systems have largely standardized on an ideal user interface. And you can read all about material UI and all these different kind of philosophies around UI. And I think a lot of that has collapsed to where, you know,
you have a pretty good expectation when you do something on your TV,
what it's going to do. Like most people know, you know,
if you press on a text box on your TV or your phone or whatever,
a keyboard is going to pop up. Right.
So these are just assumptions that you couldn't make.
Here's a random piece of trivia,rick how old is wx widgets take
a guess oh it's pretty i i i mean i know i i feel pretty good about saying it's at least
when i started working which i'm gonna say how many but i i greater than 15 so i'm gonna guess
20 it is 31 years old no way that is wild um way older i thought um so yeah qt and wx widgets they occupy the same
space more or less uh one thing that's really important that i highly recommend is um there's
something called qt creator and in wx widgets it's called wx form designer and there's probably a new one now that's that's
that's a program that i used a long time ago but these things will do code generation so you know
you kind of set up the the layout the way you want you say oh i want text box here i want a label
here you know reserve this spot for some custom widget which you don't know about but i'm telling you it's a certain size but a combo box here and then uh and then you press a button and it generates
code it can generate c++ code it can generate python code and so that python code that it
generates you can actually run that and you will get a form or you know a total desktop app it's
just none of the buttons will do anything right um and all of the
spin boxes will go to infinity there's no guardrails on them right um and so then you know
you have to go and implement all that business logic but um but yeah that those tools are
incredibly powerful like you could end up spending a lot of time just kind of aligning things you
know doing a whole bunch of visual work and if you're sitting
there looking at code saying like okay line 67 you know this object needs to be like a little
bit further down it's kind of hard sort of like a uh what is it rubbing your belly and patting
your head at the same time or whatever it was like it's kind of hard to like write code but
then be thinking solely about how this is going to look
it's much much easier to use a graphical designer um and it has this another this other nice side
effect where it kind of keeps your ui and your business logic separate because if you put business
logic in those files and you rerun the designer well guess what it just deleted all of your
business logic so it kind of forces you to like separate those two things,
which is you might look at that and say,
that's really frustrating, but you'll be better off for it.
I think the next one that we're going to talk about
is sort of, I guess it was surprising.
Like when I first heard about it,
I sort of laughed and was like,
what? No, it's not going to be a good idea.
And it still does get ridicule
from the sort of like optimization people.
Like, oh, this is such an inefficient way
of doing things.
It's so slow.
And that was when Chrome released,
one of the things they did separate
from just the browser
is they released a sort of high efficiency
C++
JavaScript execution engine so that you could run JavaScript sort of on your desktop
and use it for things outside of Chrome if you wanted. I think it's V8, I think is what it was
called. And so this combination and having an open source component to the Chromium, but also to this
V8 engine enabled this next one, which is Electron, which really sort of was the first
time I at least encountered people truly going for this hybrid thing on desktop where like
you're writing almost a web page, but it's also a desktop app.
Yeah. And so, you know, if you use Visual Studio Code or if you use Discord, the desktop app,
these are either done in Electron or they're done in a derivative.
So I think nowadays there's Neutrino.
There's a whole bunch of alternatives.
But without any loss of generality, we're going to talk about the first one, which is
Electron.
But a ton of really popular apps are actually written in Electron.
So the way Electron works, basically,
if you've ever built a website, you've probably
started by testing the website
out on your own computer.
So you spin up
a very simple web server
on your own computer, and you
go to localhost
colon 8088,
something like that, and you get to see
your website, and you can interact with it, and make changes, and reload, and all that. And you get to see your website and you can interact with it and make changes and reload
and all of that.
And then when you're happy, you deploy it to some server that other people can look
at.
And so the idea with Electron is, you know, you just, you just live in that first part,
right?
So when an Electron app starts, you know, it starts a local web server that, you know, only your local machine can get to
it's locked down. And then separately, you have a program that visits that web server. And so
in the case of, let's say, Visual Studio Code, you know, it starts up a web server, and then it has its own internal browser.
This is getting to Patrick's comment.
You're deploying a literal browser with every app.
And so it launches its own browser, which knows to talk to its own uh web server and so you get this desktop app um but you have all of the advantages
of the web frameworks so you know we talked about how you know the website knows what size it is and
people have written zillions of lines of code to make it look beautiful like in all these different
situations and you get all of that in a desktop app.
So Electron is extremely powerful.
For example, if you need something
that draws a bunch of graphs, well,
Qt has some basic graphing structure
if you want to plot some time series and things like that.
But if you start getting into complicated graphs,
if you need certain scatter plots,
if you need some kind of clustering,
you need to visualize that.
The web just has so many resources,
such a long tail of different resources that you can be confident you'll find just about anything.
And so you don't have to worry about that.
You can bring it in.
It has this other benefit where if you do want,
I mean, Discord's a good example of this.
If you want to have a website and a desktop app,
well, now you only have to write it once.
The same UI code that if you go to discord.com
is literally the same UI code you're running in the desktop
app and so that uh saves them a lot of work not being a web developer it's still it's kind of
like confusing to me like it boggles my mind that it like sort of works and it does like you said i
use i used atom for a long time i think it's now like deprecated in favor of vs code um but it's just kind of weird to me that it just works like you are like you said
you're running a like custom browser but you don't know it just feels normal it just feels like a
regular app yeah i mean you have this other issue which is um most of these like Electron, Neutrino, they're running a JavaScript web server. So even the
server is JavaScript. And so that means is if your business logic is in C++, now you actually
need a third process, you know, you need the browser, you need the web server that's hosting
the UI. And now you need your business logic in a third program and you have to do inter-process
communication to pass you know so so for example in discord right you click a button let's say
now discord might all be written in javascript but let's pretend like let's pretend like the
business logic is written in c++ just to explain so you know in discord you click a button so that's you know the browser makes a http post
to the web server saying you know patrick click the join channel button and then that thing you
know makes an inter-process communication call to the c++ code to say hey patrick you know click the
join channel game that c++ code probably makes another HTTP request
to some Discord server where it actually happens.
And so you have a lot of these hops.
Don't let that scare you, though.
I mean, that sounds scary.
It's like, oh, I have to set up this code contract,
this three-layer code contract to do anything.
But in exchange, what you get is really powerful.
And you can often...
Your API often doesn't have to be that large.
If you parameterize the things you're doing,
you might not actually need that many function calls
to get a lot done.
Like, for example, you might have 30 different channels.
If you leave any of them, it's the same function
call, right? So you don't have to implement that a bunch of times.
Off of the sort of like single app stuff, I think we had a couple of good other things that sort of
fall in the same category. As Jason kind of mentioned, I've never seen the numbers, but I would bet it's a shockingly
high percentage of applications written are written for internal use, for tests, for with
only in your, you know, just to support like use cases, or maybe they're even just throw
away.
And so I would not be surprised if actually we don't see that the
sort of long lived examples we've been giving so far, because you know about them are actually
relatively rare, even by amount of time spent, which would be weird. So of course, they're
more rare by count. But I think I would even go to say like a lot of the developer time is spent
on developing apps that no more than a handful of people or anyone outside the company has ever seen.
And so if that's the case, you have a little bit more latitude to consider things for the same purposes I've been doing and doing sort of UI and interfaces and really helping like
Jason was already showing like graphs and data. Sometimes you're just trying to provide visualization.
And so your app really doesn't need a lot of business logic. Maybe you've already processed it all down and it really just needs to do analysis or monitoring or something at the tail end. And you can avoid a lot of the interprocess communication. And so if that's true, I would say your sort of field of view can open up pretty wide and you can start to consider other ways of developing user interfaces or even applications for internal use.
Yeah, totally. Have you ever used Jupyter? I think it used to be called IPython Notebook.
I have, but I famously am not a great Python person. So I always find it a little,
the environment setup, making everything sure is installed but yes i i think you know bump
into them fairly often now and actually it's pretty convenient to have like code listed and
then a result and then code listed and then a you know result uh is is very intuitive way of
sharing somebody's analysis yeah totally i think you know google collab i think is really going to
it's one of these things that's like it's going to take a generation.
But but, you know, Google. So for people who don't know, Google Colab is a computing environment where Google will give you GPU time for free.
So if you need a GPU to train like some image processing model or something, you could use Google Colab. And there are some limitations.
I think if your program takes more than 24 hours to run,
they shut it down, things like that.
Now you can get around all those limitations
by getting the pro version,
which is only 10 bucks a month,
which is, I think, very reasonable.
But especially because a GPU probablypu probably costs like a hundred dollars
a month if you were to run it uh hundreds of dollars a month if you were to run it 24 7
um but you know google collab i think will really popularize uh jupiter and ipython even more um
than they have and as patrick said it's that environment's broken up into cells and you can uh the way it works is
that the last line of of each code block uh of each code cell is rendered right afterwards i mean
you could also do prints and stuff like that and they'll show up but now you can do a bunch of math
and then at the end say you know table as just its own line in the last line of the
cell and and that tells you know jupiter notebook that oh okay when i'm done with computing this i
want to print the table and it'll actually convert you know this like raw python data into like this
beautiful html table or you know a plot or or other stuff so it's really neat um you know
the the downside is it's very hard to actually show that to somebody else so you can give someone
a google collab notebook and they can run it themselves but for example if you wanted to
just show the results to somebody there isn't really an easy way to do that.
You kind of have to just copy it and paste it to someone.
I think you can export as PDF or something, but at that point, it's not really an interactive user interface.
So there is kind of a middle ground there called Streamlit.
So Streamlit is also kind of much more geared to internal analysis so you know if
you can plot time series and you can plot different graphs and do analysis but you couldn't for
example make a video game and stream lit uh at least not easily um but you know it's another
kind of good avenue to go down.
And I guess maybe we'll just cap it off by also putting Unity and Godot in these game engines.
I think that in something like Godot or Unity,
you have much more control over the user interface.
You could be almost guaranteed it's going to look pixel for pixel
exactly the same in every OS.
It's got these advantages.
And the clear disadvantages are you're working at the pixel level.
So even a button, you literally have to draw the button.
And so some of these will have UI toolkkits but um even then it's very primitive
like you know they won't have a pressed you know button image so um so that's pretty low level but
uh for people who are doing a lot of like graphic intensive stuff that could be a good option
at a high level i think uis are the, I think I alluded to it earlier,
but just to kind of cap it off, are one of these things where you run into it. It's actually good
to know how to do it. It's one of those perpetual, I should be better at doing this and being able to
prop one open, pop something open quickly and sort of use for internal purposes. But there are some also, again, I think like next level understanding
that people have to do, especially at least if you're coming from sort of, I'll say like Python
or C++ or C or even Java, which is, you know, we're mentioning before is multi-threading,
because like all this different stuff going on, you might have like a, you want to want to render a spinning box right like a little spinner to indicate your program is doing something but
code needs to be running the spinner for the spinner to look smooth and so if you're going
to be doing that you need to be doing your execution on something else and then the sort
of like first thing is you go into one of these creators and you draw a button when you click the
button you run your computation but of course then the button that's stuck, depressed,
and your mouth is frozen.
Everybody bumps into this early on.
And I think the UI development tools themselves
have gotten better about helping coach people
into having a wizard
where you already start off with,
hey, when a button is clicked,
it's going to dispatch a message
and you need to wait that message over here and put the boilerplate code for you there to hint you know, hey, when a button is clicked, it's going to dispatch a message and you need to wait that message over here and sort of put the boilerplate code for you there to like hint you
that like, hey, this is what you ought to be doing. But I think like this is one of the first
time people can run into race conditions where, hey, my code is processing, but someone clicked
another button. So, you know, you see that basic primitive, like start computation, right? And then it's showing some progress.
Cancel.
Well, wait a minute.
Most of the programs I've ever written didn't have an option to cancel what they were doing.
I mean, you could kill the app.
Right.
They didn't have this notion of stopping halfway through.
You start them and they either error out or they finish.
They don't have a mechanism for listening for, oh, actually, I want you to stop what
you're doing.
And so I think this is one of the places where people start to bump into needing some thoughtful architecture.
Yeah, that's a really, really good point.
I mean, on mobile and web, to a lesser extent, they really hold your hand.
Like I know iOS and Android, if you do something on the main thread that takes more than a few milliseconds,
you know, it'll pop up this big error in your log saying,
hey, you know, don't do this.
Like, go put this on another thread or something.
And I think both of them,
if you try to do an HTTP request on the main thread,
they will just crash your app.
And so it's their really aggressive way of saying,
like, look, like you need to figure out threading and all that.
Otherwise, you can't even run this app.
But on the desktop, you know, there's it's just not that opinionated.
And so you have to learn a lot of those along the way.
But, yeah, I think another really important thing, and this is kind of true across the board, is really separate your ui and your business logic like for example let's say you have an electron app um you know if you if you architect the app
in a certain way you know you could start up the ui and the ui is getting kind of its state
from your c++ program.
And if you have a bug in your business logic, which is where the vast majority of your bugs
are going to be, you can fix that bug without having to shut down the app and bring it back
up.
So this is one thing a lot of people don't realize is starting an app takes a long time.
On mobile, on desktop, you're talking like multiple you know starting an app takes a long time you know on mobile on desktop
like you're talking like multiple seconds to start an app um just to like get hello world
i just os is doing all sorts of crazy stuff under the hood you know there's usually like a visual
like the app kind of window pops up out of nowhere all of that you know it takes time
and while it doesn't sound like a lot of time, it really, really adds up. So you can get around a lot of that. And even if it's not just a time
thing, it is frustrating as a developer. Like, oh, I forgot a colon. Now I have to click the X
on the UI and start it up again and blah, blah, blah. And so you could easily,
it's some clever architecture, you could easily you know it's some clever
architecture you could easily get into a position where you know those two are running independently
and one of them knows like you can send a message from your business logic process to your ui
logic to ui process saying hey you know i'm back like i died and i came back and this is new me and then your
ui knows to like clear everything and start over without having to actually tear down all of the
graphical elements so so um i've definitely been guilty of this where um you know i didn't architect
things this way and then um you found myself taking 30, 40,
50 seconds to
do every single iteration
and you can easily kind of get yourself frustrated.
All right.
Well, thank you to all our Patreons
continuing to help
support us and just everyone listening
and I think we say it every episode, but it's been crazy how long it's been going.
But, you know, thank you all for sticking with it.
Or if you're new, welcome.
We don't have that pitch, but you can check out the website.
You do have some links there to follow, but also if you want to learn more or hear more.
But just in general, thanks for all the support and love we get from the community.
Yeah, totally. I've been getting a lot of positive feedback in my personal email and the programming throwdown email which just shameless plug is programming throwdown at gmail.com um about how
people like the duo episodes they like how we're bringing those back which is great um you know it is um you know real pleasure
to be able to share our experiences with everybody and uh um yeah and i you know this is kind of an
aside but um so many podcasts uh perished around like 2019 2020 i was actually um there was a game development podcast that i wanted to get back to
and uh you know they stopped making episodes and i just happened to be connected on linkedin to the
host so i messaged him on linkedin i said hey you know what happened and he said well um
you know i think that there's just enough out there or something like that and and you know, I think that there's just enough out there or something like that. And, and, you know, people want to move on to other things. Um, but you know, I think it's, it's, uh, really proud
that, you know, the two of us have been able to, uh, keep this going for so long and we have no
intention of stopping, uh, making good content. So that was a, that was a bit of a cliffhanger
there. Like you're leading up to something, but yeah, this is a, this is actually just clickbait.
Yeah. We're not going anywhere.
We should make the, we should make the thumbnail.
Yeah.
Like we're, we're leaving.
If we were, if we were really optimizing for SEO thumbnail, we're leaving our house to
go get dinner.
That's right.
Uh, but yeah, thanks again for all the folks.
We have people have been patrons for years and years.
We really appreciate it. Um, all of your support.
And we will catch y'all in a couple weeks.
Music by Eric Barndollar.
Programming Throwdown is distributed under a Creative Commons Attribution Sharealike 2.0 license.
You're free to share, copy, distribute, transmit the work, to remix, adapt the work, but you must provide an attribution to Patrick and I and sharealike in kind.