Testing My C++ NOOB Habits

  Рет қаралды 2,910

Cakez

Cakez

Күн бұрын

Пікірлер: 107
@theultimateevil3430
@theultimateevil3430 2 ай бұрын
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
@frroossst4267
@frroossst4267 3 ай бұрын
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 ай бұрын
@frroossst4267 Take care if you're trying to learn anything though.
@frroossst4267
@frroossst4267 3 ай бұрын
@@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.
@Brad_Script
@Brad_Script 2 ай бұрын
to sum up this video: I don't use any C++ feature in C++
@arookas
@arookas 3 ай бұрын
the std::move parts had me dying 💀
@Raspredval1337
@Raspredval1337 3 ай бұрын
just use C at that point, if you're not even using RAII and value semantics 💀
@minneelyyyy
@minneelyyyy 3 ай бұрын
​@@Raspredval1337 yes please just use C, great idea
@VACatholic
@VACatholic 3 ай бұрын
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 3 ай бұрын
@@VACatholic tagging this for later
@sledgex9
@sledgex9 3 ай бұрын
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.
@joshnjoshgaming
@joshnjoshgaming 3 ай бұрын
why not define your own begin() and end() functions in your array? they're so easy to define.
@joshnjoshgaming
@joshnjoshgaming 3 ай бұрын
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 ай бұрын
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 ай бұрын
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 ай бұрын
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 ай бұрын
Should do that you are right
@AK-vx4dy
@AK-vx4dy 3 ай бұрын
Essentially you write C not C++
@PixelThorn
@PixelThorn 3 ай бұрын
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 3 ай бұрын
@@PixelThorn why not? C+ (only one plus) is my favorite style too
@nicktsaizer6258
@nicktsaizer6258 3 ай бұрын
@@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 😁
@XeZrunner
@XeZrunner 3 ай бұрын
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 ай бұрын
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 3 ай бұрын
@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.
@batty251
@batty251 3 ай бұрын
"Compiler Warnings" Eh she will be fine
@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.
@nates9778
@nates9778 3 ай бұрын
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?
@balijosu
@balijosu 3 ай бұрын
Unfortunately even if you don't "using namespace std", many C++ headers pollute the global namespace.
@joshnjoshgaming
@joshnjoshgaming 3 ай бұрын
"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 ай бұрын
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 ай бұрын
@@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 ай бұрын
@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.
@adamkoxxl
@adamkoxxl 3 ай бұрын
44:51 can't this be fixed with "std::atomic x{};" or "auto r = std::make_shared();"?
@Giga4ever
@Giga4ever 3 ай бұрын
"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 ай бұрын
Toxic
@Giga4ever
@Giga4ever 3 ай бұрын
@@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.)
@arsenbabaev1022
@arsenbabaev1022 3 ай бұрын
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.
@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 ай бұрын
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 3 ай бұрын
@@unknown_error101 if you're manually allocating memory in C++ then you are basically just writing C. just use smart pointers
@luigidabro
@luigidabro 3 ай бұрын
39:55 ifstream is WAY slower than FILE* with fread
@Brad_Script
@Brad_Script 2 ай бұрын
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)
@balijosu
@balijosu 3 ай бұрын
I wouldn't paint the entire STL with the same brush. Some of it is ugly as sin though.
@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
@RPG_Guy-fx8ns
@RPG_Guy-fx8ns 3 ай бұрын
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 ай бұрын
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 ай бұрын
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 ай бұрын
@@Glomly imagine being productive with c++, must be so hard for you
@RPG_Guy-fx8ns
@RPG_Guy-fx8ns 3 ай бұрын
@@joshnjoshgaming KZbin 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.
@GenusNymphicu
@GenusNymphicu 3 ай бұрын
Nice rage bait
@balijosu
@balijosu 3 ай бұрын
I'm not mad, I'm just disappointed.
@lordofthe6string
@lordofthe6string 3 ай бұрын
Sorry, but what was the argument about string literals? I don't understand the point of the argument.
@janhebbel
@janhebbel 3 ай бұрын
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
@kevathiel1913
@kevathiel1913 3 ай бұрын
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 ай бұрын
Watch this video from a non-noob: "Casey Muratori | Smart-Pointers, RAII, ZII? Becoming an N+2 programmer"
@janhebbel
@janhebbel 3 ай бұрын
@@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 ай бұрын
​@@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 ай бұрын
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 ай бұрын
@@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 ай бұрын
I used to think you actually coded c++.. then I saw this video
@soggy_dev
@soggy_dev 3 ай бұрын
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 ай бұрын
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.
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 823 М.
МЕНЯ УКУСИЛ ПАУК #shorts
00:23
Паша Осадчий
Рет қаралды 4,7 МЛН
Noodles Eating Challenge, So Magical! So Much Fun#Funnyfamily #Partygames #Funny
00:33
1, 2, 3, 4, 5, 6, 7, 8, 9 🙈⚽️
00:46
Celine Dept
Рет қаралды 106 МЛН
These Illusions Fool Almost Everyone
24:55
Veritasium
Рет қаралды 4,1 МЛН
2 Years Of Learning C | Prime Reacts
22:24
ThePrimeTime
Рет қаралды 310 М.
WHY did this C++ code FAIL?
38:10
The Cherno
Рет қаралды 292 М.
Why Just In Time Coding Is More Effective
7:36
Senior Code Review Buddy
Рет қаралды 3,6 М.
Nintendo VS Palworld Lawsuit Details Revealed
17:37
Cakez
Рет қаралды 3 М.
why rust libraries may never exist.
7:26
Low Level
Рет қаралды 275 М.
No One Hires Jr Devs So I Made A Game
39:31
ThePrimeTime
Рет қаралды 324 М.
Somebody emailed me a trojan virus
14:06
Bog
Рет қаралды 1 МЛН
Arenas, strings and Scuffed Templates in C
12:28
VoxelRifts
Рет қаралды 92 М.
Microservices are Technical Debt
31:59
NeetCodeIO
Рет қаралды 635 М.
МЕНЯ УКУСИЛ ПАУК #shorts
00:23
Паша Осадчий
Рет қаралды 4,7 МЛН