Jump to content


- - - - -

When/Why to Move to C++?

58 replies to this topic

#1 David.M

    Member

  • Members

  • Reputation: 0

Posted 02 September 2011 - 05:42 PM

First let me say that it's strange to ask a question and have 'C++' be the last word (or have it in a quote). "C++?" looks weird. Anyway, on to the questions (kind of).

Background follows this sentence. 2 years ago I took a programming class at school (freshman year of high school) that used VB.Net. I didn't really like VB.Net too much. Last year I did AP Comp Sci (Java) and liked it a lot more. Now it's been about a year that I've been doing Java. I've made a couple simple clones (Pong, Space Invaders-ish game, etc) and made a game that I used to play on my calculator (TI 89) all using Swing. I've recently looked at the Slick2D library and started using it to remake my game. It's a 2D game somewhat similar to Space Invaders but better (Sounds like nonsense I know - nothing is better than Space Invaders).

That covers the background. I've heard a lot of people all over the place though, admittedly, mostly on the internet saying that C++ is used more widely in the gaming industry. I've also heard that beginners shouldn't start in C++ (I just can't put punctuation directly after C++). I haven't taken stock in the common Java myths (Java is too slow, Java can't handle graphics, etc) but do believe that C++ is used more widely. My main questions are: why switch to C++ and how much programming experience should I have before starting in C plus plus? (Work-around :))

I'm planning to do some research into C++ and games both independent of each other and together. I just thought I might get some faster results posting here. I realize that this topic may seem a bit long so I really appreciate your time in reading (and hopefully replying to) this topic.

Ad:

#2 SimonForsman

    Member

  • Members

  • Reputation: 612

Posted 02 September 2011 - 06:13 PM

View PostDavid.M, on 02 September 2011 - 05:42 PM, said:

First let me say that it's strange to ask a question and have 'C++' be the last word (or have it in a quote). "C++?" looks weird. Anyway, on to the questions (kind of).

Background follows this sentence. 2 years ago I took a programming class at school (freshman year of high school) that used VB.Net. I didn't really like VB.Net too much. Last year I did AP Comp Sci (Java) and liked it a lot more. Now it's been about a year that I've been doing Java. I've made a couple simple clones (Pong, Space Invaders-ish game, etc) and made a game that I used to play on my calculator (TI 89) all using Swing. I've recently looked at the Slick2D library and started using it to remake my game. It's a 2D game somewhat similar to Space Invaders but better (Sounds like nonsense I know - nothing is better than Space Invaders).

That covers the background. I've heard a lot of people all over the place though, admittedly, mostly on the internet saying that C++ is used more widely in the gaming industry. I've also heard that beginners shouldn't start in C++ (I just can't put punctuation directly after C++). I haven't taken stock in the common Java myths (Java is too slow, Java can't handle graphics, etc) but do believe that C++ is used more widely. My main questions are: why switch to C++ and how much programming experience should I have before starting in C plus plus? (Work-around :))

I'm planning to do some research into C++ and games both independent of each other and together. I just thought I might get some faster results posting here. I realize that this topic may seem a bit long so I really appreciate your time in reading (and hopefully replying to) this topic.

There is no good answer to these questions really, languages are just tools.

Since you've made a few games allready you should have enough programming experience to be able to pick up pretty much any language.

Almost noone "switches" to C++ , an experienced programmer will know and use multiple languages, C++ is a good language to know and it is quite heavily used in many fields but there are plenty of other languages you should take a look at aswell at some point.
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!

#3 David.M

    Member

  • Members

  • Reputation: 0

Posted 02 September 2011 - 06:15 PM

Thanks for the reply. Good point about never switching as one should certainly be competent in more than a single language. I was meaning switching between main or, if you will, preferred langages.

#4 oler1s

    Member

  • Members

  • Reputation: 329

Posted 02 September 2011 - 06:24 PM

Quote

I've heard a lot of people all over the place though, admittedly, mostly on the internet saying that C++ is used more widely in the gaming industry.
This is true. The problem beginners seem to have is that they then reach an undesirable conclusion: C++ is best language to use for games.

This is absolutely incorrect. What is widely used is not the same as what you need to use. What you need to use depends on your requirements. If it happens to be C++, then it's C++. If not, you need to pick appropriate tools.

Quote

I've also heard that beginners shouldn't start in C++
Also very true. Except in a few circumstances, beginners benefit from picking another easier language. C++ is a hard language, particularly so with the non beginner friendly informational resources.

Quote

why switch to C++
When you hit a requirement that C++ solves. Beginners do not encounter such a requirement.

