Skip to content

Instantly share code, notes, and snippets.

@mjakeman
Created February 2, 2024 01:31
Show Gist options
  • Save mjakeman/691dddfb4636a2a68b500c7223981bfb to your computer and use it in GitHub Desktop.
Save mjakeman/691dddfb4636a2a68b500c7223981bfb to your computer and use it in GitHub Desktop.
Matthew's Zig Wishlist

Matthew'z Zig Wishlist

From creating my 3D pixel game engine.

Pain Points:

  • Lack of easy polymorphism: I currently used tagged unions and it's fine-ish, but having interfaces or traits in the language would make it infinitely more ergonomic to use.
  • Casting is a nightmare: There really needs to be a shorter way to cast from int -> float and vice-versa. Compare C's (float) with Zig's @as(f32, @floatFromInt(...)). If I could write @floatFromInt(f32, ...) it would already be much better.

Nice to have:

  • Comptime methods: I wanted to add swizzling methods for my custom vector struct, however you cannot generate methods at compile time (?). It would be nice to have a function e.g. Vector(dimension, components) which can then generate swizzle methods for each combination of components. I imagine calling vec.xyzz() and having that method be generated and even inlined at compile time.
  • Easier way to do vector maths: I currently call vec.mul(other) but it would be nice to write vec * other. This requires operator overloading however, which isn't great. Maybe some kind of comptime based DSL?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment