CppCast - One Lone Coder
Episode Date: April 2, 2021Rob and Jason are joined by David Barr (aka javidx9). They first discuss Microsoft open sourcing calculator, an update to CMake and the March 2021 ISO Mailing. Then they talk to David about his YouTub...e channel, One Lone Coder, what inspired him to start it, and PixelGameEngine, the 2D game engine he works on with the One Lone Coder community. News Freestanding avr-libstdc++ Calc.exe is now open source Cmake 3.20.0 available for download ISO C++ March Mailing Links javidx9 - One Lone Coder YouTube Channel javidx9 - Twitch Channel One Lone Coder Community Sponsors C++ Builder
Transcript
Discussion (0)
Episode 293 of CppCast with guest David Barr
recorded March 31st, 2021.
This episode is sponsored by C++ Builder,
a full-featured C++ IDE for building Windows apps
five times faster than with other IDEs.
That's because of the rich visual frameworks
and expansive libraries.
Prototyping, developing, and shipping are easy
with C++ Builder.
Start for free at embarcadero.com.
In this episode, we discuss CMake updates and more ISO papers.
Then we talk to David Barr.
David talks to us about his YouTube channel and the Pixel game engine. Welcome to episode 293 of CppCast, the first podcast for C++ developers by C++ developers.
I'm your host, Rob Irving,
joined by my co-host, Jason Turner. Jason, how are you doing today? I'm all right, Rob. How are
you doing? Doing okay. I don't have any news to share myself. Anything from you? I have a new
laptop arriving tomorrow. Oh, you're giving up trying to repair your various heating issues and
just getting a new one? Yeah, I think I've just, you know,
it's a two year old laptop with integrated core i5, eighth gen video processor. I think I've just
pushed past the limits of what I need it to be able to do. Really, I don't think that's unusual
for a developer laptop to last about two to three years like that seems about right oh yeah but my like personal
problem with this is i tend to wear the laptop out right like the power connector the keyboard
something like actually breaks after a couple of years because it's my you're not satisfied until
it breaks yeah and this one doesn't have anything actually broken on it it's still in great condition which it makes it
just kind of like a little sad but i'll keep it as my when i do streaming i have two systems set
up and i use one for monitoring the stream i'll keep it as that system uh but the new one that i
ordered is a is a ryzen 7 8 core 16 thread with 32 gigs of Ram that I managed to find on the
Lenovo outlet.
So I paid a several hundred less than it should have.
It's actually very reasonable.
Very nice.
Cool.
Oh,
and I saw that you,
uh,
you changed up your Twitter avatar.
Is that right?
I did.
I thought it would be,
well,
I thought,
yeah,
I did.
It's a,
it's a little voxel portrait that was made for me by a contractor on Fiverr.com.
I found him on there and thought, hey, this looks like fun. And enough people liked it when I shared
it on Twitter. I just went ahead and made it my avatar. And now I feel like I can do no wrong
because I always look like I'm smiling and happy with this little avatar here it doesn't matter what i say it's going to come across as friendly that's my theory okay well at the top of every episode i'd like to throw a piece
of feedback uh we got this message from paul on the include c++ discord uh and he writes uh i
really enjoyed the freestanding episode if you want to try out the freestanding AVR implementation,
you can grab it here at gitlab.com
slash, I believe it's avr-libstdcxx.
If you want to try to push the limits,
I've made a Docker image available from Docker Hub as well.
It cheats a bit and also gives you the possibility
to try out coroutines with ranges
as it is built on GCC 11.0.1.
Yeah, so that's pretty cool that uh you can easily test out freestanding with this oh and an arm version of it as well
with conan packages yeah and uh i also just wanted to point out in case uh listeners weren't aware
you know we do have our own cpp cast uh like group in the include discord so if you're on there
you can find that group and uh i try to check it fairly regularly i'm always uh asking if anyone
has any like guest suggestions there so yeah and i'm always on discord in general at this moment
so if you dm me if i don't see a message otherwise i'll get it that way yeah okay well we'd love to
hear your thoughts about the show. You can always
reach out to us on Facebook, Twitter,
or email us at feedback at cppcast.com.
And don't forget to leave us a review
on iTunes or subscribe on YouTube.
Joining us today is David
Barr. David, aka
JavidX9. Hey.
Thank you very much for inviting
me on. I just think
this is one of the most prestigious
podcasts and uh i'm humbled that you've invited me it's great to have you i am i'm gonna finish
reading your bio though okay uh david by day uh is a professional programmer and hardware engineer
for 16 years in various guises related to robotics and neuromorphic engineering and by night runs the
one lone coder youtube channel and supports the
surrounding community david has programs in all sorts of fields ranging from computer games
neuroscience and image processing to physics simulations conceptual computing and robotics
and started to make videos about the core algorithms involved and how they form the
building blocks to solving many other problems before he knew it his predominantly c++ youtube
channel has gained 230 000 subscribers many of whom are using his
pixel game engine header file in videos to have fun learning about C++ programming
in an accessible way and creating their own awesome games and products. And yeah,
David, welcome to the show. Thank you very much. Yeah, it's been certainly a ride. I know you guys
have a little YouTube channel. It's not so little, but certainly I didn't expect mine to grow the way that it did.
Yeah, 230 is a lot.
Yeah.
I'm not a social media person in the slightest.
I never did social media before this, and I still don't consider it social media, but there we go.
I'm pleased that it's took off.
I'm pleased people like it, it seems.
And the Discord is busy.
I noticed you mentioned you have a Discord before, so do we.
It's a strange world.
That's all I can say.
Was it a specific video that
really accelerated your channel's
growth, or did it just kind of slowly grow over time?
I started it about
four years ago, and
I'd say, yes,
probably a specific series helped it
kick off, but the channel sort specific series helped it kick off.
But the channel sort of always had a good growth.
But I did a series about 3D graphics from scratch,
which seemed to resonate with a lot of people.
And then from then, I got lucky with the algorithm.
And it kept pulling out the interesting series and the silly videos.
Some of the comedy videos seemed to go down quite well, too.
Awesome.
I'm kind of curious about neuromorphic engineering.
That sounds very science fiction-y to me.
Well, it was at the time.
I tell you what, this would have been in the late 2010s. I was doing my PhD at the time, and we were looking at how do we take neuron anatomical structures,
how does the brain solve
problems and replicating those in custom hardware and software with fpgas and asics that we were
designing and things and it has a small but dedicated niche called neuromorphic engineers
they love that name and it's this group that sort of fostered the precursor to machine learning and
deep learning that we know today we just didn't have the computational resources back then. But the algorithms are exactly the same. So it's an interesting field.
It's got a lot of computational requirements, which is where I sort of found my niche. Maybe
we can discuss that later. But it was about applying C++ to solving lots of academic problems
in a world where they don't typically go to C++ to solve those problems.
They'll use slower libraries, MATLAB, and those fantastic tools that they're familiar with,
but they don't get any performance out of at all. That's neuromorphic engineering. They need it to be as fast and as real-time as possible. Huge data sets, lots of processing. MATLAB ain't going to
cut it. Sorry. And you said some of that was
done in FPGAs as well yeah so we're designing our own silicon and we would model those up in FPGAs
first so we were back then the FPGA technology was around the Spartan 5 would be about the sort
of most advanced you could get at the time so So we would try and emulate how the neurons work
at various levels of abstraction.
So sometimes you want them to be very simple
if you've got many millions of them that need emulating.
Sometimes if you're really interested in the biochemistry of the neurons,
you want to get stuck into the very sort of deep protein levels
of simulations of how it all works.
So we were interested in how do we distribute this information around?
Because it turns out simulating a neuron is really simple.
It doesn't matter how complicated it is.
There's just a lot of them.
But transmitting that information between neurons is really, really hard.
And nobody's really solved that problem yet.
And you look at the sort of the deep learning and machine learning things that are going
on now, and they sort of, they blur that out.
They don't treat them as individual neurons. They them as clusters of neurons and you can get a lot
of abstraction that way and and see the wonderful things that ai is doing for us today as a result
so are there still people that are continuing more down that like biology road of like actually
trying to model how an actual brain works as opposed to the computer science application of it
okay so it's useful for firstly if you're into sort of the real biochemistry of it,
that sort of drugs and how the brain is responding to therapeutic sort of remedies, that kind of thing.
But from the side that I was particularly interested in was how does the visual cortex process what we see?
So the chips that we were building in the laboratory were basically artificial retinas
that could see the image
and process it sort of on the focal plane
and deliver that to an upstream
sort of higher level system of abstraction.
And that was great for me
because it was really low level stuff all happening.
Our chip had 65,000 cores.
That was back then back then and they
were analog cores not digital so if you want to add two numbers together instead of storing them
on transistors store them as charges in a capacitor you know kirchhoff's laws do the rest
so the the the processing was actually done on the retinal plane of the chip where the image sort of
lands on it and we could output some various parametric
information about what it saw without needing to send it to some deep deep learning or neural
network type thing so the c++ side of it then was talking to that chip i assume oh yeah well we had
to develop the tool chain i had to develop compilers for it i had to develop simulation
environments for it i had to develop sort of real-time interfaces to talk to the chip.
This chip would output easily about 100,000 frames per second.
It's blasting information out.
So getting that throughput going into the rest of your system required some serious tools.
But then we also needed to look at it from a user perspective as well.
We wanted people to adopt this technology.
We weren't very successful i must confess but we wanted people to be able to
other laboratories to at least be able to interface with it and harness its power and use its
technology and we did actually successfully do that so the technology was shipped to various
laboratories all over the world and there's been other models of it made for things like Raspberry Pi and Arduino. Now, I'm not going to
name the technology specifically, but
it is out
there. It is being used.
It's strange
how far it's come in
15 years now
from those early days.
Very cool.
David, we've got a couple of news articles
to discuss. Feel free to comment on these and
we'll start talking more about uh your background and the youtube channel okay all right so this
first one is an rs technical rs technical article uh but it's about uh microsoft's calc.exe going
open source and uh if you follow links you can actually go and look at the github page where they have the open source code for the
windows calculator which is pretty cool um i i took a quick look at the code and does look like
they're using some modern c++ and it also looks like if you're interested in seeing you know how
you can use xaml and c++ in a real application uh there's examples for how to do that
i have to have to smile at that one because i did look at the code and it's a calculator and C++ in a real application, there's examples for how to do that.
I have to smile at that one because I did look at the code
and it's a calculator.
Why is there 50 individual C++ files
and there's over like 80 total files
for the whole thing?
And I'll tell you something,
if you look into the source files,
it tells you right now
that there's a big problem in C++
and graphical
user interfaces in general. I'm sure you've chatted about that before on this, but it's such
a mess, isn't it? Look how complicated it is. Look how inaccessible it is. And you'd think that
Microsoft would be dominant in this field, and they don't even know what the next GUI technology
should really be. It's a real problem. It's an unsolved problem right now i looked at the
code and thought that is frightening just how verbose it is to be a calculator i think it's uh
worth pointing out that this the article is actually two years old but the uh if you go
back and look at the github history to see that since open sourcing it um it's it's continued development right like it's
already like a 35 40 year old program or something like that right and i have like often people ask
me like how do i learn c++ better and i'm always like well just start with a project that sounds
interesting to you and and i think this kind of speaks to the idea that like even something that sounds extremely simple like i want to make
a graphical calculator you might be able to work on refining that for the next 35 years if you
really wanted to that's very true very good point how much did you kind of look to see how much has
actually changed since open sourcing and i know you said there have been multiple issues.
I noticed that there's a couple of things on making the history more understandable,
like the history of calculations that you performed.
That was the most recent interesting change that I saw.
Pretty cool.
All right.
Next thing we have is that CMake version 3.20 is now available for download.
Jason, anything, any big changes here you want to make note of?
There's nothing that jumped out at me.
There's lots of little things that might, people might be like, ooh, like, for example,
if you do target include headers, you can now say target include headers after
if you need to, like, place the headers in a certain,
or target include directories, whatever.
If you need to put them in a certain order,
you might be able to tweak that setting.
And a bunch of little changes for things
that get resources, download resources
from repositories and URLs,
but nothing that really jumped out at me personally.
How about you, David? Are you a CMake user?
I must confess, I'm not really a CMake user. I did use it back in about 2006,
and I enjoyed it back then. It was useful for the purpose I was using it for. I was making
a compiler emulator at the time. I wanted it to run on Linux and Windows specifically. It was useful.
But then I fell out of love with it because it got more and more complicated CMake. At least I
felt that it did. And ultimately, do you not feel it's become more complicated than the tools it's
replaced? It's like C++, right? Like we've added a lot to the language in the last nine years.
But if you were to start from scratch right now in C++ 20,
you could do a lot of things much more succinctly and cleanly
than you could have in 2006.
CMake is the same way.
You have to go and look for the modern CMake examples.
Otherwise, you're just going to be doing all the bad stuff.
It's interesting, CMake, because it's a very popular tool
certainly on my Discord.
I've just done a quick search now.
How many times has it been mentioned? It's over
2,500 times on the Discord.
It's usually with people asking,
how do we set it up? How do we get it configured
for various projects? I don't know if there
is enough resources being
put out there to how do you make your projects
cross-platform. It's easy for us as accomplished engineers to just run away with doing it. But
if you are starting out, where do you actually go for your first modern introduction to these
things? The resources aren't as obvious as you might think. At least I think so.
No, yeah, it's totally true. Well, I guess I may as well do a shameless self-promotion of some sort here. But on my GitHub, I have a C++ starter project, which is a cross-platform CMake-based project that you can fork and start from.
And it's got a couple of thousand stars on it right now.
I need to go back and merge in a few changes.
But yeah, I totally agree.
I recognize getting started and then trying to say, OK, well, I want to use all the static analysis or the warnings or whatever.
How do I get this thing set up? this should be a fork and run kind of
project all right and last thing we have is that the march mailing for the iso superlose committee
has come out i'll be honest i did not have a chance to look through uh these but i definitely
wanted to at least make note of it um did either of you have a chance to read through? Did you want to highlight any papers?
There was one that caught my eye. Well, there were actually two that caught my eye. One
very quickly, and this is a bit of a fan service for anybody that's watching this, was the
character sets and encoders by Jens Maurer. Only because that first video, which sort
of made my channel work, the one thing i regret doing was
choosing the wrong character set and so every day for four years i have had to tell people how to
set their character set to unicode that is without fail every day for four years i had to tell them
how to do this so yes if there's anything that can make character sets better sort that out please nice well since you brought that one up this is an
interesting the the first part of that paper starts with switch c++ to a modified model c
approach and it links to c99 there are several efforts right now to unify c and C++ and some of the little ways that they've diverged. And one of those is also
in here, a provenance-aware memory object model for C, and it's in the C++ mailing. And if you
look at it, it's actually a proposal for both languages simultaneously to unify some topics
there. I find that interesting. I don't know what that means at all, just for the record.
All right. Well, David, I guess we already talked a little bit about your background
and the neuromorphic computing. Do you want to tell us more about kind of how you got started
in C++ and maybe what you're up to these days professionally? Okay. Well, I started C++
as a result of finding Java rather boring, I think, is the accurate way to start.
Java is too easy. I need something more challenging well it was i started with turbo c like that's that's how far back i'm
going um and i remember saving up my pocket money i was a teenager at the time and i treated myself
to visual studio 6 i think it was on cd and that came with a c++ compiler and a book and the book
was full of mfc microsoft foundation class stuff and i looked at
it and i was trying my best to try and work out how to make this all work and it wasn't happening
i had no sort of at the time formal training in how to do software engineering so classes and
object-oriented programming weren't something i was familiar with i was a very procedural guy
i'd worked with pascal i'd worked with basic i'd worked with assembly language with all these
things up until that point.
Only young.
And then at university, we sort of got introduced to actual software engineering,
and they taught us Java.
And I did everything in Java.
I thought Java was the bee's knees until I needed some performance out of it.
I wanted to do games programming, and Java was terrible.
It was awful for games programming, really bad.
It's not so bad now, but then it was. We're talking sort of
around 2001, 2002.
And so I went back to
this book I had for C++, and now
I looked at it and I understood it. I understood
members, I understood inheritance,
I understood polymorphism, because I'd
been taught all of these things. And it looked
like a completely different world to me.
Yes, MFC was still awful,
but I could actually now build the things
that I wanted to build,
and I've never looked back.
C++ for absolutely everything.
I think people who claim that you can't do
complex, large projects in C++
just aren't doing it right.
I think it's a brilliant language for beginners.
I think it's a brilliant language to get work done.
I find it very productive,
and my team at work find it a productive language to
use too. So, I mean, what I do at work is I work for a company now that builds robotics for heavy
industry. So we look for hazardous environments. If you need to go and have a look at something in
these hazardous environments with a special payload of transducers or probes, you send in
one of our robots. We call them scanners.
They're not sort of like humanoid things walking into lava pits, that sort of thing.
They're far simpler than that.
But there's an embedded nature to it, and it needs to be, it's fairly critical stuff.
So they're inspecting sort of power plant facilities, and sometimes we're inspecting
aircraft parts and that kind of thing.
So it's got to work. It's's got to be reliable particularly in the radioactive environments
it has to sort of do a good job though working out what's going on and being safe right you don't
want to so i'm sorry you don't want your robot being the problem in a nuclear environment you
know i was going to ask if this was the kind of thing, if not necessarily the thing that you worked on, that would have been like examining Fukushima after the tsunami.
Yes. Ideally, we would be looking at examining it before Fukushima happened.
I mean, that is the primary purpose of our gear, really, is to sort of say, hang on, something's about to go wrong here before it happens. But yes, certainly we have actually worked alongside companies
that have gone on to sort out Fukushima
after the terrible events that happened there.
So the nuclear industry is big for us too.
Nuclear, oil and gas, and aerospace
are sort of the big three that we're targeting.
And we do a lot of embedded stuff.
So we have FPGAs there, we have PIC micros,
and we have lots of embedded power PC module-type things
that are controlling all of our robots and their behavior.
I'd love to say that they do lots of really sophisticated
artificial intelligence to work out what's going on,
but it's far more humdrum than that.
They just need to do the job reliably in these horrible environments.
Now I am so curious.
This may be going off track from an interview perspective but is your hardware hardened to prevent memory errors
from radiation or do you have error correcting code or some combination of both yes it is a sort
of a hybrid tactic it depends on the environment so So some of the environments we're going into,
you can put all the radharding in the world.
It's not going to make a difference.
It's so radioactive.
If you can get 10 minutes out of your system, that's great.
Wow.
Most of the time, we're taking physical measures.
So if we think we're going into a nasty environment,
we'll package it in a surrounding material
and try and keep it with a nice clean um sort of environment before it goes down there we it's it's the nature of
the industry if it goes down there and gets contaminated it ain't coming back right it's
it's going to get thrown away they just yeah it's uh they're not they're not bothered in cleaning it
out particularly in in in nuclear power plants you don't want it back. Stay away from it.
But in terms of error correcting and things,
yes, so in all of our communication buses,
everything is done with a,
I wouldn't say the most basic,
but a reasonably sophisticated CRC style check for transaction of communications.
We don't need things to be very fast.
So we have this, we can afford that ability.
We also use very large voltage levels unusually
that's one of our tactics for dealing with it so if things do start getting interfered with
they've got to be interfered with a lot in order to to trip them up but that that doesn't apply
to sort of off-the-shelf memory chips we will have to go and source sort of rad hardened
materials which of course triples quadruples the price you know that's interesting i i didn't
realize that using high voltages would be a tactic but i mean it totally makes sense then a stray
electron's not going to throw off yeah you just want to increase the odds of it being in your
favor yeah so just slow down the communications though that's the price you pay but if you know
motors and things you don't need it to be that quick does it also then i but it i'm guessing
not very high current even
though it's high voltage so i'm just wondering how much it has to also change the wiring
requirements like are you yeah as well we would have we would we would use fairly bulky wires to
begin with that's the first thing you want to try and do is shield everything that's going on right
but yes the current requirements for the data signaling and they're not silly high
the current requirements for some of the motors can be up there with six or seven amps which for
us is a big deal um that doesn't sound like a huge deal but it is for for our systems uh we would use
typically use 24 volt logic for for that sort of thing cool yeah yeah sorry this is stuff that
we've never talked about on the show before so now i'm just like curious about all the things so and then i find myself wondering what actual electrical
communication you use because you mentioned pic microcontrollers which are known for their um
uh shoot what's that bus that's used in cars that they use oh they use a can bus and yeah can are
you using can for communication because it already has some of that built in?
Yes, we have used CAN.
I've not used CAN for a couple of years now.
We went down a slightly more proprietary route
afterwards. And a lot of the
motor control stuff are now using a derivative
called Open CAN.
Which is some politics
involved in this.
That just makes me feel old because I don't think that existed when I last used CAN.
But, yeah, I mean, we rely on good old humble UART for a lot of it.
Good old RS-232.
Because it's nice and slow and it's high voltage.
It's perfect.
Right.
Huh.
It's amazing how some of these like really forward-looking technologies
are using technologies from 30 years ago um just because it's it's correct for the environments
that they go in yeah i mean all you need is like an rs-232 you know connector for a commodore 64
it'd be at like five volts anyhow right like exactly right much better than 1.8 you know
whatever is expected these days. Right.
All right.
Well, now that we've talked a little bit about your professional work and everything,
how did you go about starting a YouTube channel?
There's a few reasons.
I'll try not to make this too long.
The first is I was working at the university. After I finished my degree and and went on to do my post-grad and then post-doc.
I was working at the university and I was working a lot with the students there.
And year on year, hundreds and hundreds of students I'd be working with, I noticed there was a decline in their ability to be able to do basic programming.
At first I thought, is this the university's fault? And it wasn't.
I knew the teachers, the quality of the materials I thought was going up and for me it seemed as if there was
a lack of interesting resources for students. Now that's not to say there's no resources but
resources which can capture the imagination of a generation of people who just stir at their phones.
They all want to be, I'm going to get called a boomer now.
I can see people screaming.
But there's a disconnect now
between people wanting to work in the computing industry
and people actually appreciating what's involved
in working in the computing industry.
At least that was the conclusion I came to.
And so I thought, well, do you know what?
Let's have a look at what resources are out there.
And I looked at the type of videos, and they fall into two categories.
The first is the really excellent videos.
So things like the GDC talks, the really highbrow stuff that people in...
You know, you and I would quite happily sort of debate the minutiae of a particular template style.
You know, that kind of thing. Brilliant. Highbrow stuff. but totally inaccessible for those that want to get involved in computing.
Or there's the complete and utter dross, and that's the rest of it. There's nothing in between.
That sounds really offensive, but it's true. There's just thousands and thousands of terrible,
terrible programming videos out there, and they all do the same thing. They also write,
first we're going to include standard IO, and then we're going to output using C out,
hello world. And then we're going to create something that displays the Fibonacci sequence.
Who cares about the Fibonacci sequence? Who cares? If you're trying to get involved in programming,
I thought this is ridiculous. I identified that there was a lack of resources for people who knew
a little bit of Pro. People know how variables work and how loops work. That's something
that they can go and find out pretty quickly. Learning that sort of thing, yes, it takes
a bit of time, but it's something they can go and work out. There's books, there's resources,
there's terrible videos, all that exists. But once these people have developed these
sort of basic skills, there's nothing. They know how to syntactically structure a loop.
They know about a function.
They don't know how to apply it to solving problems.
And that really sort of was the final thing.
I said, right, I'm going to have a go at trying to create a channel here where we look at solving problems in a reasonably agnostic way.
It happens that I like C++.
I think C++ is great for beginners.
I've said that before.
I know that's not necessarily everybody thinks that, but I do.
And I think it's, I thought, so people with this skill set, they can go, right, what can I do with it?
Let's create some interesting, daft, silly applications.
And I think that's half the fun.
Keep it fun.
Keep it silly.
Get rid of the damn Fibonacci sequence as an example of anything,
and get people doing stuff that they enjoy.
When you started programming, I'm willing to bet you would just switch your computer on,
sit down, and start coding straight away.
That would be for me, but Rob's a little too young for that.
I need to do much more programming for college now.
Okay, well, for some of us of a certain vintage it was that
was the case you just sat down and immediately you had this interactive loop of let's play with
the keyboard and seeing the visuals on the screen you didn't have a choice exactly it was immediately
satisfying right and and that's gone that's totally gone now you switch on your pc it's
difficult to get programming you think oh how can that be the case? There's thousands of resources and there's millions of languages
and there's loads of books.
It's too much. It's overwhelming.
And it's difficult to find, hopefully, the quality stuff.
But it's now also difficult to get started.
You need tool chains, development environments, manuals.
You need to understand lots of different complex patterns
in designing software.
You need to understand GUIs, console streams, all these sort of things before you can even get going.
And I wanted to try and do something about that.
And that's why I started my channel.
And if it was successful, great.
If it wasn't, at least if nothing else, it was just some sort of legacy I could leave behind.
Because I have no sort of digital presence other than the YouTube channel.
I want to end up the discussion for just a moment to bring you a word from our sponsor
C++ Builder, the IDE of choice to build Windows applications five times faster while writing less
code. It supports you through the full development lifecycle to deliver a single source code base
that you simply recompile and redeploy. Featuring an enhanced Clang-based compiler,
Dyncomware STL, and packages like Boost and SDL2 in C++ Builder's Package Manager,
and many more.
Integrate with continuous build configurations quickly with MSBuild, CMake, and Ninja Support,
either as a lone developer or as part of a team.
Connect natively to almost 20 databases like MariaDB, Oracle,
SQL Server, Postgres, and more with FireDax high-speed
direct access. The key value is C++ Builder's frameworks, powerful libraries that do more than
other C++ tools. This includes the award-winning VCL framework for high-performance native Windows
apps and the powerful FireMonkey framework for cross-platform UIs. Smart developers and agile
software teams write better code faster using modern oop practices
and c++ builders robust frameworks and feature-rich ide test drive the latest version at embarcadero.com
so what are some of i know i kind of used this a little bit already but what are some of the
you know projects that you put together on the youtube channel that like really attracted
attention and were these good kind of products that you think are good the YouTube channel that like really attracted attention?
And were these good kind of projects that you think are good for like a first-time programmer to pick up and follow along? So there's two sort of categories of video that I end up doing. So
there's the series type videos where we look at a slightly larger project than normal,
but each episode will be broken down into a specific algorithm that that project requires in order to work so in a way the video can
be a standalone video in its own right but it comes together to form a bigger
whole they would be things simple stuff like line drawing using line drawing to
detect paths in scenes looking at various types of collision and we talk
about the mathematics behind how
does a circle interact with a square, that sort of thing. So it covers a broader thing than just
the code. It's how do we use the code to solve those problems. And that's the crux of the whole
channel. It could be in any language really, but C++ is what we've chosen. The other types of
videos are sort of the one-off curiosity videos. And these are the ones that tend to get people's attention.
So my first video was doing a first-person shooter style game
in the Windows command prompt.
Because I figured I want people to have a go at this.
I don't want them to have to download libraries and tools and things.
If they've got Windows, sorry Linux guys,
I move to Linux later on, I'll come back to that.
But if they've got Windows and Visual Studio, then how do they do this?
And everybody's got a command prompt on Windows, and with a little bit of code,
you can actually turn that command prompt into a graphics surface.
It's character-based pixels.
And that, I think, caught people's imagination that, actually, hang on,
we've got sort of pseudo three-dimensional graphics going on here in in a windows command prompt it looks daft it looks terrible I mean
go and have a look at the screenshots it looks really bad but it's running at 7,000 frames per
second which really appeals to those that want to write games they sort of see that and go oh hang
on I know what frames per second means let's uh let's run for that and the whole thing's actually what you're able to get uh that's the the the update rate of the main loop i'm
fairly certain the windows compositor for the screen obviously oh yeah yeah yeah right right
but yes the loop is actually running okay yeah the actual loop is doing that according to standard
chrono anyway that's what the loop is doing right um and the whole thing was like 200 lines of code so the idea is to to try and
break it down into these manageable chunks but at the same time it's important not to go to the
extremes now in c++ we can do some fantastic stuff in one line right we can do like the most powerful
obscure code you only have to look at some of the obfuscation competitions or some of the code golf
stuff to see what you can do but by by deliberately not
using some of these technical features you create code which people can then go and look at and
implement on any other platform they want and i've seen that happen so people take exactly the
principles from this first person shooter and go and implement it in loads of different languages
and different frameworks and then just message me to get me to show it because one of the things i
like to do on the channel is show other people's projects.
Oh, that's fun.
Yeah.
They're always really great episodes.
I love showing other people's projects on there.
They get some exposure, which they wouldn't normally get.
And I know that's gone on to actually people have had offers of being involved in larger projects.
And people have had coming to the server saying they want to recruit people and that sort of thing.
So that's worked out. So, yeah, the first-person shooter person shooter one and tetris that's another big one that we had tetris in the command line again very simple stuff but by leveraging this command prompt
as a user interface makes it very easy for for people to just get started it looks silly but
it's much better than hello world and stupid fibonacci sequence i hate that sequence well is there any mathematical sequence that you do like to demonstrate
i'm not going to answer that one but i do quite like procedurally generated lemma numbers
did you say lemon numbers lemma i don't know lemma lemma yeah okay right
so we've mentioned in your bio this uh this pixel game engine olc pixel game engine is that the
command line prompt base that is the successor yeah so the the once i've done this stuff in the
command prompt and realized hang on people are using this, but each video, I'm spending 10 minutes in each video saying how we set up the console buffer
and how we do this trick.
What we need is a single file utility that people can just quickly include
and start using these facilities.
So this was the console game engine.
And half the channel videos are done.
We got to the point where in this command prompt,
we're actually emulating the first level of Spyro the Dragon
for the PlayStation 1,
complete with textures and perspective mapping and everything,
all in the command prompt with just clever tricks
with the ASCII characters and blending of the colours
that were available to you in that palette.
But after that series,
this was the last episode of the Code It Yourself 3D series.
It's a software rendering series.
Realized, hang on, we're spending too much time now talking about how we do things in a command prompt and not the algorithms in general.
Because you have to do all these hacks and things to make it look sensible in the command prompt.
So that's when the Pixel Game Engine was born.
And so that became the tool of choice that I use now to make visualizations for my videos. And then it just so
happened that people sort of realized they can make games with it too. And so that's, it's a
single file header include tool that's, again, you just include it and you just go. And it's designed
that you don't have to sort to pre-download any tool chains
or any particular things, particularly on Windows.
On Windows, it's completely self-serving.
On Linux, it does require you to install a couple of libraries beforehand.
It needs a libpng and some OpenGL drivers.
But it's now cross-platform.
So it works on Linux, Mac, and Windows.
It's been ported to Nintendo Switch.
It's been running on PlayStation
Portable. We've had it running on Raspberry
Pi's people and Chromebooks. I know
the Linux variants, but people have
gone to town with it and started
making it work on all of these platforms.
Because it presents a very, I believe,
a very simple user interface. You just want to start
your C++ application and draw
lines and circles and images without having to worry about memory buffers or allocations or popping up the window.
And I think these are all things that we take for granted. We're very familiar with doing these
things, but if you're just starting out and you're looking at just never-ending screens of Hello
World, the alternative is you can actually see, you can control the character on the screen.
Then we've gone right back to the 80s again, where you've got this instant feedback from the software.
And I think that's part of its charm in many ways, is that it's so simple to use.
If you've ever programmed an Arduino, you can program using the Pixel game.
And you get one function at the start to load all of your resources.
It's called once.
And then there's a function called every single frame. But behind behind the scenes there's a lot of complexity to make it work across
all of these different platforms make it work across different renderers as well so it can use
open gl different versions of can use one with shaders there's a direct x version which we
haven't released yet there's uh some some nut cases working on a vulcan version no idea why
and we've also got an Inscripten backend for it now
so you can compile it to WebAssembly and
run all of these applications in your browser
without any change from the
code you would run it on your desktop.
And so this has opened up now for young
people and new programmers to then be
able to easily distribute their applications,
which is fantastic stuff. They don't
have to give their friends this dodgy executable
that their antivirus is going to pull out. They can just send them a link and it runs right there in the browser. It's great stuff. They don't have to give their friends this dodgy executable that their antivirus is going to pull out.
They can just send them a link
and it runs right there in the browser. It's great stuff.
And that was entirely community developed, I should
point out. So as
the Pixel game engine has gained a bit of traction,
the community are now involved in its development.
It is open
source, but it's not technically open
source, if you know what I mean, just at the moment.
And they've been developing all of these additional things for it. It's just brilliant.
We've got extensions for it, for joypads, gamepads, sound effects, different types of rendering.
It's become a powerful little tool. So on the each frame function that the user's writing,
they can just say, well, if the joypad one button a is pressed then do this kind of thing
like really high level yeah yeah it's very very simple to do and so it's been backed up by this
whole channel's worth of videos which yes use the pixel game engine you don't have to but it does
use them so in a way that's where the documentation is sitting people are saying oh how how does uh
javid go and make this guy walk across the screen? And they can look at the video that corresponds to how that's done.
And we can look at the physics involved in the collision detection and everything else.
So there's a lot of learning in just getting your character to move across the screen.
But in the Pixel game engine, it's one line of code in order to do that.
I think that you get that very rapid feedback.
And I think as you're learning, that's a very important thing,
that you can make a change and it's immediately tangible to the user
to actually feel and see how that change has been executed.
You learn a lot doing that.
You don't necessarily have to learn about classes and things in order to use it,
but that rapid feedback is really what it's all about.
And simplicity, you don't have to care.
The single header, you mentioned that it's all about and simplicity you don't have to care the uh the the
single header you mentioned that it's open gl vulcan direct x using all these different things
but it is a 2d game tool right it's fundamentally a 2d game tool yes uh well it grabs user input
and it displays that's that's all it does but But it displays in a fairly clever way. So it can
do individual pixel stuff. I don't know if you've ever played with typical desktop applications. If
you're drawing a single pixel, there's actually quite a lot involved in doing that. Particularly
if you're on Windows and you're going down the GDI route, it's horribly slow with pens and brushes
and all that horrible mess. but if you're going down the
open gel route you've got to set up textures and quad buffers and vertex buffers and shaders and
all that sort of thing so that's what it takes out it does all of that for you uh if you if you
just want to display that single pixel you simply draw that pixel at that coordinate and it will
the behind the scenes will choose the best approach uh in order to do that so in some
situations it will uh represent what you're trying to draw
as a whole texture being edited.
So that's the case with per pixel drawing.
But if you're drawing like an entire image at the time,
it can actually use the GPU itself
to go ahead and do that drawing.
So one of the nice things about this engine
is you don't sort of sacrifice much performance
for that simplicity.
And I think that's why people have sort of latched onto it
as being a fun tool to use.
Is that a very large single header?
No, it's 5,000 lines-ish, if you want to say.
It's definitely seen bigger.
Yeah, definitely seen bigger.
It tries where it can to leverage
all of the operating system specific
functions that are available to it. So on Windows, to load a PNG file, it needs to load in the GDI
stuff. So it tries to assume that in particular environments that certain technologies already
exist for it to use. So you don't have to download many supporting libraries or tools in order to get
it to work. And that's really where all the development effort goes into.
How do we leverage all of this technology that may be kicking around from 20 years ago
in order to provide this tool which works with modern environments?
So fundamentally, unless you set a specific flag, the Pixel game engine is OpenGL 1.
So it's going back a long way.
So it's using fixed function pipeline stuff to do its thing.
It can use shaders.
That's to just set the right flags.
And then you've got access to all of the pixel shading functions
and that sort of thing.
But the guiding principle, certainly for myself,
and we have a small dev team now on the Discord server,
is that it should behave exactly the same
across all of these different platforms.
Did you mention audio?
Does it have audio support?
It does through the form of what we call a Pixel Game Engine extension.
So it's not intrinsic to the engine.
There's a whole bunch of different files which you can include as well as the engine,
which give it this additional functionality.
Audio is one of the things that it's been there from the start.
It's probably in need of a bit of an update now.
It needs a bit of tender love and care, I think.
But on Linux, you get a choice of different back-ends it's ALSA or OpenAL and on Windows it uses WinMM now we need to update this
because we've got this in scripted version out now which allows us to
compile to web assembly and that needs that needs a new audio
solution so this is part of the problem.
As we expand the feature set and the repertoire of what this engine can do,
we need to make sure it still remains consistent across all platforms,
and that's becoming a battle.
Right.
I think you mentioned that there were some kids within the community,
and I have a 12- and a 9-year-old who are both into Minecraft
and sometimes watching YouTube videos about Minecraft.
I could totally see them being into this type of content.
I'm wondering how many kids you're aware of within the community
of Pixel Game Engine developers.
So it's interesting.
The only demographics that I get that I can reasonably trust
are those from YouTube.
Now, the YouTube channel itself tends to appeal to 25 to 35 year olds.
Which I thought was a bit older than
what I was expecting. However, on Discord,
it's a more modern technology.
It appeals slightly more to the younger.
I would say we're looking at 15 to
25 being sort of the dominant age.
And it's amazing on the Discord server,
some of the young people, the capabilities
of the young people is frightening.
They're writing code, which I have to take a second look at and go,
how's that working? What are they doing there?
And it's just so advanced. It's brilliant.
But it's great to see them come putting their projects together,
particularly when they've joined the server with basically no skills,
and then six months later, they're putting together their first applications
completely independently, not relying on anything I've produced or anybody else's technology. They're just doing it for themselves.
But yes, certainly the Pixel Game Engine has helped. I know it's being used in quite a lot
of schools and universities now as a teaching aid. So whenever it's deadline day, I get hundreds and
hundreds of messages saying, how do I do this in the Pixel game engine?
I know there's some people who think of single header libraries as like a code smell, like their own, you know, problem.
But I just, I guess if you want to give you the opportunity to kind of speak to that,
like why specifically a single header library?
Do you have any comments on whether or not
you think that's a code smell for this project?
I think it is a code smell.
I won't argue with the fact
that it's not a great way to do things.
From a personal perspective,
it's not a great way to do things.
I have to maintain this bloody great big file.
It's only 5,000 lines, you said.
It is, yeah, but it's quite a reasonably scattershot code.
But if I went back and would I do it differently,
would I break it up into a header?
It's basically a class.
There's a series of classes.
I could break it up into one header and one CPP and release it that way.
I chose
not to, and the reason was
something I learned from the original
incarnation of the console game engine
was that people don't know how
to acquire the file.
What people would do is go to GitHub,
cut and paste the code
from GitHub, and stick it into
their project. Not even like the raw
download link or whatever.
Yes, that wouldn't even pop up to them.
I could ask people now in the Discord server,
do they even know the raw function exists?
A great majority of them don't.
And so I liked this idea that you just have this one file.
You just put this at the top of your program.
Don't ask any questions.
Now, I know that's a controversial learning tactic,
but I think in some situations you've just got to say, don't ask any questions, just put this at the top of your
file, and this will provide you with all of these utilities that you can get going with. And then
as they're learning, as they're developing, they can peek inside the file and see, well, how does
it draw this line? How does it draw this circle? How does that algorithm work? How is it handling
the memory for this sprite that's been loaded up? Why is there a raw pointer there and a smart pointer there? Ask these sort of questions.
And they're encouraged to ask these questions. So that's why I say in the YouTube channel,
ask in the comments, come to the Discord, ask on the Discord. Come and learn about it,
tear it to bits, come and criticise it, get involved. And as a result, it's developed and
it's grown in maturity and lots of bugs have been fixed
but yes it's a code smell a single header solution if what if i if i went back and do
it differently i probably would i could i i almost feel like i'm getting the sense from you uh that
if you could if if if you're if your users could actually do like pound include the GitHub URL.
That would almost be like the next level
because you really just want it to be that easy
for them to use it.
That's exactly it.
For me, my entire mission is about
reducing that barrier to entry.
I want people to use C++
because I think it's brilliant.
I think really do.
It's a great language.
And I like the fact that now
Visual Studio as a tool is really good too. It's much faster. It's a great language. And I like the fact that now Visual Studio as a tool is really good too.
It's much faster.
It's snappy.
Okay, it's still a bit big to download,
but it's got loads of useful features for beginners.
But just getting started is still very tricky.
You create a new project in Visual Studio,
and Microsoft goes and fills it full of junk straight away,
and you've got to go and delete it all.
It's just bewildering.
I can imagine if I was put into that situation,
I'd just be put off, put off programming altogether.
So whatever we can do to reduce that barrier to entry,
I think is so important to make sure that C++ keeps on going
and to keep it fun to learn as well.
It's kind of funny for you to bring it back around
to that because uh you mentioned visual studio visual c++ 6 yes uh that was the first commercial
c++ compiler that i owned was visual c++ 6 in university in my first year and also had some
of those books with the mfc like how to get started. And I was I'd have I'd
already been programming to some extent for 10 years of my life at this point, I was completely
put off by that. Like I did like the Hello World create a window and MFC example. And then I'm like,
forget this. And I never literally never went back to mfc programming again like and the next gui i did was
in wx widgets and then i love wx widgets i think that is the solution right now to the original
problem of c++ gui is wx widgets for the win um so do you end up recommending to people using the Pixel game engine
that they start with VS Code or Visual Studio Community?
Certainly, what you tend to get with younger people
is that right now a lot of them want to be hackers.
So it's all Linux, right?
So everybody's got a big flashy Linux terminal up,
usually trying to run a complicated distro of Linux.
So it's not
necessarily Visual Studio, it's more Visual Studio
code, which of course
implies then that they need to get onto CMake
and everything else. That's probably why I see a lot of
CMake requests on the Discord.
On Windows,
I can't really see a sensible
alternative right now to Visual Studio Community
that's up today.
I know the msys-mingw
package is actually pretty good too.
But it's just a shame
that the other IDE on Windows
Codeblocks, I guess, is sort of the
de facto free one that a lot of
people go to. That ships with
a slightly broken version of
mingw, or at least an out-of-date version.
Which is frustrating.
Because that's one of the bugs that we're often trying
to fix. People will come and say, I've downloaded code blocks
and it doesn't work. I'll say, well, you need
a C++17 compiler.
Right, as long as you
can point them to another free alternative,
at least that's an option.
The Pixel Game Engine is very, very
compatible with the MinGW version from
MSYS 2. We have
a lot of effort goes into making sure
that we can do it with free software.
Everything about it should be free for people to use.
I feel like Visual Studio relatively recently added
the open directory feature,
so you don't even have to explicitly create a project, I think.
So that seems like that would also be helpful to you.
Yes, possibly.
And there's the new uh the new c++
features like the modules and things which we're looking into i have no idea i've not used those
perfectly myself yet but they do sound like the right uh they do sound like the right solution
interesting for this obviously you know you've been putting work into this pixel game engine
for years it sounds like it's really powerful and easy to use did you ever compare it to any of the other
uh similarly kind of easy to use game engines i know we've talked before about like sfml and
cinder okay yeah and there's just outright sdl2 as well which is another popular one and there's
uh languages similar languages sorry similar engines in other languages such as uh i call it go dot but
i'm informed it's godot and um the high game yeah pi game as well i mean i it obviously i'm biased
because it's it's my little engine but honestly with my output i'm really not bothered what engine
people are using they're happy to use as long as they're coding and they're looking at the
algorithms in terms of performance uh it is up there the pixel game engine is up there we're doing what it does best and that is rendering
2d stuff if you do want then fancy lighting effects on top of that at the moment as it stands
you're going to pay a slight penalty for that because a lot of the drawing routines being pixel
based are cpu bound it's difficult to send that individual pixel to the GPU to draw it. It's just
not efficient. You've got the overhead of calling the drawing kernel to begin with and setting
things up. It's just too much for that one pixel. So all of those sort of raster effects, they
happen by the CPU. And the performance gains happen when we start merging how the CPU and the
GPU work together to composite the scene, which the end user never gets to really have any involvement with.
It is performance.
I would say most people's applications, of course,
it depends what you're doing with it,
but most people are running sort of HD applications
at 200, 300 frames per second, but that's a nothing number.
It depends what they're doing.
Right.
But you typically would see demos of that kind of scale.
That's interesting. doing right okay but you typically would see the demos of that kind of scale that's uh interesting talking about the being cpu bound on on pushing the pixels out i was running some performance
stuff on on doom uh a few months ago playing around and realized that like i mean because
doom can run out of 700 frames per second whatever on modern hardware because it's so crazy optimized
but on a modern system it's been something something like 90 of the cpu time pushing pixels like you can do
anything else you want to do that game engine it's not going to slow it down because that's
where it's spending its time now yeah and i would completely agree when i've profiled it myself
yes probably a similar number actually it's definitely up there in the 90 most of the time
it's just checking can it write to this 2D array?
That's all it's doing.
I've not found a clever way to not have those checks.
I want the users to be able to do things safely.
And so if they do write to an off-screen area that doesn't exist,
it doesn't crash.
It's for beginners, for intermediates, it can't do that.
So I've got to do a check for every single pixel that gets written.
And that's where it spends most of its time. And It makes it really a pain in the ass to debug as
well. Because whenever you break into it, it's always in that particular function. Whenever
you press the pause button, it's always writing that one damn pixel.
Do you have like an advanced mode where you can turn off those checks for people that want to
fly by the seat of their pants?
Yeah, there's a few things like that under the hood too.
So the real pros that end up taking the engine
and doing some remarkable things with it
tend to make little modifications to the insides.
So by default, it's meant to be safe and secure,
but you can break the rules quite a bit.
And that's one of the things I tend to do with it.
So every couple of years as a community,
we'll have a jam and lots of people will enter.
I think we typically have about 100 entries, something like that.
And I always enter the jam myself.
I can't win, but I'll always try and do something
which will really push the technology of the Pixel game engine.
And each time, it's a great learning experience for me
because I'm using the tool that I've developed,
but I'm also learning all of these sort of secret optimizations
which I can put in later on
and potentially make videos about for the rest of the year.
So how often do you release videos then?
Up until now, it's every two weeks.
Okay.
Before years, something you said?
So the first year it was every week.
That almost killed me.
So I decided I've got to slow it down a bit.
It's every two weeks now. And this year it's been every two to three weeks.
But I've started doing some live streaming again on Twitch,
which is a slightly different way of doing things.
And the reason for that, and I'll take this opportunity to announce it to my fan base,
my wife and I are expecting our first child in a few weeks.
Oh, wow.
And so making youtube videos
is going to have to sort of go on hold for a little bit but the live streams can probably
still continue and it'll give me an opportunity to work on some of the bigger projects which i've
not been able to put my mind to because if it takes about 30 hours to make a video one of my
videos in total 30 hours and two weeks you know i'm a regular guy
i've got a house to look after i've got to pay the bills work full-time got a family that need
feeding that sort of thing you know uh finding that 30 hours a week uh to do the videos is
getting tougher and tougher wow 30 yeah that's a big commitment it has been it's usually about
20 hours to do the code and then 10 hours to film and edit the final result.
Is there anywhere online where people can go and see
some of the games that are created with Pixel Game Engine?
Right, yes.
That's something that we're actually in the middle of doing.
We're making like a showcase gallery for.
So right now, the only place to see it would be
the community showcase videos that are on my channel.
So I've sort of collated some of the best ones.
On our Discord server, we have a forum called Show Your Stuff,
which is not exclusively Pixel Game Engine,
but there's a lot of Pixel Game Engine applications get posted there.
I've started collecting them because now we can compile them to the web browser.
I'm hoping we can stick them all and host them all on the one loan coder.com website
which i think would be a nice thing for the guys to do yeah very cool okay well david it's been
great having you on the show today uh is there anything else you want to plug obviously we're
gonna put a link to your youtube channel in the show notes um i'm not not much of a plugger i have
no sort of marketing savvy at all on these things. So no, I'll decline
the opportunity. All right. Well, it's great having you on the show. Thank you for having me.
It's been really good fun, actually. Thanks. That was great. Thanks so much for listening in as we
chat about C++. We'd love to hear what you think of the podcast. Please let us know if we're
discussing the stuff you're interested in, or if you have a suggestion for a topic, we'd love to
hear about that too. You can email all your thoughts to feedback at cppcast.com. We'd also appreciate if you can
like CppCast on Facebook and follow CppCast on Twitter. You can also follow me at Rob W. Irving
and Jason at Lefticus on Twitter. We'd also like to thank all our patrons who help support the
show through Patreon. If you'd like to support us on Patreon, you can do so at patreon.com slash cppcast.
And of course, you can find all that info
and the show notes on the podcast website
at cppcast.com.
Theme music for this episode
is provided by podcastthemes.com.