Zig feedback from a game developer

Writing shaders in zig would be incredible :slight_smile: Looking forward to it!

1 Like

Woohoo! Woohoo!
[post needs to be at least 10 chars… :slight_smile: ]

4 Likes

This makes me very happy, and will be a really exciting addition to the language. :grin:

Being able to write your GPU code in Zig is a really nice feature, not one that exists and/or is easily accessible most other general purpose languages. I imagine it will make it attractive to AI developers, but I am personally just excited about it for the game-dev possibilities.

3 Likes

I’m pretty sure it always worked with try. Here is feature description from when it was first implemented. It doesn’t work with catch tho maybe you mixed them up

2 Likes

(regarding memory management and shrinking/growing memory)

Also, games typically oscillate around a predictable max memory usage, and object lifetimes can be roughly divided into a handful of buckets:

  1. ‘static lifetime’, e.g. created at startup and destroyed at shutdown
  2. ‘level/zone lifetime’, e.g. created during the ‘lifetime’ of a map/level/zone/region and bulk-destroyed when that area is left
  3. ‘frame lifetime’, created at some point during a frame and bulk-destroyed at the end of the frame
  4. ‘unpredictable’ anything else, although here various strategies make sense to still avoid fine-grained per-object lifetime management and unlimited growth.

For anything in the ‘unpredictable lifetime’ category I would use a fixed-size pool where items are only marked as dead and the oldest dead item will be recycled when a new item is needed. For instance for something like killed monsters you’d want their carcasses to still be around, but at the same time don’t want to pile them up beyond a maximum number.

…or for bullets (here I wouldn’t use a fully fledged game object per bullet, but something more lightweight more akin to a particle system).

Inventory items can also be fully virtualized instead of being actual game objects. E.g. just build the inventory system completely separate from the rest of the game.

Etc etc etc… IME it’s especially dangerous/tempting in games to run into the ‘everything is an object trap’, because most games deal with representations of actual physical objects.

5 Likes

I agree that it’s a good time to try out bespoke engines. Great video

1 Like