Become a Creator today!Start creating today - Share your story with the world!
Start for free
00:00:00
00:00:01
Building Fyrox: A Rust Game Engine (with Dmitry Stepanov) image

Building Fyrox: A Rust Game Engine (with Dmitry Stepanov)

Developer Voices
Avatar
2.1k Plays2 days ago

To kick off 2025 we’re looking at Fyrox a game engine built in Rust, largely by one person - Dmitry Stepanov. For an individual project, it’s covered an incredible amount of ground, covering the rendering and animation features you’d expect from a game engine, with some features that might surprise you - like Rust scripting support with hot-reloading.

As we dive into Fyrox, Dmitry explains what it takes to build a game engine, why he chose Rust (and why he’s happy with the choice), and how one person can hope to build a project of that size.

Support Developer Voices on Patreon: https://patreon.com/DeveloperVoices

Support Developer Voices on YouTube: https://www.youtube.com/@developervoices/join

Fyrox Homepage: https://fyrox.rs/

The Fyrox Book: https://fyrox-book.github.io/

Rapier Physics Engine: https://rapier.rs/

The Mine (on Steam): https://store.steampowered.com/app/898980/The_Mine/

Dmitry’s Engine: https://github.com/mrDIMAS/DmitrysEngine

GJK Collision Detection Algorithm: https://en.wikipedia.org/wiki/Gilbert%E2%80%93Johnson%E2%80%93Keerthi_distance_algorithm

WPF: https://en.wikipedia.org/wiki/Windows_Presentation_Foundation

PICO-8: https://www.lexaloffle.com/pico-8.php

Kris on Mastodon: http://mastodon.social/@krisajenkins

Kris on LinkedIn: https://www.linkedin.com/in/krisjenkins/

Kris on Twitter: https://twitter.com/krisajenkins

Recommended
Transcript

The Challenge of Building a Game Engine

00:00:00
Speaker
Building a game engine is a huge software project. We've talked about this before on Developer Voices. If you want to build a game engine, you are going to need some kind of game business logic library. You probably need a networking stack. You certainly need a rendering engine with animation support.
00:00:19
Speaker
collision detection libraries, a GUI library, maybe a whole new scripting language, probably a whole IDE, and more. It's a colossal thing to build a game engine. And as you're going to hear me say in this discussion you're about to hear, if you gave me a team of 100 programmers and five years to do it in, I couldn't guarantee that we'd build a successful game engine. So what hope could one person have?
00:00:48
Speaker
I'm joined this week by Dmitry Stepanov, and he's been working on the Fireox game engine, almost solo, for almost five years, and it's incredible how much he's built of something the world is crying out for, a viable game engine in Rust.
00:01:05
Speaker
He's got good form on it. He's been building games for years. He's built a game engine in C in the past. He worked at Larian Studios on tools for the likes of Baldur's Gate 3. He knows what he's doing. If anyone can build a game engine, he can.

Introducing Dmitry Stepanov and Fireox

00:01:22
Speaker
But can any one developer build it? This is what I had to find out. I got him in to talk about what it takes to build a new game engine in Rust. And along the way, I learned some really surprising things, like how do you do hot reloading of Rust code? Doesn't sound like it's possible.
00:01:40
Speaker
How do you do runtime reflection in a language that doesn't really support reflection? And what are the hard parts of building a game engine? The answer to that is not what I thought it was. So let's get into the questions. I'm your host, Chris Jenkins. This is Developer Voices, and today's voice is Dmitry Stepanov.
00:02:12
Speaker
Joining me today is Dmitry Stepanov. Dmitry, how are you? Hi, I'm fine. And you? Good. Yeah, I'm glad you could join us. I'm very well. I'm glad you could join us because you seem like one of the busiest independent programmers I know.

Dmitry's Passion and Journey in Game Development

00:02:26
Speaker
So, thank you for carving out an hour.
00:02:29
Speaker
You have been, I mean, if I think about large programming projects, writing a programming language and getting it to production is huge. Writing an operating system may be larger. The only thing I can think of that's actually larger than all of that, you have been trying to do solo, which is making a game engine. Yeah, but that's the stuff. so I mean, maybe the first question is why? I mean, why embark on such a huge journey?
00:02:59
Speaker
ah Because it's my passion. It's what I love to do. ah Games this is my passion since I was like a small guy. like And ah I always wanted to make my own games. And from some point in the in my life, I decided to build my own game. I was like, when I was like 12, maybe,
00:03:28
Speaker
Yeah, it's say it's but quite a long time ago. and and Yeah, it was very interesting. I was starting with this visual basic and some some some stuff like ah those ah cartoons where you draw pictures one by one and animating it in a simple way, like using a timer. like All style old sell cartoons. And yeah, then I decided to learn about ah ah C++ plus plus and well graphics libraries such as OpenGL, DirectX. And ah I was like, but it just was so interesting. And I spent all my free time on this and like, I was like,
00:04:17
Speaker
um ah you You can like give me food, a warm place, a PC, and I will be here forever yeah doing doing this. That's what I love. and in ah but When I was in university, I started to build my own ah game engine and a game, and like four years after this, I released it in Steam. Really? Yeah. It was a code.
00:04:44
Speaker
It's called The Mine. it's like ah It's like a horror game that was popular back in the day. And ah it uses custom game engine built in C++ plus plus and DirectX 9. It was already quite old at that point because there was like DirectX 11, if you're not mistaken. But the it allowed me to gain so much experience with it. It's like building everything from scratch allows you to understand very like a fundamental parts of game development and even how PC works. Because when you're writing in ah other languages or using high-level libraries, my Unity existed in that time, but I decided to my ah to build my own engine.
00:05:32
Speaker
and Yeah, you would totally, totally worth it. So it allowed me to become who I am right now. oh but The thing is, like most people, like,
00:05:46
Speaker
Most people get the surface understanding by using a library. If you go in and write your own engine, you definitely get a deeper understanding, but it's rare that you actually get to release because you go so far down the rabbit hole, right? Yes, that's that's the hard part. It's hard to release vi everything because ah Again, on my game, on my first game, it was so hard to release. It's like that law where you have have to put 80% of time to the 20% of work or something. I can't remember how how how it school yeah I remember someone saying that you spend 80% of your time on the first 80% and then the other 80% on the next 20. Yes, exactly. And it was so hard. but
00:06:33
Speaker
When you release at least one project, it becomes easier to like to do it until the end. But with game engines, it's...
00:06:45
Speaker
It's much, much bigger task. It's mostly endless because um there is like a wide range of topics there. You can start from graphics, which itself is huge. And it continues to like, guys continues to invent new techniques ah for rendering. ah and It alone could take a enormous amount of time. yeah That's why I'm trying to not focus too much on graphics.

Influence of Larian Studios on Dmitry's Work

00:07:16
Speaker
Now, we need to get into that, but what makes me curious before we dive into Fireox properly is from making your own game engine, you then went into the gaming industry, right?
00:07:28
Speaker
Yes. Did you work on the engine there, or did you work on games being used? um At my ah workplace, at Lion Studios, I worked mostly on tools. Okay. Entire those tools to with the engine. ah That was more there was a wide range of tools. yeah The entire editor, you could tried yourself. the They released their glasses editor. It's called glasses, like these are ones. And um it's like, it's somewhat close to my mix of Unity, Unreal Engine, and specific parts for games, ah for four their games. And I was working on
00:08:19
Speaker
ah animation, like other work in other editors from for numero tech, some with sound related tasks and so on and so forth. Game development is like when you dive into it, it's like an overwhelming amount of tasks that you can do. And no matter if you like hard to work as a tools programmer, you might end up working on sound, which is It isn't all related, but yeah, I worked on sound, ah on animations, on crazy amount of like different kind of tasks, optimizations, and so on. so And also, you can learn from like a like existing game engines. and So it's a good source of learning material. Yeah, so this is the thing, right?
00:09:19
Speaker
There you are, gaining experience in different parts of a game engine. And it must have taught you a heck of a lot for what came next. But it did it not also teach you that it takes entire departments to make individual parts of the system? Yeah, that's true. That's true. there's like a was 10 or so people working on graphics alone, like five or seven people working on the core functionality. And now I'm alone trying to do the same by myself. That's insane. What was it? Was it like you had an idea that would make it possible for one person, or was it just the itch that you must go and make a game engine regardless?
00:10:07
Speaker
It's probably the latter, because I can't like seem to sits sit and watch how other devs doing something interesting. And I also want to do this. And this game game engine development is an infinite source of interesting tasks. So why not?
00:10:27
Speaker
Okay. Just the do this and enjoy it. And but if you were one day like ah look back and you will be surprised how much work you've done, and it's insane sometimes. Yeah, what's that thing like when you're climbing a mountain, never look up towards the top, just focus on the bit of the rock you're on. Yeah, exactly. and What I like about game development, and game engine engine development is that ah It's like an infinite path, which you can enjoy. It's like it's not that the particular small task, which you've finished. And what's next? It's like ah quote cool it's like about the path, not not the not the goal. Right, yeah, yeah, I can see that. There's always ah always plenty more path to keep walking on. Yeah, exactly. So in that case, let's start the starting point. Because the first thing that jumps out about Firefox as an engine is that you chose Rust.

Choosing Rust for Fireox

00:11:28
Speaker
Yeah, I never regret it. Never regret it. Okay. So why why choose Rust in the first place and why has it worked out? At first, a bit of some tiny amount of history. I started the Firefox in C actually. So back in the day, or you can actually find it on my GitHub. It has a silly name of Dimitri's engine. Dimitri's engine.
00:11:54
Speaker
isn because That's no worse than Gary's mod, which I gathered. Yeah, exactly. I spent so much time trying to fix ah quite annoying bugs, like memory corruptions, because this ah this language is it's very powerful, it's cool, and it's simple. About C. and But it's so and uncontrollable. with hook how How can I code? um it could Everything could easily go out of hand and you will you you could spend like hours, like days, weeks debugging stuff simply because this um this language is so
00:12:40
Speaker
uh it doesn't control anything ah while rust on the other hand is is is a life it life life changer because it controls over like invalid use of memory like where you have something ah borrowed for a mutation you can't do another borrow for mutation ah that that prevents like that famous problem with in c++ plus plus where um
00:13:12
Speaker
and iterator becomes invalid because so ah the memory was like moved somewhere else and boy pointers in that iterator and pointing somewhere if you try to read you'll get memory corruption or something like that ah no not true excuse me right and yeah Yeah, I sometimes wonder if ah if you have to, in order to really love like the borrow checker, you have to experience like being absolutely sick of memory being unmanaged. Yes, that's true. Actually, it wasn't so easy to transition to C, because... To Rust, you mean? Oh, yeah, exactly, exactly. I'm sorry.
00:13:55
Speaker
i'm um Yeah, because... those paradigms used in C or C++, plus plus they're so but were heavily embedded in the mind. So you can't easily let them ah like release them. and yeah Yeah, you like know how to solve a problem in C, but you don't get so now you're in Rust. You don't know how to solve that problem. a bit Yes, exactly. yeah like
00:14:27
Speaker
In C or C++, plus plus you would just like have a row pointer or a smart pointer in C++ plus plus ah specifically. And um while in Rust, you can also do this. But then ParoChecker kicks in and like says, no, you can do this. Because ah but you will get this, that, and this. But you can always silence it with unsafe. But why at all switch to Rust if you want to use unsafe? That's insane. So yeah. just and accept the rules of the of the language and it will be fine. It took me three months to to realize that. It was hard really. yeah I stopped and then started over and I pushed it pushed again and again and finally come up with solutions that allow me to write it almost fluently and ah from some point in time
00:15:26
Speaker
I was like looking back at C and I used it ah daily on my job. and It was so annoying after I get used to Rust. That's insane, actually. yeah Yeah, yeah. I sometimes think the mark of a good language is you find it hard to go back. Exactly. You often don't know the real advantage of a programming language until you start to miss it. Yeah, that's true. yeah Okay, so so where do you start? I mean, assuming you're you're in the past getting to grips with Rust, settling on that as a choice, I don't even know where you start with writing a game engine.
00:16:07
Speaker
it's It's quite common that you like output in a cube, like a rotating cube. ah Start with a rotating cube, okay. Yeah, yeah yeah exactly. yeah That's what most guys are doing, it like starting with a rotating cube, and then I'm starting to to extend the functionality. But I cheated a bit because I i had a C game engine that had a scene management system, a resource management system, a basic UI, a sound system, and I um just ported it. ah to So, my but...
00:16:49
Speaker
That C engine wasn't very like capable. the yeah it It was very basic. And that constant um um fighting with random bugs because of memory memory corruption, and that was quite annoying. a And I decided to like port it. ah the first And then and was of it was a good starting point to add functionality.
00:17:18
Speaker
i If I remember correctly, ah what I was started doing after the switch to

Animation and Object-Oriented Approaches in Fireox

