Introduction
Hi, my name is Dennis and I've been studying software development hoping to one day make a game. I have some knowledge in Java and now I'm hoping to expand my programming experience by learning C++. It took a long time for me to decide which language I would choose ultimately I chose C++ after doing some research I found that a lot of games today are made using C++, one of the things at first that was stopping me from wanting to learn C++ was that a lot of people say that learning C++ can be quite difficult but after some consideration, I decided to go through with C++. So now while I'm still in school I wanted to take advantage of this opportunity to learn C++ before I graduate. In this blog, you'll be able to follow me in my journey to learning C++.
What is C++?
C++ is a general purpose programming language made in 1983 by Bjarne Stroustrup it was developed with system programming and embedded, resource-constrained software and large systems to be efficient and flexible but similar to C but it also wanted to include high level features for program organization. C++ has been used to make desktop applications, video games, servers, and many other things. It also includes object oriented programming.
Why should I use C++?
Some of the main reasons why you should use C++ is because it runs closer to the hardware so you can run programs on computers with limited resources with the memory management capabilities of C++. Another reason is C++ is very portable you are able to run the same program on multiple machines and operating systems. Another big thing about C++ is that it has a huge following being one of the most popular languages to learn with many tutorials and support around this language with enough time anyone can learn how to code with C++. C++ is one of the most used languages when it comes to making games because of its great resource optimization, some of the major engines that use C++ is unreal engine which has made games such as Fortnite and the Gears of War series
Differences Between C++ and Java
Some of the differences that C++ has to java is that it the source code for C++ needs to be compiled on every new system that it's on while java once its compiled it can run on any platform. The second difference is that C++ has manual memory management which has its pros and cons some of the pros are that you have total control over the memory which allows you to run programs on resource tight machines, but some of the cons that come with this are if not done properly can lead to many memory leaks and bugs within the program. On the other hand java all memory management is handled by the system so you don't need to worry about it. The third difference is that C++ is all about pointers while java has very limited support for them
Datatypes in C++
Here are some of the datatypes in C++ that are quite similar to java
- int which stores whole numbers
- double which stores floating point numbers such as decimals
- char which stores single characters surrounded by single quotes
- string stores text surrounded by double quotes
- bool stores value of either true or false
Here is an example of using an int in C++ and printing it out
Here is the same thing done in java
How to Install and Compile with Visual Studio Code
Downloading Visual Studio Code
- First off you'll need to download visual studio code visual studio code link
- After the installation is finished you'll want to add the extensions C/C++ extension and Code Runner
Downloading Msys2 and Mingw64
- Download Msys2 msys2 download link
- After the download is finished open msys2 and run "pacman -Syu"
- After that's you'll have to reopen msys2 from the start menu and then you'll want to run "pacman -Su"
- After that's finished the last thing you need to run is "pacman -S --needed base-devel mingw-w64-x86_64-toolchain"
Setting up Mingw64
- Search "settings" in the windows search bar to open windows settings
- In the search bar at the top search for "Edit environment variables for your account"
- Choose "Path" in the first window and press edit
- If you followed the default installation instructions when downloading msys2 then you can just click new and the path is "C:\msys64\mingw64\bin" if not then you'll need to locate the location where you downloaded msys64 and change the path according to what it is on your system
- Select Ok to save the updated Path
- After that open the command promt by opening the windows search bar and searching "cmd"
- In the console type "g++ --version" and "gdb --version" if either command is not reconized then you'll need to double check the mingw-w64 bin location
youtube link in case embedded video doesn't work
References
“C++ VS Java: Top 30 differences between C++ and Java with examples,” Software Testing Help, 03-Feb-2022. [Online]. Available: https://www.softwaretestinghelp.com/cpp-vs-java/. [Accessed: 26-Feb-2022].
“Advantages and disadvantages of C++: Make your next move!,” DataFlair, 03-Feb-2020. [Online]. Available: https://data-flair.training/blogs/advantages-and-disadvantages-of-cpp/. [Accessed: 26-Feb-2022].
“C++,” Wikipedia, 22-Feb-2022. [Online]. Available: https://en.wikipedia.org/wiki/C%2B%2B. [Accessed: 26-Feb-2022].
Comments
Post a Comment