News for hackers. Stuff that matters.
Re:Comfy, the 2D rust game engine, is now archived by daghamm on Monday September 09, 2024 @07:04AM (#41487296)
For certain things, Rust is painfully slow with no real benefits. We are starting to learn where we should and should not use Rust. If you ask me, Rust is becoming the new Ada.

Update: when I wrote slow, I meant development pace, not runtime performance

Re:Comfy, the 2D rust game engine, is now archived by pornel on Monday September 09, 2024 @07:44AM (#41487579)
The author has one major issue with Rust in gamedev: they can't easily try out new game feature ideas or gameplay tweaks by writing quick and dirty code.

Such unfinished code can be obviously buggy and unsafe, but in game dev it matters more to have short feedback loop to try how things feel, than to have a perfectly correct code all the time.

Rust doesn't do quick and dirty, and will complain about code quality even when game devs don't even plan to keep the code.

This is a substantially different situation from other domains like application and services development, where it's easier to plan what you're going to implement, correctness is more important, and you don't need to try out 20 different JSON parsers to see which one has the most satisfying feel.

Re:Comfy, the 2D rust game engine, is now archived by Aeolos on Monday September 09, 2024 @08:12AM (#41487789)
C++ doesn't do quick and dirty either. That's why in a experienced game developers combine a core engine written in a high-performance language (C++, Rust, C#), with a scripting language (Lua, Python, hand-rolled).

That approach gives you the best of both worlds: high-performance core with high-velocity iterations for gameplay. Don't use Rust or C++ for scripting... madness lies that way.

Re:Comfy, the 2D rust game engine, is now archived by pjmlp on Monday September 09, 2024 @08:45AM (#41487995)
Except hot code reloading and interpreters is something that C++ devs can reach for, and Rust ones not, at least for the foreseable future.
Re:Comfy, the 2D rust game engine, is now archived by bendhoefs on Monday September 09, 2024 @12:57PM (#41490560)
What do you mean by this? Rust has multiple game engines that support hot reloading and/ or scripting.

https://fyrox-book.github.io/beginning/hot_reloading.html

https://github.com/jarkonik/bevy_scriptum

Re:Comfy, the 2D rust game engine, is now archived by pjmlp on Monday September 09, 2024 @01:04PM (#41490683)
This the bare minimum, https://liveplusplus.tech/

Also supports is kind of relative,

"CHR is very new and experimental feature of the engine, it is based on wildly unsafe functionality which could result in memory corruption, subtle bugs, etc."

Re:Comfy, the 2D rust game engine, is now archived by bendhoefs on Monday September 09, 2024 @03:00PM (#41492226)
Why is that the bare minimum?

I also think that doc page is a little old. The feature is over 2 years old now and hot reloading is inherently "unsafe" in any compiled language. It's just letting you know that Rust's safety guarantees might go out the window if there are bugs in the code that handles hot-reloading.

Re:Comfy, the 2D rust game engine, is now archived by pjmlp on Monday September 09, 2024 @03:04PM (#41492269)
Because that is what existing game studios expect, as shown by their customer list.

Also that was only one example, there are other similar ones.

Re:Comfy, the 2D rust game engine, is now archived by desumeku on Wednesday September 11, 2024 @02:58PM (#41514274)
Funnily enough, Mojang is on that list, and I remember recently watching a video[1] of Notch hot-reloading code while developing Minecraft, except it was with Java and I'm sure he didn't pay a dime for the ability to do that.

[1] - https://youtu.be/BES9EKK4Aw4

Re:Comfy, the 2D rust game engine, is now archived by pornel on Monday September 09, 2024 @04:33PM (#41493392)
That live reload probably already works with Rust — they say they don't parse any source code, and instead analyze the compiled binary and debug info.
Re:Comfy, the 2D rust game engine, is now archived by lenkite on Monday September 09, 2024 @11:02AM (#41489172)
"C++ doesn't do quick and dirty either."

You can do very easily do quick and dirty in C++. (And shoot your foot off also..but that's a different thing)

Re:Comfy, the 2D rust game engine, is now archived by pornel on Monday September 09, 2024 @11:40AM (#41489632)
C++ will easily let you write non-thread-safe code anywhere, won't complain about multiple mutable pointers to the same object, will let you leave pointers dangling and resources leaked.

Such code is of course crappy, but the OP wants to test if things are fun before committing to implementing them properly. Rust wants things done properly on the first try (which usually is a good thing, except throw-away prototypes).

https://loglog.games/blog/leaving-rust-gamedev/

Re:Comfy, the 2D rust game engine, is now archived by Narishma on Monday September 09, 2024 @03:54PM (#41492822)
It also introduces a lot of complexity where the two languages interact.
Re:Comfy, the 2D rust game engine, is now archived by spoiler on Monday September 09, 2024 @08:06AM (#41487753)
Disclaimer: never actually shipped a game.

I've worked with Bevy, and there's it's incredibly easy to write "quick and dirty" to test stuff. I guess the major "downside" you need to account for is that the type system will try to prote you from crashes. Which can be a bit of a chore since youknow it won't crash with the values you've given it. But if you're comfortable with .unwrap and the occasional unsafe while prototyping, it's honestly fine (at least within Bevy).

Alternatively, they could try "scripting" behaviour first before implementing it in Rust, although from what I understand bevy's scripting support (I don't think it's explicitly supported, but bevy is very extensible) is still very early in development

Re:Comfy, the 2D rust game engine, is now archived by pornel on Monday September 09, 2024 @08:30AM (#41487891)
ECS is like a whole another language on top of Rust, and it is dynamically typed.

If you add a scripting language and blueprints, you're shortening the feedback cycles by using Rust less.

I like Bevy, but it seems like Rust currently is much better suited for making game engines than the games themselves. Some "RustScript" is needed.

Re:Comfy, the 2D rust game engine, is now archived by binary132 on Monday September 09, 2024 @11:33AM (#41489542)
Something wrong with Lua? ;)
Re:Comfy, the 2D rust game engine, is now archived by kaoD on Monday September 09, 2024 @09:43AM (#41488484)
> ECS is like a whole another language on top of Rust, and it is dynamically typed.

Can you elaborate? Or did you mean dynamically dispatched?

Re:Comfy, the 2D rust game engine, is now archived by pornel on Monday September 09, 2024 @11:48AM (#41489734)
1. You dynamically add components to any entity, so entities don't have a static type. Semantically they're comparable to a JavaScript Object where you can add and remove properties at will, rather than being structs or class instances with a closed set of fields.

2. Bevy's entity references are generational IDs, without static lifetime guarantees (and restrictions) of Rust's references.

Re:Comfy, the 2D rust game engine, is now archived by CaptainOfCoit on Monday September 09, 2024 @03:37PM (#41492600)
> so entities don't have a static type.

They do, they're `Entity`, always.

> where you can add and remove properties at will

I don't think this is true for either `Component` or `Entity` in Bevy. You set what fields a `Component` has when writing the code, then it remains so during the runtime. There is no dynamically adding/removing fields at runtime, at least yet.

What you do tend to do in Bevy is adding/removing `Component`s to `Entity`s at runtime, is that maybe where the confusion comes in?

Re:Comfy, the 2D rust game engine, is now archived by spoiler on Monday September 09, 2024 @04:47PM (#41493597)
I think they used it more as an analogy: components fill a similar role as properties do in JavaScript.
Re:Comfy, the 2D rust game engine, is now archived by CaptainOfCoit on Tuesday September 10, 2024 @08:15AM (#41499980)
But that's not really true either, is it? You don't query properties in JavaScript (at best you query for Objects of a certain shape/name. You don't encapsulate data in properties so one object has many different behavior based on those, you either split the Object into many different ones and have one parent, or you mix the behavior into the same Object.
Re:Comfy, the 2D rust game engine, is now archived by spoiler on Tuesday September 10, 2024 @08:42AM (#41500170)
Yeah I it's not right. Although, it's a decent early mental model for a JS dev learning ECS to adopt until better intuition develops!
Re:Comfy, the 2D rust game engine, is now archived by consteval on Wednesday September 11, 2024 @04:36PM (#41515143)
> They do, they're `Entity`, always

Yes, technically, but in how they're used - no. They're a dynamic type.

> What you do tend to do in Bevy is adding/removing `Component`s to `Entity`s at runtime

Yes, this is dynamic typing. Or, at least, one way to look at it - and what allows games to be iterated on quick.

Re:Comfy, the 2D rust game engine, is now archived by CaptainOfCoit on Thursday September 12, 2024 @05:02PM (#41525537)
> Yes, technically, but in how they're used - no. They're a dynamic type.

No, they're really not. Are you talking about Archetypes or something else? Because an Entity is just a ID + a generation, that's it. Nothing more and nothing less. You don't define them as more/less, nor do you use them are more/less either.

> Yes, this is dynamic typing. Or, at least, one way to look at it - and what allows games to be iterated on quick.

I guess a `Vec<u8>` is also then dynamic typing in your mind as you can add/remove elements to the vector? Doesn't really compute for me personally, but whatever floats your boat.

Re:Comfy, the 2D rust game engine, is now archived by ben-schaaf on Monday September 09, 2024 @10:59AM (#41489140)
> Rust doesn't do quick and dirty, and will complain about code quality even when game devs don't even plan to keep the code.

The problem might just be an aversion to using quick and dirty solutions. Rust does a good job of making it feel wrong to write code that's not production ready, but there's nothing stopping you from using unsafe wherever you want.

Re:Comfy, the 2D rust game engine, is now archived by ljm on Monday September 09, 2024 @07:21AM (#41487416)
A lot of big expectations were placed on Rust; plenty will have turned away and decided the trade-off on development velocity wasn't worth the guarantees of memory safety or the promise of zero cost functional abstractions; not to mention it still requires expertise to write something performant. I've certainly done it myself, dipping my toes in the water out of curiosity and realising it wasn't what I needed.

Many people here say that languages like Ruby or frameworks like Rails are dying, or some such, but in reality these languages just carve out their space, settle into it, and become the go-to choice because there's nothing surprising about them any more. If Rust can be considered stable or boring in this way then it will have succeeded where a lot of new and novel languages tend to fade into obscurity.

Re:Comfy, the 2D rust game engine, is now archived by pjmlp on Monday September 09, 2024 @08:47AM (#41488008)
Thing is, if one can tolerate automatic memory management (regarless of the form), than the guarantees of safety are already there, with faster compile times.
Re:Comfy, the 2D rust game engine, is now archived by pjmlp on Monday September 09, 2024 @07:21AM (#41487413)
It is already great that it managed to bring affine types into mainstream, making many programing languages designers consider how to integrate similar capabilities into existing languages, and maybe put some pressure on WG21 to take security more seriously (I remain a dreamer).

Outside very specific use cases, we already have Ada like safety on programing languages with automatic memory management.

Re:Comfy, the 2D rust game engine, is now archived by BaculumMeumEst on Monday September 09, 2024 @07:35AM (#41487522)
Watching people try to force Rust adoption everywhere over the last decade has been watching a car crash unfold at 0.00000001X speed.
Re:Comfy, the 2D rust game engine, is now archived by yu3zhou4 on Monday September 09, 2024 @07:05AM (#41487308)
For what things Rust is painfully slow? You mean runtime or build time?
Re:Comfy, the 2D rust game engine, is now archived by desdenova on Monday September 09, 2024 @07:22AM (#41487424)
Build times are a bit slow, but runtime is just as fast as what you'd get doing the same thing in C or C++.

Development time is absurdly faster, though, since you don't spend much time debugging annoying language-design bugs, and can focus entirely in your code's logic.

Re:Comfy, the 2D rust game engine, is now archived by fidotron on Monday September 09, 2024 @07:38AM (#41487546)
> focus entirely in your code's logic

That is if your code satisfies the borrow checker out of the gate, fine. I have seen Rust book authors get derailed for years by apparently simple seeming projects that do not.

Re:Comfy, the 2D rust game engine, is now archived by orphea on Monday September 09, 2024 @08:04AM (#41487744)
It's been a while when I worked with Rust, but when I did I felt like people misuse Rust references. IIRC, they are not supposed to be short-living, i.e. you get a reference, do your thing and get rid of it asap. For actually long-living references Rc<> should work pretty fine?
Re:Comfy, the 2D rust game engine, is now archived by wiz21c on Monday September 09, 2024 @07:51AM (#41487626)
When the borrow checker doesn't let you compile, it's either because it can't understand your code (and that's unfortunate and infuriating and costs a lot of time to figure out), either because your code won't be absolutely safe (and so you'd better listen to the BC instead of complaining about it).

rust can be very frustrating because it forces you to think up front at a level of safety you may not be used to. That's the issue.

I do fairly simple things with rust (i.e. just some threads, no complex data structure (but complex program nonetheless)) and rust safety helps me a lot in reducing the number of bugs.

Re:Comfy, the 2D rust game engine, is now archived by chuckadams on Monday September 09, 2024 @08:45AM (#41487991)
Looking at Rust from the outside, I see the borrow checker as something I might slam into all the time, but if it’s all static, then it’s strictness I can get used to; “if it compiles, it works,” right? But now I’m reading that there’s a dynamic borrow checker too, and I’m left wondering: does rust really crash at runtime if two scopes reference the same field at the same time? That sounds like the kind of infuriating footgun as NPEs in a non null-safe language. Does it really work like that?
Re:Comfy, the 2D rust game engine, is now archived by steveklabnik on Monday September 09, 2024 @08:52AM (#41488047)
The borrow checker is fully static.

There are types in the standard library that, if you use them, do runtime checks. If you run afoul of those checks, then yes, you’ll get a runtime failure. (The primary example being RefCell<T> linked in the article linked there, yes.)

These types are not super common in Rust code generally, but they do exist and are useful at times.

Re:Comfy, the 2D rust game engine, is now archived by desdenova on Monday September 09, 2024 @09:34PM (#41496313)
The "dynamic borrow checker" is called a RefCell, and it's a footgun you have to explicitly point at your foot and pull the trigger, not something you'd randomly stumble upon. It's something you'd use very situationally, after you really considered all your options and found out you couldn't do it by writing normal code instead, and this is a very rare situation.

Think of them like Python's metaclasses.

Re:Comfy, the 2D rust game engine, is now archived by steveklabnik on Monday September 09, 2024 @08:51AM (#41488038)
> I have seen Rust book authors get derailed for years by apparently simple seeming projects that do not.

What are you referring to here?

Re:Comfy, the 2D rust game engine, is now archived by desdenova on Monday September 09, 2024 @09:27PM (#41496277)
Just learn how to program without mutating things unnecessarily, it isn't that hard.
Re:Comfy, the 2D rust game engine, is now archived by hatefulmoron on Monday September 09, 2024 @07:58AM (#41487700)
> Development time is absurdly faster, though, since you don't spend much time debugging annoying language-design bugs, and can focus entirely in your code's logic.

I don't mean to be dismissive, but if this was really true we'd all be writing TLA+ specifications/Coq proofs before finalizing our Ada SPARK implementations. In reality, static analysis only improves development time if time_lost_to_debugging > time_lost_to_arm_wrestling_compiler, and in my experience that's not always as common as one would like to believe.

Re:Comfy, the 2D rust game engine, is now archived by desdenova on Monday September 09, 2024 @09:28PM (#41496287)
If you're wrestling the compiler, you should improve your programming skills before trying to analyze programming languages.
Re:Comfy, the 2D rust game engine, is now archived by hatefulmoron on Tuesday September 10, 2024 @06:40AM (#41499378)
Ah yes, I'm sure that all of your Rust code compiles the first time :^).
Re:Comfy, the 2D rust game engine, is now archived by glass-z13 on Monday September 09, 2024 @07:41AM (#41487562)
>Development time is absurdly faster That definitely sounds like you have never made/contributed to anything non trivial that's made in Rust. Development time is significantly slower for any non toy project where the problem domain hasn't been solved/the person/s don't have experience with.
Re:Comfy, the 2D rust game engine, is now archived by daghamm on Monday September 09, 2024 @07:39AM (#41487548)
I think the jury is still out on the development time.

Sure, once you get your code to compile things may go faster. But getting there is not always easy.

Re:Comfy, the 2D rust game engine, is now archived by FpUser on Monday September 09, 2024 @08:57AM (#41488086)
>"Development time is absurdly faster, though, since you don't spend much time debugging annoying language-design bugs,"

Utter BS. I mainly developing in C++ at the moment (not limited to this single language though) and I do not find myself debugging "language-design bugs". I do not design libraries hence my code and set of used language features is of course simpler. I tend to avoid esoteric code and do not have habit to shove everything into new templates.

Re:Comfy, the 2D rust game engine, is now archived by olivermuty on Monday September 09, 2024 @07:09AM (#41487339)
Development time is my guess
Re:Comfy, the 2D rust game engine, is now archived by JD557 on Monday September 09, 2024 @07:17AM (#41487385)
This. I assume it's a similar argument as the one presented in https://loglog.games/blog/leaving-rust-gamedev/

Edit: I just noticed that this article is also writen in the archival reason. I'll leave it here anyway for those that miss it.

Re:Comfy, the 2D rust game engine, is now archived by muglug on Monday September 09, 2024 @07:22AM (#41487420)
Yeah the Rust build time tradeoff for non-trivial programmes is acceptable iff the programme is going to be run at least 100x more than the compiler (or if the programme would be useless without the speed increase).
Re:Comfy, the 2D rust game engine, is now archived by happyweasel on Monday September 09, 2024 @07:39AM (#41487554)
My Productivity tanked when using Rust but I have not written 20k Loc yet. Ownership gets messy when you have a complex mutable application model (worse: oop written according to SOLID principles). At that Point,Just give Up and use ref counting (which you would use in c++ anyway..).
Re:Comfy, the 2D rust game engine, is now archived by larschdk on Monday September 09, 2024 @08:03AM (#41487740)
I still like to believe that the upfront cost will be offset by the lower long term maintenance cost for some types of software. Except, that that is not always the case for gamedev where shitty code can still make good and successful games. You may miss a deadline, but if you are not going to maintain the code base for 20 years, so why spend the effort on quality code?
Re:Comfy, the 2D rust game engine, is now archived by desdenova on Monday September 09, 2024 @07:20AM (#41487409)
Rust is blazingly fast, though.
Re:Comfy, the 2D rust game engine, is now archived by jessekv on Monday September 09, 2024 @07:59AM (#41487703)
The first time I saw a package described with "blazingly", I thought it was a joke! It seems to have caught on now, but it still sounds ironic when I read it.
Re:Comfy, the 2D rust game engine, is now archived by danhau on Monday September 09, 2024 @07:51AM (#41487629)
I think they meant slow as in development cycle slow, not runtime slow.
Re:Comfy, the 2D rust game engine, is now archived by stroupwaffle on Monday September 09, 2024 @07:14AM (#41487367)
Yeah it’s insanity. I think what we need is C simplicity with some of the Rust safety guarantees.
Re:Comfy, the 2D rust game engine, is now archived by psychoslave on Monday September 09, 2024 @07:22AM (#41487417)
Isn't zig more or less the closest thing we have for this currently? I really ask naively, without proper insights to give a relevant answer myself.
Re:Comfy, the 2D rust game engine, is now archived by Hemospectrum on Monday September 09, 2024 @07:30AM (#41487489)
Zig is safer than C, which is not a high bar to clear. It has safer defaults than C, and makes it a little easier to use test-driven debugging to find memory safety violations, but it has no answer to Rust’s Send and Sync traits or the mutable XOR aliasable reference model. In that sense it’s similar to dozens of other languages older than Rust.
Re:Comfy, the 2D rust game engine, is now archived by GardenLetter27 on Monday September 09, 2024 @07:46AM (#41487596)
But Zig doesn't have a nice package manager like Cargo?
Re:Comfy, the 2D rust game engine, is now archived by bobajeff on Monday September 09, 2024 @10:00AM (#41488664)
I don't see zig being that simple. I think it looks more like rust without the borrow checker. Odin to me looks like a more simple language. Go too would fit that if you want some safety.
Re:Comfy, the 2D rust game engine, is now archived by psychoslave on Monday September 09, 2024 @05:18PM (#41494027)
Nice, I wasn’t aware of Odin, thanks.
Re:Comfy, the 2D rust game engine, is now archived by pjmlp on Monday September 09, 2024 @07:22AM (#41487422)
Some would say that would be Zig, although it is more like Modula-2 safety guarantees.
Re:Comfy, the 2D rust game engine, is now archived by shortrounddev2 on Monday September 09, 2024 @07:28AM (#41487477)
I think most gamedevs will reamain in higher level languages. Gone are the days when game developers were wizards of esoteric programming knowledge and elite skill; most game developers I've met are creative types who came to programming as a tool for expressing themselves, and not programmers who use their obscure knowledge to make creative things. Artists, not engineers.

For people who want to use programming as a tool for expressing themselves, C#, python, and, above all, visual programming are going to remain the most popular choices. They don't care about memory management or type theory, they just want to easily describe the behavior of things in a language which more closely mimics human thought

Re:Comfy, the 2D rust game engine, is now archived by neonsunset on Monday September 09, 2024 @07:47AM (#41487601)
So...C#? Structs + managed references and spans instead of raw pointers for memory ranges.
Re:Comfy, the 2D rust game engine, is now archived by bitwize on Monday September 09, 2024 @07:24AM (#41487441)
Every time someone on Reddit or someplace asks "What's the appeal of Ada anyway?" I say "Think of Ada as boomer Rust."

It turns out that when you need to get the details right and be safe in a systems level language, development can be slow. This is a good thing. Studies with Ada projects compared to C have shown that time and money is saved in the long run due to fewer bugs and less maintenance. You just have to embrace that particular suck because it pays off in the end.

Re:Comfy, the 2D rust game engine, is now archived by binary132 on Monday September 09, 2024 @11:25AM (#41489426)
I always thought Ada was super cool tbh