# Is starting with gamedev too much?

## Recommended Posts

So i wanted to learn programming and got myself a nice C++ book because that seems to be the language where i can realize most of the things i wanted to do. (Things like emulation programming). I read the book, understood most of the concepts and got myself pretty comfortable in C++ (still a beginner though). So after finishing the book, i wanted to get really good with the language before i dive into reverse engineering/assembler and such things, so some people recommended to learn a nice framework as the next step. So i chose to learn SFML as my next step and make some games with it (also really interested in gamedevelopment). I read the rather short tutorials on their website and was able to make my first game within a day. Even though it was just a pong clone i had so much fun doing it so i bought myself a SFML book. This one to be precise https://www.amazon.com/SFML-Game-Development-Jan-Haller/dp/1849696845

The first chapter was still easy to understand but by the second chapter already, where the author talked about Resource Management, i couldnt follow it anymore. He used concepts i never heard of such as unique pointers for example.

So my question is, should i learn something else entirely to get better in C++, learn something even easier than SFML for game dev. or even a complete different laguage? I would like to stay at game development at first, because making games seems to be a really fun process where you learn alot.

##### Share on other sites

Hi, I don't know if I can offer the best answer, someone on these boards will no doubt be better educated to answer your question, but from my understanding c++ gives you tremendous power to develop software specific to a particular system.  So the pointers you've mentioned I think are more the nitty gritty of what C++ can do.  It's there if you really reeeally need it but isn't necessary to game development.  What do others think?  am I out to lunch on this one?

##### Share on other sites

Hi, I don't know if I can offer the best answer, someone on these boards will no doubt be better educated to answer your question, but from my understanding c++ gives you tremendous power to develop software specific to a particular system.  So the pointers you've mentioned I think are more the nitty gritty of what C++ can do.  It's there if you really reeeally need it but isn't necessary to game development.  What do others think?  am I out to lunch on this one?

I never looked at it like that, always thought everything i read in a book is super important

##### Share on other sites

std::unique_ptr allows you to create a pointer that will delete its contents when it leaves scope. It's found in the <memory> header.

One of the most common errors in C and C++ programming is called a "memory leak". This is a case where you allocate memory for an object and then forget to release the allocation after you're done using it. Apart from simple forgetfulness, there are a significant number of "gotcha" situations where it may seem like you're releasing the allocation, but the program's path of execution doesn't reach that point for one reason or another.

Rather than expending more and more resources trying to teach programmers to do something that's simply not easy for humans to do correctly, we have come to rely on design patterns that make common bugs like this either impossible to commit or else obvious and easily identified when they occur. In the case of memory leaks the answer is smart pointers.

std::unique_ptr is for sole ownership of an allocation. It can't be copied as it is not intended to be copied, so it defends its ownership. If you want shared ownership (note: this is usually a mistake) you can use std::shared_ptr<>, which allows itself to be copied and doesn't release its resource until all the copies for that resource are destroyed.

Here's an example for unique_ptr

#include <iostream>
#include <memory>

struct Derp {
Derp(int val) {
a = val;
b = a + 1;
c = b + 1;
}

int a, b, c;
};

int main() {
std::unique_ptr<Derp> derp; //this is a pointer to a Derp - the initial value is nullptr

derp = std::make_unique<Derp>(1); //use std::make_unique<>() to safely allocate and pass constructor arguments

std::cout << derp->a << ":" << derp->b << ":" << derp->c << "\n"; //you can dereference the smart pointer as if it were a raw pointer

} //when the object leaves scope it will delete the allocation automatically


It would be worth your while to check out http://en.cppreference.com/w/cpp/memory/unique_ptr.

You may also want to take a look at other common STL objects such as std::string and std::vector.

##### Share on other sites

Then I suggest you to move to a book talking about the C++ standard library. A recent one (which should cover C++ 11 at least). This one should cover all concepts/practices modern C++ programming should go along with, but which might not be covered by a book talking only about the language.

##### Share on other sites

Well, speaking from my own experience, the first thing I did with programming was decide "I want to make make games" so picked up some books focused on games programming in C++. Realistically, the very starter books were just intros to programming / programming concepts with a "game" theme.

I would say that jumping straight into C++ can be a great, and very fun experience, but it will require finding the right books / style of learning for you. There are some books I just dont get along with, so if you have the budget I would say buy a few different books to give yourself different writing styles / teaching methods.

