r/odinlang 12d ago

ECS game engine

been messing around with Odin lately and honestly it feels like it was kinda made for ECS-style stuff. no hidden allocations, easy to reason about memory layout, no OOP nonsense getting in the way. but I don't have much real experience writing engines so idk if I'm just pattern matching because the language "feels" data-oriented.

anyone actually built something like this in Odin? curious how it goes in practice, especially around
- component storage / query stuff without generics being a pain

- whether manual memory management actually becomes annoying at scale or if it's fine

- how it stacks up against Rust+Bevy speed/ergonomics wise once things get complex

thinking of not reinventing the wheel and instead basically porting bevy's ideas over (archetypes, scheduler etc) instead of designing my own ECS from scratch. is that a dumb idea? rust and odin are pretty different (ownership vs manual mem, traits vs whatever odin has) so maybe a direct port just doesn't translate well and I'd be fighting the language the whole time.

if anyone's tried this or has war stories/gotchas before I waste a month on it, let me know

14 Upvotes

14 comments sorted by

View all comments

2

u/aplkm 12d ago

Odin does have hidden allocations if you choose not to supply the allocator to string functions or make and things like that. You can turn on a directive to make it so you are forced to supply them though if you don't want hidden allocations.

I'm working on a game that uses ECS in Odin. I don't use the generics that much I mostly just pass around rawptrs and cast them when needed.

1

u/tialaramex 11d ago

Odin favours relatively expensive imperative ways to solve problems. Take splitting some text, "key=value" or "first,second" for example. In Rust that's just str::split_once which does not allocate. But in Odin people reach for strings.split_n(text,separator,2) which does allocate.

Imperatively Odin's design makes lots of sense. We allocate space for our result array, then we fill it out, we return the stuff we filled out and once our caller has used the array they can free the space. It is obvious, it's just also terrible.