5 ms·
I'm no expert on zig, but the one area I have seen it shooting up in popularity is game dev. Though I guess that is largely as a replacement for C, so "C-style"
by bodge5000 3y ago
I'm no expert on zig, but the one area I have seen it shooting up in popularity is game dev. Though I guess that is largely as a replacement for C, so "C-style" wouldnt be much of a concern
- jsheard 3y agoZig looks like a fine C replacement, but C isn't what people are using to make games in the vast majority of cases. It's all C++, and operator overloading is part of the "sane subset" that everyone uses even if they hate the excesses of modern C++ as a whole.
- felixgallo 3y agoas a long time game dev, I actively don't want operator overloading. That's some spooky action at a distance nonsense. I'm not sure I have seen a codebase that involved operator overloading, either, and I've worked in or near a good quantity of well-known titles.
- jsheard 3y agoThere's no accounting for taste, but the two major publicly available engines (Unreal and Unity) both use operator overloading in their standard math types.
- Taywee 3y agoYou'd rather use explicit function calls for all linear algebra and geometry operations? I don't think adding two vectors using an overloaded + is that spooky or distant.
- flohofwoe 3y agoFWIW Zig can do that without operator overloading: https://www.godbolt.org/z/7zbxnncv6 https://www.godbolt.org/z/7zbxnncv6
- kprotty 3y agoVectors in Zig are SIMD types. Vectors in games are probably algebraic types. Using SIMD for the latter may not be that useful if 1) specific elements are accessed frequently 2) transformations involve a different operation happen on each element.
- cyber_kinetist 3y agoFirst of all that only works with vectors, but I want operator overloading to also work on things like matrices or custom types (for example quaterions, or a symmat3 struct that represents a symmetric 3x3 matrix using only 6 floats). Additionally, for efficient math code you often want vector / matrix types in AOSOA fasion: for example Vec3<Float8> to store an AVX lane for each X/Y/Z component. I want vector/matrix operations to work on SIMD lanes, not just for scalar types, and Zig currently can't support math operators on these kinds of types.
- felixgallo 3y agoI have a marvelous proof that you can solve that with comptime but unfortunately the margins of this website are too small to contain it.
- lvass 3y agoDo us a pastebin, please.
- QQ00 3y agoYou can use pastebin, or even better, use github gist.
- another2another 3y agoI think you have briefly deluded yourself with an irretrievable idea.
- chlorion 3y ago>That's some spooky action at a distance nonsense. In pretty much all languages operators are just sugar for calling a method. There is no difference other than an easier to read syntax. In rust for example, doing a + b is exactly the same as doing a.add(b). In python it's exactly the same as doing a.__add__(b). In C++, my understanding is that its sugar for a.operator+(b) or operator+(a, b). I think there are some arguments against operator overloading but "spooky action at a distance" doesn't seem to be a very good one to me.
- pjmlp 3y agoNot really, it is mostly around communities like Handmade, most studios couldn't care less and it doesn't fit most engines that they are using.
- deleted 3y ago[deleted]
- deleted 3y ago[deleted]
- mr_00ff00 3y agoWould love to see zig in game dev. I’ve tried some rust and while I love rust in general, I find game dev in it a bit of a mess.
- adastra22 3y agoHave you tried bevy? I’m starting with bevy for a non-game project, but I’m blown away by how simple it is to use once you get used to the magic.
- the__alchemist 3y agoBevy isn't on the same level as tools like UE and Godot.
- Ygg2 3y agoTo be fair Godot isn't on same level as UE.
- adastra22 3y agoDepends on what you're doing. I'm writing a non-game app that requires a scenegraph, raycast mouse selection tool, and other tools of the sort typically required by games and provided by a game engine. But there's a lot of game stuff I don't need, and I need to make major customizations to the rendering engine. It ended up being easier to implement in bevy, due to its modularity, than it would have been in UE4 or Godot.
- nextaccountic 3y agoZig gamedev libraries aren't either
- mr_00ff00 3y agoMaybe I need to give bevy a second go. My big issue is I felt I was learning to speak “bevy” instead of using rust. A lot of functions I wrote required queries of components, but the queries were built and called behind a magically wall. I don’t have much game dev experience though outside of simple games using libraries like raylib to just move and draw stuff. Maybe once things get complicated enough they are all like bevy.