Ho Caleb, please I started learning how to code with c++ and honestly I'm not that advance in c++ but I understand the basic concept, infact I'm In love with the little basic knowledge I know in c++, I want to focus on development using c++ but I don't know any resources that can help me with that, please can you help recommend some resources for me because I'm very confused, I'm stack and I don't know what to use the little knowledge I know in c++ to do
The same fucking thing happened to me while at community college. I used a for each loop, which was introduced in C++ 11, as well. I got a zero because It didn't compile because the instructor wasn't using C++ 11 or greater, and this was in 2018... Now, in his defense, he watched me download the file that I submitted, compile it to an executable, and run it perfectly. He changed my grade to a 100. Lol.
I would think C++ 11 would be acceptable now, since that's when the nullptr, automatic typing, and as you mentioned, enhanced for loops. I feel like that update to C++ seriously changed how code reads, for the better
For school homeworks, use CMake if your teacher allows. It helps them to build your project, with the standard you use and with the libraries you linked.
tried not putting "using namespace std;" but my professor graded my work 0 cause he said i didn't use "using namespace std;" and called me out publicly
The problem will use namespace std is most of the time it's being used in the global scope. It's not beneficial mostly as it interferes with other libraries like boost. However, it is ideal to use namespace std in the local scope. This gives you more control flow. It's considered a bad habit mostly because of the boost library which c++20 implemented bits of boost and fmt so the use of the boost is no longer required in most circumstances. Please get rid of the stigma around using namespace std.
I disagree about float vs. double. Doubles are always going to be slower due to larger memory footprint leading to more frequent cache misses (regardless of architecture). There is hardly anything that would make code harder to read by using floats. Functions are often templated for both, so in worst case you might have to throw in a static_cast on the return value. In game-dev it is not premature optimization to use floats, just common sense. However, there are places where double is useful, like where precision errors can accumulate in an algorithm.
You shouldn’t care about increasing cache misses in normal code like he is talking about. He was pretty clear about that. Unless you are optimizing to the Nth degree, the use of double causing L1 cache misses doesn’t matter. Even if you are optimizing it isn’t a bug deal if you are using contiguous memory because most of the reads won’t be cache misses. Also, processors are good at precaching contiguous reads, so in many cases, using doubles will not cause any extra cache misses at all.
Your compilers optimization system only has a number of things it can do. It can't read your intent, in can't using a method like divide and conquer, it can't convert a tree to an array, ... Long long list. In recent projects I started doing measurements on what the compilers optimization provide in comparison to my optimization it was around 0.00001%. That's right 99.9+% of the optimization that can be done to a program has to be done by you. Yes, I can prove the math on that.
Using floats instead of doubles isn't just dumb, since with automatically vectorizing compiler you can quite often get 2x performance because the SIMD instructions can operate on twice the amount of floating point numbers at a time.
When I started programming in C++, it was back before move semantics existed and the STL was making copies everywhere (we thought, turns out compilers were smart enough to move elide when it didn't even have to yet). C and C++ were almost indistinguishable aside from a few extra "struct" keywords back then, and I thought the "backwards" compatibility was a real selling point. Now, I actively like to make my C++ code as incompatible with C as possible because it's fun to convert everything all to containers and algorithms and see functions shrink from 30 lines to 1 statement. I hate seeing output parameters so much now, which is the worst thing about interfacing with windows system headers; back in the old day I was all about output parameters, with pointers to pointers and references of references in every method call. What fools we were in those ancient days of the mid 2000's. The compiler was move eliding the whole time; if only we'd profiled sending our results back by value instead of trusting our professors!
Smart pointers for an ownership, a reference for data manipulation only (where ownership is not relevant, as object will live longer than method execution.
Other beginner mistakes: using raw pointers versus smart pointers; failing to make unit-tests (and failing to use a unit-test framework). I might also throw in failing to use version control/code repository.
Hi Caleb! Thank you for your content and sense of humour. I believe some of the points that you brought up in this video labelled with c++ are also applicable to other programming languages and therefore I think you hindered some potential views as they thought that this video didn’t concern them as they work with other languages. Have a nice day!
Yea but what you do when you know some language & technology that's not ideally designed for the task but you can make it work, and do the staff you wish todo or go and learn another tech, language that you think is ideal for the task, and than switch back to the first one? Than there is some languge ideal for the task or it's popular? Can it be that Rust is better for writing code for the games, but C++ has better libs, frameworks, gamengines, tutorials. Python may be great for manipulating strings, but than the engine you use uses C++ or C#, should you embed python interpreter. I think it's probally more complex decision making process usually used in practice.
Actually, arrays and vectors have different strengths. It’s not one over the other, but more the functionality you need. Do you have dynamic data that you access a few times each cycle? Vectors. Do you have static data that is being accessed hundreds of times each cycle? Arrays. For example, my game. I use an array for the tiles because there are 65536 tiles in a map, and once loaded they don’t change and are accessed every frame. For the objects and NPCs, there are only a few dozen, and they are only accessed when they move or interact.
The problem with arrays is that they often exist on a stack: I worked on many projects, where stack was really tiny (like 2-4kB per thread). So local variables on stack had to be limited. Unless you use a global memory for static objects.
One of the Most Important Thing You Brought on the Table is References. OMG I was going nuts with Pointers. The Teacher Shoved the Idea of Pointers Very Deep Down my Throat. I Never Even Knew About References. Never had the time to absorb C++ Operands and Such. Yes! Thanks to YourTube Teachers Like You Now These Ideas are Possible. God Bless and Take Care Caleb. ------- end of line ----------
A reference is a "const pointer in a disguise" - it solves different problems than pointers (actually - smart pointers, as plain pointers in C++ should be used only for specific optimizations only).
You don’t need to. It is a stylistic choice. If typing std:: all the time annoys you, then just use “using std”. People make too big of a deal about their preferences. Weigh the pros and cons and decide for yourself.
@@Dziaji There is not a problem with using std in a method, sometimes even on cpp level. But putting "using std" in a header is a total crap as it pollutes namespace in all places which includes this header - and this is not expected behavior after including a header.
It means your heart isn’t in it. Do not try to become a programmer unless you love it so much that you can’t wait to do it every day. Ignore the nonsense that guy said about motivation. Motivation is what causes humans to act; the act doesn’t cause the motivation. Maybe research cause and effect if you are confused by this.
I hear that “using namespace std;” is bad from everyone except Bjarne Stroustrup. In his book “Programming” he seems to suggest that we shouldn’t use names that directly clash with the std namespace anyway 🤔, although he does seem to suggest that for all other namespaces, don’t use “using namespace X”
Favoring readability isn't necessarily always a good thing... if you are a solo dev and can read your own code, then you don't have to fuss about whether or not someone else understands it. (The vast majority will be job-seeking or work on open-source so I realize this isn't for everyone).
“Using” exists so that you don’t have to keep typing the name of your namespace with :: Using namespace std is fine. People make a big deal about it, but it works well to make your code look cleaner and less cluttered.
So you don’t have to type std a thousand times. You can always do a grep on your codebase to add std:: to “move” or “cout” or whatever if a naming conflict manifests itself.
References are the worst idea of C++, because you can't see the difference between sending a reference and a value while reading code. And it should, always, be obvious wether the state of the object is gonna change or not.
Pretty sure this guys a sleeper, or some sort of federalee. if you look in the description he links to python courses. this is a sign of some foul play or possible nsa/cia ties. this guy glows, i wouldnt trust him.
Lol. Neither of those are real languages. They require runtime interpreters. C++ is the best language out there by FAR, and it actually compiles to machine code.
Never use JAVA or C#, because they are total garbage. Python is good for tinkering around with small projects and stuff, but if you want to make something professional, use c++.
@@Dziaji please I started learning how to code with c++, I'm not that advance in c++ but I understand the basic concept, I want to go to game development using c++ buh I don't know any resources that can help me become game developer using c++, please can help me with some recommendations