4 ms·
Question: does one have to be more smart to learn and build stuff in rust than one has to be for something like C#? Asking because everyone seems to be all in
by uhtred 4y ago
Question: does one have to be more smart to learn and build stuff in rust than one has to be for something like C#?
Asking because everyone seems to be all in on rust but i'm fucking confused every time I start reading its docs and syntax.
Is it worth using rust for anything that isn't currently written in C? i.e. operating systems and compilers?
- capableweb 4y agoRust and C# is not that different after all. You're gonna have to fight with some more aggressive compile checks than what you're used to, but otherwise it should be relatively smooth sailing. And Bevy (one Rust game engine) makes it very easy to ignore much of the problems of Rust, as the architecture (ECS) and the implementation Bevy has of it, hides a lot of "warts" that you would have to battle with otherwise. Bevy makes it really easy to learn Rust, at least that's what I've found when I picked up Rust first.
- sergiosgc 4y agoC# is classic object-oriented, while Rust skips polymorphism. It takes a while to grasp how to properly design using traits with no polymorphism. The transition is far from simple. I happen to like Rust's choice, a lot, but it is a very different approach.
- capableweb 4y agoI was thinking more about the syntax in general. Maybe I'm over-simplifying because most of my time is spent working with Clojure, but Rust and C# syntax is to me very similar to each other (together with most C-like languages). But I agree, programming patterns are different enough to make it harder to make the jump I guess.
- RussianCow 4y agoSyntax is the easiest thing to pick up about a new programming language. Semantics, idioms, etc take far more time, and in that sense, C# and Rust are very different.
- capableweb 4y agoParent specifically mentioned syntax so I specifically talked about it...
- brundolf 4y agoTechnically traits are polymorphism (and you could argue Rust's enums are too), they just look differently than in classically object-oriented languages What Rust really skips is inheritance (although you can get partway there with trait dependencies), which I think is generally a good thing
- tialaramex 4y agoSpecifically Rust doesn't have implementation inheritance. The fact that [u8; N] and Vec<String> are both IntoIter doesn't imply they are somehow inheriting any common elements of their implementation, just that they both provide means to convert themselves into Iterators when needed. In Rust we could make a Mimic by composing a Chest, and a Monster, and then implementing any traits on the resulting composite object appropriately, passing through to an underlying object in some cases -- opening this "Chest" ought to cause its status as a Monster to be revealed right?. In languages with single inheritance we need to decide, is a Mimic a Chest? Is it a Monster? Maybe all Chests are Monsters? Maybe all Monsters are Chests? In languages with multiple inheritance we can inherit from both, but we might find that isn't what we wanted either and there are likely to be conflicts from such a web of heritability.
- pornel 4y agoI don't think "smart" is the right way of framing this, but there is a lot to learn. First, Rust has its unusual way of managing memory through ownership and borrow checking. There is a steep learning curve there, but it's not that hard once you "get" it. However, some programmers need to unlearn their web-of-pointers programming style and adapt to Rust's way of thinking to get it. Then, Rust doesn't have inheritance and hates shared mutability. For game development this makes the easy "class Player extends Entity" design nearly impossible to work with. Entity-Component-System works way better with Rust, but ECS design is another big thing to learn. IMHO Rust is worth using for most things that would be written in C usually. For game development the jury is still out. Rust has great multi-threading support, which games don't use that much yet. Rust also focuses a lot on correctness and preventing bugs. This is a bit controversial in gamedev, since the usual way is to iterate quickly, and fix stuff later. Rust's proposition is to iterate a bit slower, but not have to fix as much later.
- bcrosby95 4y agoI don't know if you have to be smarter. There's just some patterns you'll probably have to unlearn. Some people really like Rust, but I don't think it's that big of a deal if you're already using a memory safe language. If that's the case, and you don't like Rust, I'd just say to not bother with it.
- amalcon 4y agoI don't think you need to be smarter, but coming from something like C#, there are some different ways of thinking that you'll need to learn. In addition to the memory management stuff, there are a number of things borrowed from the ML language family. Since you mention docs and syntax, those are more likely the things tripping you up. You're probably capable of understanding these things, but there is a definite learning curve.
- nu11ptr 4y ago> Question: does one have to be more smart to learn and build stuff in rust than one has to be for something like C#? Possibly - it requires an understanding of memory ownership and lifetimes which is something the GC in C# takes care of for you. It IS a bit of a burden and harder, but does have pay off for some domains where you want that level of control. > Asking because everyone seems to be all in on rust but i'm fucking confused every time I start reading its docs and syntax. Everybody has this the first couple times they attempt Rust. :.) It is different, but once you get over the straight up initial learning curve...it is pretty smooth sailing. > Is it worth using rust for anything that isn't currently written in C? i.e. operating systems and compilers? I think so, but I'm a bit biased as Rust is my primary and favorite language. I like the memory control it gives me as well as its functional like nature. Since it is also roughly the same speed as compiled C/C++ it can play nicely in some of those domains but with better memory safety.
- brundolf 4y agoI agree with sibling that "smart" isn't a helpful way to frame these sorts of things I think just about any programmer has the ability to learn Rust. The basics will probably come pretty easy; the syntax and general way of writing code are designed to be familiar to anyone who's used C-like languages Fully understanding it and learning the more advanced features may be hard, harder than other languages, but I think it's within anyone's capacity. I definitely find myself thinking harder about things when I'm writing Rust, but I don't think it's on a whole separate plane of ability > reading its docs and syntax I don't know which docs you started with, but just in case, I suggest you start with the Rust Book (https://doc.rust-lang.org/book/ https://doc.rust-lang.org/book/). It's designed to ease you in gradually, tutorial-style; much better than eg. starting with the reference and API docs
- follower 4y ago> but i'm fucking confused every time I start reading its docs and syntax. You are not the only one. :) I definitely walked up to Rust & then turned around & left again during my learning process. :D (And that was with the advantage of having dealt with manual memory management previously.) But I think the Rust community generally acknowledges the learning challenge that Rust may present at the beginning & work to reduce it over time. And also provide the reassurance that it's definitely not just you. At the beginning I think the resource I found most helpful was this: * <https://fasterthanli.me/articles/a-half-hour-to-learn-rust https://fasterthanli.me/articles/a-half-hour-to-learn-rust> Primarily because it's an extremely compact overview of Rust syntax which has the benefit of (a) improve your familiarity with the syntax & meaning to enable you to read Rust code; and, (b) it's all in one page so when one inevitably forgets something they can return to the page & search and/or review it. :) As the introduction puts it: > In order to increase fluency in a programming language, one has to read a lot of it. But how can you read a lot of it if you don't know what it means? > In this article, instead of focusing on one or two concepts, I'll try to go through as many Rust snippets as I can, and explain what the keywords and symbols they contain mean. It is also perhaps the shortest article by fasterthanlime on record. :D > Is it worth using rust for anything that isn't currently written in C? That's an interesting question. (FWIW C and C++ are also used for writing servers, command line & GUI applications.) One question I'd ask would be: have you run into the limits of any language you currently use in terms of capability, performance, packaging/distribution or community? If not, then perhaps Rust wouldn't currently be the best place to invest your learning time. But if there's some element of Rust that intrigues you, and you're kind toward yourself during the learning journey it's likely that at a minimum you may learn something about lower level aspects of computing that might help you when you use other languages. (One thing I've noticed with Rust is that--due to the power of the `cargo` build tooling & surrounding standardised library/crate ecosystem--once you get a relatively small way along your learning journey it can be relatively straight-forward to add a "cool"/"interesting" crate to your project & create something a bit more interesting than...a hard-coded currency exchange rate calculator or something. :) So maybe browse <https://lib.rs/ https://lib.rs/> (an alternative interface to crates.io which I find more "explorable") and see if there is a crate whose functionality makes you think "Ooo, that'd be cool to be able to use".) Good luck!