Jump to content

  • Log In with Google      Sign In   
  • Create Account

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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
18 replies to this topic

#1 Dagz   Members   -  Reputation: 110

Like
0Likes
Like

Posted 12 March 2012 - 08:02 PM

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.

Sponsor:

#2 Telastyn   Crossbones+   -  Reputation: 3726

Like
1Likes
Like

Posted 12 March 2012 - 09:05 PM

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.

#3 jbadams   Senior Staff   -  Reputation: 18609

Like
0Likes
Like

Posted 12 March 2012 - 09:52 PM

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...

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! Posted Image

#4 NightCreature83   Crossbones+   -  Reputation: 2826

Like
1Likes
Like

Posted 13 March 2012 - 03:32 AM


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.


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, Mad Max

#5 Samurai Jack   Members   -  Reputation: 212

Like
-8Likes
Like

Posted 13 March 2012 - 06:26 AM

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.

#6 SimonForsman   Crossbones+   -  Reputation: 6110

Like
5Likes
Like

Posted 13 March 2012 - 07:13 AM

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.
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!

#7 markr   Crossbones+   -  Reputation: 1653

Like
0Likes
Like

Posted 13 March 2012 - 09:53 AM

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)

#8 Zael   Members   -  Reputation: 154

Like
0Likes
Like

Posted 13 March 2012 - 10:03 AM


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.


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.

#9 Tribad   Members   -  Reputation: 855

Like
1Likes
Like

Posted 13 March 2012 - 10:28 AM

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.

#10 kunos   Crossbones+   -  Reputation: 2207

Like
1Likes
Like

Posted 13 March 2012 - 11:09 AM

...


STOP READING WOLFIRE BLOG Posted Image Posted Image

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
Lead Programmer
TWITTER: @KunosStefano
AssettoCorsa - netKar PRO - Kunos Simulazioni

#11 kunos   Crossbones+   -  Reputation: 2207

Like
1Likes
Like

Posted 13 March 2012 - 11:20 AM

First of, I'm a C++ engineer for almost 12 years now.


How come that every single time somebody starts like this on a forum the post ends up being ahemm... pretty incorrect? :P
Stefano Casillo
Lead Programmer
TWITTER: @KunosStefano
AssettoCorsa - netKar PRO - Kunos Simulazioni

#12 Dagz   Members   -  Reputation: 110

Like
0Likes
Like

Posted 13 March 2012 - 11:30 AM

Okay thanks guys, I'll take your advice and stick with XNA and C#. I'm suprised I got 9 replies in only one day, this community must be quite active.

#13 daviangel   Members   -  Reputation: 600

Like
0Likes
Like

Posted 13 March 2012 - 05:28 PM

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.

DittoPosted Image
Don't talk about writing games, don't write design docs, don't spend your time on web boards. Sit in your house write 20 games when you complete them you will either want to do it the rest of your life or not * Andre Lamothe

#14 jbadams   Senior Staff   -  Reputation: 18609

Like
0Likes
Like

Posted 13 March 2012 - 05:32 PM

First of, I'm a C++ engineer for almost 12 years now.

You mean "you're a C++ engineer from 12 years ago"? The rest of your response might make more sense in such a context.

I don't think this is the place for a line-by-line look at your post, which would be rather off-topic in the current discussion, but suffice it to say that some of your views about C++ standard library and compiler support (both of which are actually quite good) don't really apply any more, or are only relevant when talking about embedded or console development that would not be of interest to a beginner.

I do appreciate the main point you were trying to make in support of C# and XNA, but misinforming a beginner about some of the problems with C++ isn't really a good way to make the point. Posted Image

#15 Nypyren   Crossbones+   -  Reputation: 4303

Like
0Likes
Like

Posted 13 March 2012 - 08:31 PM

