CppCast - SG14 Update
Episode Date: October 7, 2016Rob and Jason are joined by Guy Davidson from Creative Assembly to discuss the work of the SG 14 game dev/low latency group including his ring buffer proposal and more. Guy Davidson is the Cod...ing Manager of Creative Assembly, makers of the Total War franchise, Alien:Isolation and the upcoming Halo Wars sequel, Guy has been writing games since the early 1980s. He is now also a contributor to SG14, the study group devoted to low latency, real time requirements, and performance/efficiency especially for Games, Financial/Banking, and Simulations. He speaks at schools, colleges and universities about programming and likes to help good programmers become better programmers. News CppCon 2016: What We've Learned From the C++ Community Compiler Explorer Update Free O'Reilly Book: Practical C++ Metaprogramming Boost 1.6.2. Release Rgat: an instruction trace visualisation tool for dynamic program analysis C++ Slack Group Guy Davidson @hatcat01 Links CppCon 2016: WG21-SG14 - Making C++ better for games, embedded and financial developers Creative Assembly Sponsor Backtrace
Transcript
Discussion (0)
This episode of CppCast is sponsored by Backtrace,
the turnkey debugging platform that helps you spend less time debugging and more time building.
Get to the root cause quickly with detailed information at your fingertips.
Start your free trial at backtrace.io slash cppcast.
And by Meeting C++, the leading European C++ event for everyone in the programming community.
Meeting C++ offers five tracks with seven sessions and two great
keynotes. This year, the conference is on the 18th and 19th of November in Berlin.
Episode 73 of CppCast with guest Guy Davidson recorded October 5th, 2016. In this episode, we discuss updates to the Compiler Explorer and a new boost release.
Then we talk to Guy Davidson, Coding Manager at Creative Assembly.
Guy gives us some updates from the SG-14 working group,
including his ring buffer proposal. Welcome to episode 73 of CppCast, the only podcast for C++ developers by C++ developers.
I'm your host, Rob Irving, joined as always by my co-host, Jason Turner.
Jason, how are you doing today?
I'm doing all right, Rob. How about you?
I'm doing pretty good. I upgraded my audio equipment a little bit after some feedback we received from CppCon. I can't remember the listener's name, but we had a nice talk about the show and he actually asked if he could buy us some audio foam, I think.
So I went ahead and bought this little setup. So there's some audio phone behind my microphone now,
which should hopefully prevent any echo, which he was complaining about. So hopefully that's
going to be better. So this is not something we have in the news items or anything yet,
but I did just notice that our video went live from the conference. Oh, really? Okay. I was
checking this morning. I hadn't seen it yet. Awesome. It was like an hour ago or something.
Okay. And I saw that Practical Performance Practices was up earlier in the week as well, right?
Yes. Yes. So I think it's pretty much every video from the conference is up now. Pretty much.
Well, do you see what the count was? I know it was like 66 or so when I checked this morning.
It was, but since I know they just uploaded a new batch because ours went up,
I'm assuming it's
probably pushing higher than that now okay awesome well at the top of our episode i like to read a
piece of feedback um this one is kind of long so i'm just going to summarize it but we actually
got an email uh a couple weeks ago from a listener in uh switzerland and oh Sweden, I'm sorry. And he wrote in that there was a C++ user group in Stockholm,
but it wasn't active.
And he listened to our episode from a while back with Jens Veller,
and it kind of inspired him to want to restart this C++ user group.
He met up with two other developers in Stockholm who also listened to the podcast, and they started the user group he met up with uh two other developers in stockholm who also listened to the podcast
and they started the user group up again and they in addition to doing the user group they did an
evening conference with a bunch of c++ talks and i got a second email uh just the other day
with pictures they took of this c++ conference they did, and one of the attendees was wearing one of our shirts, Jason.
Hey!
Yeah, so we made it all the way over to Stockholm.
And it looks like the user group is becoming very active.
So congratulations on starting up the Stockholm C++ group again.
It's great work.
You know, I've been pondering starting up the Denver C++ users group again.
So if we have any listeners out there in the Denver area who would be interested, give us a shout out.
Give me a ping.
Great idea. Well, we'd love to hear your thoughts about the show as well.
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 reviews on
iTunes. So joining us today is Guy Davidson.
Guy is the coding manager of Creative Assembly, makers of the Total War franchise, Alien Isolation, and the upcoming Halo War sequel.
Guy has been writing games since the early 1980s.
He's now also a contributor to SG-14, the study group devoted to low latency, real-time requirements, and performance and efficiency, especially for
games, financial banking, and simulations. He speaks at schools, colleges, and universities
about programming and likes to help good programmers become better programmers. Guy, welcome to
the show.
Thank you, Rob. Nice to meet you all.
I've got to ask you what your first game, though, is that you programmed in the 80s.
Right, that's going back away. um well i didn't really give it
a name back in those days games were it was space invaders or asteroids or something like that and
if you wrote a game then it was it was something like what you would see in the arcade i mean
we're talking 1980 here not just the 80s right right at the beginning of the decade was when i
wrote the first game um I probably called it Downfall
because it probably involved something
scrolling down towards you.
I'm going to also expose
my nerdiness for a minute and say
I'm actually definitely going to check
out the Total War
Warhammer game that you
guys are working on, right? Oh, we've released it.
Is it released now? I'm going to have to check that one out because I grew up playing some Warhammer game that you guys are working on, right? Oh, we've released it. Is it released now?
Yes, by now.
I'm going to have to check that one out
because I grew up playing some Warhammer.
That was fun times.
You will be delighted.
Yeah.
I can assure you.
And for listeners who haven't heard of Warhammer,
I'm not speaking about a video game.
It's an actual game where you get little mini figurines
that you paint and put on a battlefield.
But now with this video game
you can do it with a lot less effort i'm guessing yes you know i i don't know when warhammer got
started but i remember it was sometimes somewhat popular when i was in college so i think that
shows not only your age your youngness and your nerdiness at the same time i think i was playing
in high school not in college yeah and i think it's been around
for for longer than that though probably i don't think it was new when i was playing yeah okay well
we we uh have a couple news items to read guy uh feel free to jump in on any of these and then
we'll start talking to you about sg14 okay okay far away so uh this first one there's not a blog
or news article,
but we've talked about Compiler Explorer before,
obviously when you had Matt Godbolt on the show.
And he released an updated version of Compiler Explorer.
And one of the new features, I'm guessing,
is something that actually came from your work with him, right, Jason?
Being able to show multiple compilers?
Well, so he had done that work, and i think maybe someone else contributed to it also and had it ready to go on a branch on his stuff
and then suggested maybe i wanted to use it in my plenary session ah okay so that was kind of the
first maybe i don't know big public exposure of it but yeah it's all fully live now yeah so it's
pretty cool you can just
add new windows uh is there any limit to how many compilers you can be running i haven't tried yeah
give it a go i'll tell you what i the first time i saw this this miracle of the modern world was
at your session jason when you were were demonstrating the no overhead abstractions.
And my breath was taken away, quite frankly.
And it appealed to me particularly
because I started coding in the 80s in 6502 and Z80,
and suddenly seeing assembly on the side
as I'm writing the code, it was refreshing.
And also it did reinforce the fact that c++ is
you know zero overhead abstraction um yeah and but you know when i started at um creative assembly
do you know what i'm leaving ahead here it's great why don't we everyone should use it just
you know once in a while yes if you've got any question about what your compiler is doing, go to the Compiler Explorer. It will answer your questions.
Yeah. Okay, so the next one is a new O'Reilly book, which was released, and it's available for free as an e-book.
And it's Practical C++ Metaprogramming by two of our previous guests, Edouard Aligand and Joel Falcu.
Yeah. I have not yet read it.
No, I haven't either, but I'm sure it's a really good resource
and I believe they both gave talks
at CppCon this year as well.
They did. I find that a really optimistic
title, Practical C++ Metaprogramming.
I don't
know about you, but I can't say I use it much
day-to-day, although I feel like I should.
An awful lot of coverage
has been produced about metaprogramming.
It looks really
awesome and amazing.
I haven't read the e-book either, but it's certainly on my
to-read list.
I feel like every C++ programmer,
people who use C++ every
day, should at least know
what people are doing with
metaprogramming, even if you don't have a need to use it.
Exactly.
It seems like that might be the goal of goal of this book is to kind of show you some
basic metaprogramming techniques and they say, set up your metaprogramming toolbox.
So they're trying to make it more practical, I think.
Yeah.
Well, I've heard it said that the metaprogramming, you know, the template system is Turing complete.
You can, you can do everything.
Yes.
Yeah.
So, well,
gosh, we'll see. I'll read it.
I'll see what everybody else says.
It's quite a challenge, though,
isn't it, really, looking at that code and all
the braces, all the angle brackets.
It's a sea of text in front of you.
Yeah.
And really, truly, the hardest
part is getting the compiler to give you
meaningful errors when you make a mistake.
Yes, I wonder if concepts will help this, which seems to be my refrain now.
Okay, and the next one is Boost 1.620 was just released last week.
And that's fitting since we were just talking about some Boost libraries last week.
I don't see it mentioned here.
The Boost process, boost process what's still
just being proposed but um what was the other one we were talking about last week jason mingle dll
right so i believe that's in that it's just not mentioned here in the release notes yes yeah the
the two libraries that are mentioned are fiber which is a new framework for user land threads
and fibers and qvm which is a generic library for working with quaternions
vectors and matrices that's something i never use yeah it actually mentions us using graphics
and video games is that something you're familiar with guy i i have a passing acquaintance with
vectors and matrices yes and quaternions um well yeah it's the first one that I don't know how to pronounce, that I don't know what it is.
Quaternion.
Okay.
Yes, I would say it sounds like it reads, but it possibly doesn't.
If you say quaternion, everyone will know what you mean.
Well, they'll know what the word is.
I'm surprised at the number of programmers I come across
who don't actually know what a quaternion is.
Well, then go ahead and tell me what it is.
Oh, gosh, no, that's very dull.
Read the library. It's fine. It really is fine.
Okay.
Four-dimensional complex numbers. That's a start.
Okay.
And the next thing we have is a new library called Argate for instruction trace visualization.
And they have some cool videos in here that basically show a live graph of, I guess, a program running.
I'm not really sure what use one would get out of looking at this, though, to be honest with you.
It's a great screensaver.
Yeah, it's kind of beautiful.
But, I mean, I guess they do show that you can do heat mapping with it
and see what the heavily used calls are.
But, you know, they have this pretty looking live graph.
I don't think anyone could get any useful knowledge out of that.
Well, you say that.
I do wonder if it's like learning a language.
You know,
I'm just learning Spanish at the moment.
One of the things I'm doing
is listening to lots of
Spanish podcasts
and news broadcasts
and things like that.
I don't understand a word,
but stuff is going in
and bits of vocabulary
are becoming more apparent.
And in the same way,
I would imagine that
repeated use of this
facility of pretty graphs
describing what's going on,
you would start to see pictures.
It's like looking into the matrix, isn't it, really?
Yeah.
This is what it's all about.
It's stuff zipping about from node to node.
Our listeners really must click on this and look at it.
Yeah, otherwise they're going to have just no idea what we're talking about.
Yeah.
It's just one you you got to look at. When you click on it,
I want you to imagine the three of us
each staring blankly into our screens watching this.
Because that's what's happening now.
It is what's happening right now, yes.
Okay.
The last one.
Jason, you've been using the CPP Slack group a bit, right? Yeah, I've been using the CPP Slack group a bit, right?
Yeah, I've been using the CPP Slack group.
And so I just wanted to give another mention of it.
We'll put a link in the show notes for how to sign up for it.
But there's, I don't know, maybe a dozen people or so that are pretty active right now on there.
In fact, they're chatting at this exact moment.
Asking all kinds of C++ questions and getting usually you know um usually
someone's around to give you a good answer and that kind of thing it's pretty cool and you were
having a pretty active discussion when you were working on your talks right with matt at least
oh uh yeah i've had some conversation with matt when he was um helping me out getting the beta
stuff going yeah yeah i i have joined the group, but I'm just lurking right now.
I haven't contributed much there.
Okay, well, we are going to start talking to you, Guy.
Your CppCon talk actually just went live today as well.
Do you want to tell us a little bit about
what your role is with SG14
and what you talked about at CppCon?
Well, my talk at CppCon was a review
of the past year's efforts on SG14.
Describing my role is a bit tricky because really there aren't any roles in SG14. There's a chairman.
Actually, there are two co-chairs, Michael Wong and Sean Middleditch. And then there's everybody
else. The standards body is an entirely voluntary organization.
There aren't any paid roles, as far as I'm aware.
People are sponsored by their employers,
or they fund themselves to go to the meetings and to decide on what goes into the standard.
You know, the standard is designed by the people who turn up,
an excellent metaphor for modern politics, really.
And, you know, all I do on SG14 is i send mails in saying here look here's
a great idea why do we have a ring buffer why don't we have like a buffer that you can use to
communicate between threads but only takes up a fixed finite amount of space that'd be great
wouldn't it and then lots of people go yeah yeah that'd be great why don't you knock one up yeah
all right i've knocked one up look i've written a paper as well why don't you we can submit the
paper to the committee and and the committee can vote on it and go, yeah, that's brilliant.
And that's really what all of us who are in SG14 have done.
And being in SG14 is a strange notion as well
because SG14, I suppose, is a Google group.
That's really it.
We communicate on a Google group called SG14
and exchange
views and talk about
what we need in games, what would make
C++ better for
games, for financial
trading, for low latency,
efficiency, all the kind of things that
bug us, that annoy us about the language
that we wish we could
just squeeze
that little bit more performance at,
particularly as a study group.
It's the 14th C++ study group.
It's directed towards a constituency of users
rather than a particular feature.
So there's an awful lot of,
we'd like this, please.
Which is fine if it's possible.
So I don't really have a role role I suppose I started at the GitHub
and I talk about it
and I've done a talk
I've done three talks
no two talks now
at a couple of conferences at CppCon
and at ACCU
in Bristol in England
earlier this year
and I've got another one up at
albeit in
Berlin at Meeting C++.
I shall be giving
another variation of the talk.
And also I'm
speaking, I believe I'm speaking at Code Europe in
Poland in December. I'll be
talking again. So I evangelize quite a lot for SG14.
I try and encourage people to join in.
Because it's the only way we're going to make the language better.
If there's something you don't like, then propose an alternative.
It's that simple, really.
So you have yourself made some proposals, right?
I have indeed.
The proposal I have started working on is the ring buffer, as I described,
which is, it's like a cube, but it's in a fixed amount of space.
When you get to the end of the allocation, you go back to the start of the allocation,
and it's a cyclic buffer, circular buffer, ring buffer, ring FIFO.
There are so many names for it, as I discuss at length in my paper,
and as was indeed exposed to me when I first proposed the object.
Lots of people said, it's great, but why don't you call it this?
And I was astonished that that was the sole comment people had,
was call it this rather than why don't you make it this? And I was astonished that that was the sole comment people had, was, you know, call it this,
rather than why don't you make it, you know,
single processor, single consumer,
or multi-producer, multi-consumer or something like that.
The names seem to be the most important thing.
But yes, you know, that's the...
It's a simple object,
and it's manifestly missing from the standard,
because I'm sure everyone's written one.
Well, everybody in games will certainly have written a ring buffer
because it has
a fixed amount of memory. There's no
allocation going on whilst it's operating.
So is the idea that you throw
away old data?
Say you
have expanded
you've used
all of the space.
What happens?
There are two options um stood q has push and pop oh sorry push push push back and pop front or is it push right and
pop back anyway there's push and pop okay we can agree on that there is push and pop um i've added
two additional commands try push and try pop so push've added two additional commands try push and try pop
so push and pop will overwrite try push and try pop will not overwrite and will signal failure
so you have that you have that choice and it's important to make that part of the interface
because uh it's a concurrent ring you can have a producer and consumer working on separate
threads which means that any operation which inquires,
is it full or empty, is going to have to be atomic.
And you can't simply query the object,
are you empty?
And the object says, yep, I'm empty.
And then in the next command, push,
because somebody else might have filled it up.
So the importance of being able to do all your operations
atomically as part of the interface is primary.
That's interesting.
As far as I know, none of the standard containers are currently thread safe.
I don't believe they are.
I know that there have been proposals.
Lawrence Crowell, I believe, in paper N3353, obviously, did a proposal for a concurrent queue.
But I don't believe that's been voted in.
I hadn't actually thought whether or not it's the first one.
I suppose, yes, it is significant that it's the first one.
If it goes down well, then I imagine the interface
and the mechanism could be adopted for concurrent queue
as well as concurrent ring.
Well, so just to clarify, all of them are multiple reader friendly because all the read methods are const and those are guaranteed to be acceptable in thread situations.
No.
Yes, here's where it becomes tricky. The read is not const because we have, you know,
we've actually got a pointer in there that says,
okay, well, what's the back of the queue now?
And so we're going to have to change the object to say,
right, the back of the queue is here.
Right, now the back of the queue is here. Oh, no, I meant in the existing containers.
Oh, in the existing containers.
Yes, yes.
Right, okay.
So I'm sorry, go ahead can finish your discussion what you're
doing in the ring yeah uh can you repeat the question sorry so it's a bit lost there the
threads fell apart there yeah sorry so i guess in a read on your ring that you do have to have
some thread safety mechanism in there because you are moving
the pointer forward?
That's right. Well, there's not a pointer.
There's an index. Because it's a finite,
because you know the size of the thing, you can say,
well, which is my read index and which is my write index?
And it will
obviously wrap around once it gets to the
end of the allocation. So the thread
safety is required to
maintain the correct value of the index
but it being an index, we've got
atomic operations
which accommodate
all the safety.
I'll be publishing the paper very
shortly, within the next
couple of weeks. I'll pop a link up if you like and you
can read it.
I'm much better at writing this than I am at suddenly
explaining it on the fly.
So that was going to be proposed
for C++20, I guess.
Has SG14 made any proposals
that made it into C++17?
Yes, one was made by
Brittany Friedman. This is
a proposal for
uninitialized memory operations.
When you want to build
containers, at the moment,
you're doing an awful lot of low-level memory stuff.
You're rolling that by hand.
And the standard libraries,
or the implementations of the standard library,
already have implementations
for doing things like allocating raw memory
and copying into raw memory from somewhere else.
But because it's not part of the standard, they have their own names.
By effectively lifting this out of the private implementation of the standards
and making it public, then it makes it much easier to write your own containers.
And this is a very important thing for us in our environment
because we very, very rarely use the standard containers.
At the very least, we'll operate
our own allocators, but for things like
map and associative
containers,
cache coherency is so
important that we simply can't use
containers which are
derived from
red-black trees, for example, which is
standard implementation for map and set, I believe.
So you'll see that an awful lot of...
I've not worked somewhere that hasn't had its own cache-coherent map.
And that's one of the other proposals that hasn't made it into C++17,
but that's also in flight.
There's a proposal for a flat map and a flat set
where the
primary feature is that
the objects are stored contiguously so you
can iterate through them in a very cache-friendly
way. Okay, so a
question I had
when you mentioned your ring
buffer, and sorry to
make you go back to it since you don't
feel comfortable describing it all, but
you said you can signal failure if you'd have a try push and I'm curious in what mechanism
you signal failure since exceptions are one of those things that game developers seem to
shy away from yeah it doesn't send exceptions it'll return a flag returnables exceptions
we do shy away from them it would. It would be false to say that
exceptions suck like
the raw vacuum of space.
But it's not
far off for us, frankly.
Exception
handling in the 64 bits
on x86-64 is
better than it was on x86.
The code does not get so
filled up with...
Individual functions don't get so littered
with exception handling code.
But the fact still exists
that when you switch exceptions on,
your code bulk will increase.
And even if the performance is trivially different,
if the performance speed is trivially different. If the performance speed is trivially different,
the fact that you're taking up extra space
with the exception handling code
is inappropriate for an embedded system
where every byte counts.
You don't want to spend even 1% of your memory budget
on code that should never be executed.
And another aspect of exception handling
is that if a game
throws an exception,
so what?
No one's going to die.
This is not heart monitoring.
This is not a nuclear power plant. This is not an airplane.
If a game crashes, oh dear,
it's crashed. Sorry.
Shall I start again? Brilliant.
Okay, where were we?
Lovely, let's carry on.
It's a moment.
I mean, I'm possibly... I have had users get really quite irate when games have crashed,
so I'm possibly being a little glib.
But a little irate at a game crashing is not the same as somebody dying
because the plane's just fallen out of the sky.
So our view on the
value of exceptions is
lower. We would
prefer not to use exceptions.
The ring buffer
does not throw exceptions.
The code that we write
doesn't throw exceptions either.
We might handle it.
Gosh, do you know what? Really, it's about non-deterministic
input. Games have
so little input. You know exactly what's
going in. You're getting input from a
controller, and that's it.
That's the only thing that you don't know about,
is input from a controller.
So you should be able to handle
anything, really.
I suppose input from the file system as well, but even then,
the data is yours. If anything
goes wrong, it's because the machine has gone wrong.
And again, it's not something you can deal with.
Exceptions are only useful if you can deal with them.
If you can't deal with them, then there's not really much use for them.
Since we're on the topic, isn't SG14 making some recommendations for exceptions?
We're chatting. That's about the extent of it. There are several
papers in flight. No, that's not true. There aren't several papers in flight. There are
several conversations in flight about how to deal with an alternative. We have things like
expected disappointment, and there are all sorts of words floating around. Actually, I think expected is also
being co-opted for loop unrolling
or for branch prediction as well.
But there are several words floating around.
But the thing is, obviously we have
this great bulk of code
which does
which is exception safe.
The last thing we can do is
say, right, no more exceptions. Everybody get rid
of them. Thank you very much, because
that would kill, goodness knows how
many millions of lines of code. It has
to stay, but
we would like an alternative.
There's lots of chatter,
but I'm
not sure that we have any firm proposals yet.
I'm ready to be corrected here.
I don't think they're only coming from SG14.
SG14 is not the only source of proposals there.
Plenty of people will just submit straight to the library working group
or the language working group.
So the things you are talking about are all alternatives to exceptions,
you're saying, right?
Not some sort of way of making exceptions themselves better?
That's right.
Exceptions, let me get this right.
Exceptions, gosh, this is a little bit complicated.
We can't change the behavior of exceptions.
There's too much code in there.
We can't stop exceptions from requiring stack unwinding
and finding the handler.
There's nothing we can do about that.
And that's where the expense is.
The stack unwinding means destroying objects,
going to the stack, calling the destroy,
and retreating the stack pointer.
That's got to be done if you're going to jump out of your function
and jump somewhere else.
And that's where the weight comes from with exceptions.
That's where the heft, the bulk of exception handling comes from that we want to avoid is all that extra stack and winding code.
Okay.
I wanted to interrupt this discussion for just a moment to bring you a word from our sponsors.
Backtrace is a debugging platform that improves software quality, reliability, and support by bringing deep introspection and automation throughout the software error lifecycle. Spend less time debugging and reduce your mean time to resolution by using the first and only
platform to combine symbolic debugging, error aggregation, and state analysis. At the time of
error, Bactres jumps into action, capturing detailed dumps of application and environmental
state. Bactres then performs automated analysis on process memory and executable code to classify
errors and highlight important signals such as heap corruption, malware, and much more.
This data is aggregated and archived in a centralized object store, providing your team
a single system to investigate errors across your environments.
Join industry leaders like Fastly, Message Systems, and AppNexus that use Backtrace to
modernize their debugging infrastructure.
It's free to try, minutes to set up,
fully featured with no commitment necessary.
Check them out at backtrace.io.cppcast.
Do you want to talk to us a little bit about
what you're doing at Creative Assembly?
Yes, certainly.
So my role is Coding Manager,
which actually was a role made for me.
There was a bit of shuffling going on.
Some people had to be moved up because they were awfully good at their job.
And I was given an opportunity to take on a more educational role, possibly.
When I originally started at Creative Assembly, which was back in 1999,
and it was called The Creative Assembly, and there were 30 people.
There's 455 now.
Yes, indeed.
We're quite large.
But when I first started there, there weren't really any C++ programmers of longstanding working there. The last product that was there had been written in C
and there was this desire
to move into C++,
particularly for the safety
that was already afforded
by protected and private keywords,
the notion of encapsulation.
I think encapsulation was the thing
that drove it ahead most of all.
I was brought in to help out
with bringing some C++ knowledge
into the company.
And I did this by just sending out
Tip of the Week.
You might recall Guru of the Week
from long ago.
So I nixed that name
and called it Tip of the Week instead
because I don't know,
Guru is not something we use very much.
And also I really didn't want people
to see me as a guru because I'm i'm not you know i've just written
i've just written a lot of code and read a lot of books you know that's all um and so i sent out tip
of the week for a couple of years and people really lapped it up um and then as time went on
you know i was i found myself you know offering more and more advice about how to write
good code and things like that.
And it was formalized, really. That role
was formalized, and I became
the coding manager, and my job is
promoting
best practice and making good programmers
better programmers and encouraging people to write better
code. And if people ask me for a code
review, I'll give them a code review. I really, really
will.
But I also, I'm still
programming. I'm still writing code.
I look after the
platform abstraction layer
in Total War.
At the moment, our abstractions are really between versions
of Windows, but we did do
a version of Total War Attila
for Linux and OSX,
which we were really quite proud of.
It didn't sell massively.
There simply aren't that many
users, but
we did do the port, and we did
manage to get it all working nicely.
We had to do an OpenGL renderer. That was
non-trivial.
But yes, I'm writing
platform-specific code.
That's really the extent of what I do.
I keep the platform abstraction layer taking over
and keep the infrastructure going.
I'm running our build systems.
No, so I'm not running our build systems.
I'm running the fast build system
and making sure that that works.
I don't know if you've used fast build,
but it's an absolute godsend.
It's fantastic. If you've got
more than a thousand
files of source in your project, you'll notice
a benefit straight away from using
FastBuild.
Yep, that's it.
What does it do? I think we've talked
about FastBuild before. Is that where
all the source files are put together?
That's right.
FastBuild will create Unity files.. Fast Build will create Unity files.
Fast Build will create Unity files,
and you get less opening and closing of files.
You get less...
The include guards...
Effectively, the include price is eliminated.
Right.
Okay.
So you help manage the best practices in your company,
you said.
Do you have any favorite things that you would like to share?
Ooh,
a lot.
I knew you were going to ask me this question.
I absolutely knew.
I thought,
actually,
you know,
the first,
the next post I'm going to be writing is called don't hide dependencies.
And it's really easy to hide dependencies.
We have...
So the Total War project,
we've got so much code.
We've got tons of the stuff.
There's millions and millions of lines of code.
It's a very big project,
but we have the teams divided up
into a graphics team
and an infrastructure team like mine, a SAN
team, and a UI team, and a multiplayer networking team, and all that sort of thing.
And notionally, each team has a set of headers that they expose to the public, and obviously
the private implementation that sits inside it.
And that works fine, as long as nobody decides they need access to the private implementation that sits inside it. And that works fine as long as nobody decides they need access to the private implementation of the code.
And then what happens is people type hash include, pound include, sorry, for our American listeners, open quotes.
And then you'll suddenly see dot, dot, slash, dot, dot, slash, dot, dot, slash as they escape the current project
and then go into the
project they're interested in,
sound, slash, source, slash,
whatever, and
reach into private implementation.
And it's quite easy to do that. You think, you know what,
I just need that function
that they've exposed there. That's all I need.
And
things can start to unravel very badly
because obviously the person who implemented SAN
doesn't realize that somebody else is depending
on this private implementation.
And it's just like, you know,
it's the encapsulation problem all over again.
It's just like public-private protected.
You know, except that with that, when you write friend,
at least you're the person writing friend in the class.
When somebody, when a complete stranger comes along
and dives into your private implementation
just by going dot, dot, slash, dot, dot, slash, dot, dot, slash,
then you're absolutely doomed.
There's nothing you can do.
And it's a bad deal.
So not finding yourself, not hiding dependencies is my big one.
And it's not the only way you can do it as well.
You can, with the linker, you can find yourself inadvertently linking to libraries that aren't necessarily authorized.
For example, we develop in Visual Studio.
And there's a pragma which allows you to
embed in the code which library
you need
now that means it's completely invisible to me because
I build the projects
with
everything on the command line so you can see on the link
here right we'll have this library, this library, this library and this library
lovely those are the ones we need to worry about
those are the ones we need to get licensing clearance for
those are the ones we need to buy about. Those are the ones we need to get licensing clearance for. Those are the ones we need to buy licenses for.
And then if suddenly somebody snuck in the library through a hash pragma,
then again, the dependency is hidden.
So right now, hiding dependencies, that's my big tip.
But there have been tips all through the years that people have gone,
oh, that's a really good idea.
Nouns and verbs.
Interfaces with nouns and verbs.
Nouns for your const member functions and verbs for your non-const member functions.
That makes your APIs really quite clear.
Not using get and set, but actually saying, all right, it's a const function.
That means it's a thing.
It's a property of the abstraction. And if it's a non-const function, that means it's a thing. It's a property of the abstraction.
And if it's a non-const function, that means it's changing something.
If it's changing something, then it's doing something.
If it's doing something, then it's a verb.
So nouns and verbs have proven to be
quite popular with quite a lot of people.
Yeah, what else?
Loads, honestly. I could fill up the rest of the hour.
We could have Guy's Coding Hour quite happily
just on me, iterating through
the coding standards
that we've been putting together over the past
17 years now.
Well, you said you were
mostly a Visual Studio shop. That kind of sets
you apart from virtually everyone
we've had on this show.
That's common amongst games developers, though, right?
It is.
More and more so.
The Xbox and PlayStation development common amongst games developers though right it is um more and more so uh the um xbox and playstation uh development cycle is is now i mean historically the playstation development cycle has been
on a variety of different uh variety of different platforms um mainly linux and you know unix
derivatives and things like that but now everyone's in... All the three major platforms,
Windows, Xbox, and PlayStation,
are all under Visual Studio now.
So you'll find gaming studios
are pretty much exclusively Visual Studio,
which means I don't spend very much time at all
on Linux or OSX.
I did the port, but it was quite a...
I say I did the port.
I wasn't the only person who did the port.
I was ably assisted by Tom Mars.
In fact, he probably did the lion's share of the work, quite frankly.
But my Linux knowledge was
not necessarily up to the job.
And it was
quite a learning curve for me
to get any of it working.
Do you find yourself
at Creative Assembly
or talking with other game developers
using lots of modern C++
or are you still kind of using C with classes?
Well, I advocate using all the features you possibly can
because I think zero overhead abstraction means great.
You can write clearer code.
And so I promote the use of anything that makes the code legible,
more efficient, more performant, faster, better.
Historically, of course, that's not always been the case.
Compiler compliance has been patchy historically.
And if you're writing a cross-platform game where you need your code to compile
on a variety of compilers,
then you've needed to make sure
that you've used the smallest
or the largest subset that each compiler supports.
And so certainly in the 90s
and even in the early noughties,
there was no, you know,
people were very cagey about using,
you know, flashy new features.
But as time has gone on, as the number of compilers
that have required support has diminished,
certainly with Xbox and PC, Xbox and Windows,
it's fine to use anything you like, frankly.
There is less resistance to using newer features.
I think where the resistance does happen is where there's a cost to the abstraction.
So RTT unexceptions, no, we're not going to have that.
And containers which are not cache coherent.
The first thing you're going to do is to use a cache-coherent container. That's probably where
compliance is going to be most carefully
looked at, most carefully examined. So what version of Visual Studio
are you guys up to then for your development?
Warhammer came out on Visual Studio
2013. We've just upgraded on Visual Studio 2013.
We've just upgraded to Visual Studio 2015 for our next product.
I think it's...
Obviously, we're going to carry on.
I can't...
They're not announced, but obviously, we're going to carry on making products.
No, no, actually, no, we're not.
We're just going to sit here and watch the money roll in.
We are continuing to make products,
and we are quite content with Visual Studio 2015.
We're using...
One thing I do like about 2015 is that we have a slash-stood switch,
which says, right, mail everything to C++14.
Although, since C++14 came out,
several things have crept into the standard for C++17,
and Visual Studio has supported those.
It will still support those, but nothing new.
Since that C++14 switch went in,
nothing else that gets added into the compiler during the updates
will be accepted.
And I quite like that because we know where we stand,
and we're not worrying about people inadvertently trying to use modules
or coroutines or things like that, which I am so looking forward to.
Oh, my goodness.
Oh, coroutines.
They make me feel like a god amongst men, really.
State machines suddenly collapse into a function.
It's brilliant.
I can't wait to get my chops around those.
And modules, honestly.
There's so many new things I'm looking forward to.
Actually, C++11, the best thing to happen,
it really revitalized so many people's interest in C++
that suddenly there was this sense that problems were going to be solved
and everything was going to be brilliant.
And it really has been over the past few years.
Problems have been solved and great new features have turned up.
Structured bindings, I'm really looking forward to that.
Although I do wonder if C++ is turning into a performant version of Python now
with structured bindings.
Well, is that a bad thing necessarily?
Not at all.
I tell you what, I cpp cast the thing i dislike about python is white spaces syntax yeah that's that that just
that's that's wrong sorry guys that's wrong it's it's just wrong it's open to abuse though i will
accept the argument that it's a good idea, but it makes their
lambdas virtually unusable.
Because there's no way to format
a lambda that has the proper
whitespace formatting.
Well, there we are.
I don't use Python anyway. I use C++
because it's the best language. Obviously, we all know that.
Oh, and Erlang. We use Erlang too,
but that's functional and strange and weird and i don't
really i don't understand erlang so uh just another question about your visual studio work
uh did you have any problems porting from 2013 to 2015 when you started to move your your code
yes okay yes we did but that was only because at the time that we were porting from 2013,
the code base at that had been in a state where it also had to support Clang
for the Linux and OSX builds.
And at that time, Clang supported auto-generation of all the special functions
and Visual Studio did not.
And that caused us
significant problems coming up with a codebase
that was compliant with both.
And once we moved over to 2015
all the compromises we'd made
basically bit us
badly on the bum.
And I spent
several months doing the port.
But it's all done now.
And actually,
the set of problems
was very small. It was
the number of
instances of those problems that was
actually the problem.
But the migration
was conceptually painless,
if not actually painless.
But I'm guessing that the end result was probably smaller, cleaner code
by the time you were able to get rid of a bunch of if-defs or something.
Oh yeah, the source was much nicer.
Whether the compiled size, whether the binaries themselves were smaller or faster,
it's difficult to say, because obviously whilst I was doing
the upgrade,
the game was still being developed.
So there isn't really a
before and after snapshot for me to make a comparison
against.
I guess, going back to SG14
for a bit, I know
we talked about the talk you gave
along with Michael Wong and Sean Middleditch,
but there was also an SG 14 meeting at CPV con.
We didn't talk about that much.
There was,
um,
that was on the Wednesday.
Um,
so this was a formal ISO meeting,
right?
The group met,
we had an agenda.
We discussed papers that were in flight.
We took votes on papers,
uh,
to gauge the temperature of the attendees.
Basically, if you turned up, you got a vote. That was it.
And
I can't emphasize too strongly
that that's how the language works.
If a bunch of people say,
do you know what, we need to get rid of exceptions.
If like 200 of you turned up mob-handed,
went to all the
meetings and said, right, I propose
we get rid of exceptions, then
you know, actually no, it wouldn't happen
would it? But you know, it would certainly
force a discussion.
I don't know, maybe it would. Ask Herb. Ask Herb
what would happen. What would happen
if two of us turned up and said, right, we're getting rid
of exceptions.
That's democracy for you, I suppose.
Sorry, we had a meeting and we discussed
the things that
we took votes on the things that would
go forward so the ring paper was discussed
fixed point numbers were discussed
the flat containers
they were discussed
and there was all sorts of discussion
lined up but frankly we ran out of time
there is so much stuff of interest
in SG14 that
one day simply wasn't enough.
We ended up, in fact
we didn't even end up finishing all the papers, let alone
moving on to discussion.
But it was very fruitful.
Despite there being so much,
Michael Wong chaired it very well.
He did rattle through a lot of the stuff
very quickly. It was a great through a lot of the stuff very quickly.
It was a great meeting.
It was a great example of how the standard organization works.
I'm quite keen to go to an actual full committee meeting next time they're in Europe.
The U.S. is a bit expensive.
You could go to Hawaii.
It's U.S., but it's closer to the...
I'd love that.
But it's actually further than... Yeah, it'd U.S., but it's closer to the... I'd love that. But it's actually further than...
Yeah, it'd be a long flight.
You go the other way around, it makes it closer.
No, it doesn't, I'm afraid.
Are you being the American who doesn't know his geography card?
No, it's still the wrong side of the dateline.
Yes, the next one's in Issaquah, which is in Washington, I believe.
And that's...
I'd like to see more meetings in Europe.
But again, it's all down to, you know, cost.
People seek sponsor...
Rather, the WG21, which is the C++ working group,
seeks sponsorship for people who meeting space
and people
who turn up are sponsored by
their employers. In fact many of them
pay for it entirely on their own dime.
I could spend
certainly I could spend
$2,000 flying over to Issaquah. I could spend
another $2,000
on accommodation and that's a big wedge and uh yeah you know that whilst there are some
companies like you know like ibm and microsoft and you know all the big players who are quite
happy to send their staff out to you know fly the flag for c++ and who are happy to you know
return to the community return you know return investment to the community, return, you know, return an investment to the community. It's the exception rather than the rule.
Certainly, you know, the games companies
aren't in that kind of position.
We're not, you know, sitting on lakes of money.
You know, we make a game, we sell the game,
we make another game, we sell that game.
There's no kind of long-term income stream.
Well, except for possibly Blizzard and their, you know,
monthly subscription kind of stuff.
But, you know, it's the sponsors who enable C++ to continue developing.
Okay.
Jason, do you have any other questions today?
No, I don't think so.
Okay, well, guys, thank you so much for your time today.
It's been great having you on the show.
Where can people find you online?
Well, I don't really keep a blog. I'm not
great on social media, although you can find me on
HatCat01,
H-A-T-C-A-T-0-1, where I
occasionally tweet stuff.
I am probably going to start writing
a blog about a game engine because it's
several of my chums have asked me to
do this and said, you know, just write a game engine.
Just show us how it could be done.
So I probably am going to start a blog soon.
I don't know, maybe 2022, 23.
I might have some time to do that.
I'm raising three teenage children.
Come on.
It's time consuming.
Also, I fancy starting an open source project.
I met the MAME guy at CPP.
I might start on Mere Drag.
Mere Drag.
Thank you.
Thank you very much.
Mere Drag.
I met him and I fancy starting off on MAME.
So I might start blogging,
but the best way to get hold of me,
look at HackCat01.
Watch out for me saying,
oh, I've started a blog.
That's your best approach
really. Okay.
Well, thank you so much for your time today.
It was great talking to you. Thanks.
Thanks so much
for listening in as we chat about C++.
I'd love to hear what you think of the podcast.
Please let me know if we're discussing the stuff
you're interested in. Or, if you have a
suggestion for a topic, I'd love to hear about that too.
You can email all your thoughts to feedback at cppcast.com.
I'd also appreciate if you like CppCast on Facebook and follow CppCast on Twitter.
You can also follow me at Rob W. Irving and Jason at Leftkiss on Twitter.
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.