E00: Software Drag Racing: C++ vs C# vs Python - Which Will Win?

Sdílet
Vložit
  • čas přidán 14. 05. 2024
  • Retired Microsoft Engineer Davepl writes the same 'Primes' benchmark in Python, C#, and C++ and then compares and explains the differences in the code before racing them head to head to see what the performance difference is like between the languages.
    It appears the upload process does some volume leveling or loudness, so my apologies if you get startled during the into. It was mixed down in the master, honest :-)
    Thanks to the Simpsons for the inevitable reference or two that I throw in now and then! See if you can spot both in this episode!
    0:00 Start
    2:08 The Primes Assignment
    6:25 How a Sieve Works
    7:32 Coding Begins
    9:00 Python Version
    12:50 C# Version
    18:25 C++ Version
    22:22 Charts and Graphs
    23:17 Outtakes
    I've placed the code up on GitHub for your reference without any warranty for any purpose!
    github.com/PlummersSoftwareLL...
    I get a lot of questions about which keyboard I'm using as well as various other camera and studio equipment questions, so here are the highlights:
    CORSAIR K70 RGB MK.2 Mechanical Gaming Keyboard (Cherry MX Blue Switches)
    amzn.to/31UrUUD
    Sony FX3 or A7SIII Cameras
    amzn.to/31TRdWK
    amzn.to/3wG9iG7
    Aputure 120D Mark II Light and Light Dome II Mini
    amzn.to/3uya8Ts
    amzn.to/31XwBx2
    Glide Gear TMP100 Prompter
    amzn.to/3ux84Ll