00:17:25
Speaker
Rust, I started implementing animation system and and that can allow to like not normally play animation and switch between them instantly, like ah creating this weird jump effect. ah But...
00:17:42
Speaker
to do a smooth blending, so I spent some time designing the animation blending system. That was very interesting. Am I right in thinking that's the thing where a character is swinging a sword and the new press jump halfway through the swing and instead of glitching across to the jump animation, it smoothly goes into a jump from a swing. Yes, exactly. It's it's exactly what it's doing. and It's like blending two animations. It's like creating a smooth transition between them.
00:18:12
Speaker
yes The way actual humans move. yeah yeah ah I've got to ask, when you said you ported the sea, did you just like have the sea in one window and write some rust? Or did you FFI into the sea and gradually eat it away? I rewrote it from scratch basically. It was much easier because so this FFI is itself quite bug-prone and you can ah basically my ah still of of loading work to C and ah creating like a safe wrapper in Rust, but it wasn't worth it, because Rust itself is as fast as C and much more reliable.
00:18:55
Speaker
ah who and Why would you do this? Why would you why would you like ah create an FFI? there some some some um and Some tasks where you have a very large library that does specific tasks are very good and tested throughout the years.
00:19:15
Speaker
That's totally worth doing bindings and use it. But in this field where i where I'm experimenting a lot with game engine, it's like easier or to rewrite everything. Something like this. Yes, that makes sense. so So let me see if I can get the...
00:19:37
Speaker
ah how this engine works. is there im I'm thinking of um Bevy. We recently did an episode on Bevy. And that seems to crystallize around this idea of ECS. Is there kind of an overarching organization within Fireox that I can get my head around? I'm using somewhat classic OOP approach. of what the But it's classic in nothing like this weird way, which ah which is in everyone's mind, like where you have this weird ah inheritance trees, the diamond inheritance and so on and so forth. It is more like
00:20:18
Speaker
I don't know how to describe it. Maybe ah dick dick the the classic approach which was invented by Alan Key. Alan Key, sorry. And ah where we have like objects and um ah and like you use message passing to communicate between objects. But again, ah that's... um not the entire, not the full approach I'm using because um ah it's always good to find a balance between boom like,
00:20:58
Speaker
I don't know, it's just a balance or not. I mean, um In ECS you have like tightly packed data and process everything using queries like doing like budged work and so on. And you basically split your your object into components which align into ah their own containers for better cache locality and so on. While I'm using always the same, but ah while keeping the
00:21:32
Speaker
the object-oriented approach where you have object and methods and sometimes use this message passing to interact between objects. um So again, in Firefox, objects are all packed in the the contiguous memory for better cache locality but ah they are not split in those like tiny pieces but that allows you to like iterate fast and but it doesn't mean that Firefox is slow and ah simply because
00:22:11
Speaker
um I'm using mixed approaches, which are better for a particular task. So it's like a simple rule. just the the like the the to google out out quote Use the correct tool to do the job, like this. because is it yeah yeah is it so I'm trying to think, because if you're doing a mostly OO-based approach, Rust isn't an object-oriented language. So are you bolting an OO mechanism on top of Rust? or What are you doing? ah Rust is actually an object-oriented approach, because it has traits and trait objects. So you're just doing it to the trait system? Yes, exactly. okay yeah
00:22:57
Speaker
yeah so um It's like heterogeneous container that has these data-backed trade objects and allows to do dynamic dispatch that allows you to call methods of particular type. like A standard approach, I mean. Okay, so you have like a health trait on certain ah characters and enemies in the game, something like that? um Not really, ah because bill so building block in the the engine for scene objects, I mean, is ah is a node, a scene node, and that node, the node itself is
00:23:49
Speaker
It's also a trait object, so can be um so we can it has an interface that can be um implemented by some specific node types and also um To be able to extend ah the functionality of scene nodes, there is also a scripting system, which allows you to attach as many scripts to scene nodes as you want. So, okay so nodes them themselves, they are doing some specific work a to be and in a fast manner. Like, um since they are same scene graph nodes, they contain
00:24:33
Speaker
and ah local and global transformation, visibility flags, enabled or disabled flags, ah some specific parts like name tag, um and other common parts like um how it's called at the but ah the links to resources from which the scene nodes were created for a property inheritance system to create a nested prefabs. so Basically, it's like a ah like this tiny building block which you can extend. You can either create ah custom a node that will extend this functionality using composition. Basically, you have this like basic scene node. you like
00:25:28
Speaker
define it as a field in your own scene node and allowing the engine to access it so it can manage this part but how it's like. And other parts are up to the particular scene node type. and But this is not so flexible. That's why the engine offers a scripting system that allows us to attach custom data and methods to operate on that data and yeah something like this.
00:26:05
Speaker
OK, so let me see if I can get this. I'm i'm going to keep on the health example. So so ah presumably, I create a scene node, which is the world. And in that, I'll create a node, which is a camera, and a node, which is some lighting, and a node, which is my player's character. Yeah, exactly. Right. And a spinning cube, of course, because you need it to be on cube. How do I then say, OK, that character has a measure of health?
00:26:32
Speaker
ah That's quite easy. You can just add a field, like a like field called health. And ah to to be able to interact with it, you have like two basically two approaches. ah You can and directly access so one ah like the desired signals from other signals, like direct will link, and it is very fast because you will directly write in or read in memory using some... It's it's still in direct access because it uses um in in indexes to... Not pointers, indexes, like...
00:27:14
Speaker
ah ah And it's also not indexes, it's handles of and generational arenas. If you know what what it means, I can... And those are generational arenas? Yes. You've got to unpack that one for me. So, yeah, im ah let me finish with the healthy example and I will continue on that those generational arenas.
00:27:38
Speaker
and um yeah and And the second approach is to use messages ah like you can the The engine offers a message dispatch system where you can subscribe to subscribe a node to a particular message type and then um other nodes can send this message and it could be sent in different manners like you can send directly to a node and it will be dispatched to it
00:28:11
Speaker
and it will receive the message in the same frame and process it, or it can be sent globally, so all the subscribers will receive that message. Or it can be sent um in a hierarchical way, so and it also has the date its own ah flavors, um because you can um ah bubble message up um on the scene graph like you start from a certain node in some hierarchy and um ah you send in the message to the so itself and it starts bubbling up the to the root of the graph and all the nodes on that path will receive this message.
00:28:55
Speaker
And there's data and there there is also the another routing system that allows us to deliver messages message down. So ah all children nodes, will descendant nodes, will receive this message. And this is actually very ah handy sometimes, because um like a recent example, with this health-related related stuff, um I recently redesigned the damage system in my game.
00:29:22
Speaker
and i um um added hitboxes to enemies like all parts of bodies um like have their own hitboxes which moves together with limbs. So if you hit this part of the yeah area with a sword that counts as hitting the monster.
00:29:45
Speaker
ah yes yeah Yes, exactly. And since these hitboxes are actually inside the hierarchy of objects, and you can use this bubbling strategy to um and deliver messages. So ah the root actually is the... ah The like the character itself and it has those children knows and when the message is like bubbling up it will eventually Reach the character and we like it will react to this message And so I could have a bullet that hits the armor and I send the five damage message to the armor, which then gets bubbled up to the character that can actually deal with the five damage message. Yes, exactly. And it is super fast because you don't need to process process the entire graph. You can have a graph of millions, like millions signals and you don't need to process all those signals.
00:30:38
Speaker
you know exactly where where to send it and it will bubble up to the specific one. And sometimes you need to but like um like sync to the strategy, I don't know how to call it, where ah where the message comes to all the descendant nodes. And this could be useful in some other scenarios, but I haven't like used it in any place. So it could be useful in some place. I think probably the name for that is visitor, but we need something that sounds like the opposite of bubbling up. Bubbling down doesn't work. But yeah, it's the visitor pattern, right? Yes. So that's for communication between signals. So it depends on the
00:31:27
Speaker
On how fast or um maybe not meant fast. Like the first approach where you directly reference in an object, it is very fast because but direct access to memory. This one is a bit slower, but it allows to do this complex logic where you decouple ah basically decouple hitboxes from character. It could be like an explosive barrel, for example. you add the heatbox to explosive barrel, and it is not character, it is something different. And explosive barrel, it listens to these messages, and it if it differs damage message, it's decreasing the health, and at some point it explodes, and it just works. And it's an awesome part of of this message passing system.
00:32:17
Speaker
So as a user, is is this how I would do it? Like I would create a hitbox component and then I attach it to certain things and some of those can take damage messages and some of them can't. Yes, exactly. Some parents can and some parents can't, but the the hitbox component doesn't care. It just passes it up. and Yes, yes. Right. So my next question then is how do I write a component? do Am I writing that by extending a note like Now I'm not extending a node in Rust because it's not like classical inheritance. How do I do it? How do I do it?
00:32:51
Speaker
um it's like It's a script, basically. A script is like a piece of data which with methods that will be called by day by the engine. And scripts can be attached to sim nodes, and they do all like business logic that you like. ah You can also like create custom sim node, but it's like very low-level stuff and not so.
00:33:18
Speaker
Not so useful, except maybe if you need to do some ah rendering like specific rendering stuff, then it might be useful. ah ah But in on other stuff, probably, yes, we will use like script and attach it. Basically, basically every script is like a simple trade object. It's it's directly it's it's located from a random place in memory, so it it might be slow. But in reality, like ah only a handful of objects have scraped, so...
00:33:56
Speaker
If you like have 10% of objects that have scripts, it doesn't matter really. If you have 10,000 of nodes, it still will be fast. yeah especially Especially if you ah design this system properly, ah by this, I mean, you can... um You don't need to to call all the methods of this trait to be able to operate with this object, because um some object objects like have empty implementation of some methods. And um for this specific... um
00:34:35
Speaker
like optimization technique firework scissors i don't know how it's called in like in academia or something like this ah basically it has.
00:34:47
Speaker
um ah like ah a set of switches that allows you to tell the engine which method it should call or which node. Basically, you can disable an update ah so the engine won't spend time updating your script logic. and It will be fast because every such object will be registered in its own list.
00:35:12
Speaker
like um and there will be a list of scripts that need updates, scripts that need to be initialized, like specific logic. And this allows to fine-tune this without ah harming the performance. where um how you like I think in...
00:35:38
Speaker
Unity which has similar system. It does not have this ability. So if you look at the game object ah class but there, you'll be surprised how many methods it will eight it has.
00:35:53
Speaker
and ah All of these methods will be called at some place. like There are specific methods for collision detection, ah specific methods for update, post update, ah initialization, so on and so forth. And this indeed will harm the performance if you have thousands or tens of thousands or even more objects.
00:36:16
Speaker
its like some You've got some... I'm thinking of a simple example. If something's off-camera, you mark it as being off-camera, and then some kind of dispatch table says, don't bother doing Camry stuff to that object. Yes, you you can disable animations for so like ah for objects that are out of frame. You basically ah like but do this ah load balance, and it works like...
00:36:45
Speaker
it it works very good because um you You really don't need ah to do this um like super fast approaches you like you just need to think about the problem and yeah It is good when you have fast approach. Yes, but you ah You you can really do in another way like like this one yeah like throw away those methods that no don't need to be called like and
00:37:19
Speaker
Yeah, but that's the solve some problems. It's funny how in some ways, writing games is a very different kind of programming to I'm used to. And yet somehow some parts are very familiar. and Yeah. Let me ask you, so this is a side alley, but I want to go down that is, how do you do you measure performance? Is there a good set of performance measurement tools you're using to figure out where time's being lost?
00:37:46
Speaker
Usually, I don't do bench benchmarks because that's like a waste of time, really, because I don't have this production ah ready parts that needs to be benchmarked, right? So some of the parts some parts of the engine, they are production ready and they are well tested and like,
00:38:09
Speaker
um works ah quite fast and that was proven by like me me using the engine in my own games because I usually yeah so find hot spots in the code by Like do some gameplay tests and I'm like opening the profiler and see what's hot what's what path is and fixing it um so I since I'm ah mostly alone, but More to this later because there are some very good people who started working on the project the In the past like six months or or maybe more. Yes. So the team is actually bigger now and so So I can't can't tell that I did everything alone there is a lot of people like ah doing small contributions and ah um Tiny portion of those people doing
00:39:02
Speaker
like huge chunks of work and that's very cool. can we We've got to get into that but in that case I'm going to pull back and say we talked about scripting languages. No. Tell me about scripting because how does that, is it the scripting language rust?
00:39:18
Speaker
Yes, a scripting language is Rust, and it's also using

