top | item 47185082

(no title)

dpc_01234 | 2 days ago

> In my experience, the most natural way to write things in Rust is usually the fastest (or close enough) as well.

Well, a lot of C/Odin/Zig people will point out that Rust's stdlib encourages heap allocations. For actually best performance you typically want to store your data in some data-oriented data model, avoid allocations and so on, which is not exactly against idiomatic Rust, but more than just a typical straighforward Rust just throwing allocations around.

discuss

order

VorpalWay|2 days ago

Fair point, I don't tend to do much with heap in Rust (or any language) as I do hard realtime. You allocate all you will need up front.

As for data oriented design: yes, and it depends on your usage pattern. E.g. arrays of structs can still be better than struct of arrays if that matches your cache line access pattern. Zig probably makes SOA easier for the cases where that is more efficient (I haven't used Zig, but I have read a bit about it. It has some cool ideas (comptime), but also things I can't get behind such as lack of RAII, and generally lack of memory safety.)