Komentáře • 2,7K

  • @stuartogrady8787
    @stuartogrady8787 Před 2 lety +475

    Best video I have watched in a long time.

    • @fredricknilsson7
      @fredricknilsson7 Před 2 lety +4

      Yes for sure, he brings some inspiration :-)

    • @chetana9802
      @chetana9802 Před rokem +2

      time to redo this

    • @ApteraEV2024
      @ApteraEV2024 Před 8 měsíci

      Bad@$$ Studio, 🎤 🎙 with your 🧰 Toolbox & LEDs Projects🎉❤

    • @ApteraEV2024
      @ApteraEV2024 Před 8 měsíci

      22:45 Please No More "FANCY " @$$ GRAPHS 😅😅

  • @ShALLaX
    @ShALLaX Před 3 lety +1383

    A cool project would be to set up a git repo for everyone to check in their implementations of this algorithm in their favourite language. Then set up a CI pipeline to run them every time someone commits an optimisation. Chart the results.

    • @gianluca.g
      @gianluca.g Před 3 lety +32

      Nice! Reminds me of the fire routine speed challenge

    • @veritatas678
      @veritatas678 Před 3 lety +9

      That would be Hella cool

    • @techpriest4787
      @techpriest4787 Před 3 lety +32

      Time to rewriting everything everything in Rust again...

    • @HermanWillems
      @HermanWillems Před 3 lety +20

      People will write platform specific assembly code in C++ to optimize the code. But then it doesn't work on another hardware platform..... so it's kinda useless. X86 has alot alot of very specialized operations that can speed things up hundreds of times. But it will not work on another cpu.

    • @ShALLaX
      @ShALLaX Před 3 lety +44

      @@HermanWillems does that make it any less interesting of an exercise? It might make it even more fragmented and difficult in being able to set up appropriate CI pipelines, but I still think it’d be interesting.
      Aside from that, you could forbid dropping down to assembly if you felt that to be cheating.

  • @richskater
    @richskater Před 3 lety +106

    His HS CS class: Algorithm optimization competition with classmates
    My HS CS class: Creating seemingly never ending popup dialogs that ultimately climax with "You Suck"

    • @DavesGarage
      @DavesGarage  Před 3 lety +34

      Ha! It was a great class... but I've been in the one you describe too I think :-)

    • @krystian6470
      @krystian6470 Před 3 lety +10

      At least you had CS in HS. I had to learn it in College.

    • @richskater
      @richskater Před 3 lety +5

      It was Visual Basic. The class was called "Computer Applications 2" (Apps 1 was Excel, Access and PP). The teacher had learned that in theory every shuffle of the old card game Freecell is beatable. So she was on a mission to beat all 62,000 (or whatever it is) possible games.
      Basically we just learned from our books. We would quickly make whatever Fahrenheit to Celsius converter, or pizza topping chooser thing we had to do for class. Then we'd just screw around and do dumb stuff.

    • @markp5726
      @markp5726 Před 3 lety

      About the only thing I remember of my hs prog class is that we used 15 year old apple ][ computers. The teacher may've been good at geometry but not so much at programming. His robotics class was more interesting but he still caused people to drop the class on day 1 😣

    • @KipRoof
      @KipRoof Před 3 lety

      @@markp5726 We used Apple ]['s as well but they were brand new! And the students were still generally better at programming than the teachers.

  • @spotlight-kyd
    @spotlight-kyd Před 3 lety +250

    When writing tight loops in Python, you have to remember two things about the language:
    1. Attribute lookups and variable lookups not in the local namespace are slow.
    2. Calling functions is slow.
    Thus I was able to speed up the Python version in the repo from 39 iterations for limit 1_000_000 to ~150 iterations just by inlining the code from GetBits/ClearBits and creating a reference for this.rawbits and this.sieveSize in local variables (and by eliminating the superfluous check for index%2 in the inner loop).
    This speedup is achieved without any optimizations to the algorithm.

    • @mrroryc
      @mrroryc Před rokem +18

      Spot on - generating the function preamble is maybe 20 cycles or more (on x86 anyway)
      Also - keep loop conditions as simple as possible (check line 139 of the CPP)
      But the point of the video really is that in Python or any interpreted language - writing lazy code will cost you exponentially more execution time

    • @aouerfelli
      @aouerfelli Před rokem +1

      @@mrroryc What is lazy code?
      And, what do you mean by "exponentially"?

    • @mrroryc
      @mrroryc Před rokem +10

      @@aouerfelli hi there - when I say "lazy code", I mean, not taking the time to do things properly and obey the basic rules of good programming practice. Be nice to the compiler (or interpreter) and it will be nice to you :)
      As for "exponentially" - I was referring to the inherent overhead of Python being an interpreted language coupled with "lazy code", will make your code exponentially slower.
      The trade off here is supposed to be readability and ease of use - but it comes at a VERY large cost.

    • @mrroryc
      @mrroryc Před rokem +2

      Oh and btw - for line 139 - implementing that as a "do while" rather than a "while" and performing the calculation in the loop would give the compiler a better chance of optimizing it ....
      Which leads me to a question - what compiler optimization level were you using Dave? Could make a huge difference....

    • @bradleywhitefield
      @bradleywhitefield Před rokem

      Be weary that you may have different hardware which would impact your results.

  • @totallynotabot151
    @totallynotabot151 Před 2 lety +78

    Reminds me of a similar comparison that Google did a decade ago. It got kind of ridiculous when the Java engineers went "We can do better than 30% of C performance, we just need to hand-tune the VM and allocation settings!"

  • @luischinchilla-garcia4840
    @luischinchilla-garcia4840 Před 3 lety +657

    Incredible comparison!
    I'd also like to add how -- this man has successfully managed to write the most C++ looking script in Python 😂

    • @bluesillybeard
      @bluesillybeard Před 3 lety +72

      ikr, I was looking at that and thought "is this really python? this guy probably doesn't even know that there is a built-in function to get the length of an array!"
      Actually, while learning C++ arrays, I had to look up how to get a length of an array, and was unpleasantly surprised to find that there is no built-in way to do that.

    • @flamingmonky111
      @flamingmonky111 Před 3 lety +126

      @@bluesillybeard std::array has both size() and max_size() as well as the ability to call std::size(array). std::size also works on old style c arrays (e.g. int x[])which I assume is what you were looking at but std::size only entered the standard fairly recently (c++17). Tricky thing about c++ is there are a lot of out of date answers that say it can't do things, or has to do things in gross ways, that there are much better ways of doing it now.

    • @bluesillybeard
      @bluesillybeard Před 3 lety +12

      @@flamingmonky111 good to know, thanks!

    • @jb_lofi
      @jb_lofi Před 3 lety +9

      I looked for this comment earlier. Yes, I had to do a double take at that Python. :D

    • @pvic6959
      @pvic6959 Před 3 lety +4

      @@bluesillybeard I have to learn c++ for work. Ive mostly used java and python. im scared lol

  • @juvenal1228
    @juvenal1228 Před 3 lety +637

    The C++ STL does actually have a bit array! It is just unfortunately called std::vector. Seriously, the standard says this specialization of vector should be implemented as an array of bits!

    • @vaualbus
      @vaualbus Před 3 lety +16

      all STL is just bad if you can avoid it you better do that.

    • @SK83RJOSH
      @SK83RJOSH Před 3 lety +354

      @@vaualbus this opinion is so tired and old. I work in high performance systems, and we don't avoid the std. More often than not it's better than developing your own solutions or pulling in third party code. We have a very small selection of custom containers and algorithms and use the std mostly everywhere else. Vendors these days are pretty good at keeping things lean.

    • @KleptomaniacJames
      @KleptomaniacJames Před 3 lety +5

      I was under the impression that the bool type was one byte

    • @hbm293
      @hbm293 Před 3 lety +18

      @@KleptomaniacJames It may, or may not, be, but here @juvenal1228 wanted a bit array, not a byte array!

    • @hbm293
      @hbm293 Před 3 lety +1

      Let us then use the RtlInitializeBitMap() and friends from ntdll !

  • @ViorelMocanu
    @ViorelMocanu Před 3 lety +4

    Massive respect for the systematic and clear approach to this comparison (the experience you gathered over the years is very clearly showing in the methodology and explanation).
    Instant subscribe! Thanks for this and keep up the great work!

  • @randyscorner9434
    @randyscorner9434 Před 3 lety +182

    As a retired CPU designer, I am constantly surprised by the "discovery" that interpreted languages (even those that use a JIT) are so much slower than optimized C or even assembly. There is little appreciation for the massive overhead of many of these script-like languages. As a demonstration to convince a software developer that we could run their massive program on a $35 compute module I recoded their most critical routine in assembly (60 instructions long) and showed that their entire system ran with less than 10% of a very cheap machine rather than 40% of a Mac.
    The real nightmare, however, is the strato-layering of "packages" one on top of another instead for minimal additional functionality but a perceived decrease in design time. These chew up CPU cycles in massive overhead damaging the responsiveness and size of the code generated. As CS schools have stopped teaching even the rudiments of computer architecture this is not likely to change. Great for CPU producers, but a massive waste in time, power, and cost.

    • @albertmagician8613
      @albertmagician8613 Před 3 lety +4

      @randy You discovered the secret of Forth. Forth allows easy replacement of a single bottle neck.

    • @randyscorner9434
      @randyscorner9434 Před 3 lety +10

      @@albertmagician8613 Yeah, but I could not force myself to always work off a stack.... RPN on an HP calculator was great but for general purpose programming?!?
      I think it would be a great video to show how to profile some code and optimize the slowest pieces for better performance. That's effectively what I ended up doing and it makes a huge difference for any sort of interactive code, such as CAD tools.

    • @Theineluctable_SOME_CANT
      @Theineluctable_SOME_CANT Před 2 lety +4

      Yes. It's a revolting waste...

    • @nonconsensualopinion
      @nonconsensualopinion Před 2 lety +11

      Why do you think CS programs have stopped teaching such things? I graduated relatively recently and my average rated US school required two courses on embedded design, one on assembly language, and one computer design which focused on the specifics of logic gates, ALUs, etc. I suspect you're trying to strengthen your position by creating a strawman argument. I think at best you could demonstrate that the worst programs don't teach these things but that was likely always true.

    • @randyscorner9434
      @randyscorner9434 Před 2 lety +19

      @@nonconsensualopinion I have no need of a strawman as I'm not arguing, but stating an observation. Some programs do indeed require traditional logic and some architecture classes, but increasingly those are being phased out as more emphasis is placed on web programming and large variety of dialects available for layering systems. I could give a list of such programs but it's not my point. Deep layering and package-based design are making systems increasingly inefficient. The good news is that I think we're headed for more actions like the one I stated in my original post, but slowly. I also think it's a massive opportunity as server and system costs can be reduced through breaking down software layers.

  • @JuanManuelCuchilloRodriguez
    @JuanManuelCuchilloRodriguez Před 3 lety +294

    Although there were no surprises, it is a great video. Many Python programmers knows that the best way to achieve performance in Python is not using Python. This means that you should do most of the computation calling C optimized libraries like numpy, tensorflow, sklearn.

    • @retrolabo
      @retrolabo Před 3 lety +45

      But those are still python IMHO. The power of python is to be a glue language like that!

    • @nguyentranminhquang2861
      @nguyentranminhquang2861 Před 3 lety +41

      @@retrolabo yes it still python but C/C++ will do the heavy work for it, python just need a wrapper to call them, and most of language can make a wrapper to call to C/C++ function

    • @retrolabo
      @retrolabo Před 3 lety +25

      @@nguyentranminhquang2861 yes this is what I mean by glue language. This is a strange distinction: think about it "print" in python is written in C in the interpreter, does this make the print function not python? :)

    • @BrunodeSouzaLino
      @BrunodeSouzaLino Před 3 lety +9

      Using numpy or pandas to implement a sieve is the equivalent of robbing a bank with an atom bomb.

    • @retrolabo
      @retrolabo Před 3 lety +23

      @@BrunodeSouzaLino you need to win a race, whatever it takes lol... wait a minute who said we cannot use a GPU for that? :P

  • @malgailany
    @malgailany Před 3 lety +5

    I rarely see well-executed language comparisons. I love these performance/comparison types of videos.
    I really enjoyed it, thank you!

  • @s3rth30
    @s3rth30 Před 2 lety +18

    I noticed in his comments that Dave's reasoning for using std:out was to avoid printing new lines with Python's build in print function, but there's actually an easier way to do it.
    When calling the print function you can customize the endline character by using, well, endline="whatever you want as endline" as a parameter.
    That way, your endline character could be a comma followed by a space, or whatever else you needed.
    Other than that small tidbit which I came across by chance, awesome job as always Dave.

  • @pihi42
    @pihi42 Před rokem +28

    There are optimizsations you can do even on assembly level. Like using fancy vector instructions and such. I once optimized a piece of C++ code with some embedded assembly instructions to gain 10x performance just using MMX on a Pentium chip. Usually the hard part is identifying which 0.1% of code really needs to be optimized.

    • @dale116dot7
      @dale116dot7 Před rokem +5

      I’ve had one embedded application that needed to be 100% rewritten in assembly language. The compiled C code was about six times as large as the assembly language version, and the assembly language version used all but 15 bytes of 60k of flash memory. No larger memory versions of the processor were available. The C code was not anywhere close to fitting in the given processor. I think it took me about a month and a half to write the whole application in assembly.

    • @obinator9065
      @obinator9065 Před 3 měsíci

      All the major C++ compilers vectorise if optimisation is turned on.

  • @ian.e.mccormick
    @ian.e.mccormick Před 3 lety +228

    Best original Content on CZcams right now. Killing the Game Dave!!!

    • @DavesGarage
      @DavesGarage  Před 3 lety +38

      Thanks! Tell a friend! :-)

    • @bobDotJS
      @bobDotJS Před 3 lety +14

      @@DavesGarage my buddy Ian McCormick just called me and told me I had to check out this video.
      Very cool but maybe we can throw Golang and/or Rust into the mix. I'm incredibly interested to know what an OG C engineer thinks of Go vs Rust (vs C and/or C++)

    • @trevc63
      @trevc63 Před 3 lety

      Agreed!

  • @thomasersosi4595
    @thomasersosi4595 Před 3 lety +54

    This line here: `for (int num = factor * 3; num

    • @geoffstrickler
      @geoffstrickler Před 2 lety +5

      That can make a significant difference on the larger tests. Take for example, factor =709. Using factor * 3 means you’ll start at 2,127, while factor ^2 will start at 494,209, removing 353 unnecessary calls to test/clear that bit from that innermost loop. And that’s testing just one of 168 prime factors less than 1,000 (which is what would be used looking for primes less than 1M). The amount of unnecessary loops skipped by his change scales exponentially with the upper limit of primes you’re looking for.
      This will be almost unmeasurable on the smaller tests. Such as primes up to 10,000.

    • @jackgerberuae
      @jackgerberuae Před 2 lety

      Note this

    • @mikrosom
      @mikrosom Před 2 lety +2

      Additionally, above factor = 3, you can instead of 'for(int num=factor; num < sieveSize; num++)' write 'num += 6', and have two if-statements, one for "getBit(num - 1)" and second for "getBit(num + 1)", since all primes except 2 & 3 can be written as "p = 6k +- 1"

  • @pismith1
    @pismith1 Před 3 lety +7

    As someone who gets pumped following along to a free code academy tutorial video for Python. I am awe struck by this persons career and his ability to explain it to someone like myself. Keep rocking it!

  • @AirZeee
    @AirZeee Před 3 lety +25

    Beyond the "Hello World" program in C64 basic 30+ years ago, I'm not a coder. So it's a testament to your presentation style that I can more or less follow what you're doing, and enjoy watching the show. Keep it up!

    • @antaniserse
      @antaniserse Před 2 lety +2

      I would hope your C64 version of Hello World was the evergreen:
      10 PRINT "HELLO WORD"
      20 GOTO 10
      RUN
      ;)

    • @bjbell52
      @bjbell52 Před rokem

      I started out with Atari Basic. It actually wasn't an interpreted language but would compile to P-Code when a line was entered and when run, it ran the P-Code with a software engine.

  • @charlesbaldo
    @charlesbaldo Před 3 lety +24

    We are about same age, i have enjoyed many of your videos because the products were so important in my career. Its good to put a human face on the digital world and see a programmer who worked on the product.

  • @ErrorCode67
    @ErrorCode67 Před 3 lety +593

    Would love to see them run on the M1 and ARM on a Pi4

    • @amciaapple1654
      @amciaapple1654 Před 3 lety +2

      Mee too.

    • @electricketchup
      @electricketchup Před 3 lety +6

      Would also love to see them run on Sparc 64 and MIPS

    • @WarrenGarabrandt
      @WarrenGarabrandt Před 3 lety +14

      Oh, I didn't even think of the raspberry PI. If Dave needs one, I can send him a PI to have so he can do this test. I have a few laying around.

    • @space_0027
      @space_0027 Před 3 lety

      Me too

    • @DavesGarage
      @DavesGarage  Před 3 lety +151

      Cool, I will add for the Pi3 and Pi4 if I get a moment!

  • @dc9662
    @dc9662 Před rokem

    This was wild, and mind blowing. I correctly guessed the order, but the speed of the code is what really floored me. Thanks for the demo, walking us through it briefly, and for displaying the code as well.

  • @KadeDev
    @KadeDev Před 3 lety

    this is such a sick video. I love this channel now, its so cool to get these comparisons.

  • @BertLaverman
    @BertLaverman Před 3 lety +5

    Thank you for taking me back to the Commodore Pet. Our highschool didn’t have any computers when I started, but in the 4th year they started showing up in shops, and I was one of the “regulars” using the demo model. Eventually a TRS-80 model 1 was bought to help staff plan classes, (Dutch schooling allows you to select a subset of classes for 4th to 6th year, so they have to juggle schedules to ensure optimal planning.) I was then the “gang-leader” of those allowed to use it for the rest of the year. Exciting times.

  • @prezpolk4ever
    @prezpolk4ever Před 3 lety +14

    Thank you for that Simpsons reference. I’ve literally been doing that voice for 20 some odd years!

  • @gc1418
    @gc1418 Před 5 měsíci

    This was awesome. Thanks for the explanation. It's interesting to see how far we've come. I started on TRS-80 basic.

  • @SriHarshaChilakapati
    @SriHarshaChilakapati Před 2 lety +1

    This is so awesome sir! I really really wonder how come I didn't find your channel so far!

  • @larryseyer
    @larryseyer Před rokem +3

    I LOVE your channel. I learn so much by watching you. Thank you!

  • @mollybjork5499
    @mollybjork5499 Před 3 lety +127

    The first 30 seconds of this earned you a subscription

  • @MarkWitucke
    @MarkWitucke Před 5 měsíci

    Very cool, Dave. Thanks for the great content. It strikes a nice balance between educational and entertaining. Beauty

  • @mirozen_
    @mirozen_ Před rokem +1

    Nice to see good stuff from another former Blue Badge!!! Just found your channel and I'm enjoying your stuff! 😊👍

  • @phelpsio
    @phelpsio Před 3 lety +8

    These programming videos have been some of my favorites you've done! Please do the M1!

  • @paulchoudhury2573
    @paulchoudhury2573 Před 2 lety

    Excellent treatment of this topic. The only suggested follow up I would have is some discussion of why 64 bit turns out to be much faster than 32 bit and if the C# implementation uses 64 bit "under the hood". Keep them coming Dave, you've got a new fan!

  • @PixelsWorkshopVideos
    @PixelsWorkshopVideos Před 2 lety +1

    I loved your charismatic way of explaining the technical details. I was able to pull out a little bit more efficient (codewise) Python version while using the same algorithm you taught us, but still, the performance gap is astounding, I read there are many people here in the comment section sharing their viewpoint about a better Python implementation as if Dave was trying to undervalue Python, remember, this is a kind of "syntetic test" and depending on the Context it might be more reasonable to use one or the other of the languages.

  • @netux
    @netux Před 3 lety +13

    Since you asked, here some things about your Python code that I haven't seen commented here yet:
    • print() has a keyword argument for specifying the character(s) added to the end of the line, so for example you can do print("Hello, world", end="") to avoid printing
    at the end of the line.
    • From what I've seen, its convention to use all-lowercase snake_case for variables and function names, and CamelCase for class names (though the stdlib doesn't always respect that)
    • You don't need the parentheses on your if statements

    • @n-steam
      @n-steam Před 3 lety +5

      tbf naming conventions aren't language specific, they're programmer specific.

  • @algorithminc.8850
    @algorithminc.8850 Před 3 lety +9

    Really great channel and video - and fun presentation. And a fair language comparison, I'd say. We've been developing in straight C since the late 80's ... and have "secure/portable" libraries for just about everything. The modern compilers are amazing at yielding reasonable machine code (no need to spend so much time on assembly, aside for maybe some hardware specialties). We wrap our C with whatever language does the job for the client or product development. Some of those higher-level languages might be useful these days for people learning how coding works ... kind of like assembly language and BASIC may have been for us. So great finding your channel ... subscribed and telling friends ... cheers ...

  • @bassbatterer
    @bassbatterer Před 3 lety

    Nice video, that story at the beginning really rung brought back some memories.

  • @becomingmagic6047
    @becomingmagic6047 Před 2 lety +1

    First time I've ever subscribed to a channel after just one video. This was great!

  • @v300
    @v300 Před 3 lety +11

    In C++ you have the bitset class and can create a bitset of 1 million bits. And the other even faster method and more memory efficient is to create a vector.
    C++ is king.

    • @jplflyer
      @jplflyer Před 2 lety

      Wouldn't the vector allocate a byte per boolean? So that's not memory efficient, which was one of his criteria.

    • @DrunkenUFOPilot
      @DrunkenUFOPilot Před 2 lety

      @@jplflyer Nope. STL defines a special case just for vector. Sometimes you really want a vector of actual bool type values, whether that's a byte or the same size as int, but good luck defining it due to this special case. What if you want to define a reference to some Nth bool in a vector? There is no reference to a bit in C++.

  • @SpinStar1956
    @SpinStar1956 Před 3 lety +10

    The 64-bit result is shocking; I'd of never thought you'd get that much of a delta over 32-bit!

    • @MI08SK
      @MI08SK Před 9 měsíci +1

      64-bit supports some game changing new instructions witch can be used to optimise a program

    • @arithex
      @arithex Před 8 měsíci +1

      The x64 calling convention is much simpler .. first few args are passed in registers, akin to __fastcall in MS VC++. And there are a lot more registers, which means less juggling values to/from the stack frame, and it also allows for more aggressive function-inlining by the compiler.
      Also also, compiling for x64 is like an implicit hint to the compiler, "this is a modern CPU so you can use all the new SSE etc instructions.. don't have to worry about compat with a 20 year old Pentium"

  • @AtlantaTerry
    @AtlantaTerry Před 2 lety

    Dave, very nice production values: camera, lighting and sound.

  • @GamingStepByStep
    @GamingStepByStep Před 2 lety +9

    And here I struggled with iterative loops and abstract classes within my 6 months C# crash course learning lol, the amount of knowledge you must posses is truly astonishing.

  • @FabioRossiniSluzala
    @FabioRossiniSluzala Před 2 lety +4

    std::vector is size optimized for something like a "dynamic bitset"

  • @jamesross1003
    @jamesross1003 Před 3 lety +3

    Respect, that's all I can say other than I am impressed. I also am very happy, C++ has been my go to language for a long time. Keep these videos coming. The prime number program was one that we were required to code in my algorithms college course, also one that I found difficult was a program to estimate pi to a given decimal place(this was user defined at runtime). Ugh, we were forced to write that one in of all languages basic. Yes the professor would allow only basic for that one. I had a sadistic algorithms professor I suppose. He allowed me to use C for the prime number program though so can't complain too much. Love the video and will be watching your others in the future.

  • @bluehornet6752
    @bluehornet6752 Před 3 lety +1

    Awesome video, eh. Loved it--definitely a new subscriber here. Thanks for your efforts Dave!

  • @Taras195
    @Taras195 Před 3 lety

    I just stumbled upon your video, and subbed! Great explaination and interesting stories!

  • @HexenzirkelZuluhed
    @HexenzirkelZuluhed Před 3 lety +197

    Python is "compiled" into bytecode too (usually saved as .pyc files), but the bytecode interpreter is really just that. So no overhead for parsing, but no optimizations either, that's why it's slow when doing compurational intensive tasks (for which often times you just use optimized packaged/libraries). There are versions of python that jit this bytecode to increase raw performance, e.g. pypy.
    Running on my old laptop, I get 42 Passes from your Python Program when run in CPython (what most people use as "Python"). Simply switching the Interpreter to pypy I get 561 Passes from the exact same source file.

    • @mihiguy
      @mihiguy Před 3 lety +13

      Another reason why Python code is slower than C code is dynamic typing. Even when JIT compiling, the compiler needs to add checks that the types of the variables are still what the JIT compiler believes them to be. Same for array bounds checks.

    • @TurboXray
      @TurboXray Před 3 lety +14

      That's not what "compiled" means. That's simply syntax tokenized reduction. It's been around since the days of BASIC.

    • @knowlen
      @knowlen Před 3 lety +3

      ​@@mihiguy That's interesting. It seems when we re-write the Python code can be statically typed (eg; compilers like Cython, Numba, ect... all implement their own type systems) it would remove all that.

    • @mihiguy
      @mihiguy Před 3 lety +1

      @@knowlen For JavaScript, that is what asm.js is doing. Expect a restricted, strongly typed subset of JavaScript and compile directly to machine code. However, this has mostly been obsoleted by WebAssembly.

    • @malcolmxparis7158
      @malcolmxparis7158 Před 3 lety +6

      Python is just the "Flavor-of-month" at one time it was Javascript. C++ is closer to the "metal" and you have a dozens of toolkits for optimization.

  • @xamtheone
    @xamtheone Před 3 lety +45

    I like benchmarks too. I converted the C# version to PHP.
    CPU: i7-2600k
    - 5sec of iterations
    Python 3.8.5: 23 passes
    PHP v7.4.3: 50 passes
    C# .NETCore 3.1 compiled with VS 2019: 1623 passes

  • @mic9657
    @mic9657 Před rokem

    top notch and super easy to follow video. helped me a lot

  • @UNIVLOCATEFUN
    @UNIVLOCATEFUN Před 2 lety

    Excellent video, keep it up. Intend to watch you a lot going forward.

  • @michaelmoltke911
    @michaelmoltke911 Před 3 lety +18

    Omg... This is going to be soooo awesome 😎.
    I already decided my religious and no changeable attitude towards all these platforms, but damn it'll be fun to either be right or rectified :p
    More content like this... It's getting really geeky 👾

  • @chairmakerPete
    @chairmakerPete Před 3 lety +10

    Wow! Loving C# more every day!
    Just looking at Python for a project using Raspberry Pi, and have to say, it's a dog. I'm about the same age as the presenter, so his language experience really resonated with me.
    Great video! Wish I could up-vote more than once. Thanks! 👍👏👏👏

    • @alanmusicman3385
      @alanmusicman3385 Před rokem +1

      For ex-BASIC coders like myself C# is an ideal halfway house to C++. Learn C# and learn Powershell and you can address most programmic needs. Never as fast as C++ of course, but a lot less cryptic and most times it catches you when you fall and gives you a decent diagonistic message.

  • @xpwn3rx
    @xpwn3rx Před 10 měsíci +1

    Dave, your breakdown of how some of this works is very interesting to me. I'm a Server and Storage Architect and team manager, and I have a BS is Computer Information Systems. By the time I was learning in the mid to late 00's, they didn't teach about bitarrays or any of the way the assembly works, we just learned OO languages like Java, C#, J#, and of course I've done some python dabbling since. I prefer C# but getting a peak behind the covers from someone who understands the assembly behind the scenes was interesting.

  • @aaronfulkerson1151
    @aaronfulkerson1151 Před 3 lety

    My coworkers and I are very interested in seeing this same benchmark on an M1 and also with Node since you included PHP in your repo. Great video!

  • @surferdude4487
    @surferdude4487 Před 2 lety +5

    Believe it or not, I wrote a prime number generator in dBase IV. It saved the prime numbers in the database. When I packed up at the end of the day, I left it running on the IBM AT overnight. Since the prime numbers were in a database, it could pick up where it left off the previous morning. The database was handy for factoring huge numbers.

  • @isodoubIet
    @isodoubIet Před rokem +3

    Some comments on the Cpp version:
    1. There's a native bit array, it's just called "std::vector". It's slightly horrible that it's a specialization of vector, but it does work and does what you expect.
    2. The std::chrono default aliases (seconds, milliseconds etc) are all specified with integers as the base type, for compile-time safety. If you want fractional time amounts, you can define your own alias, e.g.
    using dseconds = std::chrono::duration;
    And now you can duration_cast to that, without having to fiddle with getting it in microseconds and then multiplying by a million to get more resolution.

  • @LostInThe0zone
    @LostInThe0zone Před 2 lety +1

    It's been years since I have written code, but having cut my teeth on c, I was curious. Your experiment did not disappoint.
    Recently, I have been playing with arm, so when you mentioned the M1, it peeked my interest.
    If you run it, I will watch.

  • @walterjohnston794
    @walterjohnston794 Před rokem +2

    Enjoyed the story. I took some time to work on an implementation in R and got some pretty good performance out of it. Major take-away: understanding what is REALLY going on in a programming language can allow us to write clean code. As I tell my Grad students: first get it RIGHT, then make it BETTER.

  • @makkam7575
    @makkam7575 Před 3 lety +6

    Amazing video. Btw would highly recommend taking a look at other python interpreters like pypy, to librarires like numba, or to cython. The last two options will impact the flexibility that made me love python but the results are totally worth it. Especially cython.

  • @Richardincancale
    @Richardincancale Před 3 lety +7

    Sometimes compilers and interpreters are surprising! I wrote a Monte Carlo simulation in VBA under Excel, coded as creating and destroying objects for each simulated item. Then recoded it to do all the memory allocation. and deallocation on a static array and it ran at near enough exactly the same speed! That OO stuff was implemented well!

    • @stke1982
      @stke1982 Před 3 lety +1

      or the other stuff really bad.
      main mistake was using vba and excel ;)

    • @Richardincancale
      @Richardincancale Před 3 lety

      @@stke1982 Well sometimes you have to do what the client wants! I’ve written MC simulations in a variety of languages from Fortran IV onwards! My point was that the hand crafted stack operation version was indistinguishable in performance from the OO version - to my surprise.

  • @zuruumi9849
    @zuruumi9849 Před 2 lety +2

    In C++ there is std::vector which actually is implemented as 1 bit per element, though it likely would be slower.

  • @saschacontes2305
    @saschacontes2305 Před 3 lety +1

    You look like the Chuck Norris of coders. I am even more amazed by you clear and understandable explanation than by the performance differencess. Would have been interesting to see the java and java script performance - just to finally end all those performance discussions.

  • @JannisAdmek
    @JannisAdmek Před 3 lety +7

    Implementing that same prime number generator in a new language is a fantastic idea, I'll try out something similar next time!

    • @derkeksinator17
      @derkeksinator17 Před 3 lety +1

      someone do a java2k version please!

    • @JannisAdmek
      @JannisAdmek Před 3 lety

      @@derkeksinator17 omg ok, I'll put it on github should I succeed, but that's rough

    • @pantoqwerty
      @pantoqwerty Před 3 lety

      @@JannisAdmek Has anyone tried it in Rust? Seems to be the language everyone wants to talk about these days. Be interesting to see what, if any, hit there is. Also be more interested in time for n cycles rather than cycles in t time.

  • @MultiTsunamiX
    @MultiTsunamiX Před 3 lety +10

    For python, what I managed to catch: self instead of this, index//2 instead of int(index/2), use if __name__ == '__main__' for mains, so in case you import the code elsewhere it doesn't run the main, you do not need to retype something as a string in a print, also prettier way is to use f strings, you can use **.5 instead of sqrt, but this is more optional, than previous tips. Also for the sieve, you can actually start with square multiple, instead of 3rd multiple. That was all I caught, happy coding

    • @whybother987
      @whybother987 Před 3 lety +3

      f strings are not only prettier but also faster, since they don't require an expensive function call

    • @pjkirkham
      @pjkirkham Před 3 lety +1

      There are also a number of loops that could be optimized.
      Generally speaking, in Python for-loops are faster than while-loops, and often more so, list comprehensions are even faster than for-loops. In code like this with possibly many iterations you can often see a very significant performance (and sometimes memory usage) improvement when switching to list comprehensions. Plus when you are used to using them list comprehensions are often more readable.
      You can go even further with the functools module and using "pure" functions that avoid side-effects (save calls to print or log to places outside the pure functions). This approach can lead to much more readable and succinct code.

    • @MultiTsunamiX
      @MultiTsunamiX Před 3 lety

      @@pjkirkham yeah. I saw some of those but since i did not had the code, I didnt want to tell him about it. But you Are correct

  • @PierreThierryKPH
    @PierreThierryKPH Před 2 lety

    I was hooked by Pascal's wager at the end. I subscribed. :-)

  • @muninnsmith7958
    @muninnsmith7958 Před 3 lety +1

    I've never heard of you before now. That intro was legendary. I'm building a breadboard computer this year.

    • @DavesGarage
      @DavesGarage  Před 3 lety +2

      I've never heard of you either, but I'd be interested in hearing more about the breadboard computer, what kind, what CPU, etc!

    • @muninnsmith7958
      @muninnsmith7958 Před 3 lety

      @@DavesGarage I'm not entirely sure. 🤔 I was inspired by Ben Eater. I'll keep you updated.

  • @TBaguette
    @TBaguette Před 3 lety +58

    As a little advice : to compare a value with either 'True' or 'False', use 'is' instead of '=='. Python will compare the objects' id directly and it's the most optimized way to do it.

    • @philipmunch3547
      @philipmunch3547 Před 3 lety +17

      Better yet, don‘t compare with True or False altogether, i.e.:
      if this.getBit(num):
      pass

    • @deadeye1982a
      @deadeye1982a Před 3 lety +14

      @@anonanon3066 Python is a real language.

    • @Xenthera
      @Xenthera Před 3 lety +19

      @@anonanon3066 that makes you sound like you're not a real programmer

    • @TBaguette
      @TBaguette Před 3 lety

      @@philipmunch3547 I agree, this is even better, but I have not coded in Python for a long time, I've been more into Rust recently.

    • @GothAlice
      @GothAlice Před 3 lety +2

      Yup, do not do this. Never compare against True or False using is, unless there are other "truthy" or "falsy" values that are anticipated, e.g. use of None as a placeholder, canary, or NULL equivalent. Identity comparisons may seem to operate the way you expect (True and False being literal singletons in CPython), however other situations will be far stranger. 27 is 27 → True. Some larger numbers that end up not being interred will not have this identity match, a similar problem with using this to compare strings for equality.
      Philip Münch has it right. Just use the "if" statement itself as the mechanism of casting and boolean comparison. The right tool for the job. Combined with "exit early" patterns, my special case of using None should be accounted for first, then the remainder of the function exited from if needed, so that the subsequent truthy or falsy comparison doesn't worry about None at all.
      In JS there is the paradigm of double-inversion to cast to a boolean, e.g. !!foo, Python simply does not have this silly need.

  • @tompov227
    @tompov227 Před 3 lety +7

    honestly I really enjoyed this comparison. It was so in-depth and fun and I really liked the anectode. Also, Dave's diction and oration skills are so good, like ??? the way he speaks is so engrossing
    **BIG shoutout to Dave's python code using this instead of self. If Guido didn't want us using the **correct** keyword for the current instance, he should not have made it customizable**

  • @henny022
    @henny022 Před 3 lety

    In C++ there is vector which depending on your standard library implementation is optimized for using a bitarray and takes a size at runtime.
    also a runtime comparrison between bit arrays and byte arrays might be interesting

  • @tomashcraft
    @tomashcraft Před 3 lety +1

    Thank you for showing me a baseline - how does a really passionate programmer are look like. Huge difference from many other CZcams participants. No society related talks. Just the code and figuring out things using code.

  • @casperhansen826
    @casperhansen826 Před 3 lety +6

    I created a similar program using assembly language on a ZX Spectrum with 48 kB of memory to see how fast it could fill the memory (up to about 260000), I was surprised it only took a few seconds. Note that this was almost 40 years ago!

    • @lennutrajektoor
      @lennutrajektoor Před 3 lety

      ROFL. Isane! Insane how much compute resource is getting wasted.

  • @advanceringnewholder
    @advanceringnewholder Před 3 lety +28

    Basically me watching this channel: i like your funny word, magic man

  • @kamurashev
    @kamurashev Před 3 lety +1

    If only I could be such an expert... I'm just blown away. With coding each time I stop and think I'm somewhat not bad at it, then each and every time it is happening, I see someone who makes me feel like I know nothing...

  • @El.Duder-ino
    @El.Duder-ino Před 2 lety

    Wow, thank you for making this comparison - even I am not a programmer I really do enjoy understanding why code performs better in comparison to other language... but I do agree, if you get lowest you can get and optimize it to the limit, its the best you can achieve.

  • @urikaufman4258
    @urikaufman4258 Před 3 lety +9

    You can probably speed up the Python code Cythoning some of it (Cython is still Python, well... Sort of...). Great video and excellent test!

  • @hypernautic
    @hypernautic Před 3 lety +33

    Yep very interested to see it tested on other chips, especially the M1. Now I'm curious about how Rust will perform as well as something functional like F#

    • @HermanWillems
      @HermanWillems Před 3 lety

      In Rust we will then write a module that will call special cpu specific optimalisations and beat F# the fuck out of the water. That's what's so nice about system programming languages. They can go deep into the cpu while bytecode languages cannot do that so easily.

  •  Před 3 lety

    This is very entertaining; you're doing this at exactly the pace I prefer. Looking forward to the follow up of this with more languages.

  • @ChariotduNord
    @ChariotduNord Před 3 lety +2

    What a cool comparison! I learned something too. I recently started learning Julia, so I copied the program more or less to test the advertised speed of Julia. For 1 million upper limit, I got 4228 passes in 10 seconds, an average of 2.3 milliseconds. I was quite astonished! This is comparable to C# and C++.

  • @mdelorme123
    @mdelorme123 Před 2 lety +3

    Hey Dave, love the videos keep doing them. I was wondering if you have thought of making a discord server for your community at all since I would love to be able to find more discord servers to discuss coding and help new people learn to code and you channel seems to suit that. Much love from your fellow Sask resident

  • @LukeAvedon
    @LukeAvedon Před 3 lety +4

    This is such a great channel.

  • @5cover
    @5cover Před 3 lety

    Very interesting vidéo as always!

  • @TheGadusi
    @TheGadusi Před 3 lety

    Love your presentations.

  • @tomwalker996
    @tomwalker996 Před rokem +8

    Great video! Just want to point out that most python devs wouldn’t try to do something like that in native python. We’d either use a library like numpy or build one in c. Python is really more of a scripting language, I use it to call other bits of code in a readable sort of way. Once you learn/build the main packages that are relevant to your job, it’s crazy how fast you can push out code, which might not be 100% as fast as C, but it’s fast enough and very easy to maintain.

    • @MoodyG
      @MoodyG Před rokem

      fast enough is kind of relative, isn't it ? I mean, his code ran close to ten thousand times faster in C++/64 compared to Python 😂
      I remember writing a small snippet of code a few weeks back just to count from 1 to a billion I think on C, Python, VB, and MATLAB, and I remember the code was much, much slower in Python than C, though not that much slower if memory serves.

    • @tomwalker996
      @tomwalker996 Před rokem +1

      @@MoodyG That's the thing. In real life there would never be a requirement to "count to 1 billion". But I would create a dataframe in Pandas that contained the positive integers from 1 to 1 x 10^9. If you're doing that kind of thing in native Python, you're doing it wrong.

    • @MoodyG
      @MoodyG Před rokem

      @@tomwalker996 I think you totally missed the point. Of course you wouldn't wanna count to a billion in real life. It just serves as a simple example to illustrate the comparative difference in speed between different languages. Counting up to a billion is way, way more trivial a task than what you'd actually wanna do in real life. An actual useful code for some real-life application may very well end up eating through computations many orders of magnitude more than a billion primitive addition operations.

  • @scottmilano2940
    @scottmilano2940 Před 3 lety +41

    Would be interesting to do this with C and gcc as well and see if the compiler makes a huge difference between. Also keeping track of the results as a bitmap is a great space savings, but is it really a time saving? With a modern system you could store everything in a byte array, or even an integer array.

    • @tomwilson2112
      @tomwilson2112 Před 2 lety +1

      Yeah, the bitmap seems like a downgrade. On the 64-bit compiler, an int64 is probably the fastest array type (I'm guessing.)
      However, the point is to establish relative performance between different platforms, so perhaps super-optimization is less important than using the same code on multiple machines. Actually, come to think of it, that's the best possible reason to skip the bitmap array, since some platforms may have trouble with it.

    • @tiagodagostini
      @tiagodagostini Před rokem +5

      Space saving helps speed in modern CPUS because it increases cache coehrence.

  • @alk99875
    @alk99875 Před 3 lety

    just saw 1 minute but you are good man, well done, keep up

  • @che1602
    @che1602 Před 2 lety

    Oh my, I love the style. Should’ve checked you out long ago. Instant sub!

  • @trevthea5781
    @trevthea5781 Před 3 lety +4

    From Australia, keep these coming.

  • @johnmckown1267
    @johnmckown1267 Před 2 lety +4

    I really like your pointing out that the algorithm can greatly affect the run time. Back in the 8080 days, I had a TRS-80 computer. Basically a 1Mhz Z-80 chip. I wrote a poor algorithm in assembler and a smart one in interpreted BASIC. The BASIC code ran faster.
    I don't code much anymore. I'm pretty much maintaining an obsolete system, which will be retired soon, followed by me. Now, I mainly game on a console. I can feel my brain rotting.

  • @tshandy1
    @tshandy1 Před 2 lety

    This was an excellent video, and you are fantastic teacher. I use C# in my daily job, and for what we are doing, its performance is acceptable. But the capabilities of C++, as you have demonstrated, are amazing.

  • @zaphodbeebs961
    @zaphodbeebs961 Před 2 měsíci

    Great video. Very instructional. Thank you.

  • @Infrared73
    @Infrared73 Před 3 lety +161

    Yes, please do the M1 Mac!

  • @LanceMcCarthy
    @LanceMcCarthy Před 3 lety +61

    As a junior dev, I said 'C# all the things' . As a senior dev, I said 'the right tool for the job'. As a Principal engineer, I now say 'please let me use C# for this job 😊'.

    • @DavesGarage
      @DavesGarage  Před 3 lety +15

      Pretty much :-)

    • @ThatOneWeeb420
      @ThatOneWeeb420 Před 3 lety

    • @dsuess
      @dsuess Před 3 lety +1

      Same here.. exploring/jr. dev me was, vb3-vb6 (kinda the same thing)...
      crap, im getting old

    • @todortodorov940
      @todortodorov940 Před 3 lety +4

      All 3 statements are correct, as even knowing that C# executes slightly slower, it is performant enough and most importantly, it is very productive language (ecosystem), which makes it the 'right tool for almost any job'.

    • @judgewest2000
      @judgewest2000 Před 3 lety +2

      C# forever (i'm 41 now so only need another 19 years, then I'm retiring)

  • @TurpInTexas
    @TurpInTexas Před 2 lety +1

    Cool! I got into coding on programmable calculators (TI-57). A buddy and I would compete to see who could write the same projects within the limited memory constraints of the calculator, and with the least number of steps. It was a great way to learn by trying different methods of coding to reduce the step count. Later I went on to become a telecommunications engineer and he went on to become a hard core programmer from assembly up. He would write code, then compile and link, in different languages, and benchmark sections of each by counting clock cycles, and would often rewrite the problem parts in assembly code to speed things up (he specialized in optimizing video drivers). These days I design and build test systems that have to communicate with other equipment that have different response characteristics so to help optimize the code I put timer marks that I can turn off and on at startup that help me find the bottlenecks. It would seem this is a lot of work for a little slice of time but since the code runs thousands and thousands of time every day, those little slices add up to a lot of time by the end of a year worth of testing. That said, your Software Drag Race video should be the poster child of software development for anybody running code in a high volume production environment. Thank you sir!

  • @PR-fk5yb
    @PR-fk5yb Před 2 lety

    Thanks for this video. Just to let you know that in 1982 (Or so...) Byte Magazine (John C. Dvorak and the late Jerry Pournelle) was running the sieves troughout different platforms in order to benchmark them...

  • @ChumX100
    @ChumX100 Před 2 lety +4

    Using Python's abstractions tends to be faster than trying more low-level optimizations. That's because for many of these Python is able to optimize stuff using lower level tools that are not accessible to the user, like C bindings. JS also performs quite a lot of optimizations at the engine level. If you could somehow implement the sieve using numeric methods, you could use something like Numpy and you'd be essentially running C behind the scenes.

  • @Milosz_Ostrow
    @Milosz_Ostrow Před 3 lety +10

    When I got started in computing, the "drag race" would have been Assembler vs. FORTRAN vs. interpreted HP BASIC. For a one-off problem, BASIC was usually the correct choice, because the program could be written, debugged and would have solved the problem at hand before the other two had been debugged, even though it executed at an order of magnitude slower speed than the other two choices.
    In the real world of engineering as a profession, one's employer doesn't care how elegant the solution is. All they care about is how quickly you can produce the correct result with the tools at hand, and the total time to the solution includes how long it takes to set up the tools.

    • @reinerfranke5436
      @reinerfranke5436 Před 3 lety

      That's why most engineering coding is in Matlab with a mature 20y JIT compiler. Crosscheckin the codegen C results within the Matlab enviroment is the key.

  • @Whatthetrash
    @Whatthetrash Před 2 lety

    Fantastic episode! ^_^

  • @joedeshon
    @joedeshon Před 2 lety

    8:18 The PET was one of the first computers I ever programmed on -- it's still a sentimental favorite. I remember that it took almost a minute to complete a bubble sort of about 150 items. We were impressed and satisfied that was as good as it was ever going to be for a home computer.

  • @bjbell52
    @bjbell52 Před 3 lety +6

    You should have tried Delphi (or the free Lazarus). I worked at a large bank and tried to get someone to look at Delphi but nobody did. We were a Window's shop. I was hired to rewrite their Paradox for DOS system but I tried to convince them how good Delphi was. Finally they decided after one of our best programmers had calculated he could write a trading application in VB in one year after we got a new department head who believed in free software and chose Java instead. It was way too slow and after 2 years his final work was rejected totally (and he had a 6 figure salary). I tried many times to explain that we were a Window's shop and should use Windows development tools but they fell on deaf ears. Our new boss decided to write everything else in PERL. Goodbye Windows' GUI. Finally the good programmer convinced them to try C# and in our meeting I was told not to mention Delphi again because C# had so many great features. I fought off the urge to scream and explained to them that C# was Delphi with a C syntax that was designed and programmed by the same people who wrote Delphi and Delphi had all those great features many many years earlier. It didn't matter, the company went out of business a little later on.

    • @michaelai8274
      @michaelai8274 Před rokem

      How good it is to have a view of start to finish of this situation. I guess this must have went back and forth for a couple, let me say about 3 years, I wished they had given you a chance, and tried out Delphi, lol.
      But then, life goes on.

    • @normanrichwood620
      @normanrichwood620 Před rokem

      Why look at half-dead technology. What could be the reason for this.

  • @spotandjake1008
    @spotandjake1008 Před 3 lety +76

    You should add golang and rust into the mix

    • @mdr721
      @mdr721 Před 3 lety +3

      I like to watch that

    • @SulemanAsghargoion
      @SulemanAsghargoion Před 3 lety +9

      And maybe Java

    • @Speykious
      @Speykious Před 3 lety +5

      @@SulemanAsghargoion _All of them_

    • @August0Moura
      @August0Moura Před 3 lety +2

      and the fastest scripting language: LuaJIT

    • @luukvanoijen7082
      @luukvanoijen7082 Před 3 lety +2

      @@August0Moura This would actually be really interesting, luajit is really quite fast

  • @davidgillies620
    @davidgillies620 Před 3 lety

    If you're OK with libraries, Boost has a dynamic_bitset class. Regular C++ STL has a specialisation for std::vector but I haven't had time to benchmark it.

  • @DoubleBassX2
    @DoubleBassX2 Před rokem +2

    Back in high school, the local tech college hosted a programming competition to win a scholarship. I like to tell the story of how I captained the highest-ranking C++ team, but I always come clean and tell them that everyone else was just using Java.
    We did get some t-shirts and a few balloons to go along with the scholarships though.