New to C++, could I get advice? (switching from C#)

Started by
17 comments, last by Dagz 12 years, 1 month ago
My experience with programming is C# and XNA, but I'm wanting to branch out and start using C++ as from what I've heard it's much more powerful and I don't have the overhanging shadow of microsoft. It's not that I ever expect to program a game so awesome that I might be able to sell it, but it's rather unsettling that. if such events did obtain, the game would be partially owned by microsoft (from what I hear). Regardless, I feel some what immature using XNA and that to really develop my abilities I need to start using C++.

I've been reading some C++ tutorials and have a fair enough grasp of the language, , but now I'm wanting to start working towards something a little more tangible. Of course with XNA the graphics and user input was taken care of, so I have absolutely no understanding of opengl or directx. The major pro's and cons of the two seem to be that opengl is more powerful and efficient and can run on practically all hardware, where as directx is weaker and lacking in these qualities but much easier to learn. I'm really not sure which to go for; I guess easy to learn outweighs less powerful, as I'm teaching myself. It would be nice to get feed back on this from more experienced programmers, though.

Also, for which ever you ultimately suggest, could you offer good beginner through intermediate tutorials which cover everything one might need to know? Up until now I've been looking only at opengl tutorials, and I do not understand anything. Any help I could get in this would be appreciated so much.
Advertisement

as from what I've heard it's much more powerful


This is incorrect.


if such events did obtain, the game would be partially owned by microsoft (from what I hear).


This is more incorrect.


Regardless, I feel some what immature using XNA and that to really develop my abilities I need to start using C++.


Likewise, incorrect.


The major pro's and cons of the two seem to be that opengl is more powerful and efficient and can run on practically all hardware, where as directx is weaker and lacking in these qualities but much easier to learn.


Sensing a trend yet? Incorrect. OpenGL does tend to have better driver support across operating systems. DirectX tends to be more consistently supported where it is available.


If you can do things with C# and XNA, keep doing them. Do cooler, better things. 'Reading some C++ tutorials' is not sufficient to have a fair grasp of the language. If you're going to move (and I highly encourage you not to), writing programs is the only way. Even then, C++ will bite you in the ass a few dozen times before DirectX or OpenGL are suitable libraries to pick up.
At the risk of simply repeating what Telastyn has said above, I feel it's worth re-enforcing some of the points made:


the game would be partially owned by microsoft (from what I hear)

This is absolutely 100% incorrect. Microsoft do not own any games or other software you make using either C# or XNA, even if you're using the freely available tools they provide. Furthermore, they've made the C# language an open standard, meaning they do not have sole control over the language.


I'm wanting to branch out and start using C++ as from what I've heard it's much more powerful

This one is something you often hear from people who don't really know what they're on about; it's not uncommon for them to still be reasonably skilled, and perhaps even to have released some really cool products, but the moment they say one language is "more powerful" it should trigger alarm-bells.

The term "powerful", when relating to a programming language, is pretty poorly defined, and doesn't have much real meaning.
Programming languages can be expressive; that is, more or less easily able to explain a given concept or idea, and this can be an important factor in language-choice.
Most of the time when discussing "power" of a programming language people are suggesting that programs written in that language will be less performant (i.e. slower) than others; this is actually an effect of the compiler or interpreter, the running environment, and most importantly of all the programmer who wrote the code. As a beginner it's going to be a LONG time (if ever) where you run into a performance problem because of your language choice rather than because of how you used the language.

Software written in C# can in some cases run more slowly than a counter-part written in C++ -- but that isn't by all means something that happens all the time, and it's even rarer that the difference (if one exists) actually matters. As a beginner programmer, you'll also almost certainly make more costly (in terms of program performance) mistakes with C++ than with C#, meaning that for you C++ would actually result in slower code execution.

Remember also that developer time (in this case that means your time) is valuable, and a more expressive language or one with a better tool-set is an easy way to save yourself from wasting this valuable asset.


I feel some what immature using XNA

That's a pretty common feeling, but it's also a pretty baseless one that you would do well to let go of. It's common in professional development to use existing middleware solutions or engines rather than wasting time implementing low-level solutions yourself, and if you have aspirations of one day entering the industry you would do well to be experienced at using such solutions; if you're not interested in an industry job, there's no reason at all to have to write your own lower level code, and you're just making more boring work for yourself writing the same old code to open a window and draw triangles on the screen rather than simply getting straight to the interesting game-play specific stuff. See for example some of the professional titles that use Havok physics rather than wasting time writing their own implementation, or the massive list of games that use Unreal Engine.

If you want to learn the low-level stuff and implement things for yourself that's a perfectly valid personal choice, and you're certainly welcome to take that path -- but don't feel it's something you need to do -- in many (perhaps even most!) cases professionals don't waste their time working at a lower level, and there's no reason you should feel the need to either.

...stuff about OpenGL vs. DirectX...[/quote]
The choice between these two is often just personal preference... but interestingly enough, the things you've listed are pretty much the opposite of what I normally hear. DirectX tends to be more consistently supported, and a lot of people consider OpenGL easier to get started learning.

Obviously DirectX is only available on Windows systems, but other than that the two APIs are very similar in capabilities, and if you learn either one well it should not be a big deal to later pick up the other if needed.



Honestly, I would STRONGLY suggest sticking with C# and XNA, so that you can be making much more awesome things much sooner and with less effort, and build a portfolio of completed projects, whilst still learning valuable skills that you can later transfer to C++, DirectX, Java, or whatever you might feel the need to learn in future.


It's your choice if you want to pursue C++ instead though -- if you really want to go down that path, I would suggest starting out with a higher level API such as SDL or SFML rather than either OpenGL or DirectX to start with -- although from your comment about "reading some C++ tutorials" I would suggest that you might need to actually write some programs rather than simply reading before moving on to a graphics API.



Hope that's helpful, and good luck! smile.png

- Jason Astle-Adams


[quote name='Dagz' timestamp='1331604151' post='4921543']
I feel some what immature using XNA

That's a pretty common feeling, but it's also a pretty baseless one that you would do well to let go of. It's common in professional development to use existing middleware solutions or engines rather than wasting time implementing low-level solutions yourself, and if you have aspirations of one day entering the industry you would do well to be experienced at using such solutions; if you're not interested in an industry job, there's no reason at all to have to write your own lower level code, and you're just making more boring work for yourself writing the same old code to open a window and draw triangles on the screen rather than simply getting straight to the interesting game-play specific stuff. See for example some of the professional titles that use Havok physics rather than wasting time writing their own implementation, or the massive list of games that use Unreal Engine.

If you want to learn the low-level stuff and implement things for yourself that's a perfectly valid personal choice, and you're certainly welcome to take that path -- but don't feel it's something you need to do -- in many (perhaps even most!) cases professionals don't waste their time working at a lower level, and there's no reason you should feel the need to either.
[/quote]

Getting used to working with middleware isnt the most important skill you need to pick up I found. I found that getting used to working within a codebase that is enormous is far more challenging. As you need to figure out if what you want to do is already written and if so who wrote it if you can't make sense of what they wrote and how to use it, and then there are the cases when the author has left the company.

Some of us do actually spend their waking hours fixing and maintaining these lower level systems and somethimes you actually have to dive into those levels when the middleware doesn't support what you want to do. A basic understanding of what is being done in the middleware is always necesary so writing these lower level systems can be extremely helpfull and teach you new things. Having said all that this is certainly not were a beginner should spend their time, once you are comfortable writing code in your chosen language is the point at which you can start looking at these things.

Side note: You are a gameplay programmer right. Graphics, physics, UI, audio and general programmers focus on different things and game play code is boring to them.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion

First of, I'm a C++ engineer for almost 12 years now. You would never be able to create souch rich context as in XNA in souch a short period of time. The main problem is, that C++ in theory offers too much but in praxis provides very little. For example, thare are no strings in C++. You have to use array of buffers or you take STL. But, if you take STL, there is no guarantee that it is fully supported on Linux. Besides, many compilers do not even support STL by default, you have to download some additional libraries. When you get the libraries, you'll most probably run into compiler issues.

Also, there are almost no usable C++ classes out of the box. You need to provide them by yourself. Even OpenGL. You can't load a signle texture seeking for the code to open BMP or don't even think about DDS. Once you solve that, most probably with a library, that library will most offen not work cross platform. So you get stuck again.

And directx? Compared to XNA ? Oh dear jesus. Did you know, there are no classes except for the Gui? Everything is so basic in C++, you get down to ints and floats. There is no model class, there is no resource manager, there is no audio manager. You need to write / provide wrappers by yourself.

At the beginning it is interesting, but as more time you put into it, the more pitfalls come up and you get frustrated.

If you're not able to finish a game in XNA you will never be able to finish it in C++. That's my practical answer.

C++ simply offers to little in praxis. You should take a tool where you can quickly provide results. That's not C++. That's XNA.

First of, I'm a C++ engineer for almost 12 years now. You would never be able to create souch rich context as in XNA in souch a short period of time. The main problem is, that C++ in theory offers too much but in praxis provides very little. For example, thare are no strings in C++. You have to use array of buffers or you take STL. But, if you take STL, there is no guarantee that it is fully supported on Linux. Besides, many compilers do not even support STL by default, you have to download some additional libraries. When you get the libraries, you'll most probably run into compiler issues.


Wait what ?

Using the standard library does not cause any problems on Linux, gcc has solid support for C++98 and C++03 and when it comes to C++11 both gcc and clang are ahead of msvc++. There are plenty of disadvantages to using C++ but compiler support for the language isn't one of them.
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
Without wishing to start a "holy war", you don't need to use C++.

C++ is a very difficult language - I think very few people can get it right, in particular, the way that inheritance works (notwithstanding memory management issues) tends to catch out even the most experienced C++ coder.

I think you'd be much more productive in anything except C++ (except possibly, C)

[quote name='Samurai Jack' timestamp='1331641569' post='4921630']
First of, I'm a C++ engineer for almost 12 years now. You would never be able to create souch rich context as in XNA in souch a short period of time. The main problem is, that C++ in theory offers too much but in praxis provides very little. For example, thare are no strings in C++. You have to use array of buffers or you take STL. But, if you take STL, there is no guarantee that it is fully supported on Linux. Besides, many compilers do not even support STL by default, you have to download some additional libraries. When you get the libraries, you'll most probably run into compiler issues.


Wait what ?

Using the standard library does not cause any problems on Linux, gcc has solid support for C++98 and C++03 and when it comes to C++11 both gcc and clang are ahead of msvc++. There are plenty of disadvantages to using C++ but compiler support for the language isn't one of them.
[/quote]

I am going to make the assumption that he is talking about embedded or mobile systems running linux. For example, the Android ndk requires a little bit of trickery to get the STL working.

I would say the C++ is more powerful than many languages because of the low-level access it gives (bitwise operations, pointer arithmetic, etc); however, that low level power helps very little when making a game, and can add quite a bit of complexity. It is necessary when making something like an operating system or driver, but you don't need those for game programming. That said, from what I have read C# is just as powerful. It has many of these operations disabled by default because they can be "unsafe", but they are available.

My reason for choosing C++ over C# is cross-platform compatibility. Mono and C# are available for linux, but last time I checked it didn't have much in the way of graphics support (granted that was a few years ago). I also feel much safer about C++ being supported on any new platform I choose to develop. That said, when I do programming in Java I am much, much more efficient because of how expansive the standard java library is; C# has this same advantage.

Whether you should learn C++ or not depends a lot on why you want to learn it. If you want to learn it so that you can make games that run faster, don't bother. If you want to make games that are cross-platform, java might still be a better approach. If you want to simply develop your skills, I highly encourage it. If you are hoping to work on games for a AAA studio someday, I would consider C++ a must; although, you can probably get in the door with C#, as a lot studios develop tools in C# because it is quicker.

I would also say that writing some low level classes in C++ can give you a deeper appreciation for when which classes are useful.
I started software development in a time where MS state of the art compiler was the MS C-6.0 Compiler. I learned C++ software engineering with the next generation Compiler MS C/C++7.0 compiler and since than I never stopped developing software in C/C++.

Both languages C and C++ gives you a huge variance in how to organize your code, how to organize your data structures and many other things that make up the development of a software system. But on the other hand the same variance gives you the possibility of misunderstanding concepts of these languages.

I found that only a few C/C++ software engineers are able to create easy to understand and easy to maintain systems. But these few are doing nothing else than developing software architectures and the basic structures of software systems the whole day.

So I think, if you do not want to learn C/C++ for the next years every day again and again, you should start with some other language.

...


STOP READING WOLFIRE BLOG biggrin.png biggrin.png

Anyway... the answers above sum it up pretty well. What you've heard is pretty much wrong all the way.
Having said that, learning C++ won't harm you, it can only make you a better programmer and also more likely to score a job in the game industry in the engine development department, if that's where your heart is at.

Also, don't fall into the flame wars..OpenGL, DX... learn it all, leave the flame wars to clueless teenagers.

Stefano Casillo
TWITTER: [twitter]KunosStefano[/twitter]
AssettoCorsa - netKar PRO - Kunos Simulazioni

This topic is closed to new replies.

Advertisement