Jokes aside thanks for sharing. It’s always interesting to read game source code and Rust beginners can learn a lot reading this code.
Jokes aside thanks for sharing. It’s always interesting to read game source code and Rust beginners can learn a lot reading this code.
Rust is a great language, not my preference (Julia is better imo, and I still absolutely love C), but the community and tools being built in Rust are fantastic.
Can we please stop saying X language is "better" than Y? It really does not make any sense. Both languages were designed with very different goals in mind. Each of them is a good fit for their respective use cases, but saying Julia is "better" than Rust makes no sense.
Of course, saying something is better than something else is always prefixed with an implicit "I believe that...", so it's fine to argue with it. But that doesn't mean it's an illegitimate thing to say.
Some languages are better: more conducive to popularity; safer; more conducive to not wasting resources; nicer to work with; more expressive. We don't have reliable methods of objectively measuring these metrics, but they do exist.
Rust, I believe, has a pretty high aggregate score.
* It has the performance profile of C
* A really good package manager
* I don't have to worry about segfaults/runtime issues from manual memory management
* I love the type system (yay expressive static types with pattern matching)
* Also prevents data races and other things like iterator invalidation
* Also, null safety, among other things leads to a lot fewer runtime issues I need to figure out
It does this well, since at the same time I was able to write 10k lines of JS game code into 10k lines of Rust game code: https://www.reddit.com/r/rust/comments/k3jy5g/i_rewrote_10k_...
Have since rewritten server from nodejs to Rust. There the line count grew. But async/await was splendid there, & serde made implementing the json server/client protocol straight forward
* It has algebraic data types, pattern matching, etc. - language features that just don't exist in most languages I've used. (I did play with F# for a bit and really loved its capabilities, but I've never had the occasion to get into F#, unfortunately.) Once I start using these features, I suddenly find that all these other languages are sorely lacking.
* Its safety guarantees mean that I spend more time in the IDE fixing compiler errors and less time in the running exe finding my problem. I often find that when my program compiles, it is generally correct. This has given me a lot of confidence in the quality of my releases (borne out in actual production code, not just toy projects)
* Speed of execution is (in my experience), better than an order of magnitude faster than in other languages for a similar implementation.
YMMV, and there may be some of that New Relationship Energy here, but I can absolutely see why it's been on SO's most loved languages for five years in a row[0].
[0] https://insights.stackoverflow.com/survey/2020#technology-mo...
A huge chunk of software we have today is built upon other software that is built upon other software that ... but that whole foundation is rather shaky and probably incorrect. Basically, if you want to express it that way: Everything is broken and we have played the wrapping game for far too long as a professional group. There will probably forever remain bugs in that gigantic mountain of code, that we rely on.
People get excited about rewriting things in Rust to avoid a good chunk of the legacy code written in languages that are not memory save and that do have a lot of undefined behavior or allow for race conditions easily once you even as little as touch concurrency. People want to finally have a solid basis, which is proven to be correct in implementation. Rust goes a long way towards this goal, so people like it.
I subscribe to some great projects' repositories and read the issues. These projects sometimes bring me great value and I am not saying they aren't useful. Usually however, non-trivial C++ or C (and other languages) projects have all the same kind of issues. People thinking every noun has to be a class and the standard paradigm of mutating everything everywhere, be it through setter or directly, then forgetting to update state at some point, where it was necessary. People sharing state across multiple threads and forgetting to acquire a lock or releasing it. Or in some other way building race conditions. People thinking they will be able to do manual memory management correctly and then having segfaults, which require long debugging sessions or a lot of experience to fix. Use after free bugs. Security issues resulting from such causes. This and all that kind of stuff, that a good type system should prevent you from doing. And that is where Rust delivers.
Rust has many zero cost abstractions that make writing things easier.
It’s super high level at the speed class of C - sometimes even faster given that libraries for common tasks are well programmed. With the high level abstractions the compiler may probably reason and optimize better?