News for hackers. Stuff that matters.
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.