Jump to content

  • Log In with Google      Sign In   
  • Create Account


What are the most important things that should make me consider moving to 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.

  • This topic is locked This topic is locked
47 replies to this topic

#1 KappaG3   Members   -  Reputation: 131

Like
0Likes
Like

Posted 12 September 2012 - 08:29 PM

Hello, new user here.

I started to program in C# about a year ago, after having some random general knowledge. Well, things change over time and now I'm pretty confident about my amateur-ish skills in C#.
Lately, though, I'm considering moving to C++. Being used to VisualC# I downloaded its counterpart, Visual C++. Which is good, simple and powerful. Lacks intellisense, but I guess I can deal with it.

Anyway, what really made me consider this option was seeing actual C++ source code. All those "shortcut symbols", pointers and more control over the code were what caught my eye. I'm not entirely sure about what I saw and am trying to code, and this is why I started the thread. Is C++ a viable (and better) option for amateur programmers or is it only useful to more experienced users?

On a related note, what would be a good library to make games in? I'm used to XNA, I think I can shift to something else though. I've heard that it all boils down to OpenGL vs DirectX.

Sponsor:

#2 greenvertex   Members   -  Reputation: 510

Like
6Likes
Like

Posted 12 September 2012 - 09:16 PM

Anyway, what really made me consider this option was seeing actual C++ source code. All those "shortcut symbols", pointers and more control over the code were what caught my eye. I'm not entirely sure about what I saw and am trying to code, and this is why I started the thread. Is C++ a viable (and better) option for amateur programmers or is it only useful to more experienced users?


Back when dinosaurs roamed the earth - and I was still in school - I cut my programming teeth on C/C++. It's not that it's a more "professional" language, it's really just more expressive. This can be good: one could construct exactly the types of things one wants pretty much without exception. This can be bad: one can easily construct themselves into very nasty dark corners of their computers.

Don't let the bad deter you though, it's an incredibly interesting language to learn. One that I've found to be far more elucidating of the workings of a computer than managed languages - Java/C#/AS3/etc. Granted, someone who knows more about it can use it far more elegantly than someone who does not, but that's universally true of all languages. Your first program is not going to be as "good" as your last provided you're always learning and trying new things.

On a related note, what would be a good library to make games in?


I've found SDL to be a pretty good library for making 2D games. There are plenty of tutorials out there for it if you Google around, and there plenty of DirectX/OpenGL tutorials as well if you want to get straight into 3D. As for the language itself, you can get started here or here. The sites themselves will also end up being pretty invaluable resources for the language and the STL once you're ready for that.

#3 KappaG3   Members   -  Reputation: 131

Like
0Likes
Like

Posted 12 September 2012 - 09:28 PM

Thanks vertex, your answer pretty much covers all my questions.
Speaking of the resources you posted, thanks again. I'll surely look into SDL as I need to get familiar with 2D programming, but is it good if I need to use some 3D models? There's a project I want to realize with a friend (who is in the same situation as me, migrating from a managed language to c++) and it could work in 2D, but I was thinking of making it 3D to learn some more while performing almost every calculation on a 2D grid (Tower defense says enough?).

Edited by KappaG3, 12 September 2012 - 09:29 PM.


#4 greenvertex   Members   -  Reputation: 510

Like
2Likes
Like

Posted 12 September 2012 - 09:52 PM

Speaking of the resources you posted, thanks again. I'll surely look into SDL as I need to get familiar with 2D programming, but is it good if I need to use some 3D models?


SDL essentially wraps OpenGL to provide its graphics functionality so you could definitely mix the two. There's a sub set of calls in SDL that allow you to operate directly on the OpenGL context should you need to.

There's a project I want to realize with a friend (who is in the same situation as me, migrating from a managed language to c++) and it could work in 2D, but I was thinking of making it 3D to learn some more while performing almost every calculation on a 2D grid (Tower defense says enough?).


I should warn you that adding a dimension sometimes complicates things severely. Instead of using sprite sheets for characters, for example, you're now skinning animated skeletons, applying textures to them, etc. If you're new to game programming in general, consider taking smaller steps first. If not, by all means, 2D is - mathematically - a subset of 3D so anything expressible in the lower-order dimension is expressible in the higher.

My opinion on the whole 2D/3D argument is that you should consider carefully what you're getting out of using the extra dimension versus what you're adding to your workload to pay for it. If the benefits are clearly there, then that's enough of an argument for. If not, that's enough of an argument against. In your case, I'm not sure you're going to get anything beyond the "cool" factor. Maybe I'm way off on that, but consider it in any case.

#5 greenvertex   Members   -  Reputation: 510

Like
2Likes
Like

Posted 12 September 2012 - 10:11 PM

Quick addendum: you might want to check out SFML over SDL, I just stumbled across another thread where they were talking about it and it appears to be an object-oriented cousin of SDL.

#6 KappaG3   Members   -  Reputation: 131

Like
0Likes
Like

Posted 12 September 2012 - 10:12 PM

Yeah, it would be strictly related to the 'cool' factor, while being essentially a 2D game under most aspects. That's why I tought that making it 3D wouldn't be such a big deal, but I'll take my time to see and consider what I can do.

@Addendum: Even better, thanks again (again Posted Image )!

Edited by KappaG3, 12 September 2012 - 10:12 PM.


#7 Servant of the Lord   Crossbones+   -  Reputation: 17125

Like
3Likes
Like

Posted 12 September 2012 - 10:27 PM

I won't comment on whether the move to C++ is wise or not (I'm not experienced enough in multiple languages to make that call, I mostly just use C++ myself - it's the only language I know in-depth), but if you do make the move to C++, I'd suggest SFML as a good 2D library... and you can use it with OpenGL if you are going to make the move to 3D. SFML will setup the window and handle input, if you want to use OpenGL (OpenGL doesn't handle that stuff for you).

However, DirectX may be a better option overall - I'm not versed enough in the OpenGL vs DirectX debate... but I am familiar with the SDL vs SFML choice (being very experienced in both), and I'd recommend SFML, but either one is a viable option.

It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.

[Fly with me on Twitter] [Google+] [My broken website]

All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.                                                                                                                                                       [Need free cloud storage? I personally like DropBox]

Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal


#8 apatriarca   Crossbones+   -  Reputation: 1603

Like
0Likes
Like

Posted 13 September 2012 - 08:46 AM

What are your objectives? Why do you want to move to the C++ language?

#9 KappaG3   Members   -  Reputation: 131

Like
0Likes
Like

Posted 13 September 2012 - 10:49 AM

What are your objectives? Why do you want to move to the C++ language?

That's what I'm asking in this thread.
Why should I move to it?

Anyway, I've already got enough replies to think that I'll just move to it. I prefer the syntax and it's good to know that I can do more than before, even if maybe I'll need those functions rarely.

Edited by KappaG3, 13 September 2012 - 10:50 AM.


#10 Telastyn   Crossbones+   -  Reputation: 3718

Like
1Likes
Like

Posted 13 September 2012 - 12:31 PM

That's what I'm asking in this thread.
Why should I move to it?


Do you have a bunch of existing code in C++ that's easy to reuse?
Is your team a pile of experienced C++ developers without much exposure to other things?
Does your target platform only support C++, but that's where the money is?
Did your boss/class demand you use it?

These are really the only reasons, given the headaches the language puts on you to use it.

#11 SimonForsman   Crossbones+   -  Reputation: 5770

Like
2Likes
Like

Posted 13 September 2012 - 12:41 PM

Why should I move to it?

Anyway, I've already got enough replies to think that I'll just move to it. I prefer the syntax and it's good to know that I can do more than before, even if maybe I'll need those functions rarely.

First off, you shouldn't move to any language, add languages to your toolbox, change your favourite language but never leave a language behind.
As for reasons to learn C++ there is only 2 good ones in my opinion:

1) Because you have to. I.E it is the only language that can do what you need to do. (This mostly applies to embedded systems or consoles where the language options and system resources can be fairly limited (Allthough C++ is not an option on all platforms, it is however fairly commonly available)).
2) Because you want to learn the language. (It is a fairly good language to know simply because of how widely used it is, (The same goes for C#, Java, Python and a bunch of other languages).

In general it is better to learn languages before you are forced to learn them. (The game industry have fairly good control over their language choices though but if you end up as a consultant maintaining old custom systems for clients things can get very interesting)
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!

#12 greenvertex   Members   -  Reputation: 510

Like
-1Likes
Like

Posted 13 September 2012 - 12:41 PM

These are really the only reasons, given the headaches the language puts on you to use it.


I don't know that "headaches" is the best word for it. C++ simply does things differently than C#. At the end of the day it's all the same to the machine, but sometimes it's worth getting closer to said machine to learn a little more about how it works. I'm pretty emphatic about the fact that my experience with C++ has made me a better developer in other languages. If the ultimate goal here is to learn something new, that should be plenty reason to consider C++, or Java, or Haskell, or any other language really.

#13 laztrezort   Members   -  Reputation: 954

Like
3Likes
Like

Posted 13 September 2012 - 12:48 PM

I'd agree with Telastyn, except for maybe adding "just for the sake of learning it" to the list. Keep in mind that going from C# to C++ you will generally see a massive reduction in productivity. This is even ignoring the time it will take to pick up C++. The only time I have seriously gone back to use C++ in the last 6 or so years is when someone paid me to - and they paid me by the hour.

Going from XNA to DirectX, you will see yet another massive reduction in productivity. This is not meant to discourage, but keep this in mind if your goal is to get a specific project finished, you will need to choose for yourself depending on what your goals are.

#14 Washu   Senior Moderators   -  Reputation: 4469

Like
2Likes
Like

Posted 13 September 2012 - 12:56 PM


That's what I'm asking in this thread.
Why should I move to it?


Do you have a bunch of existing code in C++ that's easy to reuse?
Is your team a pile of experienced C++ developers without much exposure to other things?
Does your target platform only support C++, but that's where the money is?
Did your boss/class demand you use it?

These are really the only reasons, given the headaches the language puts on you to use it.

Quote for truth.

Learning isn't a valid excuse to switch to C++, you can learn C++ on the side in the years to come (and it will take years).

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
ScapeCode - Blog | SlimDX


#15 Serapth   Crossbones+   -  Reputation: 5179

Like
2Likes
Like

Posted 13 September 2012 - 12:58 PM


That's what I'm asking in this thread.
Why should I move to it?


Do you have a bunch of existing code in C++ that's easy to reuse?
Is your team a pile of experienced C++ developers without much exposure to other things?
Does your target platform only support C++, but that's where the money is?
Did your boss/class demand you use it?

These are really the only reasons, given the headaches the language puts on you to use it.


Pretty much this.

There are a few edge cases, but those are exactly that.

I would also be curious to know what C# prevented you from doing. I came to C# from C++ and rarely if ever found myself unable to express certain code adequately. There have been a handful of times I had to pInvoke native code, but interop is certainly one of C#'s strengths ( especially compared to JNI). There are certainly things you do differently between languages, but there are few things I can think of that you can't do in C# that you can in C++. Hell, you can even get remarkably implicit with memory management if for some bizarre reason you really want to.

I will say this... when moving back to C++ there are certainly things I miss. Linq, beautiful link, perhaps being one of the biggest. Although a sensible class library is certainly high up that list.

#16 Memories are Better   Prime Members   -  Reputation: 769

Like
2Likes
Like

Posted 13 September 2012 - 01:08 PM

If you wish to learn C++ go for it, dont abandon C# though, both languages work very nicely together. No one can tell you 'why' you need to learn C++ though, only you can decide on that.

I went from XNA to SlimDX / SharpDX and I didnt regret my decision, sure the learning curve is greater than say an engine or other libraries but honestly after the initial few weeks every problem became fun and a game itself, however I should state my end game was purely to learn with and open schedule on when to stop. This may not be the best advice for you, but if your aim is to learn and you have a generous amount of free time (im talking months to years too) then a lower level graphics library may not be a bad idea.

#17 Telastyn   Crossbones+   -  Reputation: 3718

Like
6Likes
Like

Posted 13 September 2012 - 01:42 PM

At the end of the day it's all the same to the machine, but sometimes it's worth getting closer to said machine to learn a little more about how it works


Even though I disagree that low level languages teach you how the machine works, and even though I disagree that such knowledge is useful for generalist programmers:

Then use C. Then use Assembly. Go write a compiler.

There are better ways to get this sort of knowledge without the gotchas inherent in the language's design.

I'm pretty emphatic about the fact that my experience with C++ has made me a better developer in other languages.


Experience with any language makes you a better developer in other languages. Working with C++ for years made me a better developer once I migrated away from it. The issue is that if I spent more of that time actually programming rather than fighting the language's pitfalls or re-implementing things that every other modern language takes for granted, I would be a far better programmer.

#18 greenvertex   Members   -  Reputation: 510

Like
1Likes
Like

Posted 13 September 2012 - 02:24 PM

Then use C. Then use Assembly. Go write a compiler.


Sure, all of these have plenty to teach. I understand the ultimate logical conclusion here: if you really want to learn how a computer works start building switches. This would also be valuable, but is so far removed from making games it's not worth pursuing in order to make one. In my opinion, C++ is not a bad candidate for making games and learning some things higher-level languages might give you very little to no exposure to. Sure, these languages exist for exactly the reasons you describe: they absolutely make life easier if you're looking to get something done quickly, focus on game play, etc. There is definitely value in that.

There are better ways to get this sort of knowledge without the gotchas inherent in the language's design.


To what are you referring here?

#19 Serapth   Crossbones+   -  Reputation: 5179

Like
1Likes
Like

Posted 13 September 2012 - 02:28 PM

There are better ways to get this sort of knowledge without the gotchas inherent in the language's design.


To what are you referring here?


I am not speaking for him, but I would answer:

- C legacy cruft... ( malloc, stdio, etc )
- the shitastic link process
- the precompiler
- byzantine inheritance rules
- pre-STL C++

Those are the warts that leap immediately to mind, but only really scratch the surface. There are little niggling things too, like scoping rules in for loops or the ++ gotchas.

#20 Telastyn   Crossbones+   -  Reputation: 3718

Like
3Likes
Like

Posted 13 September 2012 - 02:42 PM

In my opinion, C++ is not a bad candidate for making games and learning some things higher-level languages might give you very little to no exposure to.


And I respectfully disagree.

Well, not so much about the second half of that. I agree that you'll learn things that higher level languages give little exposure to; I just think that they're insignificant.

To what are you referring here?


I have about 6 years of history on the forums detailing pitfalls (and a few years before extolling its virtues). Easy enough to find.

I should just write it up one day and link to it.




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