• lime!@feddit.nu
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    2 months ago

    alternative joke

    C++: “Hey, what’s your name?”
    Python: *grabs C++* “what is my name?”

      • anomnom@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        1
        ·
        2 months ago

        Pythons weak typing means it never knows what is what. It’s up to the programmer to not screw it up.

        • Splendid4117@piefed.social
          link
          fedilink
          English
          arrow-up
          1
          ·
          2 months ago

          I think it’s more that a ton of popular python libraries (things like pandas, tensor, etc) are actually built in C, so python is just C wearing a mask

      • lime!@feddit.nu
        link
        fedilink
        English
        arrow-up
        1
        ·
        2 months ago

        one of python’s strong suits is it’s foreign function interface. it’s very easy to call code in other languages from python, which can speed execution up significantly

      • Saleh@feddit.org
        link
        fedilink
        arrow-up
        1
        ·
        2 months ago

        It might not be a language but a skill issue if your python code performs significantly worse than your C code

        • thebestaquaman@lemmy.world
          link
          fedilink
          arrow-up
          0
          ·
          2 months ago

          That completely depends on what you’re doing. If you’re doing tasks that python can completely offload to some highly optimised library written in C/C++/Fortran, then yes. However at that point you’re not really comparing Python to C anymore, but rather your C implementation to whatever library you used.

          A fair comparison is to compare pure python to pure C, in which case you need to mess up the C-code pretty bad if Python is to stand a chance.

          • Ephera@lemmy.ml
            link
            fedilink
            English
            arrow-up
            1
            ·
            2 months ago

            I do think, it’s fair to use Python code which uses C under the hood in benchmarks, because it does often match reality. But then it also has to be realistic code. If it’s just a single line of Python code, which calls into C and then everything happens there, then there is really no point for you to use Python.

            Python only makes sense to use, if you do write some amount of glue code with it. And then it does require significantly more skill to write performant code than it does with many other languages, as lots of costly abstractions are hidden from you. And it often also requires more effort, since you might not find performant libraries, since so much of the ecosystem only has performance as an afterthought. Reality is messy, which is why realistic Python code still tends to do terribly in benchmarks, whether it calls into C or not.

            • thebestaquaman@lemmy.world
              link
              fedilink
              arrow-up
              1
              ·
              edit-2
              2 months ago

              100 % agree here. If you’re testing an actual use-case, it’s fair to compare realistic python to realistic C. However, I would argue that at that point you’re no longer benchmarking Python vs. C as languages, but Python vs. C for that particular use-case.

  • wheezy@lemmy.ml
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    2 months ago

    I know people joke around about this a lot. But I was blown away by a recent switch to I did from using cv2 with python to using cv2 with C++.

    I had literally hundreds of thousands of images to analyze for a dataset. My python script would have taken 12 hours.

    I ported it to C++ and it literally destroyed it in 20 minutes.

    I’m sure I was doing something that really wasn’t optimized well for python. I know somewhere in the backend it probably was using a completely different library with multi thread optimization. Or maybe turbojpg is just garbage in python. I’m still not even sure what the bottleneck was. I don’t know enough to really explain why.

    But holy shit. I never had that much of a performance difference in such a simple task.

    Was very impressed.

    • bobbyfiend@lemmy.ml
      link
      fedilink
      arrow-up
      1
      ·
      2 months ago

      Not having true vectorization and having to regularly code that into Python helps even the odds.

  • bobbyfiend@lemmy.ml
    link
    fedilink
    arrow-up
    1
    ·
    2 months ago

    This has got to be the best, most legitimately funny programmer/computer joke I’ve seen in years.

  • BeeegScaaawyCripple@lemmy.world
    link
    fedilink
    English
    arrow-up
    0
    arrow-down
    1
    ·
    2 months ago

    my dudes i had the idea for the stupidest little app that i could charge 50 cents for that maybe a million people would download because like 50 cents but i have no idea how to code beyond “hello world” and I AM NOT VIBE CODING AAAA

    it’s a map you put pins with notes in it. you will get nothing more than that out of me because it’s very cute and then you will make it