programming.dev
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
theory@feddit.uk to Programmer Humor · 2 years ago

Too close to home

feddit.uk

message-square
37
link
fedilink
  • cross-posted to:
  • [email protected]
546

Too close to home

feddit.uk

theory@feddit.uk to Programmer Humor · 2 years ago
message-square
37
link
fedilink
  • cross-posted to:
  • [email protected]
alert-triangle
You must log in or register to comment.
  • Guilvareux@feddit.uk
    link
    fedilink
    arrow-up
    25
    ·
    2 years ago

    Oh and .clone()

    • meisme@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      2 years ago

      And .copy()

      • philm
        link
        fedilink
        arrow-up
        4
        ·
        2 years ago

        .copy()?

        • tatterdemalion
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          2 years ago

          Are you copying a Result or Option?

          • philm
            link
            fedilink
            arrow-up
            2
            ·
            2 years ago

            I don’t understand…? I think I never explicitly run a method/function that is called copy (there isn’t at least not for the trait Copy)

            • tatterdemalion
              link
              fedilink
              arrow-up
              2
              ·
              2 years ago

              Lol yea I think the .copy() comment was a little gaslighting or something.

              • darcy@sh.itjust.works
                link
                fedilink
                arrow-up
                2
                ·
                2 years ago

                no its not youre crazy

  • pulaskiwasright@lemmy.ml
    link
    fedilink
    arrow-up
    24
    ·
    edit-2
    2 years ago

    I thought it was randomly adding Send and Sync traits to function signatures until rustc is happy.

    • theory@feddit.ukOP
      link
      fedilink
      arrow-up
      3
      arrow-down
      1
      ·
      2 years ago

      That too

      • charolastra
        link
        fedilink
        arrow-up
        4
        ·
        2 years ago

        Randomly wrapping things in Arc::new()

  • danwardvs@sh.itjust.works
    link
    fedilink
    arrow-up
    22
    ·
    2 years ago

    This was me in courses that used C. Keep adding and removing * and & until the IDE was happy and it usually worked.

    • philm
      link
      fedilink
      arrow-up
      8
      ·
      2 years ago

      Ah the good old times with C, when things were much more simple (but unsafe…)

      • Rikudou_Sage@lemmings.world
        link
        fedilink
        English
        arrow-up
        3
        ·
        2 years ago

        (void*) flashbacks intensify.

        • philm
          link
          fedilink
          English
          arrow-up
          3
          ·
          2 years ago

          The “best” way to program dynamically typed…

  • mvee@lemmy.ml
    link
    fedilink
    arrow-up
    18
    ·
    2 years ago

    I’m gonna have to borrow this book

    • HeavyRust@lemm.ee
      link
      fedilink
      arrow-up
      6
      ·
      2 years ago

      Me too. I also want to make some changes to it at the same time.

      • mvee@lemmy.ml
        link
        fedilink
        arrow-up
        4
        ·
        2 years ago

        Better apply for a mutable library card now before someone else does

  • SubArcticTundra@lemmy.ml
    link
    fedilink
    arrow-up
    16
    ·
    2 years ago

    Hahaha yes tfw Rust forces you to put your shit in a Rc<Cell<Option<>>>

    • nothacking@discuss.tchncs.de
      link
      fedilink
      arrow-up
      6
      ·
      2 years ago

      New your program deadlocks instead of crashing, peak safety.

      • tatterdemalion
        link
        fedilink
        arrow-up
        9
        ·
        2 years ago

        EVERYBODY STOP. Nobody make a move or the memory dies. We have a Mexican Memory Standoff.

  • Blackthorn
    link
    fedilink
    arrow-up
    13
    ·
    2 years ago

    Follow up of: “Mmm… should I put lifecycle annotation in these 10 structs or just use and Rc and call it a day?”. Rc and Box FTW.

  • raubarno@lemmy.ml
    link
    fedilink
    arrow-up
    12
    ·
    2 years ago

    So… now the rustc borrow checker is the new video game boss that is nearly impossible to beat for newcomers, right?

  • skomposzczet@lemm.ee
    link
    fedilink
    arrow-up
    5
    ·
    edit-2
    2 years ago

    I think that’s the only thing I dislike about rust. Not having to use * to dereference but later having to use is tad confusing. I know it’s still clever solution but in this case I prefer c++'s straightforward consistency.

    Using ampersand never was problematic for me.

    • Pfosten@feddit.de
      link
      fedilink
      English
      arrow-up
      24
      ·
      2 years ago

      C++ does have the problem that references are not objects, which introduces many subtle issues. For example, you cannot use a type like std::vector<int&>, so that templated code will often have to invoke std::remove_reference<T> and so on. Rust opts for a more consistent data model, but then introduces auto-deref (and the Deref trait) to get about the same usability C++ has with references and operator->. Note that C++ will implicitly chain operator-> calls until a plain pointer is reached, whereas Rust will stop dereferencing once a type with a matching method/field is found. Having deep knowledge of both languages, I’m not convinced that C++ features “straightforward consistency” here…

  • nautilus@lemmy.dbzer0.com
    link
    fedilink
    arrow-up
    6
    arrow-down
    2
    ·
    2 years ago

    Replace that with golang and now we’re talking

    • BravoVictor
      link
      fedilink
      arrow-up
      2
      ·
      2 years ago

      Yeah, popped in the comments to say the same.

      I dont know what my damage is with pointers…

      • nautilus@lemmy.dbzer0.com
        link
        fedilink
        arrow-up
        3
        ·
        2 years ago

        honestly with Go in general I’m in a perpetual cycle of being annoyed with it and then immediately being amazed when I find some little trick for efficiency - with stringer interfaces and the like

  • nothacking@discuss.tchncs.de
    link
    fedilink
    arrow-up
    4
    ·
    2 years ago

    Same for C, & yields a pointer to a value, and * allows you to access the data. (For rust people, a pointer is like a reference with looser type checking)

    • Aloso
      link
      fedilink
      arrow-up
      7
      ·
      2 years ago

      We have pointers in Rust, too :) see documentation

      • nothacking@discuss.tchncs.de
        link
        fedilink
        arrow-up
        4
        arrow-down
        1
        ·
        2 years ago

        I doubt many people have ever use that or any of the other low level memory API. The main appeal of rust is not having to do that.

        • Aloso
          link
          fedilink
          English
          arrow-up
          1
          ·
          2 years ago

          Sure, but raw pointers and unsafe Rust are still covered in the official learning material, so I assume that most Rust devs know about raw pointers.

  • preasket@lemy.lol
    link
    fedilink
    arrow-up
    1
    arrow-down
    1
    ·
    2 years ago

    https://www.youtube.com/watch?v=co3ewqQlX-8

    • Anafabula@discuss.tchncs.de
      link
      fedilink
      arrow-up
      12
      ·
      2 years ago

      The actual video, not the reaction: https://www.youtube.com/watch?v=TGfQu0bQTKc

      • PipedLinkBot@feddit.rocksBannedB
        link
        fedilink
        English
        arrow-up
        7
        ·
        2 years ago

        Here is an alternative Piped link(s): https://piped.video/watch?v=TGfQu0bQTKc

        Piped is a privacy-respecting open-source alternative frontend to YouTube.

        I’m open-source, check me out at GitHub.

    • PipedLinkBot@feddit.rocksBannedB
      link
      fedilink
      English
      arrow-up
      2
      ·
      2 years ago

      Here is an alternative Piped link(s): https://piped.video/watch?v=co3ewqQlX-8

      Piped is a privacy-respecting open-source alternative frontend to YouTube.

      I’m open-source, check me out at GitHub.

Programmer Humor

programmer_humor

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: [email protected]

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 542 users / day
  • 4.46K users / week
  • 8.2K users / month
  • 18.1K users / 6 months
  • 2.4K local subscribers
  • 23.3K subscribers
  • 1.39K Posts
  • 52.3K Comments
  • Modlog
  • mods:
  • adr1an
  • Feyter
  • BurningTurtle
  • Pierre-Yves Lapersonne
  • BE: 0.19.11
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org