Live data from Hacker News

Leaving Rust gamedev after 3 years

loglog.games

941–950 of 996 posts

Re: Leaving Rust gamedev after 3 years

#941
post #889

Earlier quoted context omitted.

I wonder if Rust is killing flies with canons (as we say in spanish). There are perfectly safe alternatives or very safe ones. Even in a project coded in Modern C++ with async code included, activating all warnings (it is a cards game) I found two segfaults in like almost 5 years... It can happen, but it is very rare at least with my coding patterns. The code is in the tens of thousands of lines of code I would say,…

I'm not answering your question here, just saying my opinion on C++ vs Rust. I think that the big high-level difference (before diving into details like ownership and the borrow checker) is that C++'s safety is opt-in, while Rust's safety is opt-out. So in C++ you have to be careful each time you allocate or access memory to do it in a safe way. If you're working in a team, you all have to agree on the safe patterns…

An evolution of the C++ model could be something like Hylo. Hylo is safe. Hylo does not need a borrow checker. Hylo does not need a garbage collector.

That is what I mean by evolution. I do not mean necessarily C++ with Core Guidelines.

Re: Leaving Rust gamedev after 3 years

#942

Earlier quoted context omitted.

> ripgrep, fzf I think these are great examples of where prototyping and rapid iteration are really not needed at all, and hence Rust shines here. Writing a game is completely different.

The initial version of ripgrep was absolutely a rapid prototype. I do rapid prototyping all the time. I'm not saying Rust is good for game dev, but the idea that Rust cannot be used for rapid prototyping in any context is a myth.

Are there any particular techniques or styles that stand out to you as useful when prototyping in Rust?

Re: Leaving Rust gamedev after 3 years

#943

Earlier quoted context omitted.

It does in my domain of systems programming with async data handling. Tokio works like a dream - slipping into the background and just working so I can concentrate on the business logic.

I know this is a late reply to your post, but your wording prompted a question. I will preface by saying this is not some sort of semantic flamebait, it is also not supposed to be a gatekeeping exercise. You state your domain is systems programming, but then talk about the event loop and scheduler for your program as ancillary details and say that your concentration is on business logic. I tend to view systems progra…

Even within what you discuss, things like renderers, audio engines and physics calculations have business logic, which I interpret as being the logic pertinent to their specific tasks, as opposed to support logic. Clearly these sorts of terms are heavily overloaded, so please don't too hung up the precise term I used.

That said, I think the view of systems programming is more relevant. My understanding is essentially the same as Wikipedia: "systems programming aims to produce software and software platforms which provide services to other software, are performance constrained, or both". I don't see business logic excluded from that definition.

For context, the area I use it is in direct interaction with an FPGA in the middle layer of a bigger system. The software acts as a performance critical controller of the FPGA and data marshalling system, controlling the DMAs and shunting the data into the network subsystem. Another bit of the system on different hardware then receives the data and does some performance critical signal processing before passing the result to the application layer. The "systems programming" stuff is responsible for translating high level application API commands into low level FPGA control and low level FPGA data and feedback into high level application structures.

Async works really well on the data handling. I have a full back pressure chain from the application, across the network, across the DMA subsystem right down to the FPGA. It also allows careful pinning of different tasks to different cores with pinned runtimes, which is important in maximising the network throughout on the resource limited cpu cores.

Rust async is great for this kind of stuff. I read a post a while ago, which I annoyingly can't find anymore, in which the author was using custom reactor and executor to hide cache latency. It was really beautiful and incredibly simple and annoyingly forgotten by me (!).

Re: Leaving Rust gamedev after 3 years

#944
post #190

Earlier quoted context omitted.

Your post is "flagged" to oblivion, just like my earlier post questioning the "inclusive" culture of the Rust community. What is it called when a person or group's actions don't match their words?

> Your post is "flagged" to oblivion Personally, I think downvoting insults is more inclusive than not downvoting insults. > just like my earlier post You made an entire submission asking users of a specific programming language to defend themselves. It's a bad HN submission. Flagging it is neither inclusive nor uninclusive. It's just marking it as a bad submission. How do those actions fail to match words? What word…

So your magic ball tells you why did people hit the "flag" button on my post. Thank you for sharing that.

For a moment I thought every hint of criticism towards Rust is suppressed or censored by the Rust zealots.

Re: Leaving Rust gamedev after 3 years

#945

Earlier quoted context omitted.

TBF this is not really true. Unsafe Rust is a lot harder than comparable C/C++, because it must manually uphold all safety invariants of Safe Rust whenever it interacts with idiomatic Rust code. (These safety invariants are also why Safe Rust can often be compiled into better-optimized code than the idiomatic C/C++ equivalent.)

Unsafe Rust is not harder or safer than C/C++. If you can uphold all safety invariants for C/C++ code (OMG!), then it will be easier to do same thing for unsafe Rust, because Rust has better ergonomic.

Better ergonomics for what? For refactoring with a zillion lifetime annotations? Annotations go viral down the stack call. That is a headache. Not useless. I know it is useful. Just a headache, a price to pay. For linked structures? For capturing an exception.

No, it is not more ergonomic. It is safer. That's it.

And some parts of that enforcement via this model is terribly unergonomic.

Re: Leaving Rust gamedev after 3 years

#946
post #443

Earlier quoted context omitted.

The game dev industry could form a consortium to launch its own dedicated general purpose language built from scratch to compile very fast like V or Go, run predictability, be much safer, be more reusable, and be extremely productive with the lessons learned from C, C++, C#, and more. Also, I think LLMs will be able to run against code bases to suggest mass codemods to clean things up rather than having humans make a…

Jonathan Blow’s Jai is an attempt at something like this. It’s looking promising so far!

> It is still in development and as of yet is unavailable to the general public.

Is it still the case?

Re: Leaving Rust gamedev after 3 years

#947
post #942

Earlier quoted context omitted.

The initial version of ripgrep was absolutely a rapid prototype. I do rapid prototyping all the time. I'm not saying Rust is good for game dev, but the idea that Rust cannot be used for rapid prototyping in any context is a myth.

Are there any particular techniques or styles that stand out to you as useful when prototyping in Rust?

`clone()` and `unwrap()` and `todo!()` without fear. Just let it loose.

For me, prototyping is, IMO, about finding shortcuts to demonstrate something that is unknown to you. The idea is that shortcuts represent things you know how to do, but would otherwise take work to avoid and aren't necessary for demonstrating the thing that is unknown. `clone()` and `unwrap()` are just Rust-specific examples of that.

Re: Leaving Rust gamedev after 3 years

#948
post #109

This is a sobering read. Thank you for sharing. This sums it up for me: > Rust as both language and community is so preoccupied with avoiding problems at all cost that it completely loses sight of what matters, delivering an experience that is so good that whatever problems are there aren't really important. This doesn't mean "ship crap games", it means focusing on the game being a good game, not on the code being go…

To be fair, many (non-game dev) Rust projects I have seen/used do provide great user experience precisely because they are laser-focused on performance and have blown existing alternatives out of the water. (Think ripgrep, fzf, etc.) Prototyping is certainly necessary but it shouldn't be at the cost of runtime performance – at least not too much –, because it will typically be very difficult to improve performance af…

Fzf is written in go fwiw

Re: Leaving Rust gamedev after 3 years

#949

Earlier quoted context omitted.

> The "async" system is optimized for someone who needs to run a very large web server, with a huge number of clients sending in requests. Can you please elaborate on this? I see a lot of similar concerns in other contexts too. Linux kernel's scheduler for example. Is it a throughput/latency tradeoff?

The current popularity of the async stuff has its roots in the classic "c10k" problem. ( https://en.wikipedia.org/wiki/C10k_problem ) A perception among some that threads are expensive, especially when "wasted" on blocking I/O. And that using them in that domain "won't scale." Putting aside that not all of use are building web applications (heterodox here in HN, I know)... Most people in the real world with real appl…

> If you ever pull up a debugger and step through an async Rust/tokio codebase, you'll get a good sense for what the overhead here we're talking about is.

So I didn't quite do that, but the overhead was interesting to me anyway, and as I was unable to find existing benchmarks (surely they exist?), I instructed computer to create one for me: https://github.com/eras/RustTokioBenchmark

On this wee laptop the numbers are 532 vs 6381 cpu cycles when sending a message (one way) from one async thread to another (tokio) or one kernel thread to another (std::mpsc), when limited to one CPU. (It's limited to one CPU as rdtscp numbers are not comparable between different CPUs; I suppose pinning both threads to their own CPUs and actually measuring end-to-end delay would solve that, but this is what I have now.)

So this was eye-opening to me, as I expected tokio to be even faster! But still, it's 10x as fast as the thread-based method.. Straight up callback would still be a lot faster, of course, but it will affect the way you structure your code.

Improvements to methodology accepted via pull requests :).

Re: Leaving Rust gamedev after 3 years

#950

Earlier quoted context omitted.

Yeah, this is the bit that stood out for me, too. Does anyone knowledgeable here have a sense for whether there are any insurmountable roadblocks to bringing hot reload to Godot?

Godot 4 already has hot reloading.

Hmm so it reloads godot-rust/gdext while the Godot environment is running (recentish new feature), but can it also reload while the game itself is running?

I should really give it a shot..

Post reply on HN