Semi-complete Newbie

Started by
33 comments, last by ChaosEngine 5 years, 7 months ago

Hey everyone first time posting here! I was wondering what you all thinks is the best way to learn C++? I'm sorta familiar with Python and C# so I'm not completely new to programming. I want to get into C++ because from my understandings it is widely used for video game programming and that's what I eventually want to do

Edit: Also please correct me if I'm wrong on C++ being a good language to learn for console gaming. Theirs so many sources that I never know what ones to trust!

Advertisement
1 hour ago, Ryan Wood said:

Hey everyone first time posting here! I was wondering what you all thinks is the best way to learn C++? I'm sorta familiar with Python and C# so I'm not completely new to programming. I want to get into C++ because from my understandings it is widely used for video game programming and that's what I eventually want to do

Edit: Also please correct me if I'm wrong on C++ being a good language to learn for console gaming. Theirs so many sources that I never know what ones to trust!

Learning C++ is the same as learning any other language. Pick up good learning materials such as a book like C++ Primer (5th Edition) and work your way through it. Then begin making a lot of programs using the concepts you've learned. The other thing to consider is that as a programmer you're going to learn more than just a few languages, so adding new languages is just like adding new tools to your tool-belt. I actively work in over seven languages depending on the project. C++ has also been widely used for many reasons, such as a lot of development kits required C/C++, platform restrictions, and also many teams have a large established code library built upon C++. I personally was using C++ back in the day due to being able to work on different platforms, and being able to manage memory, it was also a requirement for the APIs I was using. Things are much different now then it was years ago with the vast amount of engines available.

C# has also become very popular in the game development world due to engines like Unity, but if you still want to push forward with C++ you can jump on Unreal for game development, or use the many libraries available.

Regarding console development, you should check which consoles you want to develop on, and what languages those dev-kits require and which engines support the console. Unity with C# is a multi-platform engine and Unreal with C++ is also multi-platform. Both engines will deploy to PS4, Xbox One, and Switch.

I hope this helps!

 

Programmer and 3D Artist

1 hour ago, Ryan Wood said:

Theirs so many sources that I never know what ones to trust!

If you really not a complete newbie,  you have to know that tools for implementation such as programming language etc., have to be selected on task analisis stage to better fit a needs of specific task.

1 hour ago, Ryan Wood said:

Also please correct me if I'm wrong on C++ being a good language to learn for console gaming.

If we talk about videogames it is kind of soft real-time software. "soft" mean that it will no real disaster in case software not meet deadline, just game will become nonplayable. So to have a stable gameplay we have to meet requirements and best practicles of realtime software. Of cource we can not meet some requirments like RT-ready OS but on videogames it not so importent becouse it works with virtual control objects instead of real robotics software, so only link with real-world is a user input that is not time critical becouse user response abilities a much slower than requrments for frame deadlines (On 60 fps it is reuired to draw approx 3 frames between two klicks of double-klick). But we have to follow other common requirments and best practicles of realibile real-time  programming. One of main requirments is predicable time of each separate specific operaton and avoiding of dynamic memory reallocations (it is only way to warranty presence of required memory - have it allocated on start of system. ).  Obviuosly managed languages with automatic garbage collection can not fit it requirements. So we have to select from modern native languages. So we have a 3 options - Pascal, C++ and ADA. Modern dialects of Pascal such as Delphi curently have a specific usage and limited set of supported platforms and also uses not controlled by programmer heap reallocations for strings and arrays. ADA especially designed for real-time applications but have a specific niche and specific sets of language concept mistakes that outclass all advantages of core-implemented  type relations tools, and also ADA design tools is not implementet for most gaming platforms becouse it just have no sence to implement RT language for non-RT OS. So looks like C++ is only (and by my personal opinion is best by language abilities) option for vido games specific tasks.

#define if(a) if((a) && rand()%100)

I might get some flack for this but I would actually learn C before C++. That doesn't mean you have to spend years learning it, just spend some time getting to know the basics and write some small console (as in windows text console, not game console) programs to get familiar with it. You can even write some simple text based games if you want.  There is a certain school of thought that claims you should jump straight into C++, but generally I think this leaves huge holes in your knowledge that will give you problems later on.  After you become comfortable with C you can move on the C++.

When I started learning C years ago I used the book known as K&R (The C Programming Language by Brian W. Kernighan and Dennis M Ritchie).  It's still a pretty good book. It's very concise but it's pretty clearly written and easy to follow.  It's now ridiculously expensive I guess because of snob appeal (people put it on their desk because they think it makes them look hard core or some such), so see if you can get it used.

As for C++ there is always Stroustrup's book which I use. However I don't necessarily recommend it since his writing style isn't so easy to follow sometimes. There are plenty of online sources and plenty of books on amazon. I've know C++ so long, I really haven't looked into it in a long time but check reviews and stuff.

50 minutes ago, Gnollrunner said:

I might get some flack for this but I would actually learn C before C++. That doesn't mean you have to spend years learning it, just spend some time getting to know the basics and write some small console (as in windows text console, not game console) programs to get familiar with it.

Really most of elementary math algos looks on C same as on C++. And it really very importent to study how to implement it on C separately before use C++ to assemply it together to complexe systems with complexive resources managment.