And as mentioned above, make sure the books are up to date, most will state C++11 etc on them so you can see which ones will be using the newer features of the language. The only time this is slightly less relevant is when you have a decent amount of experience and are looking for books on certain topics where you would be able to easily adapt the code examples to use the newer features yourself.

##### Share on other sites

Oh I remember the days when I first learned c/c++ over a high school summer break. I also grabbed a book on making video game during that time. I had to learn how to make a c/c++ game using vga's modex. I still have that book on my book shelf, ripped in two down the spine, and I just paged through it after reading the original post. In my opinion; SFML is metaphorically like programming for dos. Make some system calls here and there to setup your graphics, sound, and input and then make some library calls to render some geometry after some processing in your main loop. My two cents here is to say go for it!

Since it was mentioned that emu programming is a driving aspiration to learn; I suggest my favorite starter book here, because the author really simplifies the explanation on how to build a computer literally from relays and transistors. I think that would guide you towards understanding how computers truly work.

##### Share on other sites

Since it was mentioned that emu programming is a driving aspiration to learn; I suggest my favorite starter book here, because the author really simplifies the explanation on how to build a computer literally from relays and transistors. I think that would guide you towards understanding how computers truly work.

Looks like a really interesting book, but im studying technical computer science so i have a bit of knowledge about that already :P

Yea the book is rather old, its was written in 2008/9 or something and i bought it when i was 14 or 15. Never really finished it until recently.

##### Share on other sites
C++ can be a rough road. I took two semesters of the language in college and foud it to be a fun challenge. When it comes to C or C++ I always tell people to look at their end goal and ask a question. Is there a more modern language I can use to achieve my goal? If the answer is yes then use that language. The biggest learning curve is on your first language if you have learned the basics of programming in C++ then interpreting those concepts in modern day languages isn't likely to pose the same challenge as your initial experience.

The simple fact is that you are the artist l. Languages, libraries and frameworks are tools. Always choose the most efficient tools that will allow you to express your vision.

##### Share on other sites

It is easy, only what do you want : something windows ?, that is more difficult, alot to learn.

Get your project where you can program in, and forget all the windows codes, later you can adjust.

Dont forget, test every aspect, add small things and test and fix before adding big things, testing cost more time then programming.

##### Share on other sites

unique_ptr is one of many C++-specific concepts you will have to learn. It's definitely a difficult language to start with; you'd have a far easier time with Python for example. And it's not like Python's limitations would be an issue for you anytime soon; you can write great games and even emulators in it if you want. By the time you're advanced enough to run into some of its limitations, you'll be in a great position to decide where to go from there and whether that's C++ or something else.

Edited by Asik

##### Share on other sites

C/C++ is the best language to learn as a first language.  It shares concepts and keywords with most other high level languages such as C#, Java, Javascript, etc.  Learning it first makes learning those other languages easier, but not necessarily the other way around.  C# is simpler for beginners to avoid mistakes, because it wipes your butt for you a lot, but it also encourages, or at least fails to discourage, bad programming habits, like the infamous failure to deallocate memory and other resources.  It also doesn't really bring anything to the table that I have seen.  Admittedly I've only been using it sporadically for a couple years now, and mostly just for writing scripts in Space Engineers.  Everything I write professionally is in C++ or assembly.

What framework you use is entirely up to personal taste.  Frameworks change more often than the weather, and what is popular today might be deprecated a few years from now.  Understand that I'm coming from 35 years of programming. My first game was written in GW-BASIC (Nuclear Bomber) and everything was line art and sprites.  When I started serious (non-game) programming, DOOM (the original) and Castle Wolfenstein (the Original) were the epitome of high end game development, raster operations where done by the CPU, most of which didn't even have floating point units, graphics cards were little more than VRAM and a DAC.  Over the years I've seen hundreds of frameworks come and go, and even a few languages, but C++ has stuck around.  So I'm not basing my suggestion on some entrenched elitism.  C++ is here to stay.  It has everything a language truly needs and 50+ years of history.  You will never regret learning C++ as your first language.

##### Share on other sites

C/C++ is the best language to learn as a first language.

Highly debatable. It's worth mentioning that the FAQ we tend to guide beginners to advocates against C++ as a first language: https://www.gamedev.net/reference/faq.php/_/for-beginners-r1

##### Share on other sites

