CppCast - C++ and Typescript at Ubisoft Massive
Episode Date: March 29, 2018Rob and Jason are joined by Ólafur Waage to discuss the work done at Ubisoft Massive using C++ and Typescript for application development and much more. Ólafur Waage is a Generalist Programm...er at Ubisoft Massive where he works on the Uplay PC client and services. His work focuses mainly on programming with C++ but Python and C# do appear from time to time. In his spare time he plays video games which is not surprising given his job but he also likes puzzles, non fiction audio books and it would be a very strange day if it were not filled with music in some way. News Explore the design of a modern C++ library: MemCache++ case study Usability improvements in GCC 8 My Little Optimization: The Compiler is Magic Announcing Microsoft DirectX Raytracing! Ólafur Waage @olafurw Ólafur Waage's GitHub Links Malmö C++ User Group Massive Entertainment Sponsors Backtrace JetBrains Listener Survey CppCast Listener Survey Hosts @robwirving @lefticus
Transcript
Discussion (0)
Episode 143 of CppCast with guest Oliver Waga, recorded March 21st, 2018.
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.
And by JetBrains, maker of intelligent development tools to simplify
your challenging tasks and automate the routine ones. JetBrains is offering a 25% discount for
an individual license on the C++ tool of your choice, CLion, ReSharper, C++, or AppCode.
Use the coupon code JetBrains for CppCast during checkout at JetBrains.com.
In this episode, we talk about some usability improvements in GCC 8.
And we talk to Oliver Wager from Ubisoft Massive.
Oliver talks to us about mixing C++ developers by C++ developers.
I'm your host, Rob Irving, joined by my co-host, Jason Turner.
Jason, how are you doing today?
Pretty good, I think.
How are you doing, Rob?
I'm doing okay.
It's snowing here again in North Carolina.
Nothing's sticking, though.
But apparently a little further north,
they're getting hit with like a foot and a half,
which is a pretty big deal for the East Coast.
We got snow a few days ago,
but today it looks like it'll be nice and sunny
and I can go on a jog sometime after this.
That's nice.
Anything else you want to share
anything coming up soon um no just lots of training travel things that are disrupting
our recording schedule but uh nothing specific to talk about yeah i guess uh since i talked about
the weather and since we're talking about just opening our recording schedule this episode's
going to come out a week after we recorded it.
We're trying to pre-record a few so that we don't miss another episode like we did two weeks ago.
And I don't think it's entirely obvious, even to our regular listeners, that generally our episodes are quite fresh.
Yeah, usually we record on a Wednesday and put it out on a Friday.
Right.
So our news and everything is just up to the minute as much as we can be.
Yeah. This one's a week behind, but yeah, we won't miss one. So that's good.
Okay. Well, at the top of our episode, like through a piece of feedback, uh, this week,
we got an email from Gerardo Hernandez. He wrote in, thanks for hosting the show. It really helps
maintain a sense of community and C++ world, especially for those who cannot
usually attend meetings. I'm a
C++ developer based in the south of England,
and would like to suggest one topic,
Ccache. The C++ world
tools to speed up compilation times
are still really important, and Ccache
is awesome. First created by Andrew
Trigel, is now actively
maintained by Joel Rostal.
Reading the code in GitHub, it seems to have very good quality,
and it'd be great to dedicate an episode to Ccache
and related tools like DiskCC and Credibuild.
So we did do that episode on Credibuild a while back,
but it would definitely be good to talk about Ccache.
Yeah, it could be definitely interesting
if anyone wants to come on and talk about
basically the open source
environment i guess ccash and dcc how those things can work together and how you might be able to use
that for your builds yeah i think i sent an email to joel but did not get a response back but uh
if anyone listening knows him or is a contributor to ccash and would like to be on the show
let us know okay and 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 cpcache.com
and don't forget to leave us a review on
iTunes. Joining us
today is Oliver Uwaga.
He's a generalist programmer
at Ubisoft Massive where he works
on the Uplay PC client services.
His work focuses mainly on
programming with C++,
but Python and C Sharp do appear from time to time.
In his spare time, he plays video games,
which is not surprising given his job,
but he also likes puzzles, nonfiction audiobooks,
and it would be a very strange day if it were not filled with music in some way.
Oliver, welcome to the show.
Thank you for having me.
I'm going to ask you a question
I haven't asked a guest in a while, I think,
but how did you get started with C++?
For me, it was always, you can think of it as an iterative process.
I mean, I started programming because I thought the internet was neat.
Like, hey, you can put a web page up and you just have something online pretty quickly.
So what was the tool of choice then, back then?
PHP3, maybe, depending on when I started.
And then I learned a little bit more, learned about Java.
Okay, Java can do some things.
And then you just keep on going, keep on going.
And it kind of drove me slowly to the low-level world in that area,
but still liking to have the abstractions and the tools that a lot of the C++ has.
So when I went to university, at least the one I went to,
they were like, oh, we're C++ focused.
I'm like, yes, score.
So that's kind of how I went into basically the industry as a whole.
Okay, now I have to ask because i hear so many different stories from university and even
you know my own university like did they teach good practices did they teach what was modern
and considered best practices at the time or was it just like c with objects every now and then
right it was mixed based on the classes uh the i like the introduction courses because they were
like we're not going to talk about classes we're not going to talk about all i like the introduction courses because they were like we're not going to talk
about classes we're not going to talk about all the like the modern day because also this was in
like 2007 yeah i'm making me feel old i mean i'm also like i started when i was 30 i didn't go
directly to university oh okay i was in like I was working as a web programmer for a while.
So yeah, I went into the university late because I felt bored.
I wasn't learning anything new in the web industry.
So I was like, I want more.
So I went to school with a two-year-old having to transfer to kindergarten and school after that.
So yeah, the introduction courses were basically
like here's a function here's a variable um let's talk a little bit about algorithms and it ended
with like iterators i think like here's a here's a thing and you can do with a vector uh but then
you had the next classes okay we're going to do class Okay, we're going to do class. After that, we're going to do algorithms.
After that, let's talk about...
Yeah, so it was like four or five,
like the mainline classes that went down,
like slowly evolving, slowly evolving,
up until you went into compiler design.
That was kind of one of the last ones.
But it wasn't at all, I think, focused on what we call now modern C++.
Okay.
Or like C++11 and beyond.
Yeah.
So most compiler classes that I am aware of,
by the end of the semester you have implemented some sort of a simple compiler.
Yeah.
What did you do? I'm curious.
So it was a compiler for a pascal like language which was
it was a pascalite because for parsing reasons mostly because they didn't want the students to
get bogged down by all the little parsing micro annoyances because the the big project the
compiler is like at the end of the semester or, is at the end of the semester
or close to the end of the semester,
and you're doing minor projects on the way.
So yeah, they didn't want to sit there like,
oh, but what if this and what if that?
So it was very parsingly easy.
And the idea was to just convert it
from that Pascal-like language
to another language type,
which they then had an interpreter for.
Okay.
So the idea was let's focus more on what is the idea of a compiler
and what is the purpose of a compiler
rather than having something super low-level
because what is going to be running on the computer,
sure, okay, it's going to be some instructions.
What are those instructions?
I don't know, and I kind of don't care,
because that's not mainly the point.
You can go into, like, assembly instruction classes
or, like, any kind of those kinds of things,
but the idea was, what is compiler?
Why do we need it? What does it do?
So that was kind of the focus of the class
That makes a lot of sense it sounds like
I mean you don't want to make parsing C++
to be your first introduction to compiler
since that's nearly impossible really
Yeah, there are Wikipedia articles about how troubling it can be
Yeah
But there are two universities in iceland that are yeah there
are two of them don't worry the first one that like the main one is more uh how could i say this
we could say the second one is more practical focused about like practicality and the first
one is more theory focused. You would have people
not only writing functions,
they would have to then define
the pre and post conditional
expectations for every
single function you're writing.
Even though that's not done much,
at least not that I've seen.
So the university
I went to was just more on the practical
side. As I understand, university is inexpensive so the university i went to was just more on the practical side and uh as i understand
university is inexpensive for icelandic residents is that yeah the first university is free okay
the second one does cost uh but it's not much um and you can get a loan for it from basically
there's an institutions that will loan you for the university and that is a kind of
a loan that like it doesn't carry on to your children and it's very cheap as well and mostly
what you will take is like loans that so you don't have to work while you're studying okay so you'll
get living expenses up to enough that you can actually rent apartments and food and a car and
everything that's pretty cool that's and food and a car and everything.
That's pretty cool.
That's pretty good.
And it's similar here in Sweden,
and probably even cheaper,
where in some cases, if you go up to a doctor's level,
they will pay you for being a doctorate student.
Wow.
That is different than I know the people who have gotten doctors.
I don't know if it's still like that, but that was the story I heard.
They want people to, they want specialty.
They want knowledge in the community.
So they should have incentives, basically, for it.
Okay.
Well, Oliver, we got a couple news articles to discuss uh feel free to comment on any of these and then we'll start talking more about
the work you're doing at ubisoft okay yep okay so this first one uh was on cpp depend and it's
kind of a case study exploring the design of the c++ library memcache++. And Jason, have we spent much time talking about CPP depend
on the show before?
I feel like it's been brought up,
but this case study did a pretty good job
of showing what this tool is capable of.
It's pretty interesting.
Yeah, to me, the thing that's most interesting about it
is if I'm reading this correctly,
it effectively builds a database of your code
and then you can run queries against it.
It's pretty cool. You can run queries based on different types
and properties of types within your code.
In this library, he used it to explore
memcache, like I said, and explore different namespaces,
what type of programming
concepts were used, whether it was object-oriented
or template-based.
And yeah, it was
a pretty interesting article, and the tool
looks pretty powerful.
It does. I totally agree.
I would wonder, actually, what would be the...
Because it seems to be
a tool that's been up for a long time,
because I bump into articles by CppDepend from time to time
where they're using this tool and see what we can do with this tool.
But I've never actually used it myself,
so I'm wondering on a pretty significant code base,
what are the edge cases there?
Because the code base being looked at there, at least, it's not big.
It's about 600 lines
apparently by the from the article yeah that's a good question i don't know like and ultimately
what would be the use case of could you run you know transformation against your code or something
could be very interesting if you could transform the code i'm not sure if it supports things like
that but it does look like the the tool at least has a free trial i'm not sure if it supports things like that. But it does look like the tool at least has a free trial.
I'm not sure how much it costs, but if your listeners are interested in trying it out, it does seem to have a free trial at least.
Right.
Okay.
Next article is usability improvements in GCC 8.
And this is written from David Malcolm, who works over at Red Hat. And he's just going over some of the error description improvements
that went into the latest release of GCC that he worked on.
And they're pretty good improvements.
Some of these errors were pretty cryptic before.
And it's really simple things like the placement of a semicolon
points down to the next line instead of the line where the semicolon is missing.
So definitely some good improvements here.
There was one interesting thing about this article when I saw it originally was
probably only in C++ is there an article
about usability improvements in the compiler that starts with a quiz
about the language itself.
Well, yeah.
And this is kind of one of the things that when people started using Clang and LLVM
would point to saying like,
hey, look at what Clang's doing.
So I'm really happy seeing GCC
pulling your weight now as well.
Yeah.
And it's one thing down here
I think gets totally lost in the middle of it
that I don't believe Clinked can do.
And no, I've just lost it.
There we go.
F diagnostics generate patch.
If it knows what needs to be fixed,
it can generate a patch file for you that will automatically apply the fix.
That's pretty good.
That's pretty neat.
The fixes that it's generating there are to include a couple of the
standard headers is that something that lvm is able to do suggest which headers you might be
missing if there's like an unknown type in your code well that was pretty impressive too i know
most ide's can do that now sure i don't think Clang itself can do that, but I could be wrong.
I did just notice, though, that it's actually generating the wrong includes for a C++ file,
since the example is supposed to be C++.
I mean, it's an article about C++.
Actually, no, the example itself is a.c file, but it makes me really curious,
because it is including stdio.h
and if this were a C++ file, it should be including
cstdio.
I think he's showing that it works for both
C and C++.
There's that example and then lower down
he's showing
this other example using std string
and std string is not recognized
and recommends including string.
I also imagine that this is only working for basically the includes that the compiler knows about already that are built in.
It wouldn't go looking in your code, I guess.
Yeah, I know.
The article even says something like looks for a few hints that were common issues.
Added hints to telling you which header files are missing
for the most common cases, right?
I could certainly see that being the next step
if you wanted to go further with this.
If the compiler already knows what your include folders are,
then maybe you could go and find one.
Yeah.
Maybe.
Could be.
Could be kind of weird to choose
because it might not know the,
if you can think of the include hierarchy that you have.
Right, that's true.
Because for some libraries,
it's like, oh, I have all these header files,
but then I'm collecting them into one header file,
which I then expose as the header file
that the library user should be using.
So you have like this hierarchy,
even though it's not actually a strong hierarchy.
So it might be weird there.
Yeah, basically.
I'm sorry, go ahead.
I'm just saying it's still good to see GCC pull its weight like this.
Oh yeah, and absolutely. Some of these things
are like one of these is
if you tried to access a private
member, it can actually show you
the public accessor for that member
and suggest a fix for
that that's i'm not i have not seen any other tool that can do that specifically yeah that's
that's a nice uh helpful compiler yeah okay and then the next article we have is this is on
belkadan software's website and it's my little optimization
the compiler is magic and it's basically an article about uh string view right jason yeah
pretty much i mean the author goes through great lengths for how you might optimize the search
through a bunch of different strings and then shows that string view can do it better. Yeah.
So I when we looked at this article
I was curious about like
because it doesn't go in great detail about
how better it is
it's saying that it is better and faster
so I ran
it through QuickBench.
Of course.
Yeah, which is by the way a great tool if you have if any listener doesn't know about that I would recommend QuickBench. Of course. Which is, by the way, a great tool if you have
a question. If any listener doesn't know about that
I would recommend QuickBench because it's wonderful.
Yeah, so I
put in all the cases
and the functions that he had
and the first three are about
the same. Yeah, there is a benefit from it
but that last one, the recursive
swing view, or recursive, it's the
templated swing view,
it's about a factor of two faster.
Oh, okay.
So I was kind of shocked.
I was thinking, oh, it would be good or fast,
but it's a significant improvement,
at least in this kind of case,
which I felt was a little contrived,
but it's still a case for looking
at string view and what it can do. If I may make a couple of comments on the actual code, though,
has attribute always inline? And I'm looking at these functions going, well, both of these
functions can actually be constexpr. And if you make them constexpr, then there's no reason to try to force the inliner.
The compiler's more likely to inline it anyhow.
And GCC, in fact, did inline it when I made it constexpr.
So you could just make them constexpr,
get rid of the attribute lookup,
and then depending on what you're doing
further down in the code,
probably get some of these string lookups
actually happening at compile time too.
But I'm always thinking about constexpr.
You are.
I am.
You are.
We have proof of that in various forms.
Various forms, yes.
Okay, well, Oliver,
can you tell us a little bit about
what it is you do at Ubisoft Massive?
Because you're not working on the games themselves, right?
You're working on other software that supports the games?
Yes.
So I work on the Uplay PC team.
And Uplay is a gaming client, launcher, etc., etc.,
basically around any of the Ubisoft games.
So if it's a Ubisoft game on PC
we are involved in some sense
either through the user
launching the game to us, downloading the game
to us, adding friends
joining their friends, getting achievements
yeah, all those gamey
type things, doing patches on games
and
let me see
so I started working there about 4 years ago Um, and, uh, let me see.
So I started working there about four years ago and, uh, uh, basically focused on the client to begin with.
So I was a client programmer, anything with the client structure itself.
And I can go into that a little bit later.
And then about a year ago, I focused more on the service end.
So, because we have the databases about what you own,
when you're requesting a download,
we need to check for ownership
and for, if you can download,
we need to sign the downloads
and all those things,
like security-based things.
And if you're chatting with someone,
we have like chat servers
and we need to think about scalability there.
So my work revolves a lot about, like the things that we always And if you're chatting with someone, we have chat servers, and we need to think about scalability there.
So my work revolves a lot about the things that we always have to think about is the scalability, because it is a lot of people playing a lot of different games.
So I often joke about when someone is talking about what I do is
there is no book about what happens when you have to deal with all the
users at once
you can think of it that way
because we
have a lot of users and
they are connecting, disconnecting
downloading, if a game
is released there's a lot of
users coming to the system at once
a lot of users starting to play games
at once, if a patch is coming
out for a game, a lot of people
automatically download those patches immediately
if there's a problem
with the game, the game servers might
go down and as I
talked about before, we have
SDKs for the game teams
so they can, because
Ubisoft is a big company so there's
a lot of different teams and services
within the company.
And we have to have simple accesses
to all those services for the games.
So the game doesn't have to say,
okay, we want to see your friends
and I don't want to re-implement anything.
Or hey, I would like to unlock achievements
and I don't want to re-implement it again and again.
So if a game might have a problem
and users might reconnect there,
we have to deal with that as well.
Yeah, so if I can go a little bit into the client itself,
like how it's set up.
Sure, sure.
So the client is using Chromium Embedded Framework, so CF.
Okay.
We were, I think, one of the early
ones to grab that framework
because what we wanted is
we want a desktop UI
without having to go through
things like Qt
or similar applications.
We wanted HTML.
We wanted JavaScript. we wanted JavaScript,
we wanted CSS
because getting designers
to work on that kind of thing
rather than going into Qt,
which at that time didn't have HTML.
I think they have an HTML renderer now,
but didn't at the time.
So basically saying
we are a Chrome browser
with a custom backend,
if you think of it that way.
So the UI and the frontend is all HTML, JavaScript, CSS.
We're basic.
We use off-the-shelf frameworks.
We use off-the-shelf CSS things.
So getting changes into the UI is easy,
which also means that it can't be any business logic on the UI front
because that's just a file somewhere on the disk.
I mean, it's just HTML and CSS and JavaScript.
So it kind of forces a separation.
Yes.
So business logic is on the C++ end.
The CF, or Chromium Embedded Framework,
gives us an interface to...
We could craft a JavaScript command to send to it,
and then we can also attach a callback
to when someone calls a certain function
on the JavaScript end.
So there we have a pipeline, you can think of it,
of messages that can pass from UI to C++.
And the client itself on the back end,
and this is a thing that we want to work on
and have been working on for quite a while now,
is that the client is all asynchronous messages.
So when the client starts, we fire up an HTML file saying, here's the login window.
But when you log in, that's just a message. We think of just a JSON message being sent from the
UI down, which is then that JSON message has to be converted into a C++ class of a message,
who has a JSON message class. And then that's passed along to a bus
that's listening for that message.
So we overload on the message type.
So the bus would just say,
I'm listening for a message login.
I have a function that is called onMessageLogin,
which takes in message login, which is a class.
So it overloads on the type there.
And they are very simple structs of username and password
or whatever the message is going to be.
And then we have a pretty simplistic job system
that says, okay, someone wants to log in.
Here's a message, and we fire off a job,
which can be thought of like a...
Think of it as a function, but it is a class that we can then start off.
And those jobs can call other jobs, which do more narrow and narrow tasks,
until you hit the point of, here's a job doing a very specific task.
So breaking the system down like this has helped us in maintaining a large application like this because it is a lot of code, it is a lot to maintain, but not only is it like that, it is the industry we're in moves at such a rapid pace.
Like, we can't stop and say, like,'s uh let's do this for a little while like
no there's a game coming out or no there's this feature that has to happen and we wanted to help
them or we need to deal with uh there's this problem in scaling on this end or whatever
so what this has helped with is when we get a junior coming in or anyone new coming in, they can isolate themselves very well on a specific job
dealing with a specific message.
They have no clue that they are on a thread.
They have no clue that they are in a much larger call stack.
You can call it like that.
They have this tiny little job that does this one little thing.
They can put a breakpoint there.
If the problem is not there,
they can see what other jobs
that job is calling and then go there.
So it has been
immensely helpful when we get new
employees to get them started pretty quickly.
But it also helps
us when we're programming it.
It is not fully, but it's kind of like correct by construction,
if you think of it that way.
If I need to make this kind of request, I have those systems there,
or I can puzzle them together, these kinds of jobs,
to then get all this stuff working.
So is the main communication then between your web interface and c++ backend
is all json so it the web interface is sending a json message down the uh then we have a certain
thing called we call a message router which converts uh the message into into the class itself.
So currently what we're doing is the router would register that this string corresponds to this T,
or whatever the T would be.
So I say this string is message login.
This T is message download game.
This string is message friend at.
And you have this long list
of the registration of
things that can come from the UI.
Then when the message
comes down, it would
find that mapping. It would find
that registration
basically.
It's saying like, hey, here's this string
that I have stored
somewhere.
It has a, what was the RTTI thing called?
Type index, I think it is.
So we have a hash map of type index to a function call.
So when I registered it, I took the T, I took the type, I think it's type index, I might be wrong on that.
It's the RTTI to get the type ID.
Yeah. Well, type index
is the C++
11 or 14 way or whatever of passing
one around, I think. Yeah. Yeah. So I can
store a type index in a map. I can
store a function
in the map and say
when this type index comes in,
I can call the function that knows
how to decouple
or basically
turn the
JSON into its
respective class.
Then every message has
a toJSON, fromJSON
that we can then call. Because we're doing it
on a T, we know that the T should have
this thing, so it knows
that, hey, this message is coming down, it's mapped
to this class, let's instantiate
that class, call the fromJSON on it,
and then pass it along onto the message
bus. So then you get a compile time error
if you try to use some type that you haven't exposed
yet. Bingo. Which is a thing
I find, like, turning
compile
time errors into run time errors is something I hate,
so I avoid it at all times. I want everything to be perfect at compile time errors into run time errors is something I hate, so I avoid it
at all times
I want everything to be perfect at compile time
which is not always the case
yeah, so
that kind of system has evolved
with us
and that's a thing
for example I've maintained a little bit
over the years, so much so that
we are now
moving towards
TypeScript on the
C++, no, on the UI end.
Interesting. Which is
typed. And I'm like, okay,
can I turn this little
system of ours into
where I have a C++
class on one end that
corresponds to a TypeScript
class on the other end and just have
the conversion automatic between
those layers. So what
we've been working on now also is a
language in
big air quotes
where I can define a message
I can define the types
of the members of the message
in both C++ and TypeScript
type because the TypeScript
types can be
they're like colon
not colon
you can have string
dash, well not dash
I'm blanking on the name of the
character. Pipe?
Pipe, there we go
I'm interpreting his
hand signals for our listeners.
Yeah, exactly.
The pipe.
You can say string, pipe, null, pipe.
You can concatenate the types like that.
And so we use that so I can define a message,
which is then converted by this compiler into a TypeScript class
and into the C++ message classes.
So whoever's making a message that has to go to UI and then back to C++
and only has to write the little message class,
and he has type safety all the way through.
Real quick for our listeners who haven't heard of TypeScript before,
could you give an overview of what that is and its relationship to JavaScript?
From what I've heard, the description is basically it is JavaScript with type safety added on top of it.
Right.
But there is so much that has so much been added to the language in the recent years that the paradigm of programming in TypeScript is different than JavaScript now.
But still, the rule still is all JavaScript is valid TypeScript also.
So moving your project over should be as simple as just rename the files,
run them through the TypeScript compiler.
It will output the same stuff or almost the same stuff.
And you can then just keep adding types.
Like, oh, here's this function
that I always hate when I do the error
and let me add the type
to the signature of the function
because I know it's always a string
that's coming in.
But I'm always putting an int by accident.
And then you're safer,
a little bit safer.
So you can go this iterative way of taking your current JavaScript
and just pop it over.
I think it's Microsoft that's spearheading this,
but it is an open source project.
So it's really good.
And yeah, we've been embracing it
and all their libraries and toolings that they have.
There's great tooling in Visual Studio Code, which I really enjoy.
That sounds like a pretty neat way to bridge the C++ and JavaScript world.
I don't recall ever talking to anyone else who had come at it from the TypeScript approach.
Yeah, and this kind of came out of necessity because if we sat down and said, what are the bugs?
If I'm going to enumerate the bugs, what is the thing that's happening with programmers?
Because they make mistakes.
And this cropped up so many times.
Like, oh, I forgot to initialize this member
because it's a struct.
So we don't create the constructor for it directly.
We have a default constructor
and then you just put the members.
And it's like, okay.
So that means that we want to have a constructor
for all the members.
But that's a lot of work going forwards.
Right.
Okay, can we generate that?
Yeah, we could generate that.
What is the problem on the JavaScript end?
Again, someone is forgetting to put a member in the JSON.
So it comes down, the toJSON doesn't know about it,
and it doesn't get deserialized into the C++ class.
So in the end, we just thought, no, let's just make this so we don't have to worry about
it.
And that's a kind of a mantra we want to have here is I would like the code base to be set
up in such a way that I don't have to worry about it.
Maybe that's a thing that we can afford a little bit
because we are not frame sensitive.
We are not super data structured oriented.
We are a desktop application,
at least on the client end.
On the server end, it's a little different.
So we can afford a few cycles to avoid bugs
so I always
want to think of if I'm doing
code reviews is am I going to
have to worry about this later
like oh but you have
to remember this thing here
like no no you don't
do that you write the code
where I'm like I can put it into a
corner and then I don't care about it
anymore. Um, that's, I feel like that sounds like a great summary of code review philosophy
in general, just like, will someone have to worry about this later? Yes or no? Yes. You need to
rethink it. Another thing that, thing that I can probably talk about
about our code base is
we have almost no comments.
Okay.
And this is because your code is self-documenting?
Yes.
No, the idea is if someone...
You need to get a code review from a person
that didn't help you
if you got help with the work you've been doing.
So that person comes in and if that person has any questions, any problems with the way the code is
structured, you have to restructure it. Again, we can't sacrifice a few cycles on a thing
by putting it into a function or making it more explicit. Because, yeah, if you put it into a function and you name it well,
that is documenting.
Right.
And since our flow is so very similar,
it's always these jobs, that these jobs do this one little thing
and then they go away.
The jobs have names.
The functions within the jobs have names.
And they're very tiny so
or some of them are very tiny that you only put comments in where it's basically
we kind of have to have it like this either from business restrictions or language restrictions or
like whatever that is so it changing it would be harmful, basically.
So put a little comment in saying like,
hey, we have to do it like this because of that.
Here are my expectations of the code, blah, blah, blah.
Because the idea is if you have comments,
not if you have code, we all have code.
My code is comments only yeah exactly if you have comments you're maintaining two states always right you have doubled the state of your of your code base uh which means that
yeah you're doubling your work um if that's fine cool. For us, that was just too much.
We had too many cases of here's a comment, here's a code, they mismatch,
and someone has to sit down and figure out what the hell is going on.
Of course, the code rules, but usually when you come upon a code,
it's because you're investigating a problem.
You have a problem with the code code and then you have to look through
what's going on.
Did he mean what he did
by the comment
and wrote the bug in the code
or is the comment
just strangely worded and the code
is actually fine? So you've just wasted
a little time.
On the server end, it's more because we are more cycle dependent we need to process as
much as we can and as little time as we can because we have a lot of users but we try to
scale things down by having like you can think of a front layer that the users connect to, and then you have the actual services behind it.
Because we have problems where
we have that many users connecting to our services
that we can run out of memory by socket connections alone.
Like there's nobody using the service
and we're out of memory, or we are low on memory.
Because it's just too much.
We have problems that we need to program stuff to avoid that we detouch ourselves.
Like retries within the client have to be very careful
because if one of our services goes down,
you just set a retry timer on all these users.
You have 10 million users all trying to retry to connect to the download the latest patch, basically.
Exactly. You have all these users who have a 10-minute retry or 5-minute retry, whatever that is.
So in those 5 minutes, you're kind of screwed now.
Right.
So that has to be mitigated.
I mean, it's not hard.
You put a random range on that.
That's one of the solutions to this.
But those are the kinds of things that you have to think about.
We have to have heavy caching. We have to have heavy caching.
We have to have good throughput.
We have to have mitigations against just being basically at this stage, at this scale.
And it is very hard and it's very tricky to work about.
And I don't think there is a solution to these kinds of things.
We just have to measure and look at the world and like,
where are we now?
And what can be done?
There isn't.
Yeah.
Like I said,
in the beginning,
there isn't a book about this.
If you can look into and say like,
ah,
yes.
When,
when,
when Skype had this issue,
they did this.
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 life
cycle spend less time debugging and reduce your mean time to resolution by using the first and
only platform to combine symbolic debugging error aggreg 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.
I want to
bring it back to the desktop client for a moment.
Does the Uplay desktop
client, is that just on Windows or is it
on Mac and Linux too? Because I'd imagine
that this combination of C++ and HTML
and JavaScript is a really good way to do
cross-platform development.
It was on Mac in the
beginning. Was on.
Yeah, it was on. It's not anymore.
And also, like we talk about the team,
it's usually you play PC.
So we're on Windows now.
It mostly moved away from Mac
because of just interest in sales.
Right.
It's that market, at least at that time,
because this was close to a decade ago now,
or it can be almost a decade ago now,
where that market wasn't that strong.
Maybe stronger now,
but I'm not in the business of that,
so I don't know.
So yeah, we focused on PC only.
The same thing with Linux.
The market isn't that big
that we do Linux ports of the games.
So there is a Mac port of Assassin's Creed 2, for example.
But that's, yeah, Assassin's Creed 2.
What's that, 2008, 9, 10?
I don't know.
A while ago.
Right.
But, yeah, I mean, we...
Zippo Plus is a great target to do this.
And for us to then say, yeah, Mac is blowing up again.
Let's do a Mac port.
That wouldn't be a big problem, we think.
I mean, Chrome works on Mac OS.
There's a Mac version of CF or a Mac build of CF.
You can do that.
A lot of dependencies are just file reads, file writes,
something probably minor with the networking.
So I don't think there's a big jump to do that.
It's more of a, why should you, if there isn't a game you are,
like if I would make a Mac build right now,
the user couldn't play anything because there's no Mac port or anything.
But that doesn't mean that our servers can be on whatever.
So
that's something that
we do look at and we do think about,
especially since we are in the
C++ world. There is one
thing that has happened.
It started about pretty
recently. I think it's called GeForce
Now on Mac
where you can launch a little Windows's called GeForce Now on Mac, where you can
launch a little Windows
instance from GeForce
and you can play a game on Mac.
So it's like a little cloud instance
from them.
And apparently that has been
pretty successful and well received by
players, so maybe that
inspires another Mac boom.
Maybe not, Who knows?
That's for the future to decide.
You briefly mentioned Linux.
Any of your games currently, are they ported to Linux also?
Do you know?
No, none of the major ones, no.
I'm not sure if any of the smaller indie teams have a Linux port.
I'll have to look at that.
But I don't think there is, no.
I love Linux, use it all the time.
I never game on Linux,
but I am always surprised when I look on Steam, for instance,
or a latest indie release.
It seems like in the indie world,
cross-release on Linux and Windows
is almost expected for many things,
but those are indie developers.
Yeah, and they have,
if you have Unity,
if you have Unreal, a lot of them have
basically file export
Linux.
It's more of a, why not?
Right.
If they haven't programmed it
in any obscure way, then yeah,
it's, in most of
these cases, it's
you can get a Linux build out pretty easily.
That's pretty cool.
But with larger titles, they usually have custom engines
where a lot of the engine work has to also then work on other platforms.
Never mind.
You had the best idea ever.
Well, okay, I'll go ahead and say it out there.
I mean,
you're,
you're involved in the,
you're not involved in the engine stuff.
You are not a games developer from what you've told us.
Right.
But I just,
just the announcement from Microsoft,
like two days ago of real time retracing with direct X.
And I was just curious if you had any thoughts on that or if you had seen that
article,
it looks really cool.
I think I saw the article a little bit.
Okay. Really good. Uh, that or if you had seen that article it looks really cool i i think i saw the article a little bit okay really good uh but i'm not that deep into those kinds of things where i could get it give any smart comments on it basically well yeah and i can't either i'm just like oh i mean that's
something as someone who's been you know kind of moderately interested in 3d graphics for the last 25 ish years or something like that
i've never implemented my own ray tracer i've never actually done anything like that i just
like playing with the tools every now and then when they come out i'm like oh that could be
pretty cool i did a graphics course at university where we looked at ray tracing and then I, we implemented it in,
yeah,
I think we did C++ as like a basic,
like,
Hey,
here's how you fire away.
Here,
here's how you do the collision.
And then I did one later on again,
myself.
And I know enough about them to know that this is a very hard problem.
Right.
Because you basically want,
like the best case scenario is you want
basically lasers firing out at every single thing in your scene to know how far away they are and
how every single light is interacting with it and what the light can see but that's big oh crazy right yeah go that way big oh crazy i've never seen that notation
that's uh you you weren't taught that big oh crazy it was not
so that's why like you have all these optimizations where you're like sparsely
like i'm not going to fire a laser at everything i'm going to intelligently
know what i should fire a laser at based on other lasers around me because here's an edge or here is
a feature right probably more optimization but because you have to be smart because you don't
have the cycles to actually do the the right thing So you have to do what's going to look good
for the eye.
What is the
C++ community like over in
Sweden? Is it hard to find people at Ubisoft
Massive?
So where we are now,
Malmö, which is in the southern
Sweden area,
it is a pretty small town.
There is a university in Lund,
which is pretty close by.
So like the general population we have already isn't that big.
We have Copenhagen,
two pixels away.
And which has a large scene as well.
You have IO,
that hitman there.
And we have King over here as well for us
and a smaller other game studios.
And there's a lot of companies that are doing
technical hardware things in C++.
I don't remember the names right now,
but I do know that there are a lot of air traffic companies here as well.
Interesting.
The ATC industry is heavily focused on C++ as well.
And I know that because that's what I did before I came here to Sweden.
So I was in the air traffic industry,
which basically inspired my love for Linux as well.
That's why I have basically always a bash terminal up
or a virtual machine somewhere.
Because I just can't work unless I have my little bash window.
Yeah, so the scene here isn't that big.
But like how we look at it, we are willing to relocate the the
correct people and we do so but you are currently hiring then we are a a bunch of people a bunch
okay we are company is gonna grow by i think i saw a report by about 100. I think we are 400 now.
So we're going to grow by 100.
We're moving to a new state.
Big increase.
So we are basically getting,
because we're exploding the building that we are right now.
That sounds dangerous.
I'm not literally exploding.
And I think with us, our team as well,
because our team has been relatively small.
We're not that many
and we're going to like increase by about one fourth one third in the entire team so like yeah
we we are hiring and we would love we would love smart people so is it like um many of the teams
that i've heard about in europe do you expect development basically happens in english there or what languages do people need to know to apply
that doesn't help
so uh no no so even though we're in sweden it is in english because we have many many
nationalities here uh so they all development here is in english we talk english
this the swedes might uh talk swedish between each other but uh i i sometimes give them a stern look
if i don't understand what they're doing they're talking about uh but yeah we we do we do english
here so you i mean obviously speak icelandic and english and then uh what is it danish is the other
language you learn in school
in Iceland? Or am I getting those confused?
No, so we're not getting that
confused. We are, we learn
Danish first.
Then we learn English. So you can say English
is my third language.
I don't know that
much Danish. It is a tricky
language to learn.
So from the Nordic languages, yeah, so we learn Danish because we used a tricky language to learn. So from the Nordic
languages, yeah. So we learn Danish
because we used to be under Danish rule.
But when I came here,
Swedish took a little
time to get used to, but
at least for me, it's a thing
where I
can listen in on conversations.
So it's familiar enough with the
other languages that you know? Yeah.
Yeah.
Okay.
I think it's basically Old Norse
modernified a little bit.
Not that much.
And you're working
on starting a new user group in Sweden
too, right? Yes, I am.
So April 24th
we're going to have a
user group meeting at Foo Cafe, which is a meetup place here in Malmö, which has been doing a lot of, basically, helping people do meetups.
And I hadn't heard about any C++ groups here.
And I asked on Twitter, like, hey, so what do you do?
Because I know there's one in
in stockholm right so they just say just make one okay that is pretty much yeah how it goes i guess
apparently you're like like you you thought of the idea it's your idea now you own it. It is. So I have a logo set up. I have a speech.
I have a talk I'm planning now,
which is basically,
if you're interested in more of the things I've been talking about,
it is going to be about the transfer of objects
and communications from the UI layer to the C++ layer.
Cool.
So we're going to go into code and details
and how we do that, basically,
and how you can then also create
your own desktop application like that.
I was going to ask,
is this type of desktop application development
something you guys completely came up with on your own,
or is it documented somewhere out there?
In the beginning, it wasn't documented,
so we kind of had to
fly by the wire on that one.
The CEF now
has a whole bunch of examples.
They have, I think, three
types of example applications
based on how complex you want to do this.
There is a lot of
boilerplate you have to do if you want to go
the full way.
There's going to be, on our end, there is a bunch of classes and there is a bunch of code we want to do if you want to go like the full way like there's going to be like on our
end it is a bunch of classes and it is a bunch of code we want to write because you have to have
this all kinds of handling for windows and dragging and resizing and and if you want to capture that
and like what do you want to have happen because uh yeah there's there's a lot of capturing you have to do. But I think it's called Electron,
which is a wrapper around CEF,
has a lot of these abstractions taken away from you
if you're not that invested in core performance.
I know that Slack and Discord are both implemented in it.
So if you just want a desktop application thing,
Electron can be something for you.
If you want to just see how this works and make one your own,
you can look at CF directly.
Cool.
Okay.
Yeah.
Well, it's been great having you on the show today, Oliver.
Thank you very much for having me.
Thanks for coming on.
Thanks for listening to this episode of CppCast.
We're currently conducting a listener survey so that we can learn more about our listeners and improve the show.
If you have a minute, please go to bit.ly slash CppCastSurvey.
That's bit.ly slash CppCastSurvey.
Or click on the link in the show notes.
Thanks.
Theme music for this episode is provided by PodcastThemes.com.