...because of the low-level access it gives (bitwise operations...


Low-level? "You keep using that word. I do not think it means what you think it means."

#16 NightCreature83   Crossbones+   -  Reputation: 2826

Like
0Likes
Like

Posted 14 March 2012 - 05:39 AM

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.

You won't get your foot in the door with only knowing C#, at least not on a game team that is using C++ as the main game language. The games industry doesn't really allow you to learn a language from scratch on the job if that is the main teams language. Now learning C# on the job however does happen, but defenitly not C++ from a beginner level, your application will be looked and and discarded if the job requires C++.
Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, Mad Max

#17 Memories are Better   Prime Members   -  Reputation: 769

Like
0Likes
Like

Posted 14 March 2012 - 05:52 AM

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 am rather curious about where you heard this as OpenGL is known to be easier to learn than DirectX and both are equal in terms of what can be achieved (although I prefer the way DirectX is structured).

Anyway you dont have to leave C# to use DirectX / OpenGL, theres well known stable wrappers that have all the benefits of DirectX / OpenGL, have a look at SharpDX, SlimDX or OpenTK and if you are still worried about performance, which tbh you shouldnt be as the performance difference is unnoticeable, have a look at http://code4k.blogsp...11-apis-vs.html it is an old thread and I typically avoid benchmarking articles but it does give an idea on how close C# can be to C++

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


This.

Comparison wars happen with everything, ranging from programming to politics (theres even a Egg vs Tofu war :S), nothing except for flaming and bitching occurs in these wars, the smart people are the ones who learn both areas. In the end you will likely get flamed for anything you use, I get slack all the time for preferring SQL Server over MySQL and picking .net over Java. However as one evil genius once said (and I love this quote) "You can either succeed in one area, or ultimately fail trying to master two", this isnt to say you should stick with C# for the rest of your life, its to say take one area at a time.

#18 SimonForsman   Crossbones+   -  Reputation: 6110

Like
0Likes
Like

Posted 14 March 2012 - 09:43 AM


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 am rather curious about where you heard this as OpenGL is known to be easier to learn than DirectX and both are equal in terms of what can be achieved (although I prefer the way DirectX is structured).

Anyway you dont have to leave C# to use DirectX / OpenGL, theres well known stable wrappers that have all the benefits of DirectX / OpenGL, have a look at SharpDX, SlimDX or OpenTK and if you are still worried about performance, which tbh you shouldnt be as the performance difference is unnoticeable, have a look at http://code4k.blogsp...11-apis-vs.html it is an old thread and I typically avoid benchmarking articles but it does give an idea on how close C# can be to C++

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


This.

Comparison wars happen with everything, ranging from programming to politics (theres even a Egg vs Tofu war :S), nothing except for flaming and bitching occurs in these wars, the smart people are the ones who learn both areas. In the end you will likely get flamed for anything you use, I get slack all the time for preferring SQL Server over MySQL and picking .net over Java. However as one evil genius once said (and I love this quote) "You can either succeed in one area, or ultimately fail trying to master two", this isnt to say you should stick with C# for the rest of your life, its to say take one area at a time.



It is perhaps worth mentioning that the benchmark you linked primarily measures the cost of API calls (native calls have quite a bit of overhead in managed languages), The overall performance difference in an actual application will most likely be far lower.
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!

#19 Dagz   Members   -  Reputation: 110

Like
0Likes
Like

Posted 14 March 2012 - 06:33 PM

:/

I am rather curious about where you heard this as OpenGL is known to be easier to learn than DirectX and both are equal in terms of what can be achieved (although I prefer the way DirectX is structured).

From people who I suppose were no better informed than me.

Anyway you dont have to leave C# to use DirectX / OpenGL, theres well known stable wrappers that have all the benefits of DirectX / OpenGL, have a look at SharpDX, SlimDX or OpenTK and if you are still worried about performance, which tbh you shouldnt be as the performance difference is unnoticeable, have a look at http://code4k.blogsp...11-apis-vs.html it is an old thread and I typically avoid benchmarking articles but it does give an idea on how close C# can be to C++

Thanks, yes I have descided to stick with C# and continue using XNA. I'm planning to start trying to duplicate many of the features of the game Ragnerok Online. I love tilebased/3rd person/mouse action games like RO, and I'd like to make one like it some day. Happily I've found a website that's ripped a ton of sprites from the game, creating graphics is such a hassle :P




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS