Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Programmer Humor
  3. average c++ dev

average c++ dev

Scheduled Pinned Locked Moved Programmer Humor
programmerhumor
116 Posts 63 Posters 9 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • danhab99@programming.devD [email protected]

    I don't think that casting a range of bits as some other arbitrary type "is a bug nobody sees coming".

    C++ compilers also warn you that this is likely an issue and will fail to compile if configured to do so. But it will let you do it if you really want to.

    That's why I love C++

    G This user is from outside of this forum
    G This user is from outside of this forum
    [email protected]
    wrote on last edited by
    #5

    Don't be average

    1 Reply Last reply
    2
    • danhab99@programming.devD [email protected]

      I don't think that casting a range of bits as some other arbitrary type "is a bug nobody sees coming".

      C++ compilers also warn you that this is likely an issue and will fail to compile if configured to do so. But it will let you do it if you really want to.

      That's why I love C++

      P This user is from outside of this forum
      P This user is from outside of this forum
      [email protected]
      wrote on last edited by
      #6

      I actually do like that C/C++ let you do this stuff.

      Sometimes it's nice to acknowledge that I'm writing software for a computer and it's all just bytes. Sometimes I don't really want to wrestle with the ivory tower of abstract type theory mixed with vague compiler errors, I just want to allocate a block of memory and apply a minimal set rules on top.

      L J 2 Replies Last reply
      77
      • P [email protected]

        C++ is kinky that way. You can consent to all manner of depraved programming patterns. Great for use in personal life, but maybe not appropriate for the office.

        korne127@lemmy.worldK This user is from outside of this forum
        korne127@lemmy.worldK This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #7

        But does it have cargo-mommy 😛

        D V Q 3 Replies Last reply
        44
        • danhab99@programming.devD [email protected]

          I don't think that casting a range of bits as some other arbitrary type "is a bug nobody sees coming".

          C++ compilers also warn you that this is likely an issue and will fail to compile if configured to do so. But it will let you do it if you really want to.

          That's why I love C++

          C This user is from outside of this forum
          C This user is from outside of this forum
          [email protected]
          wrote on last edited by
          #8

          What do you mean I'm not supposed to add 0x5f3759df to a float casted as a long, bitshifted right by 1?

          sunoc@sh.itjust.worksS F 2 Replies Last reply
          81
          • danhab99@programming.devD [email protected]

            I don't think that casting a range of bits as some other arbitrary type "is a bug nobody sees coming".

            C++ compilers also warn you that this is likely an issue and will fail to compile if configured to do so. But it will let you do it if you really want to.

            That's why I love C++

            W This user is from outside of this forum
            W This user is from outside of this forum
            [email protected]
            wrote on last edited by
            #9

            My issue is C++ will "let me do it", and by that I mean "you didn't cast here (which is UB), so I will optimize out a null check later, and then segfault in a random location"

            V 1 Reply Last reply
            26
            • danhab99@programming.devD [email protected]

              I don't think that casting a range of bits as some other arbitrary type "is a bug nobody sees coming".

              C++ compilers also warn you that this is likely an issue and will fail to compile if configured to do so. But it will let you do it if you really want to.

              That's why I love C++

              W This user is from outside of this forum
              W This user is from outside of this forum
              [email protected]
              wrote on last edited by
              #10

              Thank you for including the text as text.

              1 Reply Last reply
              14
              • C [email protected]

                What do you mean I'm not supposed to add 0x5f3759df to a float casted as a long, bitshifted right by 1?

                sunoc@sh.itjust.worksS This user is from outside of this forum
                sunoc@sh.itjust.worksS This user is from outside of this forum
                [email protected]
                wrote on last edited by
                #11

                1 Reply Last reply
                29
                • C [email protected]

                  What do you mean I'm not supposed to add 0x5f3759df to a float casted as a long, bitshifted right by 1?

                  F This user is from outside of this forum
                  F This user is from outside of this forum
                  [email protected]
                  wrote on last edited by
                  #12

                  //what the fuck?

                  S 1 Reply Last reply
                  57
                  • P [email protected]

                    I actually do like that C/C++ let you do this stuff.

                    Sometimes it's nice to acknowledge that I'm writing software for a computer and it's all just bytes. Sometimes I don't really want to wrestle with the ivory tower of abstract type theory mixed with vague compiler errors, I just want to allocate a block of memory and apply a minimal set rules on top.

                    L This user is from outside of this forum
                    L This user is from outside of this forum
                    [email protected]
                    wrote on last edited by
                    #13

                    People just think that applying arbitrary rules somehow makes software magically more secure, like with rust, as if the compiler won't just "let you" do the exact same fucking thing if you type the unsafe keyword

                    P S B W A 5 Replies Last reply
                    6
                    • L [email protected]

                      People just think that applying arbitrary rules somehow makes software magically more secure, like with rust, as if the compiler won't just "let you" do the exact same fucking thing if you type the unsafe keyword

                      P This user is from outside of this forum
                      P This user is from outside of this forum
                      [email protected]
                      wrote on last edited by
                      #14

                      I don't know rust, but for example in Swift the type system can make things way more difficult.

                      Before they added macros if you wanted to write ORM code on a SQL database it was brutal, and if you need to go into raw buffers it's generally easier to just write C/objc code and a bridging header. The type system can make it harder to reason about performance too because you lose some visibility in what actually gets compiled.

                      The Swift type system has improved, but I've spent a lot of time fighting with it. I just try to avoid generics and type erasure now.

                      I've had similar experiences with Java and Scala.

                      That's what I mean about it being nice to drop out of setting up some type hierarchy and interfaces and just working with a raw buffers or function pointers.

                      1 Reply Last reply
                      1
                      • L [email protected]

                        People just think that applying arbitrary rules somehow makes software magically more secure, like with rust, as if the compiler won't just "let you" do the exact same fucking thing if you type the unsafe keyword

                        S This user is from outside of this forum
                        S This user is from outside of this forum
                        [email protected]
                        wrote on last edited by
                        #15

                        You don't even need unsafe, you can just take user input and execute it in a shell and rust will let you do it. Totally insecure!

                        I 1 Reply Last reply
                        10
                        • deegeese@sopuli.xyzD [email protected]

                          C lets you shoot yourself in the foot.

                          C++ lets you reuse the bullet.

                          M This user is from outside of this forum
                          M This user is from outside of this forum
                          [email protected]
                          wrote on last edited by
                          #16

                          C is dangerous like your uncle who drinks and smokes. Y’wanna make a weedwhacker-powered skateboard? Bitchin’! Nail that fucker on there good, she’ll be right. Get a bunch of C folks together and they’ll avoid all the stupid easy ways to kill somebody, in service to building something properly dangerous. They’ll raise the stakes from “accident” to “disaster.” Whether or not it works, it’s gonna blow people away.

                          C++ is dangerous like a quiet librarian who knows exactly which forbidden tomes you’re looking for. He and his… associates… will gladly share all the dark magic you know how to ask about. They’ll assure you that the power cosmic would never, without sufficient warning, pull someone inside-out. They don’t question why a loving god would allow the powers you crave. They will show you which runes to carve, and then, they will hand you the knife.

                          1 Reply Last reply
                          31
                          • L [email protected]

                            People just think that applying arbitrary rules somehow makes software magically more secure, like with rust, as if the compiler won't just "let you" do the exact same fucking thing if you type the unsafe keyword

                            B This user is from outside of this forum
                            B This user is from outside of this forum
                            [email protected]
                            wrote on last edited by
                            #17

                            It's neither arbitrary nor magic; it's math. And unsafe doesn't disable the type system, it just lets you dereference raw pointers.

                            1 Reply Last reply
                            23
                            • F [email protected]

                              //what the fuck?

                              S This user is from outside of this forum
                              S This user is from outside of this forum
                              [email protected]
                              wrote on last edited by
                              #18

                              https://en.m.wikipedia.org/wiki/Fast_inverse_square_root

                              Q 1 Reply Last reply
                              42
                              • danhab99@programming.devD [email protected]

                                I don't think that casting a range of bits as some other arbitrary type "is a bug nobody sees coming".

                                C++ compilers also warn you that this is likely an issue and will fail to compile if configured to do so. But it will let you do it if you really want to.

                                That's why I love C++

                                M This user is from outside of this forum
                                M This user is from outside of this forum
                                [email protected]
                                wrote on last edited by
                                #19

                                There are no medals waiting for you by writing overly clever code. Trust me, I’ve tried. There’s no pride. Only pain.

                                C 1 Reply Last reply
                                37
                                • S [email protected]

                                  You don't even need unsafe, you can just take user input and execute it in a shell and rust will let you do it. Totally insecure!

                                  I This user is from outside of this forum
                                  I This user is from outside of this forum
                                  [email protected]
                                  wrote on last edited by
                                  #20

                                  Rust isn't memory safe because you can invoke another program that isn't memory safe?

                                  S 1 Reply Last reply
                                  12
                                  • M [email protected]

                                    There are no medals waiting for you by writing overly clever code. Trust me, I’ve tried. There’s no pride. Only pain.

                                    C This user is from outside of this forum
                                    C This user is from outside of this forum
                                    [email protected]
                                    wrote on last edited by
                                    #21

                                    It really depends on your field. I'm doing my master's thesis in HPC, and there, clever programming is really worth it.

                                    M 1 Reply Last reply
                                    20
                                    • L [email protected]

                                      People just think that applying arbitrary rules somehow makes software magically more secure, like with rust, as if the compiler won't just "let you" do the exact same fucking thing if you type the unsafe keyword

                                      W This user is from outside of this forum
                                      W This user is from outside of this forum
                                      [email protected]
                                      wrote on last edited by [email protected]
                                      #22

                                      I want you to stop what you're doing, pause and read your comment again slowly.
                                      What you're arguing is analogous to: "People just think that strapping a cloth to them in the car will make driving more secure. As if someone can't just not use the seatbelt and still die in a car crash from that."

                                      It's not arbitarious rules, it's math and computer science. Wth are you some kind of science denier? Have they reached the computer science realm, like "Big O is out to get you?"

                                      These rules do make Rust safer than c++ not in term of business logic but in terms of memory handling. I've been doing c++ for a looooooong time and once in a while there are times where we lose days if not weeks tracking down a race condition or memory bug where we could have been tracking down business logic bugs, improving code quality and coverage, adding features, etc

                                      L 1 Reply Last reply
                                      18
                                      • W [email protected]

                                        I want you to stop what you're doing, pause and read your comment again slowly.
                                        What you're arguing is analogous to: "People just think that strapping a cloth to them in the car will make driving more secure. As if someone can't just not use the seatbelt and still die in a car crash from that."

                                        It's not arbitarious rules, it's math and computer science. Wth are you some kind of science denier? Have they reached the computer science realm, like "Big O is out to get you?"

                                        These rules do make Rust safer than c++ not in term of business logic but in terms of memory handling. I've been doing c++ for a looooooong time and once in a while there are times where we lose days if not weeks tracking down a race condition or memory bug where we could have been tracking down business logic bugs, improving code quality and coverage, adding features, etc

                                        L This user is from outside of this forum
                                        L This user is from outside of this forum
                                        [email protected]
                                        wrote on last edited by
                                        #23

                                        That's not what I meant. I understand that rust forces things to be more secure. It's not not like there's some guarantee that rust is automatically safe, and C++ is automatically unsafe.

                                        W D 2 Replies Last reply
                                        4
                                        • danhab99@programming.devD [email protected]

                                          I don't think that casting a range of bits as some other arbitrary type "is a bug nobody sees coming".

                                          C++ compilers also warn you that this is likely an issue and will fail to compile if configured to do so. But it will let you do it if you really want to.

                                          That's why I love C++

                                          U This user is from outside of this forum
                                          U This user is from outside of this forum
                                          [email protected]
                                          wrote on last edited by [email protected]
                                          #24

                                          I used to love C++ until I learned Rust. Now I think it is obnoxious, because even if you write modern C++, without raw pointers, casting and the like, you will be constantly questioning whether you do stuff right. The spec is just way too complicated at this point and it can only get worse, unless they choose to break backwards compatibility and throw out the pre C++11 bullshit

                                          mobotsar@sh.itjust.worksM zacryon@feddit.orgZ 2 Replies Last reply
                                          23
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups