Skip to content
DevMeme
7280 of 7590
Performance Post #7980 · source on Telegram

Batman Slaps Robin: C++ Speedup Matters at Billions of Runs

Description

Classic Batman-slapping-Robin comic panel meme (imgflip watermark) on a red background. Robin's speech bubble says 'YOUR 3000 LINES CPP IS JUST 0.001 FASTER THAN MY 10 LINE PYTHON', and Batman, mid-slap, replies 'TRY RUNNING IT A FEW HUNDRED BILLION TIMES.' The meme distills the perennial Python-vs-C++ performance argument: per-invocation differences look negligible in microbenchmarks, but at hot-path scale - billions of executions - small constant factors compound into massive compute and cost differences, justifying the verbosity of systems languages

Comments

68
Anonymous ★ Top Pick At one run it's premature optimization; at a few hundred billion runs it's the difference between a t3.micro and a datacenter line item with its own VP
  1. Anonymous ★ Top Pick

    At one run it's premature optimization; at a few hundred billion runs it's the difference between a t3.micro and a datacenter line item with its own VP

  2. Anonymous

    A millisecond is negligible until 10¹¹ calls turn it into 3.17 CPU-years.

  3. @je_rocve_tof_t 3mo

    It absolutely depends on the situation if what matters the most is the extra performance or the time to production

    1. @ferriego 3mo

      Fuck ttp

      1. @a_desant 3mo

        Fuck ttp My homies never ship

      2. @VexelX 2mo

        You look like a .Net master indeed...

        1. @ferriego 2mo

          Im your slave bro

  4. @RiedleroD 3mo

    performance is for the users. time to production is for the shareholders.

    1. @RiedleroD 3mo

      ok I guess to some extent ttp is for the users too. my point with this was to say that in our short-term-profit-driven world we often seem to be optimizing for ttp and hype at the expense of all else.

      1. @RiedleroD 3mo

        in other words: ttp is well and good, and yes a feature shouldn't take forever to land, but we should also make sure to take enough time to do it right.

        1. @death_by_oom 3mo

          Claude, you are a senior developer. One shot this feature

          1. @death_by_oom 3mo

            No mistakes

      2. @je_rocve_tof_t 3mo

        Not only users or stakeholders, ttp is for the business. Time to production have been sometimes a big market competitiveness factor, with major examples as YouTube / Google Video

    2. @theodolu 3mo

      I'm sure users won't care when there is a runtime bug in the 3000 lines

  5. @Agent1378 3mo

    C/c++ is the reason for 99% of all CVEs. The people are a reason but try giving AK to a chimpanzee

    1. @death_by_oom 3mo

      Wow, the language that has been used for the majority of performance oriented security critical code for the past 40 years is the reason for most of the CVEs, what would be the reason for that

      1. @Agent1378 3mo

        Any other compiled language, like idk pascal, would have 99-100% of performance and removed 80% of cves because it just doesn't allow everything c allows

        1. @death_by_oom 3mo

          Well, most of the important stuff from the past half century is written in C/C++. We'll never know if Pascal would have been better in this regard because it's not as wide spread, but I suspect that it wouldn't be any different.

          1. @Agent1378 3mo

            It has much stricter syntax and automatic array ranges checking, it had this even in old compilers from 80s. That would solved like 90% of problems

            1. @death_by_oom 3mo

              Rust has much stricter compiler rules. There is still 113 vulns in the uutils coreutils

              1. @death_by_oom 3mo

                People will write vulns in any language they are given

                1. @Agent1378 3mo

                  Thats true, especially those people who tend to see themselves as superior to others and stop questioning their own actions, like rust programmers....wait...oh shit😁

                  1. @death_by_oom 3mo

                    I just think that the fact that most of the critical software we use today is written in C/C++ is the main reason there are so many CVEs for it, not the fact that it's inheritely unsafe

                    1. @death_by_oom 3mo

                      I think the creators of all the major OSs, all the major DBs, Browsers and so on knew what they were doing when picking a language to use

                      1. @Agent1378 3mo

                        1000 billion shit eating flies are right, right?

                        1. @death_by_oom 3mo

                          I have people I look up to, yes. That is called having a direction to move towards. And I think people who created widely used performant systems like Linux, GNU utils, OpenSSH, Postgre, OpenSSl, V8, SQLite, MacOS, Chrome, Firefox, are a good north star.

                          1. @Agent1378 3mo

                            It's just a coincidence, c was there in the right place at the right time, and so everyone went with it.

                            1. @death_by_oom 3mo

                              Pascal was created 2 years before C

                              1. @Agent1378 3mo

                                But it wasn't in the right place

                        2. @death_by_oom 3mo

                          You were literally talking about the arrogance of rust Devs in the previous message, the irony of this is oh so delicious

                    2. @RiedleroD 3mo

                      I hate C++ but I do agree

                  2. @RiedleroD 3mo

                    borderline ragebait

                    1. @death_by_oom 3mo

                      Nothing borderline about this

                  3. @Daonifur 3mo

                    The "just use Linux" types for the last 10+ years

                    1. @Agent1378 3mo

                      Well, latest windows developments make ir more and more true😐

                      1. @Daonifur 3mo

                        Fair but it didn't make as much sense when Windows 7 was popular

                        1. @Agent1378 3mo

                          Yes. And Linux desktop is the same headache as always, especially if something unconventional is needed, then its back to "./configure" baby. Maybe steam take is a little better, didn't tried

                          1. @Daonifur 3mo

                            I'd rather just use whatever OS I want. The amount of people with the "just use Linux" line makes me never want to use it

                            1. @Agent1378 3mo

                              Don't listen to people they are stupid mostly.

                              1. @Daonifur 3mo

                                Lol, reminds me of the "just use this game engine" types. I found it easier to make my own engine in C but kept getting those types commenting when I'd run into issues, along with the "just use Linux types"

                                1. @Daonifur 3mo

                                  Although now it's an irony because I use Godot atm for game dev but it's so much easier when you know the limitations and workarounds in your own engine, since you can just add whatever features you want

                                  1. @Daonifur 3mo

                                    I'm also doing this in Android for Android devices, for added difficulty and convenience (you can have a phone everywhere where laptops and PCs usually stay put)

                            2. @ferriego 3mo

                              I use arch btw

                      2. @Daonifur 3mo

                        Although that's almost their solution to everything. Having problems with Android? Install Linux. Having problems with Apple? Install Linux

                        1. @Daonifur 3mo

                          If you're having problems with a specific game, install Linux, even if the game is unavailable for Linux

                          1. @Daonifur 3mo

                            Or my favorite, if you use FL studio and people say to switch to Linux, even though LMMS is pretty bad

                          2. @Agent1378 3mo

                            Stupid people

              2. @Agent1378 3mo

                #unsafe detected lol

                1. @feedable 3mo

                  you could've just read the actual list of cves, it's straight up embarrasing and none of it is related to unsafe or any of that bs almost all of it may have happened in any other language where users refuse to think with their brains, and decide that some mechanical god will protect them from all the curses https://seclists.org/oss-sec/2026/q2/332

                  1. @Agent1378 3mo

                    Lol

              3. @deimossos 3mo

                Hmm I wonder what's safer: c/c++ code that has been battle tested for decades or a rewrite in rust few months old

            2. @SamsonovAnton 3mo

              At what cost? Software-based range checking has its own performance overhead. Hardware-enforced memory protection is cool, but hard (next to impossible) to use in general-purpose software with large codebase.

              1. @Agent1378 3mo

                There are probably something like 0.5% of the code where software range checking really made it slower for the entire app. So write these hot spots without checking, and leave it on for everything else. So ok, some hi load server will have 90% of the current performance because of that, big deal.

                1. @death_by_oom 3mo

                  If you have a server that is 10% slower on average, your P99 baloons, given most modern websites require multiple calls to a server per action, the situation becomes even worse

                  1. @Agent1378 3mo

                    Well, just add some more cores and memory and servers

                    1. @death_by_oom 3mo

                      JS dev ahh take

                2. @SamsonovAnton 3mo

                  That's how .Net works, afair: it disables range checking inside sequential loops, checking just the lower and upper bounds. But still, according to my rough estimations, .Net performs ≈10x slower than C/C++ on a "computational" code (not necessarily floating-point math, but cryptography or big integer arithmetics) — where the CPU is the bottleneck, not the I/O.

                  1. @Agent1378 3mo

                    10x slower? I would like the example or the link for that that sounds insane. Or maybe you're talking about a first run of the code? Before JIT kicks is [yo]

                    1. @SamsonovAnton 3mo

                      No, the code being repeated enough for a relevant comparative benchmarking. The numbers I remember for a Blowfish cipher implementation were, like, 2500 vs 28000 key probes per second on a single Core i7-2600 core — just enough to use .Net for brute-forcing 10000 possible keys, but definitely leaning towards C for brute-forcing 2⁴⁰ combinations. I don't remember the exact number for big integer math (for DSA signatures), but the ratio was similar — an order of magnitude, at least for the time of those experiments 10 years ago, when .Net 4.5 was the most recent version (of the classic .Net, not the rebooted one).

                      1. @Agent1378 3mo

                        Thats crazy, that it was so bad

  6. @blue_bonsai 3mo

    No-fun-allowed zone

  7. @paranoidPhantom 3mo

    They forgot to mention that it’s the same instructions running on the cpu

  8. @Ajay_Jammu 3mo

    Just use assembly

    1. dev_meme 3mo

      sybassss

  9. @ddamiryh 3mo

    10 lines of the python in question: from something_written_on_c import read, loop1, loop2, loop3, write if __name__ == '__main__': a = read() b = loop1(a) c = loop2(b) d = loop3(c) write(d)

    1. @nwordtech 3mo

      Every single time

  10. @abra_mixabra 3mo

    so switching languages will magically solve everything, right? right...? https://www.cvedetails.com/vulnerability-list/vendor_id-39558/product_id-190816/Uutils-Coreutils.html https://discourse.ubuntu.com/t/an-update-on-rust-coreutils/80773

  11. @ZmEYkA_3310 3mo

    I use void btw

Use J and K for navigation