Testing My C++ NOOB Habits

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 พ.ย. 2024

ความคิดเห็น • 107

  • @theultimateevil3430
    @theultimateevil3430 2 หลายเดือนก่อน +13

    This is extra cursed. The guy in the video is replacing bad practices with other bad practices, with a sprinkle of working around the C++ default behavior

  • @Brad_Script
    @Brad_Script 2 หลายเดือนก่อน +7

    to sum up this video:
    I don't use any C++ feature in C++

  • @arookas
    @arookas 3 หลายเดือนก่อน +15

    the std::move parts had me dying 💀

    • @Raspredval1337
      @Raspredval1337 3 หลายเดือนก่อน +4

      just use C at that point, if you're not even using RAII and value semantics 💀

    • @minneelyyyy
      @minneelyyyy 2 หลายเดือนก่อน

      ​@@Raspredval1337 yes please just use C, great idea

  • @frroossst4267
    @frroossst4267 3 หลายเดือนก่อน +4

    Cakez is quickly becoming my favourite programming youtuber, I feel like I can actually relate to him. Loved his video trying out Zig! The frustrations are real and raw.
    Love watching you videos!

    • @balijosu
      @balijosu 3 หลายเดือนก่อน +4

      @frroossst4267 Take care if you're trying to learn anything though.

    • @frroossst4267
      @frroossst4267 3 หลายเดือนก่อน +1

      @@balijosu I'm not a beginner by any means, I just enjoy him airing his frustrations cause that is me some times, and in a lot of these programming tutorials you don't see the ''struggle" behind the project.

  • @VACatholic
    @VACatholic 2 หลายเดือนก่อน +2

    You should watch Ryan Fleury's video on memory management. He goes into why allocing arrays in a virtual memory backed arena allocator is actually potentially better than a single allocation. It's a really good talk.

    • @PixelThorn
      @PixelThorn 2 หลายเดือนก่อน

      @@VACatholic tagging this for later

  • @AK-vx4dy
    @AK-vx4dy 3 หลายเดือนก่อน +13

    Essentially you write C not C++

    • @PixelThorn
      @PixelThorn 2 หลายเดือนก่อน +7

      Yeah, he's writing C and compiling it in a C++ compiler and being all proud and street smart about not using the STL or whatever

    • @nicktsaizer6258
      @nicktsaizer6258 2 หลายเดือนก่อน +2

      @@PixelThorn why not? C+ (only one plus) is my favorite style too

    • @nicktsaizer6258
      @nicktsaizer6258 2 หลายเดือนก่อน +1

      @@PixelThorn c++ at it's peak is dealing with much more abstraction without any benefits

    • @Brad_Script
      @Brad_Script 2 หลายเดือนก่อน

      @@PixelThorn isn't the C compiler faster ? why not just write C code at this point lol

    • @PixelThorn
      @PixelThorn 2 หลายเดือนก่อน

      @@Brad_Script don't know, thats what he should be doing 😁

  • @joshnjoshgaming
    @joshnjoshgaming 3 หลายเดือนก่อน +8

    why not define your own begin() and end() functions in your array? they're so easy to define.

    • @joshnjoshgaming
      @joshnjoshgaming 3 หลายเดือนก่อน +1

      and again you can use std algorithms on your own container types if you do a tiny bit of research and figure out how to implement the neccessary interfaces.

    • @izikpfirrmann8775
      @izikpfirrmann8775 3 หลายเดือนก่อน +1

      this is literally what i was thinking, he already has a .first() and .final() functions on his array class which basically do the same thing as .begin() and .end(). because the array is a contiguous buffer, if he changes the names of the functions/ adds .begin() and .end() methods, and has the return types be T*'s then he'll be able to use them with range based for loops (and algorithms but he doesn't like using the standard for some reason ¯\_(ツ)_/¯)

    • @RPG_Guy-fx8ns
      @RPG_Guy-fx8ns 3 หลายเดือนก่อน +1

      Traditional loops just store the integer iterator and comparison in the processor registers. You don't need range based iterator Objects on the stack, they just waste memory, and they don't make code easier to read.

    • @Giga4ever
      @Giga4ever 3 หลายเดือนก่อน +5

      He is ignorant. If you watch his streams you will see that he never reads any docs and just cowboy codes his way through. He is just not aware of begin() and end(). He watched Handmade Hero and never went out of his way to learn anything else

    • @Cakez77
      @Cakez77  3 หลายเดือนก่อน +4

      Should do that you are right

  • @joshnjoshgaming
    @joshnjoshgaming 3 หลายเดือนก่อน +4

    "it's best that you do make mistakes and learn" is great when it doesn't compromise millions of users private information and more, which is the reality of C and C++ memory management mistakes.

    • @Glomly
      @Glomly 3 หลายเดือนก่อน +4

      In game development, nobody cares that some hacker got an access to some random trace of game's memory. On the other hand, database leaks happen all the time no matter the language those databases written in, there's no language that's 100% safe

    • @Giga4ever
      @Giga4ever 3 หลายเดือนก่อน +1

      @@Glomly It's not about 100% safety, that reducing all the long hanging fruits, which account for like 90% of the issues.
      Also, things like memory leaks or crashes can ruin a game as well.

    • @Glomly
      @Glomly 3 หลายเดือนก่อน

      @@Giga4ever memory management is hard for those who come from garbage collected languages, so they don't understand fundamental design difference. In "manual" languages you need to keep everything as simple as possible, be conservative, keep related things together, allocate them together and release them together. In "automatic" languages you can have as much complexity as you want and create heap allocations left and right, transition to absolutely different layout midway through, knowing that the "garbage" is going to be collected after you done using it. One leads to extremely fast development iteration but bad performance, the other to slow iteration fast performance. The problems start when you try to simultaneously make your program' memory layout complex(as allocate lots of different small things in different places throughout your program) and manage the memory, ofc you get a disaster.

    • @joshnjoshgaming
      @joshnjoshgaming 3 หลายเดือนก่อน

      @@Glomly Security statistics disagree with your statements, manual memory management is a problem.

    • @balijosu
      @balijosu 3 หลายเดือนก่อน +1

      @joshnjoshgaming It's certainly the reality of C (only in relevant applications of course--many applications have no security concerns by their nature). But C++ gives you a lot of tools to avoid typical C problems.

  • @sledgex9
    @sledgex9 3 หลายเดือนก่อน +2

    46:34 "I do have compiler warnings from fontconfig and I can't anything about those". Yes, you can. You should include external libraries as "system libraries". For example, in gcc use the "isystem" flag instead of the "I" flag for include directories. I think MSVC has a pragma for this. What it does: The compiler won't output warnings coming from system headers aka libraries that you have no control over.

  • @XeZrunner
    @XeZrunner 3 หลายเดือนก่อน +5

    I feel like people that use the full C++ std:: feature set have an entirely different mindset on what programming is like, where more complexity somehow means the code is better.

    • @spidermanlift4527
      @spidermanlift4527 3 หลายเดือนก่อน +2

      I use parts of it, but there's many parts of std I just find overcomplicated for its purpose where I just made my own things instead.

    • @balijosu
      @balijosu 2 หลายเดือนก่อน +2

      @XeZrunner I've literally never met an industry dev who thinks that way. Use the STL if it helps you. Use something else if it helps you.

  • @aaronwinter7911
    @aaronwinter7911 หลายเดือนก่อน

    he did say OVER use of magic numbers. Not use of magic numbers. In some instances its fine. IMHO as soon as you use the same magic number twice is where it gets tricky.

  • @unknown_error101
    @unknown_error101 3 หลายเดือนก่อน

    I don't understand how manual memory management can be bad. Tbh, it can be hard keeping track of when destructors are called for certain classes and manual control just lets you understand exactly what's happening at any given moment.

    • @sledgex9
      @sledgex9 3 หลายเดือนก่อน +2

      Unless you forget to do your cleanup in one place or forget to account for all exit paths. And this might be due to mental fatigue not due to skill issue. Destructors are called at the variable's scope end and in reverse order created. I don't understand what's hard about it. You don't need to think about it really.

    • @unknown_error101
      @unknown_error101 3 หลายเดือนก่อน

      @@sledgex9 I agree with you, I was moreso arguing against how they guy in the video made it seem like manual memory management was a bad thing and to strictly use destructors. I think you could probably use destructors most of the time, but I also feel like there's a time and a place for really precise control. Plus it helps you understand exactly when something like a memory deallocation happens because it's written out as a statement, rather than automatically called in the background if that makes sense.

    • @sledgex9
      @sledgex9 3 หลายเดือนก่อน

      @@unknown_error101 RAII should be the default for a programmer. If performance issues arise, you can fallback to manual resource management. If you want to see where memory deallocation happens for educational purposes that's fine. But usually the docs for each class should clarify enough what it does behind the scenes with resources.

    • @professionalbreather62
      @professionalbreather62 2 หลายเดือนก่อน

      @@unknown_error101 if you're manually allocating memory in C++ then you are basically just writing C. just use smart pointers

  • @batty251
    @batty251 3 หลายเดือนก่อน

    "Compiler Warnings" Eh she will be fine

  • @balijosu
    @balijosu 3 หลายเดือนก่อน

    Unfortunately even if you don't "using namespace std", many C++ headers pollute the global namespace.

  • @arsenbabaev1022
    @arsenbabaev1022 3 หลายเดือนก่อน +4

    C++ noob habit is using C++.

    • @balijosu
      @balijosu 3 หลายเดือนก่อน

      @@arsenbabaev1022 🙄

    • @adamrushford
      @adamrushford หลายเดือนก่อน

      Is that your take or your opinion?

    • @balijosu
      @balijosu หลายเดือนก่อน

      @@adamrushford Think of it like a child watching a professional and thinking "I could do better than that". They're oblivious to their shortcomings.

    • @adamrushford
      @adamrushford หลายเดือนก่อน

      @@balijosu think of it like a fisherman so good they jump into his bait bucket, only it's a scientist and he tags and releases to better the future species ;)

    • @balijosu
      @balijosu หลายเดือนก่อน

      @@adamrushford Ok, now I'm unclear whether you agree with arse or not.

  • @nates9778
    @nates9778 3 หลายเดือนก่อน +2

    13:08 Also string literals are placed into a read-only section so if you try to write to the underlying bytes you get a access violation.
    15:41 I compile the code with gcc -O3 and it compiles it to a constant value. So I don't understand why you would do this.
    40:32 I'm pissed off! I use C not C++ why did I watch this?

  • @Giga4ever
    @Giga4ever 3 หลายเดือนก่อน +13

    "I don't know/use it so it doesn't count" is such a silly argument when you consider that my grandma would have 0 "NoobCounter" with the same argument. Knowing fundamental language features and the standard library are all are all part of knowing a language. It's valid to not use them, but disregarding everything because of ignorance and not for actual reasons, is unfortunately common with the "C subset of C++" people. Also, you missed the point of like half of the things in your typical 2Head behaviour

    • @Cakez77
      @Cakez77  3 หลายเดือนก่อน +1

      Toxic

    • @Giga4ever
      @Giga4ever 3 หลายเดือนก่อน +4

      @@Cakez77 Truth = toxic? Weird dude

    • @eduantech
      @eduantech 2 หลายเดือนก่อน

      So he should count it towards the noob counter? Or what? Lol

    • @psteven5
      @psteven5 2 หลายเดือนก่อน

      you’re malding and it’s showing

  • @balijosu
    @balijosu 3 หลายเดือนก่อน

    Ok, so you don't fall into these traps for the same reason I don't fall into any traps when I use Visual Basic. (Because I've never used Visual Basic.)

  • @GenusNymphicu
    @GenusNymphicu 3 หลายเดือนก่อน +3

    Nice rage bait

    • @balijosu
      @balijosu 3 หลายเดือนก่อน +3

      I'm not mad, I'm just disappointed.

  • @luigidabro
    @luigidabro 3 หลายเดือนก่อน +1

    39:55 ifstream is WAY slower than FILE* with fread

    • @Brad_Script
      @Brad_Script 2 หลายเดือนก่อน +1

      yeah but fopen is broken on Windows, it doesn't work with filenames with unicode character lol so you have to use the wide char version. This applies to all io functions (rename, unlink, mkdir, etc)

  • @janhebbel
    @janhebbel 3 หลายเดือนก่อน +2

    The guy that made the original video is actually the noob if he thinks that any manual memory management is noob behavior. If, like Cakez said, you manage memory in a way were you allocate only one or a few times for memory arenas that keep the memory valid for different lifetimes in the program from which you suballocate, that's actually the pro move. It's fast, it's simple, it's easy to understand, memory leaks can only happen in those few places. There is not a single valid argument you can make against this in my opinion.

    • @psteven5
      @psteven5 2 หลายเดือนก่อน

      a terrifying amount of chat thinks exactly the same in that regard as the guy in the video apparently

  • @adamkoxxl
    @adamkoxxl 3 หลายเดือนก่อน

    44:51 can't this be fixed with "std::atomic x{};" or "auto r = std::make_shared();"?

  • @adamrushford
    @adamrushford หลายเดือนก่อน

    Wait a second your other video title was "Why I Write C++ Like it is C."... no dude you're just compiling C code as C++ Apparently lol

  • @balijosu
    @balijosu 3 หลายเดือนก่อน

    I wouldn't paint the entire STL with the same brush. Some of it is ugly as sin though.

  • @RPG_Guy-fx8ns
    @RPG_Guy-fx8ns 3 หลายเดือนก่อน +12

    boomer loops are better, I always use a loop index, linear search is almost always better than maps, you don't need objects, you don't need templates, you don't need garbage collectors or dynamic memory, you don't need to individually malloc and free every little thing, block allocate a fixed size of data, and free it all at once, pointers are ugly, and pointers can be replaced with indexes into arrays. C++ is mostly a bad language, and C++ noob code is probably more performant, easier to read, and faster to compile, than C++ pro code.

    • @joshnjoshgaming
      @joshnjoshgaming 3 หลายเดือนก่อน +5

      So no one ever has a use for templates and meta programming, and arrays and arena allocators can solve every scenario?
      Sounds like a closed minded take from a hobbyist who writes one kind of software.
      also I love claims of performance backed with nothing but opinion.
      of course parts of everything you said have some grain of truth to them in certain scenarios, but to think that applies to everything is just silly

    • @Raspredval1337
      @Raspredval1337 3 หลายเดือนก่อน +2

      good luck wasting runtime time and memory with c\stl regex instead of CTRE 😎

    • @Glomly
      @Glomly 3 หลายเดือนก่อน

      @@Raspredval1337 noobies write their own pattern matching instead of using regex

    • @Raspredval1337
      @Raspredval1337 3 หลายเดือนก่อน +2

      @@Glomly imagine being productive with c++, must be so hard for you

    • @RPG_Guy-fx8ns
      @RPG_Guy-fx8ns 3 หลายเดือนก่อน +2

      @@joshnjoshgaming TH-cam is deleting all my replies. Probably t r i g g e r e d them with the B word. Everything is hate speech to the kommies running this site.

  • @lordofthe6string
    @lordofthe6string 3 หลายเดือนก่อน

    Sorry, but what was the argument about string literals? I don't understand the point of the argument.

  • @kevathiel1913
    @kevathiel1913 3 หลายเดือนก่อน +9

    37:28 was so painful to watch. You clearly have no clue what resource management means, yet you have the audacity to shout "wrong" like a child. It is not just about memory allocation, he even literally showed you another example of resources with the file opening. Not knowing why RAII is important, even outside memory allocations, makes you a beginner in C++ period. Imagine you load a file and do something with it, and something went wrong(e.g. you load a shader and it has a compile error), in this case it is easy to forget to actually close the file in ALL early returns. Now you lose the handle and you have the file permanently opened, which can cause all kinds of issues(.e.g unable to fix the shader for example when hotrelaoding).
    Also, your whole memory argument is even kinda dumb, because you can jut use custom allocators and track stuff there instead of always over-allocating everything and being unable to release memory.

    • @rohitaug
      @rohitaug 3 หลายเดือนก่อน +2

      Watch this video from a non-noob: "Casey Muratori | Smart-Pointers, RAII, ZII? Becoming an N+2 programmer"

    • @janhebbel
      @janhebbel 3 หลายเดือนก่อน +1

      @@rohitaug I agree with you but I'm just going to assume by the way he wrote his message, that anything Casey will say in that video will fall on deaf ears.

    • @kevathiel1913
      @kevathiel1913 3 หลายเดือนก่อน +6

      ​@@rohitaug I am aware with Caseys video, but if you actually listen to his arguments, you will find that there are not any. He is just dogmatic and ignorant, where he makes claims without backing them up. Probably not the best idea to listen to the guy who has no gameplay in his game after 10 years, despite even taking money for it by making false promises.. But you are missing the point: I am talking how Cakez missed the entire point of RAII. Whether he agrees to RAII or not is his own decision, but he should disregard it for the correct reasons and not just reduce it to the "resources are just about memory". Also Cakez is using the early memory allocation, not the chunk based arena one, which even Casey said was just to make the beginning easy(so he replace it in like episode 300 or something), but Cakez unironically uses the "noob allocation strategy" in his actual production project.

    • @rohitaug
      @rohitaug 3 หลายเดือนก่อน +2

      Your arguments against Casey don't take into account that Casey does handmade hero in his spare time. Also he is teaching how to make engine code, not gameplay. Whether an allocation strategy is good or bad depends on how difficult it is to work with. If Cakez is not having the issues you're saying he is supposed to have, how is it a problem? I won't say that Cakez is an expert but declaring RAII as "the expert way" as the video suggests misses the mark, which is what Cakez says is wrong. Not that RAII itself is wrong for every project.

    • @kevathiel1913
      @kevathiel1913 3 หลายเดือนก่อน +5

      @@rohitaug He didn't do a new HMH video in a long time. He abandoned it for his next money making scheme where he "teaches" others, despite not delivering on the original promises. Cakez misunderstood the RAII part(as many other points in the video) and only reduced it to memory allocation, despite the example clearing being about file handles, so he was wrong, and that is I was originally pointing out. Let's not talk about all the issues that Cakez has with his code, there is a reason why his little Tower Defense game has not a single tower done, let alone a full level, after 3 years of fulltime work. He is constantly re-doing things.

  • @shrekeyes2410
    @shrekeyes2410 2 หลายเดือนก่อน +1

    I used to think you actually coded c++.. then I saw this video

  • @soggy_dev
    @soggy_dev 3 หลายเดือนก่อน +2

    People saying the square bracket operator initializing on read isn't hidden behavior are coping so hard. As a non C++ dev, that shit's crazy

    • @balijosu
      @balijosu 3 หลายเดือนก่อน +1

      It returns a reference you can assign through. How else could it work?

    • @lucaxtshotting2378
      @lucaxtshotting2378 3 หลายเดือนก่อน

      It is the same in python though

    • @meanmole3212
      @meanmole3212 3 หลายเดือนก่อน

      I did not find mention about that on cpp reference unordered_map page, but if it is true I have no words to describe this language anymore without youtube shadow banning me.

    • @joshnjoshgaming
      @joshnjoshgaming 2 หลายเดือนก่อน

      @@balijosu iirc in C# that's an exception, items must be added to dictionaries manually ( could be wrong its been awhile)

    • @balijosu
      @balijosu 2 หลายเดือนก่อน

      @joshnjoshgaming Never used C#. Seems nice though.
      I should add: I generally don't like operator overloading. I prefer functions with descriptive names unless the point is to make something usable in contexts where you also want to use primitive types.