Hacker News new | past | comments | ask | show | jobs | submit login

Ex-gamedev here, I have no idea what you're on about.

Gamedev isn't some place of rainbows and unicorns that makes it a unique snowflake. I spent more than my fair share of time chasing down heap corruption, invalid iterators and all sorts of other fun issues.

If anything working on a console where the compile, cook, upload, play cycle can be long having something that removes a whole class of errors would have been great back then. I don't think anyone is saying Rust is a silver bullet but it certainly has aspects that are beneficial in certain contexts.




Oh I agree with you: memory bugs are annoying and I've had my share of them. My contention is that, while they waste time here and there, the biggest problems are 1 or 2 layers of abstraction up. I've probably spent 10x more time debugging random physics issues than I did dealing with invalid iterators or heap corruption.

But I mainly take issue with the cockiness of my parent post. Rust is a reasonable evolution which, as you point out, eliminates one class of bugs. But my parent post took it for granted that things should be rewritten in it whenever possible, and that the gamedev community is ignorant of best practices.

The tech industry's demographic pyramid has a really wide base, which is possibly why it seems to build cults around new programming languages so much. Last time it was Ruby, and if we all listened to the equally self-assured Ruby crowd, everything would now be message passing up the wazoo.


You should probably go reread their post cause I definitely didn't read the same thing you did.


Well… Many Rust enthusiasts treat it either as a silver bullet or everything else as unholy (unsafe).

Besides, syntax and complexity wise I think Rust is even worse than C++.

As a gamedev I am not interested in Rust. Zig, Jai and Odin seems much cooler/interesting.


> Well… Many Rust enthusiasts

I really hope this sort of strawmanning doesn’t become common here. In response to any reasonable discussion about Rust the response seems to be “you’re fine, but the other enthusiasts are so unreasonable”. Where are these enthusiasts? Why bring them up when you can just respond to the person you’re talking to?

It’s super annoying because even on irrelevant threads such haters will call people’s attention to these imagined enthusiasts. Like this comment from 6 days ago calling people jihadis if they like a language - https://news.ycombinator.com/item?id=32640154. Note that the jihadis didn’t exist on the thread, only in the commenter’s mind.


Looking at https://lwn.net/Articles/893346/, I'd definitely describe mjg59 as unreasonably bashing unsafe languages (like some Rust users), though he says at https://news.ycombinator.com/item?id=31251199 that he doesn't know Rust.


Yeah, the linked comment says it pretty clearly

> I will say that I've never written a line of Rust in my life and certainly can't be described as representing the Rust community in any way.

If this is the best example out there then it does feel like GP was arguing against a strawman.

But even otherwise, please let’s acknowledge that in any large community there’s going to be a minority who are loud and rude. It doesn’t advance the conversation much to point it out. They don’t represent the whole community any more than the comment I linked to represents the whole HN community.

All I can say is that whenever I’ve seen such rudeness it’s moderated out pretty quick, whether here or elsewhere.


The irony here is that you're also responding to comments by other people in different threads!


> Well… Many Rust enthusiasts treat it either as a silver bullet or everything else as unholy (unsafe).

I don't think anyone here is saying that, at least in this thread the parent(and myself) were both careful to qualify there might be contexts that it could be useful in. If you see anyone saying that Rust solves every single problem then feel free to call them out for being full of shit :).

I'm not going to be giving my designers a Rust tutorial the same way we did with scripting Lua, you're still going to have a FFI somewhere which will require unsafe and a bit more care. However having had maintained pretty significant codebases in quite a few languages I will say that Rust code is more stable, crashes less and still runs in the same footprints as C++(C gets the codesize edge by having a much smaller stdlib and surface area). It's about knowing where your tools do well and where they have rough edges and a better tool is appropriate.

Having to switch between C, C++ and Rust codebases on a regular basis I think you're underselling the complexity of C++ and overselling how difficult Rust is. C++ has a huge surface area, you have to figure out what subset you want to use(exceptions: y/n?, RTTI: ditto, stdlib or custom containers, etc). Then you get into Rule-of-5, move semantics, template metaprogramming, undefined behaviors(don't use global constructors/destructors). I could easily list 20 years of various ways I've seen C++ explode in spectacular ways(volatile semantics anyone?).