Quote

how much programming experience should I have before starting in C plus plus
When programming is a language and technology agnostic task for you.

#5 FantasyVI

    Member

  • Members

  • Reputation: 3

Posted 02 September 2011 - 06:25 PM

well first of all before i answer your two question i just would like to say that my answers are based on my personal opinion and experience with c++.

View PostDavid.M, on 02 September 2011 - 05:42 PM, said:

why switch to C++ ?

i think the reason why to switch to c++ is because it is a industry stander language where you can do pretty much any software you want from a simple calculator to a huge 3D software like 3D Max, Adobe Photoshop and 3D - 2D games.
Java is more of a language that deals with web applications and phone software like Nokia, Google Android, HTC ...etc

View PostDavid.M, on 02 September 2011 - 05:42 PM, said:

how much programming experience should I have before starting in C plus plus?

First I just want to emphasize more on my point earlier that what i'm going to tell you is in my personal opinion and experience. first of all i'm not the world greats programer, in fact i think i have a very long way to be any where as good as the other guy.

The first programing language that i learn was Basic, and all i did in it was just a simple "Hello World" program. after a very long research i found out that c++ was the way to go if i want to be a game programer. so i went to YouTube and searched for C++ tutorials and i started teaching myself. and to be honest i found the language very easy to understand, and i didnt understand why was every one telling me dont learn c++ as your first language.

after i finished watching the 20 tutorials videos on YouTube about c++ i want ahead and bought a c++ book and started to read. Yes at first some of the concepts in c++ was hard to understand at first but then when i read it for the second time everything became clear to me, and i was 17 year old at that time, now i'm 19.

so to answer your question, in my opinion if you put your mind to it you will understand everything. so no i dont think you need any programing experience to start learning c++ but in your case you already know java so that will make c++ easier for you to understand since java and c++ and C# are very a like.

once again this is just in my personal opinion.

Until now i'm studying c++ and trying to master it but that would be a long time like any other language out there.
if you want to get into game programing i suggest you to learn the basics of c++ and when you get a good grasp on the language start with SFML ( simple fast multimedia library ) which is a 2D graphic, sound, network library which is based on OpenGL for the 2D graphics.

here is a great great c++ tutorials on YouTube from a guy called The New Boston. check them out.



he also has lots of other tutorials like C#, PHP, Google Android dev, Java, Unreal Engine and many others.

good luck

#6 David.M

    Member

  • Members

  • Reputation: 0

Posted 02 September 2011 - 06:31 PM

Thanks for the replies. Based on what I've heard so far I think I'll get a book and get my feet wet with C++ for maybe a month or so and see how I like it. From there I can decide whether I want to continue in it or not (for the time being). If anybody else has anything to add I'd love to hear it.

#7 ApochPiQ

    Moderator - General Programming

  • Moderators

  • Reputation: 1921

Posted 02 September 2011 - 07:02 PM

Don't be seduced by the apparent "easiness" of C++ and how fast you can get sort-of-working code written, especially coming from syntactically related languages like Java. It may only take a few days (or even hours) to get a simple program done, and once you've gotten that far, it's painfully tempting to go "hey, I know C++ now, that wasn't so bad!"

I wince every time I read someone's personal story where they "learned" C++ in a matter of days/weeks/even months, and then go on to talk about how easy it is and how they don't understand why people warn against it.

This is why C++ is hard. I know people who have been using C++ for years who can't answer those quizzes. I know I can't guarantee that I'd get every question right on the first try, at least not just off the top of my head. And those quizzes just barely scratch the surface of the complexity and difficulty that C++ can present.


There is a vast gulf between "hello world" and a 3D game engine. You can write small, simple, perfectly legal C++ programs forever without running into an issue, and therefore feel justified in your belief that you "know" C++ and can avoid all the dangers of large-scale software development in the language. Then you write something that's actually large, and suddenly it crashes or leaks memory or does all manner of unspeakable evil and you can't tell why - because you never actually knew C++ to begin with.


I don't want to sound like the grouchy old guy who overhypes the dangers of crossing the street; if this sounds hyperbolic or exaggerated, consider carefully that it's not. I'm being deadly serious here. C++ is an immensely powerful tool, but like most powerful tools, it is very easy to use incorrectly. Worse, you can use it incorrectly for years and not know it, until finally you cross that invisible threshold of complexity and the whole thing blows up in your face.

