I have been programming in Rust for about 8 years now. I love the language. But I feel I have some confessions I must make.

  1. I don’t know if I use tabs or spaces in my final code. I just assume that it all get solved correctly by cargo fmt. I don’t even understand that people have been arguing about this for real? I vaguely remember this being important in C and C++, but I am hoping I never go back to those dark days.

  2. I never do linebreaks, not even when adding my semicolons. I hit “:w” and if shit doesn’t move around on my screen, I fucked up somewhere.

  3. The only lifetime I ever use is '_, 'a or 'static otherwise I give up

  4. Wtf is the 'de lifetime in serde deserialize??

  5. Rocket is the best web server

  6. I actively chose software written in Rust over other software, even if it’s not better, and I argue that it is.

Okay, got that of my chest. Never dared telling anyone this before. Feels scary

  • Ephera
    link
    fedilink
    English
    68 hours ago
    1. Wtf is the 'de lifetime in serde deserialize??

    Aside from 'static (and the anonymous lifetime '_), the exact name isn’t actually meaningful beyond explaining to the reader what you intend to use this lifetime for.

    So, whether you call it 'a or 'de or 'database doesn’t change anything about the lifetime itself.
    Serde calling it the 'de lifetime is just to clarify that this is the lifetime of the deserialized object.

  • @[email protected]
    link
    fedilink
    English
    610 hours ago

    Honestly if you never had to deal with more than one lifetime parameter per function and/or type, good for you! As for what 'de is used for in serde — it’s the lifetime of the data you’re deserializing. It’s not really relevant unless you’re deserializing borrowed data, which is very very rarely the case, especially when it comes to web development which I’m guessing you’re most familiar with

    • @[email protected]OP
      link
      fedilink
      English
      39 hours ago

      Done a lot of embedded work as well, but now mostly webstuff. I think I would prefer the embedded again, web is horrible the more you get to users and browsers, wasm isnt really all that, so many caveats.

      Embedded is exhausting with its unsafe and slices everywhere. And whoever wanted most of the HAL traits to be fallible had me spinning in embedded-hal.

      Why have the errors when you can’t really handle most of them?

      But Jesus if probe-rs and the gang att ferrous systems aren’t revolutionizing the embedded space. It’s amazing. And now the official hal from esp32, it’s moving places!

  • Eager Eagle
    link
    English
    4
    edit-2
    10 hours ago
    1. What are you talking about, it’s always better.

    But seriously, I don’t have much Rust proficiency and I still pick software in Rust because 1. installing and updating rust itself and things installed with it is a bliss; and 2. the CLI experience of Rust programs tends to be much better than alternatives.

    Contrasting that with installing something with Go, which is a common alternative for things written in Rust:

    • First, I need Go. So if I chose to install it via another package manager - perhaps with the exception of pacman - I may end up with an out of date version that may cause issues when compiling newer code. I had this happen a few times.
    • If I chose to build it myself, first I need an older version of Go to compile a newer Go. Very fun.
    • If I chose to install it via their website, it’s a manual .tar.gz download and extraction of an executable that doesn’t self-update, so next time I not only have to repeat this, but I need to remember it.
    • Then there’s the gvm project, which promises to resolve some of this friction, and it was my method of choice, but I’m not sure it’s maintained anymore and I always have to look up their commands because of things like: gvm list works, but to list versions for download it’s gvm listall instead of gvm list --all)

    Now for Rust:

    • curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
    • optional cargo install cargo-update to update everything else with cargo install-update -a
    • @[email protected]OP
      link
      fedilink
      English
      29 hours ago

      :D mostly, there are still a few nice tools written in go that is quite useful, I just hope they will be replaced by rust software soon. Following the iroh project quite closely, I’m guessing someone will rewrite syncthing using that or p2panda soon.

      But yeah, the rust Cli tools are just godsent compared to everything else. Ripgrep, fd-files, helix are used daily by me. Started using smartcat recently but I feel dirty knowing that Ollama is actually Go software…

  • @[email protected]
    link
    fedilink
    110 hours ago

    How do you feel about Arc<Mutex<T>>? Personally, I just put every variable in an Arc Mutex to make my life easier.

    • @[email protected]OP
      link
      fedilink
      English
      19 hours ago

      When I need something like that, I usually go with with Arc<RwLock<T>>, from parking lot, I have not ever run into a posioned state that I need to handle.

      Otherwise I have been using dashmap. But after having a team that went nuts with it, and it started having it deadlock, which they didn’t know how to handle, I am more careful.

      OnceCell is also quite useful, it all depends on the situation.

  • @[email protected]
    link
    fedilink
    09 hours ago
    1. I actively chose software written in Rust over other software, even if it’s not better, and I argue that it is.

    Rust has quite a high barrier for entry which is likely to deter inexperienced developers. I’d say that’s enough justification to favour software written in Rust.

    Python on the other hand is far too easy to get started with, thus the ecosystem is plagued with terrible software. I avoid it like the plague. Yes, there some decent projects written in Python but they are rare things

    • @[email protected]OP
      link
      fedilink
      English
      29 hours ago

      Oh yeah, not only inexperienced, but uncaring. Python is for people who truly do not care. They want it to “just work” and once it worked once, it’s done.

      And then they notice it wasn’t done, slap some shifty patchwork on top of it. Prince and repeat for a truly masterful piece of spaghetti al dente

      • Ephera
        link
        fedilink
        English
        29 hours ago

        Prince and repeat

        That should be an album name or something. 🙃

        I assume, autocorrect got you, but just in case, it’s “rinse and repeat”.