About us

Breaking

2021/04/21

C++


Brand new series in which you are going to know everything about C++. We're gonna learn C++ specifically in the context of game development however it's not just gonna apply to game developing a game programming we're just gonna use games as an example. This series is gonna apply to pretty much everyone whether you're a beginner or you're advanced. We'll cover the basics of the language but we'll be quite concise with that so basically if you are a beginner you can still follow along with this series but you're gonna have to be able to Google things and do some research and finds find some of the basics out for yourself. Basically just just be a normal person and Google things that you don't understand. So now the question is why would you want to learn C++ . C++ kind of an outdated language but still why what good is there in learning C++ nowadays.
 
C++ is still pretty much the most used language when you need to write fast code that performs well or if you're writing for a weird architecture or a platform and you need the code run natively if you want direct control over hardware.Games industry uses C++ extensively and game engines like unity,Unreal Frostbite they're all written in C++ so the question is why would we want to act access to hardware? why all of these game engines written in C++? why not use another language?  The biggest reason for using C++ is the direct control over hardware. How C++ works? 
 
 
Write your code in C++ you pass your code into a compiler and that compiler will output machine code for your target platform. Machine code is the actual instructions that your device's CPU will actually perform. So using C++ we can literally control every single instruction that your CPU executes. What
platforms does C++ run on, you ask pretty much anything you just need a compiler that will output machine code for that platform for example an x64 compiler will output x64 machine code and thus
run on x64 CPU's. So to give you an example of some of the platforms that C++ is commonly used to develop for Windows, Mac, Linux any other desktop operating systems pretty much all of them mobile operating systems IOS Android for example you can write applique in C++ and all the consoles. So Xbox, PlayStation and all the Nintendo stuff like the 3ds, the Wii U, the switch everything uses C++.
 
C++ is great when you need Y platform support because as long as there's a compiler you can get C++ to compile into native code that will run on that platform of course there are other native languages out there it's just the C++ as the one that's been around since the early 80s and it's just so popular and everyone knows it. Everyone's using it other languages like C sharp or Java differ because they run on a virtual machine this means that your code gets compiled into an intermediate language first and then when you actually run your application on that target platform the VM the virtual machine will basically convert it into machine code at run time.
 
If you will pretend that you wrote a book in English but you want someone in Germany who only speaks German to read your book so what you've decided to do is actually sell the book in English at the German store however when you buy the book you also get like a translator like an actual person to
come home with you. So the person comes home and then that German person wants to read the book. The translator reads the book in English and then just basically stops talking in German. So it's like live translating the whole book for the person that's kind of what running on a virtual machine. It would be a lot more efficient it would be a lot more efficient if you just translated the book itself into German and then sold that in German stores so that the way it would be in the native language in German and that's of course not a perfect metaphor but that's kind of what it's like to run say boss blasts versus a language like Java or C sharp. 
 
C++ is a native language the C++ compiler produces machine code for that target platform and for that target architecture and then that's it.It's there as native code it will only run on that platform however it's already in that platforms machine code language so there's absolutely no translation or anything required you just run them which you just push the machine code instructions CPU instructions into the CPU and it will perform all of your instructions. Just because your code is native doesn't mean it's going to be fast. If you write bad code in C++ it's gonna be slow in fact it'll likely even be slower than virtual machine languages like C sharp or Java because they tend to optimize things on the fly a lot better than C++ world. So if your write bad C++ code C++ will definitely be slower than C sharp or Java.
 
when we just need to write tools or things that don't necessarily need to squeeze every bit of performance out of them. C sharp is a fantastic language plan but this series is gonna be for when we actually need that performance for when we need to write circles bus so we're gonna learn all about how to write C++ correctly.  How to write good code? how to write fast code?  
 
We're gonna start with the basics. When it comes to the basics because you're gonna have to
just google the things that you don't understand. It should be pretty easy to follow the key to learning.
We're gonna actually go through pointers and memory properly. Memory arenas, custom allocators, smart pointers, move semantics,templates and how to actually use them properly. If you know how to use templates well they're extremely powerful and they'll make your life a lot easier. Macros and how to program for multiple platforms.

No comments:

Post a Comment