It's kind of like people who accidentally shoot themselves in the head while cleaning their guns. You can look down the barrel of an empty gun and pull the trigger, and live; you might even get lucky enough to do that thousands of times. But if you don't understand that this is a bad idea, and that you're taking a serious risk by doing it, you will eventually splatter your brains all over the place.

The tragedy of beginners learning C++ is that most of them don't understand why they shouldn't look down the barrel to begin with. After all, it only ever goes "click" when you do that, right?

#8 Serapth

    Member

  • Members

  • Reputation: 458

Posted 02 September 2011 - 07:06 PM

Bet this gets your goat then ApochPiQ... :)


Posted Image

My Site: GameFromScratch.com -- Documenting game development from beginning till end.
My Twitter: @Serapth

#9 FantasyVI

    Member

  • Members

  • Reputation: 3

Posted 02 September 2011 - 07:12 PM

View PostApochPiQ, on 02 September 2011 - 07:02 PM, said:

Don't be seduced by the apparent "easiness" of C++ and how fast you can get sort-of-working code written, especially coming from syntactically related languages like Java. It may only take a few days (or even hours) to get a simple program done, and once you've gotten that far, it's painfully tempting to go "hey, I know C++ now, that wasn't so bad!"

I wince every time I read someone's personal story where they "learned" C++ in a matter of days/weeks/even months, and then go on to talk about how easy it is and how they don't understand why people warn against it.

This is why C++ is hard. I know people who have been using C++ for years who can't answer those quizzes. I know I can't guarantee that I'd get every question right on the first try, at least not just off the top of my head. And those quizzes just barely scratch the surface of the complexity and difficulty that C++ can present.


There is a vast gulf between "hello world" and a 3D game engine. You can write small, simple, perfectly legal C++ programs forever without running into an issue, and therefore feel justified in your belief that you "know" C++ and can avoid all the dangers of large-scale software development in the language. Then you write something that's actually large, and suddenly it crashes or leaks memory or does all manner of unspeakable evil and you can't tell why - because you never actually knew C++ to begin with.


I don't want to sound like the grouchy old guy who overhypes the dangers of crossing the street; if this sounds hyperbolic or exaggerated, consider carefully that it's not. I'm being deadly serious here. C++ is an immensely powerful tool, but like most powerful tools, it is very easy to use incorrectly. Worse, you can use it incorrectly for years and not know it, until finally you cross that invisible threshold of complexity and the whole thing blows up in your face.

It's kind of like people who accidentally shoot themselves in the head while cleaning their guns. You can look down the barrel of an empty gun and pull the trigger, and live; you might even get lucky enough to do that thousands of times. But if you don't understand that this is a bad idea, and that you're taking a serious risk by doing it, you will eventually splatter your brains all over the place.

The tragedy of beginners learning C++ is that most of them don't understand why they shouldn't look down the barrel to begin with. After all, it only ever goes "click" when you do that, right?

ok you kind of scared me a little :unsure:
so what do you suggest to do ? i think if you don't code and make mistakes and sometimes shot your self in the foot you will never learn.

#10 David.M

    Member

  • Members

  • Reputation: 0

Posted 02 September 2011 - 07:19 PM

Thanks for that ApochPiQ. You do bring up great points. I can definitely empathize with your feelings on people spending little time in a language and thinking that they are competent with it. I was thinking of getting a good book to learn from by people that really know what they're doing (I generally hate YouTube and such 'tutorials) and spending about a month learning the basics and see how I like it. Sort of test driving the car before I decide to buy. Does that seem good to you and, secondly, could you recommend such a book or learning resource?

#11 Serapth

    Member

  • Members

  • Reputation: 458

Posted 02 September 2011 - 07:40 PM

The book situation for C++ is actually pretty piss poor. That Stroustrups book is one of the best recommendations is telling ( as its a very difficult read ). C++ without Fear is probably the hands down best beginners text.

That said, if you do pursue C++ ( and like Apoch, I generally recommend against it ), you MUST buy Effective C++. It is singly the best C++ treatise ever written, and will make you a better programmer. There are only a handful of EUREKA!!! texts out there, and this is one of them.
My Site: GameFromScratch.com -- Documenting game development from beginning till end.
My Twitter: @Serapth

#12 laztrezort

    Member

  • Members

  • Reputation: 101

Posted 02 September 2011 - 08:13 PM

View PostSerapth, on 02 September 2011 - 07:40 PM, said:

That said, if you do pursue C++ ( and like Apoch, I generally recommend against it ), you MUST buy Effective C++. It is singly the best C++ treatise ever written, and will make you a better programmer. There are only a handful of EUREKA!!! texts out there, and this is one of them.