If you want to use C, Zig, or C++ more power to ya. No one is forcing you to use Rust but for those of us who are interested in a language that isn't dragged along with decades of baggage Rust offers a compelling development story and largely delivers on the areas it aims to hit(accessible systems development, memory safety and first-class tooling in my experience).


The complexity of C++ really does come from the yes/no decisions that every project, library, and code path get to take. Do you know if a library call will throw? hopefully they commented their code well! even better if they maintained comments for all of their dependencies...


Might a library call throw? Assume yes.

Next question.


And since about half of all game codebase are compiled with -fnoexcept... that means we are left assuming that all library calls may randomly crash or corrupt the stack


Trivial to fix.


If you don't know what's exploding left and right, how are you going to fix it?


Compile without -fno-except.

There is no substitute for engineering, if you care. So, engineer.


so what am I to do? wrap all libraries in a try/catch call? Run tests and hope I've exhaustively verified all possible states?


Catch exceptions at a few select spots where you actually know something meaningful to do about them. Keep cleanup code in destructors, where it always runs reliably.

Avoid triggering exceptions too hard to recover from. That might involve work, but less work than fielding error codes would have been. There is no free lunch.


Have you written any Rust code by chance? I personally think Rust is easier than C++, possibly because it is a lot smaller language than C++ (at present). It isn't magic, but it kinda feels like it. To be able to do low level coding knowing you can't blow your foot off is pretty cool.


I have, even if mostly hobby stuff.

Some stuff that places Rust going into the same kind of complexity as C++.

Figuring out how to turn DAG algorithms into tree based ones, two macro systems, async infrastructure, Pin and PhantomData special fields, GAT (when they arrive).

Lets see how it looks like with 40 years of production code, on the other hand C++ is indeed reaching PL/I levels of complexity for those that care about ISO legalese.


I guess it depends what kind of code you are writing. I've written all of the above w/o too much trouble, but yes, those are the harder parts. However, most of my code is just basic logic, so has very little interaction with that stuff (with exception of async, which I use every day). My C++ is more rusty (pun not intended), but I'm sure there are powerful features that you might use occasionally, but generally don't use much. My point is that day to day coding in Rust is very easy and pleasant, and every once in a while needing an advanced feature that you have to lookup doesn't necessarily make the common case challenging. Like any language, it is hard to tell all this without writing a large project in it.


I've been using C++ on and off since the 90s (borland C++ 5 times) Tried rust at initial release. Read a csv file line by line, split each line read (because I couldn't find any streams), converted to numbers and calculated some stats. Never again. What rust feels like: you are riding a bike, but it has six safety wheels instead of any normal wheels.


I think it’s fair to say that Rust has changed massively since initial release. There are certainly safety aspects, but doing what you describe should be trivial and trigger none or almost none of them.

The compiler’s error messages are fantastically helpful these days. Might be worth a tinker some rainy day, but understand being completely turned off of something as well.


One major change since initial release was the introduction of a more permissive borrow checker. The newer one accepts many more valid programs thanks to the introduction of non-lexical lifetimes.


You can always use “unwrap()” in throwaway code.

https://play.rust-lang.org/?version=stable&mode=debug&editio...

If that code ever gets more use than that you expect, you can trivially find all the uses of “unwrap()”, and add the proper error handling. And yes there are quite a few places where things can go wrong.

But this explicit “signing for technical debt” when it relates to error handling is a really convenient productivity feature in practice.

A simple throwaway CLI for your own use is absolutely fine to use unwrap(), and you can fix it later on if it becomes a problem.


Unwrap is good to use for things that are expected to work 100% of the time. If unwrap fails in such situations, it’s fine to have the program panic and shut down.


I'm no Rust expert, but I believe reading a file line by line, splitting them, converting to numbers and doing something with them is just a handful of lines using methods on iterators. I suppose it was much harder in the initial release.


Why on earth would you say complexity would be even worse?

I can't go along with this at all


> I don't think anyone is saying Rust is a silver bullet

Jeezus.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: