2 ms·
Operator overloading makes simple math cleaner, but that's just a nice to have. The real kicker is value type semantics. You have two options with reference ty
by moonchrome 4y ago
Operator overloading makes simple math cleaner, but that's just a nice to have.
The real kicker is value type semantics. You have two options with reference types : you can either do math in-place or allocate on each operation. First option is a huge foot gun because the ownership is unclear it's super easy to share references to something and update something unintentionally. And it can be hard to track down. Second option is super taxing on GC. And the overhead of going through reference for simple 3 float tuple (and object type info, etc.) is large - but for large arrays you can sort of work around it by primitive arrays. But that's like hand rolling assembly and you're supposedly using a high level language.
C# with structs and operator overloading is an ideal high level language for gamedev - most of the time it's really ergonomic and high level, but it has the tools to get down to memory layout control without it looking like disassembled code.