Skip to content
0:00 / 0:00

#rust#ecs#entity-component-system

RustConf 2018 - Closing Keynote by Catherine West

Confreaks

42K subscribers • 90 videos on Hallway • Conference channel

YouTube
  • Recommended by 3 people: 3 in engineering communities.
  • Presented by Catherine West
  • May be out of date. Uploaded 8 years ago, in an area where tools change fast.
  • An opinion. It argues one side of a question engineers disagree on.

Intermediate. Assumes working knowledge.

7.5K views8 years ago3 recommendations

Programming languagesGame developmentRustUnity, Unreal and GodotDesign patterns

Catherine West explains why traditional object-oriented patterns fail in Rust and how entity-component systems solve these architectural challenges in game development.

RustConf 2018 - Closing Keynote by Catherine West When you’re just starting out in Rust, you start by building small programs. As we all know though, medium and large projects can have very different, unique kinds of problems that smaller projects never encounter. As our projects grow in size, we need to be increasingly concerned about code organization, separation of concerns, implementation hiding, and other techniques to manage growing complexity. Most languages have tools and patterns to deal with this, and Rust is no exception. However, the patterns that we learned from other languages, especially in mainstream OO languages, are often unhelpful when applied to Rust, and this can lead to a roadblock when trying to transition to building moderate or large Rust programs. This talk will cover a case study of a moderate sized game engine written in Rust and Lua, and show strategies for implementing things in Rust where common implementations in other mainstream languages are a poor fit. I’ll also discuss some examples of problems unique to Rust that ended up with very nice —but sometimes not obvious— solutions. Along the way, I’d also like to discuss working with Rust in game development generally, and what it’s like getting Rust to run on mainstream game consoles.

Why it's here

3 people recommend this

What people say. Highly recommended as the definitive talk on why OOP patterns clash with Rust's borrow checker and how ECS solves it.

u/OmnipotentEntityin r/rust • Recommends

On “Shattersong Online - New Rust MMO Browser platformer in development by former Starbound and Wargroove devs”

Kyren gave the keynote a few years ago at RustCon about how she should have used an ECS for Starbound, so I assume that that's what they're doing. link to this video

u/oconnor663in r/rust • Recommends

On “Hey Rustaceans! Got an easy question? Ask here (40/2019)!”

This problem comes up frequently when you have entities which don't "own" each other but which need to refer to each other. As you've noticed, holding pointers tends to make your code not compile. And for good reason: there's no way for the compiler to know that your employees live long enough not to create dangling pointers. (C++ has similar problems. Unlike Rust it'll let you compile the code, but then you'll wish it hadn't.) The recommended solution is usually to create something like an `EmployeeVec` or `EmployeeMap`. Then your `direct_reports` field becomes a `Vec<EmployeeID>`, where `EmployeeID` is either a `Vec` index or some kind of `HashMap` key. You then pass the `&mut EmployeeVec…

u/oconnor663in r/rust • Recommends

On “My Thoughts on Rust's Future - A Positive Outlook”

> thus you clean up by destroying all nodes and arena after finished. There are alternatives, like slabs and generational indices. Watch this talk: link to this video

u/reboin r/rust • Recommends

On “Managing Memory in Rust: Entity-Component Systems”

Generational arenas are a blanket term for data structures that allow constant time access (like a vector) for deletion without invalidating access (like a hashmap). They usually do this by combining an index with a generation. The SlotMap used in the article is one example. https://github.com/orlp/slotmap Another is: https://crates.io/crates/generational-arena Here is a video on c++ slotmaps link to this video Here is a video of a rust talk on game dev where generational arenas were referred to at the end link to this video SlotMap is really nice you should try it.

u/manurangain r/programming • Mentions

On “Rant: Entity systems and the Rust borrow checker ... or something.”

TL;DW **Original vid -** on youtube r/proggit r/rust blog * Rust borrow checker nudged me away form OOP and I used an ECS instead * What are good libs/techniques when writing an ECS in Rust **This vid -** * ECS is just ***a*** solution to the problem of transient graphs. Rust doesn't offer any novel/better way of solving the fundamental problem. * ECS written is Rust doesn't have any better compile time guarantees compared to one written in C++. So borrow checker adds little value to an ECS.

u/manurangain r/programming • Mentions

On “Rant: Entity systems and the Rust borrow checker ... or something.”

TL;DW **Original vid -** on youtube r/proggit r/rust blog * Rust borrow checker nudged me away form OOP and I used an ECS instead * What are good libs/techniques when writing an ECS in Rust **This vid -** * ECS is just ***a*** solution to the problem of transient graphs. Rust doesn't offer any novel/better way of solving the fundamental problem. * ECS written is Rust doesn't have any better compile time guarantees compared to one written in C++. So borrow checker adds little value to an ECS.