not digg
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Maven (famous)@lemmy.zip to Programmer Humor@programming.dev · 1 day ago

// Implement

lemmy.zip

message-square
21
fedilink
166

// Implement

lemmy.zip

Maven (famous)@lemmy.zip to Programmer Humor@programming.dev · 1 day ago
message-square
21
fedilink
alert-triangle
You must log in or register to comment.
  • MyTurtleSwimsUpsideDown@fedia.io
    link
    fedilink
    arrow-up
    36
    ·
    1 day ago

    implemented

    • KairuByte@lemmy.dbzer0.com
      link
      fedilink
      arrow-up
      12
      ·
      1 day ago

      So one understood the assignment.

  • Lembot_0004@discuss.online
    link
    fedilink
    arrow-up
    41
    arrow-down
    1
    ·
    1 day ago

    It might be an absolutely adequate method. Imagine that is C++. operator-- is overloaded and controls some machinery. You can’t just command capacity = currSize. Process is important.

    • marcos@lemmy.world
      link
      fedilink
      arrow-up
      16
      ·
      1 day ago

      Yeah, just to say it more clearly: that kind of thing is why lots of people out there insist that operator overloading is a bad idea.

      And yeah, it’s a C++ thing that mostly doesn’t happen in other languages.

      • TeamAssimilation@infosec.pub
        link
        fedilink
        arrow-up
        2
        ·
        1 day ago

        Sincerely agree. Explicit is better then implicit, that’s a general engineering axiom.

        Instead of overloading and making the next maintainer hunt for overloads, a clearly named function that does the critical steps would make the code immensely more maintainable. C++ is C gone wild.

    • Eager Eagle@lemmy.world
      link
      fedilink
      English
      arrow-up
      30
      arrow-down
      4
      ·
      1 day ago

      that’s why c++ gets bullied

      • Lembot_0004@discuss.online
        link
        fedilink
        arrow-up
        10
        arrow-down
        3
        ·
        1 day ago

        That is why it is loved: it allows you to use ideas/objects the same way as you do as an engineer. Super cool.

        • CanadaPlus@lemmy.sdf.org
          link
          fedilink
          arrow-up
          14
          ·
          1 day ago

          Until the next person with a slightly different mental way of defining things comes along. Or just a future version of you.

        • Eager Eagle@lemmy.world
          link
          fedilink
          English
          arrow-up
          18
          arrow-down
          1
          ·
          1 day ago

          yes, but in this particular case I wouldn’t want to second guess my decrement operation just happens to also be calling the white house or whatnot. Just make a method.

          • SpaceNoodle@lemmy.world
            link
            fedilink
            arrow-up
            6
            ·
            1 day ago

            It is a method!

            • Eager Eagle@lemmy.world
              link
              fedilink
              English
              arrow-up
              4
              arrow-down
              1
              ·
              1 day ago

              thanks

          • leo85811nardo@lemmy.world
            link
            fedilink
            arrow-up
            2
            ·
            edit-2
            1 day ago

            That’s just life of a C++ programmer: you second guess everything, and there are still optimization you haven’t tried, and pitfalls you haven’t got into

          • leo85811nardo@lemmy.world
            link
            fedilink
            arrow-up
            1
            ·
            1 day ago

            deleted by creator

        • mkwt@lemmy.world
          link
          fedilink
          arrow-up
          5
          ·
          1 day ago

          But when you do shoot yourself in the foot, it blows your whole leg off.

          • Lembot_0004@discuss.online
            link
            fedilink
            arrow-up
            2
            ·
            1 day ago

            As a shotgun. That’s why people don’t shoot themselves in the foot with a shotgun.

    • melechric@lemmy.world
      link
      fedilink
      arrow-up
      8
      ·
      1 day ago

      Yes. Sometimes you’re limited by the hardware you’re controlling. This code is a bit hard to justify with that excuse though. Normally your code would do a read from hardware to see if the value decremented and then repeat the write. (Possibly a sleep/yield in there if required.)

  • unalivejoy@lemmy.zip
    link
    fedilink
    arrow-up
    10
    ·
    edit-2
    1 day ago

    Thank goodness for the JIT and compiler optimizations.

    • setVeryLoud(true);@lemmy.ca
      link
      fedilink
      arrow-up
      2
      ·
      16 hours ago

      …would JIT optimizations even help here?

  • Eager Eagle@lemmy.world
    link
    fedilink
    English
    arrow-up
    14
    ·
    1 day ago

    a logical skeuomorphism, how eccentric

    • mobotsar@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      3
      ·
      1 day ago

      Haha! I had the same thought.

  • anton@piefed.blahaj.zone
    link
    fedilink
    English
    arrow-up
    8
    ·
    1 day ago

    If those are normal integers, the compiler optimizes that to a simple compare and branch/cmov.

    • Eager Eagle@lemmy.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      edit-2
      1 day ago

      for others - https://godbolt.org/z/osaKrxsPx

Programmer Humor@programming.dev

programmer_humor@programming.dev

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: !programmer_humor@programming.dev

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.

  • 1.22K users / day
  • 4.06K users / week
  • 8.21K users / month
  • 19.7K users / 6 months
  • 1 local subscriber
  • 25.4K subscribers
  • 1.62K Posts
  • 16.4K Comments
  • Modlog
  • mods:
  • Feyter@programming.dev
  • adr1an@programming.dev
  • BurningTurtle@programming.dev
  • Pierre-Yves Lapersonne@programming.dev
  • BE: 0.19.5
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org