• @nivenkos@lemmy.ml
    link
    fedilink
    62 years ago

    I’d recommend reading The Rust Programming Language official book and Rust By Example.

    Then when you get more time Learn Rust With Entirely Too Many Linked Lists to get used to some of the trickier parts of the borrow checker.

    • @Monad
      link
      12 years ago

      To add another fantastic free book: https://highassurance.rs/

      It’s still being written but introduces a wide array of topics alongside Rust.

  • Ephera
    link
    fedilink
    32 years ago

    If you place data in a struct, you usually want that to be owned by that struct, so you usually don’t want to store a reference in a struct.

    If you pass data around as parameters, you usually do want to pass those by reference, except for simple data types, i.e. anything that is itself smaller or the same size as a pointer.
    For example, on a 64-bit system pointers have a size of 64 bits, so u8, u16, u32, u64, i8 etc. can all be passed around by value (they’ll automatically get copied).

  • @vi21@lemmy.ml
    link
    fedilink
    22 years ago

    Even if your program clones some data instead of referring to them, it can be still fast.

  • @rauba_code@lemmy.ml
    link
    fedilink
    22 years ago

    A bit more generic answer not fixed to Rust.

    Python is an interpreted language, C# is compiled to intermediate language which is executed by runtime (.NET or Mono). In contrast, Rust is compiled directly to machine code and therefore it is more complicated language (although it’s fun). I would recommend you to start learning C++ or even C first because much is needed to be understood about how your code is translated to the machine code, how memory works, e.g. what is a pointer, what is static allocation, what is dynamic allocation, why dynamically allocated pointers should be freed after use. In Python and C#, all the memory is managed by the Garbage Collector (GC), whereas in C/C++, the user should free memory manually. Moreover, Rust takes a lot of design from C/C++, such as automated placement of destructors (C for primitives, C++ for objects), fat pointers (a safer way to use C-style pointers), etc. And keep in mind that Rust is not a fully object-oriented language (i.e. objects cannot inherit objects but can inherit ‘traits’, or ‘interfaces’ in C#). To sum up, in your place, I would install Dev-C++ or some other IDE and start learning down from the lowest level, and only when I’ve understood C and C++ well, then I would jump to Rust.

    Free C resources: https://notabug.org/koz.ross/awesome-c#learning-reference-and-tutorials

    Free C++ resources: https://github.com/fffaraz/awesome-cpp#videos

    Standard library reference: https:/cplusplus.com and https://en.cppreference.com/

    For practice, try to solve some problems from competitive programming archives: https://open.kattis.com/ or https://codeforces.com/problemset They accept all languages.

    TL;DR Begin with C++ first, learn about memory, then start with Rust, your learning curve will go much smoother.

  • @Monad
    link
    1
    edit-2
    2 years ago

    deleted by creator