I want to add my 2cents here to wholeheartedly agree about Effective C++, it is the single most important book I've ever read on the subject. That said, it isn't for the beginner or feint of heart - but then, as has been pointed out, neither is C++.

#13 Serapth

    Member

  • Members

  • Reputation: 458

Posted 02 September 2011 - 09:18 PM

View Postlaztrezort, on 02 September 2011 - 08:13 PM, said:

View PostSerapth, on 02 September 2011 - 07:40 PM, said:

That said, if you do pursue C++ ( and like Apoch, I generally recommend against it ), you MUST buy Effective C++. It is singly the best C++ treatise ever written, and will make you a better programmer. There are only a handful of EUREKA!!! texts out there, and this is one of them.

I want to add my 2cents here to wholeheartedly agree about Effective C++, it is the single most important book I've ever read on the subject. That said, it isn't for the beginner or feint of heart - but then, as has been pointed out, neither is C++.

Actually, the ability to comprehend that book is a good litmus test for if you should (yet) even be bothering with C++ or not. It is not an especially difficult book to understand, as it is exceedingly well written, but you need a certain amount of exposure to programming before you can really appreciate what the book is teaching.
My Site: GameFromScratch.com -- Documenting game development from beginning till end.
My Twitter: @Serapth

#14 kuramayoko10

    Member

  • Members

  • Reputation: 6

Posted 02 September 2011 - 09:22 PM

Quote

I wince every time I read someone's personal story where they "learned" C++ in a matter of days/weeks/even months, and then go on to talk about how easy it is and how they don't understand why people warn against it.
Correct me if I am wrong... I believe that learning a language never stops. I mean, I study Computer Science, I have already taken advance courses on C,C++,Java and implemented advanced data structures, etc. But everyday I try doing something different, I discover a new thing about the language I have never imagined before.

@topic
Let's put some facts on the table:
  • C++ is greatly used on the industry because it is, until now, the best language to manipulate the lowest levels of your system and still be user friendly.
  • Because it access low level features of your system, you can program it to be as fast and powerful you wish it to be.
  • Now the important one, "With great power comes greater responsibility" - Stan's Lee teaching is perfectly applied here. Because you can go deep down the system, it will be likely to you to commit fatal errors, etc.
Now read the facts above with attention. None of them should scare you... they should challenge you, and that is a great thing for a programmer -> to be challenged, to seek more knowledge, true knowledge (not superficial stuff like what I am writing here xD)

My suggestion:
  • Learn everything you can about Object Oriented Programming. This is the soul of C++, Java etc. This is what gives us the power with a beautiful weapon in hands!
  • Don't be afraid to test everything you imagine on C++. If you think it would be cool to declare a pointer to an array of 10 positions and make that array move 20 steps instead. Do it, watch your system throw garbage at you, crash, etc.
  • When we clarify a doubt (like the tests above) it really gets stored on our brains (HD). Doing what we are told to do (good examples on books) are stored on volatile RAM memory that gets erased on sleep.
At last, dont think about C++ (and other languages) as a bunch of obscure syntax that are there to annoy you with errors, instead draw its little pieces on a paper, draw your program communicating with your system, draw all the pointers walking through your memory, make it real to you. And don't forget to learn everything about Object Oriented programming...

Enough of long answers =D
Hope it helps! (It helped me =D)
Programming is an art. Game programming is a masterpiece!

#15 Fekete

    Member

  • Members

  • Reputation: 2

Posted 02 September 2011 - 09:30 PM

Instead of starting with C++, why not start with C?

It's a crazy idea, but C++ really builds off of C.

Yes, C++ is an Object Oriented language whereas C isn't; thus they are different languages arguably, but get used to the syntax first and then worry about OOD design - Design of any kind is done before coding thus should be studied separately from coding. Since C++ offers so much more than C, you may feel overwhelmed at first.

Just try C, you'll be learning C++ at the same time, basically. :)

