kuuhana
  • Communities
  • Multi-communities
  • Support Lemmy
  • Search
  • Login
  • Sign Up
Programmer Humor@programming.devbyMaven (famous)@lemmy.zip
11 months

// Implement

lemmy.zip
22
    You must log in or register to comment.

    • Lembot_0004@discuss.online
      11 months

      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.

        • Eager Eagle@lemmy.worldEnglish
          11 months

          that’s why c++ gets bullied

            • Lembot_0004@discuss.online
              11 months

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

                • Eager Eagle@lemmy.worldEnglish
                  11 months

                  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
                      11 months

                      It is a method!

                        • Eager Eagle@lemmy.worldEnglish
                          11 months

                          thanks

                        • leo85811nardo@lemmy.world
                          11 months

                          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

                        • CanadaPlus@lemmy.sdf.org
                          11 months

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

                          • mkwt@lemmy.world
                            11 months

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

                              • Lembot_0004@discuss.online
                                11 months

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

                                  • Avicenna@lemmy.world
                                    10 months

                                    Actually

                                    https://neshobademocrat.com/stories/man-accidentally-shoots-his-foot-with-shotgun,121925

                            • marcos@lemmy.world
                              11 months

                              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
                                  11 months

                                  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.

                                • melechric@lemmy.world
                                  11 months

                                  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.)

                                • MyTurtleSwimsUpsideDown@fedia.io
                                  11 months

                                  implemented

                                    • KairuByte@lemmy.dbzer0.com
                                      11 months

                                      So one understood the assignment.

                                    • Eager Eagle@lemmy.worldEnglish
                                      11 months

                                      a logical skeuomorphism, how eccentric

                                        • mobotsar@sh.itjust.worksEnglish
                                          11 months

                                          Haha! I had the same thought.

                                        • unalivejoy@lemmy.zip
                                          11 months

                                          Thank goodness for the JIT and compiler optimizations.

                                            • setVeryLoud(true);@lemmy.ca
                                              11 months

                                              …would JIT optimizations even help here?

                                            • anton@piefed.blahaj.zoneEnglish
                                              11 months

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

                                                • Eager Eagle@lemmy.worldEnglish
                                                  11 months

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

                                                Programmer Humor@programming.dev

                                                programmer_humor@programming.dev

                                                Subscribe from remote instance

                                                Create post

                                                Report community

                                                Modlog
                                                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

                                                This community is visible to everyone.

                                                • 45 users / Day
                                                • 205 users / Week
                                                • 212 users / Month
                                                • 14.5K users / 6 months
                                                • 2.33K posts
                                                • 89.8K comments
                                                • 2 local subscribers
                                                • 31.9K subscribers
                                                • UI: 1.0.0-beta.0
                                                • BE: 1.0.0-alpha.20
                                                • Modlog
                                                • Instances
                                                • Docs
                                                • Code
                                                • join-lemmy.org