C/C++ is the best language to learn as a first language.  It shares concepts and keywords with most other high level languages such as C#, Java, Javascript, etc.  Learning it first makes learning those other languages easier, but not necessarily the other way around.  C# is simpler for beginners to avoid mistakes, because it wipes your butt for you a lot, but it also encourages, or at least fails to discourage, bad programming habits, like the infamous failure to deallocate memory and other resources.  It also doesn't really bring anything to the table that I have seen.  Admittedly I've only been using it sporadically for a couple years now, and mostly just for writing scripts in Space Engineers.  Everything I write professionally is in C++ or assembly.

What framework you use is entirely up to personal taste.  Frameworks change more often than the weather, and what is popular today might be deprecated a few years from now.  Understand that I'm coming from 35 years of programming. My first game was written in GW-BASIC (Nuclear Bomber) and everything was line art and sprites.  When I started serious (non-game) programming, DOOM (the original) and Castle Wolfenstein (the Original) were the epitome of high end game development, raster operations where done by the CPU, most of which didn't even have floating point units, graphics cards were little more than VRAM and a DAC.  Over the years I've seen hundreds of frameworks come and go, and even a few languages, but C++ has stuck around.  So I'm not basing my suggestion on some entrenched elitism.  C++ is here to stay.  It has everything a language truly needs and 50+ years of history.  You will never regret learning C++ as your first language.

• There is no language called "C/C++". There is C, and there is C++, and if you can't name ten differences between the two off the top of your head, you know neither well enough to recommend languages to anyone.
• Sharing "concepts" and "keywords" is less than meaningless in this context. Python has some keywords that overlap with C++. Intercal has some concepts that overlap with C++. All three are vastly different languages.
• Learning programming and learning C++ is a tall order. Learning programming in a more forgiving environment and then diving into C or C++ is much more gentle. This ground is so well-trodden on GDNet that we have a FAQ about it, linked above.
• The fact that you have to try really hard to even make mistakes like memory leaks in C# is a powerful reason to embrace it; C# - like most modern languages - goes out of its way to make it difficult or even impossible to make certain categories of programming errors. It isn't "wiping your butt" and that language is frankly condescending and borderline offensive.
• C# is actually responsible for popularizing a lot of modern programming concepts: generics without type erasure (c.f. Java), first class functions, concurrent garbage collection, LINQ... the list goes on. Even things that C# did not "invent" it did a lot to drive forward into mass adoption.
• If you haven't done professional or even non-trivial programming in C#, why are you advocating against it? By your own statement you don't know the language well enough to make that value judgment for yourself let alone for an impressionable beginner.
C++ is a roaring dumpster fire of a language that was barely saved from extinction by C++11 and C++14. The existence of better languages is largely what has motivated its slow crawl away from stagnant extinction in the past decade. It hardly has "everything" and yet some would even argue it has far too much.

It also doesn't have "50 years of history" unless you count all of its predecessors (C, BCPL, etc.) and even that's tenuous at best.

It's fine if you like the language, but please keep in mind that your personal taste is not objective truth, and what you like is not necessarily the right thing to recommend to a beginner.

Oh, and Wolfenstein 3D was not the "original" Wolfenstein game. That honor goes to, well, Castle Wolfenstein, originally on the Apple II. Edited by ApochPiQ
Afterthought

##### Share on other sites

I wouldnt really call C++ a roaring dumpster fire .. but thats probably because I love it as a language, was the language I started out with all of like a decade ago now. It's not the worst language to start out programming with because as mentioned it really does leave a lot of ways open for you to fuck up so you either end up with poorly made programs or you improve your coding standard fairly fast.

I would say that a transition from a C# programmer would probably be harder than the other way round obviously, though C# is a pretty decent language and it would introduce the key areas without frowning you in "oh god I need to be super careful on my code".

I would still say that learning C++ first is the proper "trial by fire" .. heh "trial by roaring dumpster fire" way to learn programming. Though it wouldnt be suited to everyone.

##### Share on other sites
@gibbonthatcodes

That is a perfect analogy. The first day of my C++ class in college my professor said "I can't really teach you to do this, but I can weed out the people who can't". The course was two semesters we started with 25 ended with a dirty dozen, the instructor was fairly merciless, but we learned a lot. We existed in stark contrast to our joyful Java counter parts, we were working for it and it felt great. When the year was done they had flashier toys, but we had an understanding that went much deeper than theirs.

##### Share on other sites

It's interesting to see how mentalities have evolved. 10 years ago when I started, people would generally agree C++ was the way to go as a first language for game development, and I was the weird guy recommending C# or Python instead. :P

Edited by Asik

## Create an account

Register a new account