50 minutes ago, Gnollrunner said:

but generally I think this leaves huge holes in your knowledge that will give you problems later on

Really to study object-oriented programming easily, it required to study procedural programming well first, to feel what same on procedural programming concept not enought fit needs of your tasks and better understand for what same you using classes. 

#define if(a) if((a) && rand()%100)

I usually oppose the idea of learning C before C++. I mean, C++ is easier to learn and you will end up using C++ anyway. However, in the game programming case, learning C first might be better as you will know how things work under the hood.

Anyway, general advise would be, you don't have to learn C before C++. You can jump straight to C++ as the basic constructs are almost identical between those two. Just don't start with OOP, and you will be fine :).

Edit: oops, I've just notice OP has experiences in other languages already. So you don't have to start with C in this case. You can start with mapping feature betweens something you already knows and C++.

http://9tawan.net/en/

7 minutes ago, mr_tawan said:

first might be better as you will know how things work under the hood

If you mean "how STL works under the hood" it is must know option for any kind of realtime and reliable programming. Becouse for its purposes only option for STL - do not use its outdated garbage at all and make a own set of similar tools that ready for RT, complexive resources managment and modern concepts of objects lifetime managment.

#define if(a) if((a) && rand()%100)

4 hours ago, Fulcrum.013 said:

 Obviuosly managed languages with automatic garbage collection can not fit it requirements.

Are you saying all managed languages are useless for game development, and should be avoided?

Hello to all my stalkers.

For me, the answer would depend on both where you're starting from, what motivates you to learn and where you want to end up.

As others have said, the majority of low level coding in games is in C++ for performance reasons (typically complete control of memory allocations). However, within gaming, there are multiple layers of coding:

  • The game engine itself (presumably C++)
  • Scripts to control the behaviour of game objects (take your pick here, Lua, Unity uses c# I believe etc.)
  • Tooling - personally, I use C# here

If you're a complete newbie who doesn't know how to code, then TBH I'd start by learning to code in general, i.e. the application of logic using the medium of code. That can be anything from doing hacker rank challenges, to teaching yourself simple ways to get buttons on screen using WinForms etc. This doesn't have to be a long project, just get yourself used to coding anything*. Personally, if I was starting now, I'd pick either c# or python. Both of them come with easy to find dev environments (Visual Studio is free etc.) and there are lots of tutorials and the like available. Both of these will shield you from having to worry too much about memory allocation / deallocation patterns which you would then pick up on your next step (if you wanted to) of C++.

Given that you're not a complete newbie, then I'd be inclined to suggest either:

  1. Use Unity and hence C# to control your game objects
  2. Use the below mentioned UWP approach and write a game using C#. Subsequently porting the code to C++ can be a step 2 if you need to / want to. Certainly for me, going from an event driven view of the world (WinForms / server programming in C#) to a polling based approach (of having to do something 60 times a second and checking whether something else has happened) was a bigger change than the actual language.

Point #1 is probably also more applicable if you're looking at more commercial options I'd guess, unless you desire to be a low level programmer within the team.

Note for games, if you're writing for the Xbox 1, then, under the creators collection program, you can write a UWP application in C# and have it run on the console. Clearly this won't give as much control as the C++ layer would, whether or not that's relevant would depend on your game. As mentioned previously by @Fulcrum.013, if you're dead set on never dropping a frame at 60fps, then get used to C++, if it's a card game or something with simpler requirements, then you'll almost certainly get away with C#.

As for me, I started back in the day with Basic then, C and ARM assembler (1990s) before moving to Java and then to C#. For game creation, C and assembler were kings back in the day. MS introduced XNA which was exciting as I could write a game in the same language I used in my day job (which inspired me to create a game again). MS then realised that with DX10+ that the model they were using wasn't going to work with being able to drive the GPUs fast enough and so they've invested heavily in getting people to use C++ again. Note that the modern versions of C++ are so much easier to use that using it actually isn't that bad (I've certainly removed my hatred of it, but I still prefer C# for everything else in my stack).

Hope this helps

Steve

*My thinking here is that once you understand coding, different languages add / remove portions - especially memory management which can be tricky at first!

6 hours ago, Lactose said:

Are you saying all managed languages are useless for game development, and should be avoided?

Yes. Managed and GC is not acceptable for realtime becouse have unpredicable time of GC and JIT operations and also not able to place a temparary data on stack so uses massive heap reallocations were it not needed.. Also automatic GC limit abilities of automatic objects lifetime managment so it better way to have a memory leaks. Really GC able to collect automatically only garbadge that language core shit   to heap. In case language core not used heap without direct programmer command it just no need a GC. Also GC under hood limit prograamer in garbage collection mechanisms to primitive one that can not be ajusted to specific tasks realities. For example it makes a huge headpain with self deletion of objects and so on. Really semi-automatic strategy that works on 2-way pointers and weak owning an processng lists many tmes much robust, flexble and reliable than managed languages GC. Really  languages wth GC not capable ever to create a good desktop gui framework becouse not allow to complete control a objects lifetame.

#define if(a) if((a) && rand()%100)

This topic is closed to new replies.

Advertisement