Live data from Hacker News

Zig gamedev project – left my job to build games in Zig lang

github.com

101–110 of 126 posts

Re: Zig gamedev project – left my job to build games in Zig lang

#101

Earlier quoted context omitted.

Adding bounds checks and ASan is not an order of magnitude improvement over C. Chrome, for example, is doing all of this already in C++ in a more advanced way than anything I've seen in Zig. Clang offers UBSan [1], which is extremely advanced. Yet it is not enough. It is not a "nuanced and balanced" approach: Zig is simply not memory safe . [1]: https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#...

If you're shipping a game that runs on a player's computer, you're most likely going to make production builds with -O ReleaseFast (safety checks off). Rust is overkill for this use case. The only benefit memory safety brings to this use case is making debugging easier. But if we're measuring how debuggable a language is, there are many more factors, such as iteration speed due to compilation times.

Memory safety also adds reliability, by catching bugs statically that you didn't catch during (automated or manual) testing. It's the same argument as for static typing.

It's of course true that some developers may judge the tradeoffs differently for their individual projects—that's why they're tradeoffs! But there are benefits to memory safety that go beyond security.

Re: Zig gamedev project – left my job to build games in Zig lang

#102

Earlier quoted context omitted.

If you're shipping a game that runs on a player's computer, you're most likely going to make production builds with -O ReleaseFast (safety checks off). Rust is overkill for this use case. The only benefit memory safety brings to this use case is making debugging easier. But if we're measuring how debuggable a language is, there are many more factors, such as iteration speed due to compilation times.

Memory safety also adds reliability, by catching bugs statically that you didn't catch during (automated or manual) testing. It's the same argument as for static typing. It's of course true that some developers may judge the tradeoffs differently for their individual projects—that's why they're tradeoffs! But there are benefits to memory safety that go beyond security.

the only memory safety gamedev needs are bound checking and use after free protections

everything else is just bloat and noise that hurts iteration time

and even if one would still value them, you'd need to check only once for whatever memory check you want to run, when you build your allocators for example, and not at every builds, and you could even write the logic yourself and have a debug allocator to ensure memory safeties

you want sub second and not "double digit seconds" build times

it takes one to try to make a game to trully understand why iteration time is far more important that anything else (other than performance of course)

you don't want to wait multiple seconds everytime you change the speed of your character, or tweak the rendering/AI code

that's why then some devs end up using scripting language and they loose all the advantages of their native language, because they want to speed up iteration time

that's why i personally stick to D for my game, my engine + game fully rebuild in under 1 second

you don't get to create memory bugs when you work on your gameplay code ;)

Re: Zig gamedev project – left my job to build games in Zig lang

#103

Earlier quoted context omitted.

Zig fixes many more memory safety issues than C or C++ though, simply by being less "sloppy" and enforcing more correctness (e.g. no implicit type conversions, no over/underflows, proper range-checked arrays and slices etc...) - IME most memory corruption issues in C and C++ are actually secondary effects of such simple correctness issues. Zig just isn't quite as "extremist" as Rust (also, Rust is a great language fo…

All of these are available and widely used in C++ (for example [1]). They are not enough. [1]: https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#...

"Widely used" might be a bit of an exaggeration, MSVC only added address sanitizer support very recently but doesn't support any of the other sanitizers, and none of the sanitizers are enabled by default in Clang.

Re: Zig gamedev project – left my job to build games in Zig lang

#104

Earlier quoted context omitted.

Memory safety also adds reliability, by catching bugs statically that you didn't catch during (automated or manual) testing. It's the same argument as for static typing. It's of course true that some developers may judge the tradeoffs differently for their individual projects—that's why they're tradeoffs! But there are benefits to memory safety that go beyond security.

the only memory safety gamedev needs are bound checking and use after free protections everything else is just bloat and noise that hurts iteration time and even if one would still value them, you'd need to check only once for whatever memory check you want to run, when you build your allocators for example, and not at every builds, and you could even write the logic yourself and have a debug allocator to ensure memo…

> the only memory safety gamedev needs are bound checking and use after free protections

Disagree, but in any case, we're talking about the fact that Zig doesn't provide use-after-free protection.

Re: Zig gamedev project – left my job to build games in Zig lang

#105

Earlier quoted context omitted.

