Live data from Hacker News

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

github.com

91–100 of 126 posts

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

#91
post #39

Earlier quoted context omitted.

Contributions are another one I think. Both the authors and potential collaborators might find it more attractive to use their language of choice. Compilers also tend to pose a variety of challenges that force one to really dig into a language.

Yep. I know it's entirely other end of the language spectrum, but I think that's why Typescript got successful while Flow did not; Typescript is in Typescript, while Flow is in OCaml. And nobody knows OCaml. OTOH, eslint is making waves now and it's in golang, so. Who knows.

I suspect that you might mean esbuild (not eslint).

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

#92
post #40

Earlier quoted context omitted.

I know it might be fun to develop your own engine That's it right there. You can spent years pretending to write a game while optimizing your from-scratch engine for features that probably no-one will ever use [1]. But I think it depends on what your goal is. If it's a small hobby project, and you enjoy the process of writing your own engine (which, granted, can also be a great learning experience), then why not? You…

Well, though I’ve also seen people do the same thing inside of existing engines, for example trying to use Unity but become so frustrated with its design so much that they begin to spending their time building their own external systems and tools. It seems more of a mindset problem than what engine you actually use (whether you build your own or not). If you have some amount of self-discipline and implement your cust…

Of course it can be done. It has been many times.

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

#93
post #90

Earlier quoted context omitted.

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

(I'm the author of that post) Michal is a seasoned AAA dev who has worked at AMD, Frostbite, EA DICE, Intel - I'm sure he knows exactly what tradeoffs he's making. Different folks have different goals, and that's OK. My goal with WebGPU is to aim for a future where we have truly cross-platform graphics. I suspect your goal is similar. But I don't think it's wrong to aim for the present, to use an API you're familiar…

Well said!

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

#94
post #54

Earlier quoted context omitted.

Memory safety is a pain point of C, and Zig doesn't fix that. There is no free lunch: you either accept garbage collection or deal with something that resembles the borrow checker.

I believe Zig takes a more nuanced and balanced approach to memory safety as a spectrum, rather than the extremes you present of either GC or borrow checker. For example, Zig offers spatial memory safety, and provides test allocators to catch temporal memory safety issues. That's already an order of magnitude improvement over C. Memory safety is also just one aspect of safety, whereas sometimes programmers conflate t…

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#...

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

#95

Earlier quoted context omitted.

Memory safety is a pain point of C, and Zig doesn't fix that. There is no free lunch: you either accept garbage collection or deal with something that resembles the borrow checker.

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#...

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

#96
post #87
post #61

Earlier quoted context omitted.

Ada, Modula-2 and Object Pascal, minus compile time execution that they lack, and you have Zig almost 40 years ago. Sad that we have to go in circles to keep programming fashion going, instead of adopting best practices from the get go.

You say "minus compile time execution"... but when you take comptime away from Zig, you lose both generics and compile-time reflection. The remaining language is C without a preprocessor. So, yeah. Strip out the most useful and innovative feature from the language, and it looks primitive.

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.

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

#97
post #47

Earlier quoted context omitted.

From my point of view in terms of memory safety with Zig, we could just use Modula-2 or FreePascal/Delphi instead, but they aren't as fashionable.

As much as I love Delphi, the language syntax hasn't aged well. Single pass compilation was great to have in the 1980's but nowadays even the humblest Raspberry Pi will chew through thousand of lines of C++ and link an optimized executable within seconds. We deserve and can afford a lot more comfort than Pascal (and siblings) provides. Incidentally, modern language ergonomics also adds much in the way of coding safet…

Indeed, and that is why for me modern language ergonomics is a synonym for Swift, C#, Nim, D, and Rust.

For Zig to be part of that list, a story for use-after-free must exist as well.

Others won't agree with me, and that is fine, different strokes for different folks.

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

#98

How is zig compared to nim, where you can also disable safety(even disabling the gc)? To me nim seems more "ergonomic", but they both try to hit the same problem space.

Asking since I want to build a ray tracer and voxel engine in nim as a side project at some point. But I really like the approach of high level safety and optional low level performance from both languages. I was considering Rust, but I don't like having to deal with the borrow checker all the time.

Nim is a little bit more straightforward for writing application code, by dint of simply having more features to throw around. Both languages can be pretty darn fast, enough that I would not rate it as a factor for most applications, including rendering side projects - the speed difference we are talking about really has to do with how detailed your resource allocation methods are, and if you want that form of speed you have to invest time researching memory access patterns for your use case to get beyond educated guessing. So you would have to turn your voxel engine into full-time work to get to the point where it has both usefully broad functionality and top-end performance.

Expect some maturity/stability issues with either one. Zig is much earlier in its lifecycle and I have seen showstoppers, but it's also been moving faster. Nim has struggled in the past with stabilizing its high-concept features - use it mostly like C and it's fine.

Zig's biggest appeal is in how close it is to a fully bootstrapping environment - low level, clearly defined control over all resources is just what you want if you are writing a kernel.

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

#99
post #96
post #87

Earlier quoted context omitted.

You say "minus compile time execution"... but when you take comptime away from Zig, you lose both generics and compile-time reflection. The remaining language is C without a preprocessor. So, yeah. Strip out the most useful and innovative feature from the language, and it looks primitive.

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 criticizing.

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

#100
post #54

Earlier quoted context omitted.

I believe Zig takes a more nuanced and balanced approach to memory safety as a spectrum, rather than the extremes you present of either GC or borrow checker. For example, Zig offers spatial memory safety, and provides test allocators to catch temporal memory safety issues. That's already an order of magnitude improvement over C. Memory safety is also just one aspect of safety, whereas sometimes programmers conflate t…

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.
Post reply on HN