Learn the *pointers, memory allocation, structs, enums, etc. And then move onto classes, (which you'll find remarkably similar to structs syntactically at least), templates, overloaded operators, etc.

*emphasized because pointers tend to be a pain until you get used to them.

#16 Serapth

    Member

  • Members

  • Reputation: 458

Posted 02 September 2011 - 09:42 PM

View PostFekete, on 02 September 2011 - 09:30 PM, said:

Instead of starting with C++, why not start with C?

It's a crazy idea, but C++ really builds off of C.

Yes, it's an Object Oriented language whereas C isn't; thus they are different languages arguably. Since C++ offers so much more than C, you may feel overwhelmed at first.

Just try C, you'll be learning C++ at the same time, basically. :)

Learn the *pointers, memory allocation, structs, enums, etc. And then move onto classes, (which you'll find remarkably similar to structs syntactically at least), templates, overloaded operators, etc.

*emphasized because pointers tend to be a pain until you get used to them.







This is basically a mistake.

C++ was a (mostly) superset of C... when it was created, in 1983. Since then, many many things have changed in both languages. C99 is vastly different than K&R C.


More importantly, C++ was built on the bones of C as much out of necessity as any other reason. Put simply, C was a popular language of the day, so "being a better C" was a good trick for language adoption. To this day the language creator says the weakest points of C++ are from the inherited bits from C, and in many cases I agree with that. ( Although I think Bjarne Stroustrup is horrifically incapable of being introspective and acknowledging the many other flaws in his baby that he can't blame on other people, nor can he acknowledge that strengths of new languages like C#, of which he is horrifically dismissive. In some ways he is the ultimate C++ language troll, but at least, he has a good reason to be! ).


Anyways... anyone learning C++ today as "a better C" are doing it wrong, massively wrong. Hell, to someone learning and mastering C++ today should do everything in their power to avoid pointers and memory allocation, which are goals of what the newest C++ standard have worked towards. If you are constantly fiddling with bits and pointers with C++ these days, you are using it wrong.
My Site: GameFromScratch.com -- Documenting game development from beginning till end.
My Twitter: @Serapth

#17 Gamer Gamester

    Member

  • Members

  • Reputation: 21

Posted 02 September 2011 - 09:42 PM

Don't feel the need to switch to C++. This has got to be one of the most common traps for beginners. Anyone who advises otherwise is probably a good example of the Dunning-Kruger Effect.


Learn multiple languages -- this is a great idea. But as a beginner, I would only learn C++ as an academic exercise (sort of like learning assembly), not as a practical one. Does C++ have practical uses?... yes, but not for beginners. A beginner (or even intermediate) programmer is simply not skilled enough to make anything that requires C++. Think AAA console games that push the hardware as far as possible... are beginner's making these things? Are these games the next logical step after Space Invaders?

Whatever you do next will not require C++, and this language will just get in the way (unless your goals are purely academic and you don't care if you produce anything tangible).

Want a fun new language to try? Try Python or JavaScript. You'll learn a ton and grow as a programmer. These languages are usually even easier to work with than Java. And don't be scared off by my use of the word "easier". Some of the most skilled programmers out there use these languages to do amazing things. Many imply that using an easier language implies that you're stupid... in actuality it's the opposite: using the tools that makes your tasks easiest is very smart. The problem of programming is one of managing complexity. Anything you can do to reduce this complexity is good for you.

Heed our warnings: The most dangerous aspect of C++ is that, upon first examination, it feels like you understand it. The language appears "not as hard as they say it is" -- and this leads to the conclusion: I must be a genius! The reason so many people warn away from C++ is because most people aren't as brilliant as I.

#18 ApochPiQ

    Moderator - General Programming

  • Moderators

  • Reputation: 1921

Posted 02 September 2011 - 09:48 PM

View Postkuramayoko10, on 02 September 2011 - 09:22 PM, said:

Correct me if I am wrong... I believe that learning a language never stops. I mean, I study Computer Science, I have already taken advance courses on C,C++,Java and implemented advanced data structures, etc. But everyday I try doing something different, I discover a new thing about the language I have never imagined before.

You're absolutely right, and this is certainly the right attitude to approach programming with. I definitely wouldn't claim to have "stopped" learning in any language, especially not C++.

What I'm warning against is people who think they are done learning just because they wrote Program X and it appeared to work.




#19 oler1s

    Member

  • Members

  • Reputation: 329

Posted 02 September 2011 - 09:53 PM

If you think C++ is about low level access, give examples. Also, do you think C++ is portable?

C++ is a nuanced language. If you think it's not, try answering this question, which is a repost of a question I saw earlier:

What is the difference between: A *a = new A; and A *a = new A();

Answer that without Googling.

#20 Serapth

    Member

  • Members

  • Reputation: 458

Posted 02 September 2011 - 09:56 PM

View Postoler1s, on 02 September 2011 - 09:53 PM, said:

What is the difference between:
A *a = new A;
and
A *a = new A();

Answer that without Googling.

Pshhhh, that's easy.


()



:D
My Site: GameFromScratch.com -- Documenting game development from beginning till end.
My Twitter: @Serapth






We are working on generating results for this topic
PARTNERS