Hot Reloading and Physics in Fireox

00:39:22
Speaker
hot reloading. So basically, it turns the Rust in scripting language, because you can like push the button, compile the the module, um and it will after automatically be taken up by but the game and the the editor, and the new logic will start spinning. How's that working? Because I don't think of Rust as, in any way, a scripting language.
00:39:46
Speaker
ah you can Think of a few techniques that might work. What's your actual technique for hot reloading Rust? It's quite simple and uses very well-known techniques like dynamic libraries from operating systems. ah Pretty much any operating system allows you to unload i mean load and unload code into a process.
00:40:08
Speaker
and ah The only problem that you need to solve is to um how somehow manage the data ah between those ah loads and unloads um but that's solved by a simple serialization because every object used by a scripting system requires to be serializable and so basically When you change the game code and click build, yeah it will um it will build a separate library, then the engine will spot it. It will create a copy of this library of new version. Then it will ah find all ah entities from this plugin that you've rebuilt.
00:40:57
Speaker
and serialize these objects, and it will be quite um a fine-grained, because it will not reload the entire scene, it will reload only specific portions, so it will be super fast.
00:41:15
Speaker
and like For example, if you have a bunch of scripts from your plugin in some scene and then do a hot reload and then the engine will ah serialize those scripts, ah unload the library and at this point nothing from your ah from your plugin is attached to the to the engine itself, the scene. And then it will ah um it will load the new version and will create the new versions of the objects and try to de-serialize their state. And basically, we'll attach them back to scene. It is simple, but rather sometimes it's weird. in ah some like ah It could create a the virtual
00:42:05
Speaker
pointer tables on demand and those virtual pointer tables will be pointing to like weird places in your game and if you created an engine object inside a plugin and then unload this your you will get crashed because this vtable was created in the plugin and it points to the process memory that is currently unloaded and yeah So you can reload elements in the game, but you can't dynamically reload a whole plugin.
00:42:40
Speaker
ah ah You um who can reload the the plugin itself, because it's also serializable. Everything is reloadable, actually. because ah It creates additional like additional problems when you do this, because, for example, I um made a game, a network game, which which kind of connects those connections to Sera and... like ah those non-serializable stuff, and ah having this strict ah strict constraint on and that, that your your old like your plugin needs to be fully serializable and de-serializable sometimes makes your life a bit harder, because you can serialize the server connection.
00:43:33
Speaker
Yes. Yeah. Do you have any notion of like those live resources that can't be serialized, but must be recreated from scratch transparently? Or um not yet. Maybe human mean objects. like but I'm thinking like a TCP connection.
00:43:54
Speaker
to to the network server. You can't serialize that, but do you have some kind of life cycle when you restart? This is how you will recreate it from the serialized IP address.
00:44:05
Speaker
Yeah, basically ah it will try to reconnect and ah like do handshake stuff. like Do I just write that into my deserialize code? um myself Yes, unfortunately, yes. yeah so you can yeah Because it's negative code, you have no other option because it's basically you unload it from process memory and load it back and you have like nothing left, ah you you ah your objects play playing data, I mean, without those fancy pointers and stuff like, I mean, but just bytes, you can leave those in process memory, because they're both of them using the same memory allocator. So the memory will be fine when you are not the plugin itself.
00:44:52
Speaker
so ah But for those objects that have those interconnections, this won't work. yeah okay so how I'm just wondering how this plays out in practice. If I am writing a game and testing it out, the character has jumped onto the first platform, I change the script that affects its jump height and just reload that. Does the rest of the state scene stay where it is? Does the character stay where it is?
00:45:19
Speaker
Yes, indeed, it will stay. So it can independently change parts of a running game without restarting the level. Yeah, exactly. And yeah the the good part is that it it minimizes and the risk of crash because of this, it's really yeah like super unsafe stuff when you go like unload parts of the process and reload it back. yeah Because m ah The engine will try to minimize the changes. like If it will see that some script changed, it will only affect that script. It won't reload everything else, because it's just slow and you want fast iterations. Out of curiosity, does it like freeze the game world while that's happening? If a bullet was coming towards me, will it pass through me while I'm reloading? Or will it just freeze and wait for me to come back in?
00:46:07
Speaker
It will freeze, ah reload, and the simulation will continue from the same point before reload. It's very good for fast iterations. But sometimes it crashes because of sub-delicious with those like memory management virtual table pointers, virtual pointer tables. And um yeah, but it indeed saves heaps of time.
00:46:36
Speaker
okay yeah I can see that being like essential for fine-tuning a game, which I gather is a huge part of the process of building like feel the pain of those guys that using the engine, the engines without hot reloading, like I was like this myself. And when you spend like two minutes building the game, running to a specific point to test stuff, some stuff, and the testing actually takes like five seconds. And basically every direction it takes three or more minutes. That's, that's insane. Yeah, I don't know how you get anything done in that world.
00:47:16
Speaker
Because you're trying to tweak, like, how high a character can jump by the time you get the next experiment. basically changing title is more variable, and you need to restart the game. that's just like It could be solved by ah having a config files, actually, but and not everything could be placed in such files. so so It's like my code reloading doesn't allow you to change game logic in any way you like. But config files can't do this. They're just affecting data. and yeah yeah Yeah, you can change numbers with a config file, but you can't change like control flow. Yeah, yeah. OK.
00:47:56
Speaker
OK, so yes, I can see how you can begin to see how you get the very necessary feature of hot reloading for for a game and still do it in Rust. Does that mean does that mean you aren't committed to Rust the whole way through? ah No, and not really, because ah recently um They're like lower was added for the engine, but it's a separate separate project. So it allows you to create scripts ah in lower and those as far as I know.
00:48:36
Speaker
are also hot reloadable quite easily. and ah Since this is those are interpreted languages, it works much, much faster and much more reliable because you don't have to mess with the process memory and such low-level things. yeah and Also, there is some research, as far as I know, to add C-sharp support.
00:49:04
Speaker
ah But that's in very, very early phase, and I don't know how it will like came out come In that case, let me think about ah various subsystems, because i I know there's at least one part of, I think it's the collision detection system, which you haven't written. You've ah you've got a Rust library bringing that in. yeah so what are they what What are the interesting libraries and what are the bits you've bitten off yourself?
00:49:34
Speaker
um I'm using the Rapier 3D and 2D for 2D physics and it's very awesome library it's very stable and with recent updates it's like super stable because some so in some early versions it had problems with joints, stability. Like when you're creating a ragdoll, it like blows up, like some, some, uh, some limp merging into another and then like explodes and your character like fly away. yeah Yeah. Your character's arm falls into the other arm and suddenly it looks like an explosion waiting to happen. And it's like, uh, sometimes stuck in objects and create those blood splatters.
00:50:22
Speaker
Yeah, I'm sure I've seen that in demos. Yes, it's like a very common bag. And as for um ah other ah parts um of physics, yeah, but basically, yeah, I'm relying on the Rapier physics library, and it does the all the heavy lifting. But previously, I had my own physics library. But this topic is like, it requires some very, very good ah knowledge of math and like,
00:50:52
Speaker
It's not enough to have basics of linear ah algebra to get into it. So I implemented some um collision detection algorithms back in the day. It was a GJK algorithm for um intersection detection of convex Polygons, or no, convex objects, and then implemented the expanding polytop algorithm to get a penetration vector between two two objects, like how much you need to like push objects away from each other to ah make them don't contact anymore. and
00:51:38
Speaker
ah But after that ah it was the time for like rigid body dynamics and that's the part where I gave up because I realized that I need to do joint system then and it involves some math that I that i don't understand it's like Jacobians and other other parts like from math that yeah like 10 tensors say if I'm not mistaken are also used there and
00:52:09
Speaker
I can imagine you being very glad to outsource that particular part. Yes, exactly. Can you not face the same with rendering? I know, because ah rendering is actually much easier for ah programmers, because it does it mil it it uses ah math as well. And sometimes those like scary parts, like integrals and derivatives and stuff. But in reality, it's much simpler. And also, there are...