the only memory safety gamedev needs are bound checking and use after free protections everything else is just bloat and noise that hurts iteration time and even if one would still value them, you'd need to check only once for whatever memory check you want to run, when you build your allocators for example, and not at every builds, and you could even write the logic yourself and have a debug allocator to ensure memo…

> the only memory safety gamedev needs are bound checking and use after free protections Disagree, but in any case, we're talking about the fact that Zig doesn't provide use-after-free protection.

Zig is allocator aware, use after free protection is covered with the ``GeneralPurposeAllocator``

Re: Zig gamedev project – left my job to build games in Zig lang

#106

Earlier quoted context omitted.

> the only memory safety gamedev needs are bound checking and use after free protections Disagree, but in any case, we're talking about the fact that Zig doesn't provide use-after-free protection.

Zig is allocator aware, use after free protection is covered with the ``GeneralPurposeAllocator``

Is GeneralPurposeAllocator the one that quarantines memory forever? That isn't practical, as I've mentioned before. To name one problem, allocating 1 byte in a 4kB page leaks the entire page.

Re: Zig gamedev project – left my job to build games in Zig lang

#107

Earlier quoted context omitted.

Is that part paid in the Rust or LLVM portion of the compiler chain?

rust portion. For example, LLVM has no internal concept of ownership.

That's true of borrowing, but I'm not sure if it's true for other abstractions. I imagine generics (due to monomorphization) adds to the burden on the LLVM side.

Re: Zig gamedev project – left my job to build games in Zig lang

#108

Earlier quoted context omitted.

All of these are available and widely used in C++ (for example [1]). They are not enough. [1]: https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#...

"Widely used" might be a bit of an exaggeration, MSVC only added address sanitizer support very recently but doesn't support any of the other sanitizers, and none of the sanitizers are enabled by default in Clang.

The biggest companies on the planet with massive C++ codebases are all very aware of the clang sanitizers and use them regularly. UBSan has far more deployment than Zig.

Re: Zig gamedev project – left my job to build games in Zig lang

#109
post #99
post #96

Earlier quoted context omitted.

The languages I mentioned all got generics during their lifetime, so yeah they were all more powerful than C. C won due to UNIX, had UNIX not been a kind of free beer that companies could build their workstations with and universities avoid paying for commercial OSes like VMS, history would have taken a different path.

What about compile-time type reflection? Also, lisp has pretty much always been more powerful than C. But what zig brings to the table is an extremely simple language which is also very powerful. Much of the power results from the entire language being available at compile time. You seem so ready to throw that away in favor of could-have-been nostalgia, I wonder if you've taken the time to understand what you're crit…

I was quite clear that compile-time type reflection was the only thing missing.

Zig isn't the only AOT compiled language with compile-time type reflection in 2021, and exactly because of could-have-been nostalgia, we don't need newer systems programming languages that don't have an answer for use-after-free in safe code.

https://github.com/ziglang/zig/issues/2301

https://github.com/ziglang/zig/issues/1966

Naturally I have taken the time, and did not come out impressed, given my background and programming language beliefs.

However as I say in another thread, other people seem to be happy with such shortcomings.

Re: Zig gamedev project – left my job to build games in Zig lang

#110

Earlier quoted context omitted.

Could be personal preference. I worked with OP at Intel during the early days of Vulkan and he was the go-to person for anything Vulkan related, so he's certainly familiar with the API.

Well, that is not a pragmatic approach to make games, specially for indies, to just target one graphics API, that limits the audience you can reach We solved this issue already with WebGPU, it uses what ever is native to the platform you target.. https://devlog.hexops.com/2021/mach-engine-the-future-of-gra... Everyone wins

Note, that it is easier to ship a game for one platform. I don't have resources to test several platforms.

WebGPU is just 3D rendering. I will also need vector graphics, machine learning stuff, video playback, etc. Windows gives me that for "free" (DirectML, Direct3D 12 Video, Direct2D, DirectWrite).

My main goal is to ship a game and build interesting demos/mini-games as part of zig-gamedev project. I don't want to spend my time supporting and maintaining code for several platforms.

Also, using wrappers like WebGPU adds another layer of abstractions. I want to write my shaders in HLSL using dxc.exe, I want to directly see messages from DX debug layer and have full control over my code. WebGPU would just slow me down.

My game will run only on Windows 10+ and I'm fine with that.

Post reply on HN