Rendering Complexities and UI Development

00:52:40
Speaker
quite a lot of good loading materials throughout the internet and like some advanced stuff like Google Filament that allows you to build your own physically based renderer and it has like math and code are together ah On the same page and you're like, oh man, this like integral. What does it do? And then you see it? Oh, right. It does this part and it's much simpler. So um ah And rendering itself it's like not about math in general, but its it's super complex itself because it requires you to and do ah proper but basically, it's about
00:53:23
Speaker
How will you prepare data for GPU? like it's You need to pack data, send it to GPU, it's start processing. Then you need to write three letters that does the math on the GPU.
00:53:38
Speaker
and ah ah Sometimes the slow part is this preparation step wherein you to prepare batches for GPU and send this. This is an interesting task itself.
00:53:53
Speaker
like ah can be so solved in many ways like using the render graph and such other stuff but I'm using the evolutionary approach I'm not trying to like um create a cutting edge approach right away. I'm like starting with something simple, adding more functionality, refactoring stuff. and like ah You need to split complex tasks into smaller ones because otherwise you will just you can can't finish anything otherwise.
00:54:32
Speaker
Yeah, yeah. i'm i'm I totally believe that. I'm just surprised that you managed to split all these small tasks, still be writing most of them, and write at least one game in this engine at the same time.
00:54:45
Speaker
it it's actually three games that I wrote and there are quite a lot of projects that I know that using the engine ah and some of them are um in like commercial projects. Really? Yes, but some like I had a conversation with the with the person who like, here's the money ah for for your work. i got I got some like commercial task and and I did it with your engine, and like this is your part of the money. And they told me that they will like showcase their work ah in the Discord server, but it isn't there. I don't know why. Sometimes people yeah sometimes people come to Discord and like complain about some problems in the engine. And I see that they are working on something, but they for some reason don't want to share their work.
00:55:57
Speaker
I don't know why this happens. did This is beyond my imagination. Yeah, I imagine in the game release cycle, you want to kind of have a hype budget, right? You kind of don't want to say what you're working on until it's ready. But that's the first time I've heard of someone being reluctant to talk about the project but still willing to send the open source developer money for it.
00:56:21
Speaker
That's quite nice. Yeah, that's cool. Okay. no I am beginning to get something of the shape of this in my head, right? You've got, okay, so you've got, I see how the scripting system works, object hierarchy, hierarchy message passing, rendering. ah You've just about convinced me that that's a tractable problem by a solo developer.
00:56:44
Speaker
Another huge part of this and I think must be really important for it building proper game engine is like the whole UI toolkit. Oh, yeah. that's out loud and but yes Since i've I'm a tools programmer and yeah, the UI is is very hard task actually. And ah back in the day I used WPF from Microsoft at my ah my job. And um it was like like this enterprise, huge package that allows you to build interfaces with just this markup language called XAML. And ah it has
00:57:32
Speaker
has like tons of features but you you use like a tiny fraction of them and yeah I was so impressed by this library so I basically created my own UI library inspired by this by the WPF and it was a super hard task really because I've never done anything like this before. I did some simple UIs, like what do you need in games? Like button buttons, text, some sliders, maybe lists. And when you're like trying to like do a generic approach with this, you immediately start to realize that it's like an iceberg, like a small tub.
00:58:24
Speaker
And the rest is hidden under the water. Yeah, you can see at least 20 years of arguing about UI frameworks in the JavaScript world, right? Yeah, exactly. This never stops. And um the UI system and the engine, it is um inspired by WPF, the but it since it's written in Rust, it uses very specific Rust approaches because um as For example, ah the layout system, which is the core of any decent QI library, so that this system doesn't you doesn't force you to directly specify positions of items, texts, and so on, some other widgets. Instead, you're telling
00:59:15
Speaker
This widget will be at the right top of the parent widget in which bounds it like stays. And you can change the alignment of it for any corner of center, left, right, bottom, and so on.
00:59:30
Speaker
and um some ah other stuff like direct positioning is also applicable in here, like sometimes the sliders allow you to do constrained movement along particular a axis. And ah this layout system is it's probably the most hard part of a us ah UI system because it is It is complex because it requires you to do two passes. First pass measures the widgets. The entire hierarchy is measured. So you know how much size each widget wants to take. And ah it just it starts to become complex when you like have arrangements like grid.
01:00:24
Speaker
Because in Grids, you have um you can specify um that your row will take ah this the the height of ah the largest object in it. It could have like like three rows and ten ah columns. and The height of the row will be the max height of every widget that occupies this row.
01:00:53
Speaker
um and like Some rows require to be stretched, so they will fill the rest of the space a available in parent bounds. like And yeah there are a lot of these like arrangement techniques, like at least there are stack panels. Basically, at least there's ah it's like a stack panel, like it stacks on the next item above the previous, or it could it could stack them in a horizontal way.
01:01:30
Speaker
and and definitely think of situations in like CSS where the child constrains the size of the parent and the parent sometimes constrains the size of the child. Yeah, exactly. And ah sometimes you need to measure twice, which could lead to like,
01:01:49
Speaker
ah This increasing complexity, ah like normally you would have like O-N, like ah this asymptotical complexity. And um when you measured twice, you could end up in like O-N power of two, and this is quickly get out of hand and starts to like, even performance like crazy.
01:02:16
Speaker
but I'm really surprised to hear you say that when we talk about 3D rendering, you say, oh, that's just casually linear algebra and integration. When you're a UI, suddenly you're worried about performance and algorithms. Genuinely, that's the that's the scariest part. ah Yes, this that's because I'm building the editor and the editor is and probably the most complex thing I have worked on. Seriously, because that's it has so much of moving parts. it's it you ah um At the bottom layer, it uses the engine itself. So it see it is built using Fireox itself. so um So is in one sense a Fireox game? ah Yes, it's sort of a game on the engine.
01:03:05
Speaker
um and the The next layer is those ah windows, ah the docking manager that allows you to like hold windows in specific places on your screen, detach them, drag them, attach in different places, split places for two windows, attach them there.
01:03:27
Speaker
and oh And ah we also need to build a lot of different tools like you need to ah how it is called a world outliner or world viewer and that allows you to see which objects you haven't seen and how they are related to each other like this object have these children are and objects and they are you want to see like a like almost like a file system, tree hierarchy browser. The tree. and And also this tree also needs to be implemented in the UI library. So I mentioned that ah ah which amount of widgets you need to have to build an editor. ah Currently, Firefox have 45 widgets, or maybe more.
01:04:17
Speaker
And all of them I used. like And sometimes you have very weird widgets, like a curve editor. And why would you need this? Of course. Yeah, yeah. You need Bézier splines. Yeah, exactly. for animations For animations, you need to have an ability to say, to tell the engine how the like parameter will change over time, and which should transition will use a little bit linear, or cubic, or or something specific.
01:04:45
Speaker
And um It's in any way you go, you will face specific tasks that will take a huge amount of time. like I was creating an animation editor for four months, maybe, or five months, and still sometimes it it requires some attention to it because there are bugs in it that only found when you're using it extensively.
01:05:18
Speaker
um That's part of the reason why I'm using, why I'm building my own game using the the engine and the editor because this is the the only reliable way to find at least most of the bugs. yeah if you If you use this, the tool you're making, you will be familiar with this like quirks and other weird places and you can fix them.
01:05:46
Speaker
um And since you are using it, you and you built it, ah you can fix it quite fast. So you don't need to to be like Unity. This is like insane. ah It's a very bad example, actually, because they...
01:06:05
Speaker
ah As far as I know, they at some point made a game using Unity, and there this game was built by their own department. I can't remember it in the name, but recently they decided to like throw it away and ah let the community test their engine. And sometimes it leads to bug reports that aren't closed for like decades.
01:06:32
Speaker
and Why do we need to care? Those guys will fix them by themselves. ah yeah Yeah, I sometimes think one of the hardest things in industrial computing is like, if you're writing an accounting package, as a software developer, it's a very, very small chance you'll ever want to be a user of it, right? A lot of industrial computing, that's even worse. I mean, when would I use an insurance accounting system? Yes, exactly.
01:06:59
Speaker
you You need to like trust to the the competence of those developers. They can't get that experience. Whereas if they're games developers, they stand a chance of like getting the experience of the engine you're making. Yeah, yeah exactly.
01:07:16
Speaker
this so All of this is fair yeah like um very interesting because you are creating a tool and you are the user of it. So ah you are your it's your interest to build a reliable tool and helpful tool that will save time. So yeah pretty much any tool.
01:07:36
Speaker
that to people that like humans made throughout the history you were designed to save time. like Why would the game engine not do this? If a game engine like spends most of your time on simple tasks, and why use a game engine?
01:07:52
Speaker
I can see why you'd end up in a situation where you're going to the effort of putting in hot reloading, because that only really starts to matter if you're feeling the pain of not having it right. Yeah, it was so painful because the hot reloading is like an maybe be a year. Yes, it was implemented a year ago, maybe, or maybe even less. And before that, it was, it was so painful. Like a rust is, its it can be compiled pretty fast. Like you can cut down to less than a second, but
01:08:26
Speaker
Your game state will be lost and you need to reiterate all over again to create those exact situation that goes back Yeah, um it's not just recompiling the whole system. It's also running through the game to get to level three, right? Where where the thing you wanted to test was exactly and that takes like a normal amount of time but um Here's a small example from my previous work at Larian they have this like go ah their editor and it was super slow to compile like a small change and it will compile for 10 minutes even on a beefy machine like with like 16 core CPU and so on. yeah And like you did some stuff, first compile
01:09:16
Speaker
ah like wait for it to finish and you return to it and forget what are you what I was working for. yeah ah I know I changed a number, but what did the number mean? and yeah exactly How it go to total test my change? ah It's like this. And those iterations are super slow and so annoying.
01:09:37
Speaker
and I remember there was an old PlayStation game that solved that problem by having Lisp as the business logic and would just send Lisp over the wire, which, you like you said with Lua, you can do that with an interpreted language, a compiled language. That sounds like it'd be much harder to get right.
01:09:55
Speaker
a Yeah, compiled language. Since this is native code, this the basically leaves you alone with the like the CPU. and like if you If you do something wrong, it will just stop your application and tell the operating system to shut it down and like yeah go with this dump memory dump and try to debug it. Have fun. I've got to ask then, how long did it take you to get the hot reloading system working reliably?
01:10:31
Speaker
um I tried to implement it even like before and Before this and was it was like maybe three years ago and that was a failure because I amm like used to draw an approach. For some reason, somehow I got in the situation when ah the game and the engine used the different versions of the the um of the code. So um it's basically like...
01:11:08
Speaker
not Sorry, not not the the engine. they israel and The game used different um ah different engine versions. So basically, it was two two libraries. and um take her They are very incompatible and because they weren't produced by the same comp from the same compilation like procedure. And REST generates some internal, um for example, type IDs, that simple numeric values, that are different across compilation attempts.
01:11:45
Speaker
i and um ah I couldn't solve this and then ah like a year ago I asked a friend ah to to help with this ah and he was soon experimenting with this hot reloading for quite a long time ah in in his own rust engine and him with with him helping me I managed to um
01:12:17
Speaker
so Finally, ah figure out those weird dependency issues where you like have these wrong library versions and so on. and um Basically, it took me in some maybe i am maybe a month or so.
01:12:38
Speaker
Because yeah it sometimes, but ah like ah and those examples with ah vtable ah vtable related crash, it was alone like a week trying to debug where it happens. A month sounds fast, but a second attempt with someone else who's crossed that path. Yeah, exactly, exactly. you but We don't need to work alone if we can ask help. Yeah. So, so let's lead into that then. Cause you, you worked on this mostly alone for something like four, four and a half years. Yes. Something something like this. that Yes. And there were some contributors that came along and like I did a huge chunks of, uh, of code, like, um,
01:13:29
Speaker
ah Reflection system was initially, yeah, reflections yeah and serialization also was written by a single person ah from Japan. and When you say reflection, you mean like runtime introspection, not yeah like bouncing off the water.
01:13:48
Speaker
Yes, exactly. Yeah, just checking. yeah Yes, exactly. um Because I needed the reflection system for the editor so the editor can introspect objects, so it can edit them, and so some something like this. it's it's ah um It does not allow you to do some crazy stuff like C Sharp's reflection ah system, say a something like ah um colon methods in the dynamic way.
01:14:14
Speaker
But it provides access to internal infrastructure and that's very, very, very helpful to build in the editor. Rest unfortunately does not have this built-in yet. As far as I know, there are some proposals for this. Maybe sometime it will be implemented.
01:14:33
Speaker
Whatever. i just built ah We've just built our own system. Go on, give me some hints. i'm I'm too curious not to ask. How do you how you retrofit um reflection into Rust?
01:14:46
Speaker
It's basically be built on top of, yeah not on top, or using the procedural macroses of Rust. It allows to like execute some code written in Rust to modify the abstract syntax tree of your codes, insert some functions, ah implementations for trades. Basically, it's ah called called generation. Generation of like the the... compile time information you're going to need. Yeah, exactly. Okay, that makes sense. And it is indeed restricted in some places, but it works for like 95% of time. And yeah, it's super helpful. Yeah.
01:15:33
Speaker
And the serialization is also written using the procedural macrocystoscope generation. because it's basic But it is much much simpler than reflection, because reflection requires you to um like create a lot of methods that allow you to access various fields.
01:15:55
Speaker
of structures and um like walk walk over them yeah in the like like would walk over a tree structure. and ah like You need to fetch some information like name of a field, ah type of it, and maybe some additional information like a description string for the editor, so they sort you ho hover the mouse over some fields and it will give you a hint of what it does.
01:16:24
Speaker
ah So, yeah, it took, to build a simple ah simple basic version of it, took probably, I don't know, probably like three weeks maybe, but then it was extended and it's still not done yet, because it sometimes requires of specific specific routines, like that's specific to the engine itself, like,
01:16:52
Speaker
since the engine allows you to like create prefabs, which is a so small scene that contains a set of objects, basically a subgraph. and Those objects could have their properties, um and you can instantiate this prefab on your some other scene.
01:17:18
Speaker
and ah When you change this prefab itself, the changes will often automatically reflect on those instances. And this also works in a hierarchical way, so you can like have a room, and this will be... like a a prefab that contains other prefabs such as this microphone and some some chair or or something like this. and the These objects can have their own objects because everything is built from much smaller parts. and like For example, you have 10 such rooms in your a large level and at some point in time you decide to change
01:18:06
Speaker
um something in the room in that room. And ah if you wouldn't have the system of property inheritance, ah you will be in huge trouble because you need to manually ah change all those instances. But with this inheritance system, you just need to open that profile, i change something in it, and it will be ah reflected on all those instances.
01:18:31
Speaker
and Here you go. It's super simple. Yet it it took me like three years to implement it correctly because it sometimes still fails yeah for some weird situations.
01:18:45
Speaker
Weirdly, that's reminding me of like prototypical inheritance in JavaScript. I haven't used this and yeah sort of, uh, there's sort of an archetypal parent object, which isn't really, that just contains properties that everything else, every child refers to. If I'm not mistaken, there's the similar concept in war, uh, called meta table. Yeah. Uh, yeah. So I'm familiar with, but, but, uh, and it also, like a hierarchical, right? So you can like extend this archetype and ah like create a derived version of it and then again, derive version from it and change the space and that will reflect in ah in the those derived, how would you call it, archetypes, right? This all adds up to you pushing Rust quite a long way from kind of its origin story.
01:19:47
Speaker
Yeah. it's but But again, it's it's interesting. And I basically can do this whole all the all day. Yeah. and mean I mean, I suppose, given how you can build all those kinds of languages out of C, there's no reason you couldn't build all kinds of interesting language features on top of a Rust core. together right Yeah, right. But again, this makes me think,
01:20:15
Speaker
How do you, as a largely solo developer, manage to fit this in? I mean, if if I hired a team of 100 programmers and you gave me five years, I couldn't guarantee it would work. Yeah. just It's like it's like a this ah like anecdote, maybe, when a woman can't born, um like like and nine women can't born a child in one month. Yeah.
01:20:44
Speaker
yeah And the same is with the engine. When you start, you like have a small number of places where people can work on, because you basically don't have anything. like But when the engine starts getting bigger,
01:21:07
Speaker
you clearly see that you have sound, editor, graphics, UI, and other other parts. and Probably the best way to do this is like to start with a small team and then add people to maintain ah more mostly ready parts.
01:21:32
Speaker
yeah so I can't build the UI engine when there's no rendering engine to render it with, so you can't parallelize it. yeah except is this why excuse me Is this why something like four and a half years in, you're starting to farm out the work to other people? Or is that more a social thing that people are starting to give attention to the project?
01:21:52
Speaker
It's the latter and people just like starting to get interested in the engine and work on it on design for some ah some parts I haven't touched for like years years and like ah somebody ah starts working on this and I'm I couldn't even realize that something is broken in there because I haven't used that in a long time and people like this stuff needs to be rewritten or it's like have these some bugs and these bugs and and so on and that's cool when you have flower changing and like it's it allows you to um get a high level of parallelism to like
01:22:41
Speaker
It's like an ideal parallelism where ah each one do not interfere with each other. i ah So in that case, that raises the double-sided question of what state would you say Firefox is currently in and where do you want to get it to next?
01:23:02
Speaker
It is currently able to ah create pretty much any kind of game um starting from simple 2D platformers and ending up maybe like relatively big open world games. It still and don't have ah some features that needed for these kind of games like world streaming and well streaming. Yes, exactly. It's where you ah have your world divided into chunks and then do not load everything at once, but load.
01:23:36
Speaker
Sorry and load that when you like traversing the world like you've come closer to an other chunk it is get loaded and ah the other one is unloaded and because you like don't have all memory in the world and processing powers you like limited to some small amount of memory.
01:23:55
Speaker
This is the old thing like in the Grand Theft Auto games where to get to the next island you'd have to cross a bridge that was suitably long and boring that the game could secretly unload one island and load it the next. Yes, yeah exactly. yeah It's exactly is like exactly this. You need to um be able to hide that part of the world that you don't use. As worldstreaming. Yes, exactly. and um Maybe ah ah if you have like tons of objects, the current approach with OOP is not so good. Because again, you see it's here and not not just because everyone wants to use it for some reason. It's exactly for solving specific problems. It's another tool that but has its own uses.
01:24:45
Speaker
like specific use is maybe high parallelism with large number of objects like maybe a real-time strategy where you have like thousands, tens of thousands of enemies on map and like maybe yeah maybe the ghost good example will be like ah Total War game, maybe something like this. or I don't think I know that one. but ah it's it's It has huge armies, if I'm not mistaken, the title. the title
01:25:19
Speaker
um It has a lot of moving parts on screen, let's say, in this way. And ah you need to process everything at once, and you need to efficiently use CPU resources for this. How is this like the kind of games where you've got a battlefield simulation and there are tens of thousands of fighters and you're trying to model each one individually rather than as a battalion? Exactly. yeah yeah Imagine how many moving parts are there. It's a crazy amount of moving parts.
01:25:51
Speaker
And yeah um so, but again, this could be solved by using GCS with the engine and there's nothing wrong about it. ah you late and du Basically, people use UCS with Unity, Unreal Engine, we need it and get this crazy performance when needed. So again, use the right do tool for the job and it will be solved pretty easily. So there may be some time in the future where ECS gets bundled into Firefox.
01:26:26
Speaker
but Maybe. Will you just roll your own? um Maybe. I don't know, really. Because um and um I don't want to try to build everything in ECS because i it's the counterintuitive. like Building UI in ECS, it's like, I don't even know how to do this because it is So it's a different like task. It's like in parallel dimensions.
01:26:57
Speaker
ah okay Because UI, naturally, is like a um hierarchical structure where you're using either are callbacks to interact with like events from widgets or maybe message passing that Firefox uses.
01:27:17
Speaker
and It uses hierarchy to deliver events or maybe co callbacks and so on and so forth. And I simply don't understand how would one build that in ECSS. The guys who try and And it's totally fine with this. I'm totally fine with this. ah But yeah, it's like um super complex and counterintuitive, in my opinion.
01:27:48
Speaker
I don't want to start another flame war, like which engine is better, which one. Well, let's say that a hierarchical UI is a well-trodden path that doesn't need too much research. Yeah, exactly. yeah Okay, so ah i I'm now thinking of one other incredibly large part of this project.
01:28:10
Speaker
which I don't know if you're responsible for it directly, but there's a whole book on how to use fire rocks, right? Yes, exactly. And then I also made this. You wrote the book as well? Yes, exactly. you How many of you are there? hu Guys, can you please like get in there? There are like an army of my clones, right? That's the secret. Just clone yourself. Yes, exactly.
01:28:37
Speaker
And this is not my apartment. It's like an open space where a lot of people sit in there, but mostly mostly my clones. How do you find time to write a book on top of this? ah It's basically ah when somebody asks a question in Discord server, I go to the book and write an article there and like Here's the link, and just to read it. And the answer questions once. Yes, once and for all, I hope. and But that's really that's a really good approach because you don't need to
01:29:15
Speaker
answer that question over and over again and some so at some point it starts to annoy you and newcomers might consider you like a toxic person and when you ah they don't know that you have answered this question like thousands of times already. Of course not. So you're actually seeing writing a book as a time saver.
01:29:38
Speaker
It's a huge time saver. I don't need to answer those questions ever again. They both are in the book and also there are like ah tutorials for the engine and just There is also documentation for specific parts of the engine like of what each send node does how update loop is ah is is working which events ah ah which for and so on and so forth and Yeah, it's it's an iterative process, as usual. You start from something simple, like how to build the engine, and then you start adding some useful information here and there, and eventually it gets bigger and bigger. um i As far as I know, I added Google Analytics to the book, and each day it is visited by a few thousand people.
01:30:34
Speaker
yeah So it's just imagine those people will go to Discord and start asking questions there. I will be probably not happy to say the least.
01:30:45
Speaker
yeah so so where Where are you going to go to in this? like If if i were to I were to phone you up three years from now, do you think you'll be, do you think Fireox will be in some games, a lot of games? Will you still be building the engine or will you be stopping and building your own games on top of it?

Future Aspirations for Fireox

01:31:06
Speaker
I hope it will be used in like and games like those that you can download from Steam and play. ah Currently I'm building my own game ah that allows me to like improve the engine and I hope I will release it someday because ah i need I need this because i I want also to switch to other game genre because I'm kind of bored by third-person shooters that I'm currently building. it's like when you do When you do this for like three more more than three years, it's like becoming like a job and it is quite annoying.
01:31:47
Speaker
and so And also when the engine changes and you need to change a relatively large game, it's and so annoying. Imagine that you like ah yeah ah Unity would change almost everything in every version.
01:32:04
Speaker
I don't think that developers would like this at all. yeah You've only got one person to blame, though. yes so um add that That's part of the reason why I'm trying to um introduce as at least to breaking changes as possible. I'm the user of the engine too and I'm not interested to rebuild the game from scratch yeah and again and again because yeah I wouldn't create anything good from this. It would be a waste of time. Yeah, yeah, totally. So if you're not busy out there selling games on Steam to support this, how is it supported?
01:32:46
Speaker
ah It's like most donations from people. The engine is funded by donations. And yeah, but those donations are this small, maybe.
01:33:00
Speaker
ah it's The life of an open source developer. Yeah, exactly. It's like at peak it was like three, maybe $400 per month. And it was like for a few months. And but then it's like dropped to $200 and now it is like 50 bucks.
01:33:23
Speaker
And still you keep going. Yeah, um but that's because that's my passion. It's not about money. It's about solving interesting tasks. And, you know, like when you have something interesting, you can spend all day doing it and nothing can distract you. Even like maybe hunger will distract you. but think It's one of the few things. Basic bodily functions. and um
01:33:54
Speaker
I have some savings. So I like to work like maybe two or three years, then take a break for a few years. That's, more that's how I'm working right now. Um, currently in the, in this, uh, how, how would you call it a vacation state? Maybe they call it, um, a sabbatical.
01:34:20
Speaker
Yes, exactly. You take the time off, but you're still working jolly hard. Yeah, yeah, yeah exactly. Exactly. yeah like I worked for almost three years, learning studios, helping them build the Winter Region of Scene 2, Baldur's Gate 3. And then I have like a year, more more than a year break. And then um I was hired by Playrix to create some mobile games. And then I worked there for like almost more than two years, I can't remember exactly. And that allowed me to build some savings, like five five for financial assistance. A war chest. Let's give it a gaming term. A war chest. And so I can live without the fear that tomorrow I will like eat nothing um or something like this.
01:35:17
Speaker
It is actually a very good approach if you want to work on your own ah like project. and But that's indeed not for everyone, because family eats quite a lot of money monthly, so you need to have a huge pile of money to to support.
01:35:40
Speaker
ah Yeah, and living with the uncertainty isn't easy either. Yeah, exactly. So you can focus on your project while being like unemployed and with a tiny amount of money. yeah So you need to build like a stple stable foundation.
01:35:58
Speaker
Okay, then speaking of stability, if we want to answer me these two questions. If we want to commit to the stability of Firox and support you, how how does someone donate? And if someone wants to start writing a game, where do they start? What are those links? About donations, there are three options, basically. You can like either donate via Bitcoin, which is um as acceptable for some people. And there is Patreon, there is a local services for my country. And ah so you can do any you like. But I think the most um
01:36:45
Speaker
and valuable for me would be to see a game on the market. to ah that's a I think that's the dream of most of open source developers. But sometimes it like gets a bit i o it' it's bit gets a bit annoying when you see your work, but you don't get any recognition from this. and ah like maybe ah my my own dream would be to have a developers like a team of developers, like a few people maybe, ah ah who will work on the engine one full time, because I'm myself not working on full time. but Basically, I'm working on it where
01:37:36
Speaker
where I feel passion for it. But I'm trying to so do something every day, so I want to detach mentally from the project so much. And yes, something like this, maybe... ah
01:37:56
Speaker
maybe um some some document Maybe somebody could write some documentation, maybe ah didn like contribute to the to the code itself, maybe create some tools, and something like this. There are lots of ways. If you don't have money, you can invest some time in it, which is basically equivalent of money. release a hit game and make sure people know that you wrote it with fire rocks and maybe send us more royalty or what? Yes, something like this. It's the engine will be free forever. I'm not like unity who did
01:38:33
Speaker
dirty things. A little of that controversy. Yeah, that that was insane. Like this ah fee that that they ah a train were trying to push. Yeah. Okay, so should I, if I put a link in the show notes, should I start with the book to learn how to use firework?
01:38:53
Speaker
Yeah, exactly. yeah It has pretty solid um like chapters for beginners. There's how to install the engine, how to create the scene. There are tutorials, like how to create a 2D platformer, how to create a first-person shooter. They're all not not so finished. They're in the platformer maybe two parts.
01:39:20
Speaker
In the first person shooter there are three parts covering various aspects even the animations and Yeah, it's a good way to start i I'm also sometimes people ask me to do ah video tutorials, but I don't really like them because they will I can't update them easily because if the engine changes it's like very quickly becomes obsolete. And you can't be constantly refilming videos, it's hard. That would be insane. This is insane to rewrite the book when something changes but hopefully Rust helps here too because
01:40:05
Speaker
it has an ability to test code snippets in the book using the end the any library you want. So you basically click a button and it tries to compile code snippets and tells you where is there. So you will have this up to date and nobody will complain that here and there you have messed up code. Right. So that's one of the thing you need then, which is like,
01:40:35
Speaker
a YouTuber constantly creating videos about fire rocks who is delighted for an excuse to record a new video and re-release it. um ID the poll someday, maybe even two times or maybe three. ah Which kind of tutorial would you like to see? And most of the people maybe 85% was for the text produce plus images version, not the videos. Because ah in a video I would like speak in this
01:41:11
Speaker
ah OK, like broken English that I'm speaking right now. and um It can't be it can be easily translated. But with today's tools, like an AI-assisted ah translation, this feasible, but yeah it's still not so not so great. so And text all that textual versions can be easily scrolled to any point you like and you can read it at your own speed and it is much more comfortable than than videos. but Maybe at some point I will ah create a video tutorial when I feel that the engine is stable enough that this part won't change, at least for maybe a year or so.
01:42:00
Speaker
Well, if if you weren't busy enough already, there's another thing to get involved in. Yeah, um I have a lot of free time. Yeah, sounds like it. Because of all your army of clones, on which point? I'll probably leave you to go and feed the clones. Dimitri, thank you very much for joining me. so Thank you.
01:42:22
Speaker
Thank you, Dimitri. As usual, I'll put links to the Firefox homepage, the Firefox book, and everything we discussed in the show notes. I'm also going to put a link to Pico 8 in the show notes. If you haven't heard of that one, that's a really interesting project. It's another game engine. It's also built by one person. But the way that they controlled the scope of that project was by saying, this is just for making retro games for a virtual 80s style console.
01:42:49
Speaker
Very cool project. Lots of fun to play with. I have tried and failed so far to get in touch with the author, but they remain on my wish list of guests. So if you know them and you know how to persuade them to be in a podcast, please do. I would hugely appreciate it.
01:43:07
Speaker
I would also hugely appreciate it if you took a moment to click like if you liked this episode, rate it if you're on one of the podcast apps, maybe share it with a friend and make sure you're subscribed because 2025 now lies ahead of us and we've got some great episodes coming down the line. So make sure you're subscribed and you won't miss them. In fact, on that note, I best go and record the next one. So I've been your host, Chris Jenkins. This has been Developer Voices with Dmitry Stepanov. Thanks for listening.