Jump to content

  • Log In with Google      Sign In   
  • Create Account


C++ As First Language


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
72 replies to this topic

#1 shadowstep00   Members   -  Reputation: 478

Like
0Likes
Like

Posted 11 July 2012 - 04:32 AM

Ok guys i have been hearing a lot about how bad C++ is as a first language. Well before i had read this topic here:http://www.gamefromscratch.com/post/2011/08/04/I-want-to-be-a-game-developer.aspx

I had already started learning C++ with this book C++ Primer Plus and went ahead till the second chapter with no real problems. The book has learned me so far how to creat functions, some statements and explained about the prepocessor directives,directives and very little about classes and objects. Well i had no prior experience from any other programming language but still i think i got how things work till now.

So my final question is.. Is really C++ that hard for a begginer? is it impossible to learn C++ as first language? or it just requires some more dedication than other languages? or maybe i just havent got to the difficult things yet....


PS. After i read that article that i mentioned before i started learning C# but it really didint got my attention so much and also the books where not traditional like those of C++ which first learn you how to write "hello world" , variables ect... Most of C# books empasize fist on Visual Studio and dont get you to the basics of the language first. I would like to work on a book that first learns me how to write and then introduce me to Visual Studio.

Sorry for my English.

Failure is not an option...


Sponsor:

#2 SimonForsman   Crossbones+   -  Reputation: 5973

Like
6Likes
Like

Posted 11 July 2012 - 04:42 AM

So my final question is.. Is really C++ that hard for a begginer? is it impossible to learn C++ as first language? or it just requires some more dedication than other languages? or maybe i just havent got to the difficult things yet....


C++ is harder than many other languages yes.
No it is not impossible to learn C++ as your first language. (You will run into some issues that you wouldn't encounter with other languages later on), Having a good book makes it far less painful though (Many of the worst issues will be avoided if you write modern proper C++ rather than the bastardized mix between C and C++ that some online tutorials teach, also make sure you understand each chapter before moving on)
and yes, things will get harder.
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 MoroS84   Members   -  Reputation: 229

Like
-5Likes
Like

Posted 11 July 2012 - 04:49 AM

Hi ShadowStep.

Many of the worst issues will be avoided if you write modern proper C++ rather than the bastardized mix between C and C++ that some online tutorials teach

A big +1 on that one Simon. Besides C is a lot better for understanding basic language syntax (functions, conditional instructions, loop instructions, basic code layout, etc.). C++ adds a lot more to that.

Edited by MoroS84, 04 August 2012 - 09:08 PM.

Regards,
MoroS84

#4 Inuyashakagome16   Members   -  Reputation: 835

Like
0Likes
Like

Posted 11 July 2012 - 05:00 AM

Yes C++ as a first language usually isn't that great of an idea. There are some things in C++ that are just best learned through another language. I learned Python first and I don't regret it. C++ is still my favorite but only after I had a good hold on the other language. (Python, .net, Java)

#5 kunos   Crossbones+   -  Reputation: 2203

Like
7Likes
Like

Posted 11 July 2012 - 05:04 AM

No it is not impossible, and C++ is not the little baby eating monster like some people seem to suggest.

but

You are not doing yourself a favour choosing it as your first language. I think C++ has lots of things going that make it hard to get into:

1) It is HUGE. The point of C++ is to give you as much freedom as you want regarding programming paradigms and to try to never sacrify performances for that. This create some monsters, "my" C++ is vastly different from somebody else's C++. Most companies need to have "guidelines" to avoid coders going out to strange programming paths with C++. I came to love the simplicity that languages like Google Go offer.. a small, clear and elegant language that you can learn in 2 weeks and in which everybody's code looks much more similar.

2) Lots of things make sense from a compiler point of view, but from a user point of view, they don't make sense at all. ie, forward declarations, headers, non initialized variables.

3) Often C++ libraries and tools are targeted to "real men" Posted Image Take DX11 as an example, no model loading, no font rendering, no scene management, geeky fullscreen management, no shader high level support. It's like, as a C++ programmer you are expected to do more work yourself. Compare this with things like XNA and you will see the different approach.

4) C++ is changing, C++11 (the new standard) just came out and brings a lot of changes in how things should be approached. But, at the moment, there is no book about C++11, so, most probably, you'll learn to do things in a way that will be considered "wrong" or "old" in a few months.

To recap, I'd suggest you to take a step back, and consider C# and especially Go as your introduction to programming.

Edited by kunos, 11 July 2012 - 05:07 AM.

Stefano Casillo
Lead Programmer
TWITTER: @KunosStefano
AssettoCorsa - netKar PRO - Kunos Simulazioni

#6 rnlf   Members   -  Reputation: 1116

Like
7Likes
Like

Posted 11 July 2012 - 05:17 AM

I don't think it is a good idea to learn C before learning C++ for several reasons:
  • Modern high level C++ has very little to do with C (you usually try to avoid pure pointers wherever possible, you don't do explicit memory management, you don't use C style I/O, preprocessor constants etc)
  • You're most likely not risking adopting a bastardized C/C++ mixture, it is almost impossible to avoid it, because as a beginner, you do not have the experience to discriminate between what you need for C++ and what you don't.
  • In C, simple programs are much harder to get right than they are in C++, because beyond "Hello World", you need to work with pointers or pointers in disguise (arrays), manual memory management, the syntax is much more restrictive in a lot of ways and so on...
If you *really* want to learn C++ as your first language, try to avoid the C parts of it as long as possible. It may be hard to understand the STL in the very beginning because template instantiation may take a while to get behind, but it will free you from all the nightmares, beginning C programmers used to have.

Don't get me wrong though, I am a huge C geek myself, but it took me years to let go of old C practices when I switched to C++ and even today as a professional software engineer, I sometimes have to force my self to do things in a clean way instead of the quick C hack way.

Oh, and if you can, try to find a book that covers C++11. I don't know whether there are any beginner books on this topic available yet, but with C++11, it becomes much more accessible to beginners.

But in the end, I typically advise people not to begin programming with C++ before they know some important concepts. It is possible, but it is also quite frustrating from time to time. You better start out with an easier language like python (or even this horrible C# thingy Posted Image)

Edited by rnlf, 11 July 2012 - 05:20 AM.

my blog (German)


#7 Telastyn   Crossbones+   -  Reputation: 3726

Like
4Likes
Like

Posted 11 July 2012 - 06:19 AM

Is really C++ that hard for a begginer?


'hard' isn't really the proper description. It's not hard to learn so much as it's hard to learn right. There's a lot of little gotchas that aren't obvious, and things that are correct yet less optimal than other things.

Worse yet, C++ requires a lot of overhead to make sure you're doing things right. That overhead would be better spent on learning to program. Since learning to program can be done with any language really, it's better for you to work with one that requires less overhead and has less gotchas.

I would like to work on a book that first learns me how to write and then introduce me to Visual Studio.


This is (arguably) unwise. Visual Studio is what you see first, and it's important to make sure that you can compile and run your code before giving you too much code to write (since you should be writing code as you work through the book).

#8 laztrezort   Members   -  Reputation: 955

Like
0Likes
Like

Posted 11 July 2012 - 06:21 AM

If you are enjoying it, and not feeling disuaded or overwhelemed, then go for it. Programming is not an easy discipline no matter the language (for most people, anyway), even failures and false starts can be a learning experience - the only real danger is becomming discouraged and quitting. With C++, there is probably a higher "drop-out rate" due to added complexity and annoyances specific to that language.

Heck, I consider myself somewhat experienced, and these days I only use C++ when I have to (mostly this coincides with someone is paying me to) - it's not a particular easy and smooth experience for anybody, compared to many other languages (note that for many people, easy =/= enjoyable, however).

#9 shadowstep00   Members   -  Reputation: 478

Like
0Likes
Like

Posted 11 July 2012 - 06:41 AM

First of all, I thank you for all your answers they really help me out.

I wanna tell you that this book that I am reading C++ Primer Plus http://www.amazon.co...&pf_rd_i=507846
is updated to the C++11 standard cause it was realeased 2011 and in the description says that includes C++11 standard.

Apart from that it also does not mix the C language with C++ but it does

mentions some things that you can skip(i skip them) for those who have come from C to make it easier for them.In addition i think that if i get each chapter right and do all the exercises correctly( and some similar more of my own) i should be on the right way.

I think from what you have mentioned here is that the most difficult thing about C++ is the freedom that it gives you in terms of how you can write a program in too many different ways.

Other than that what should i watch out? Where i might be tricked? So to be Extra alarmed in that chase....

Edited by shadowstep00, 11 July 2012 - 06:50 AM.

Failure is not an option...


#10 rnlf   Members   -  Reputation: 1116

Like
2Likes
Like

Posted 11 July 2012 - 06:52 AM

A good indicator of a bad way to teach C++ could be if you stumble across pure pointers or the keyword "new" in code example quite early (like earlier than halfway into the book). This *could* mean the book might still use some old fashioned (and thus error-prone and dangerous) ways to achieve certain things.
Even pure arrays might be an indicator of such a problem.

I don't know this book, but I don't think a C++ book can easily be adopted to cover C++11, because a lot of the basic workings of the language have been improved substantially, thus rendering section relying on the older standard obsolete.

Maybe somebody knows this book and can give a more facts based assessment of it.

my blog (German)


#11 Telastyn   Crossbones+   -  Reputation: 3726

Like
0Likes
Like

Posted 11 July 2012 - 07:04 AM

Other than that what should i watch out? Where i might be tricked?


Scott Meyer's collection of C++ books are a good collection of these. Unfortunately, they only cover a fraction of all the things you might run into and won't help for the things you can't avoid.

http://www.amazon.com/Scott-Meyers/e/B004BBEYYW

#12 rnlf   Members   -  Reputation: 1116

Like
0Likes
Like

Posted 11 July 2012 - 07:06 AM

I think, Effective C++ & Co. are more useful to people who already know C++. Otherwise you will have no clue what he's talking about.

my blog (German)


#13 Telastyn   Crossbones+   -  Reputation: 3726

Like
0Likes
Like

Posted 11 July 2012 - 07:16 AM

I think, Effective C++ & Co. are more useful to people who already know C++. Otherwise you will have no clue what he's talking about.


That's true.

#14 boblehest   Members   -  Reputation: 75

Like
-7Likes
Like

Posted 11 July 2012 - 08:21 AM

To recap, I'd suggest you to take a step back, and consider C# and especially Go as your introduction to programming.

Wait, what?
You recommend he doesn't start with C++, but C# is OK? I'd NEVER recommend C# to anyone, unless they want to do what's best for Microsoft, and not for themselves.

#15 Serapth   Crossbones+   -  Reputation: 5263

Like
4Likes
Like

Posted 11 July 2012 - 08:35 AM


To recap, I'd suggest you to take a step back, and consider C# and especially Go as your introduction to programming.

Wait, what?
You recommend he doesn't start with C++, but C# is OK? I'd NEVER recommend C# to anyone, unless they want to do what's best for Microsoft, and not for themselves.


If this was 2006, I *might* ( probably still wouldn't ) give this argument an ounce of credence.


The existance ( and success ) of Mono, as well as the fact C# is an ECMA standard pretty much render your argument moot.

Now you could make that claim in regards to certain .NET libraries like WinForms and WPF which aren't part of the standard, but again, this is pretty silly. It would be like shunning Qt because it is controlled by a single entity.

#16 kunos   Crossbones+   -  Reputation: 2203

Like
0Likes
Like

Posted 11 July 2012 - 08:47 AM

also it's fun to notice that the whole Mono / Xamarin group seem to be way more interested in promoting C# than MS itself is at this stage.
Stefano Casillo
Lead Programmer
TWITTER: @KunosStefano
AssettoCorsa - netKar PRO - Kunos Simulazioni

#17 Serapth   Crossbones+   -  Reputation: 5263

Like
7Likes
Like

Posted 11 July 2012 - 09:13 AM

As the author of the article, I suppose I should chime in. First, and some of this might be lost due to language barriers, but a lot of the criticism leveled at C++ in the article is pretty firmly tongue in check. It is certainly hyperbolic. Although with that said, C++ is still a crappy language to start with. I say that with absolutely no caveats. There is not a single metric by which I would call C++ a good beginners language.

So my final question is.. Is really C++ that hard for a begginer?


Hard is a relative expression, and pretty meaningless on it's own. Is C++ harder to learn than almost every other modern programming language? Yes.

is it impossible to learn C++ as first language?

No.

or it just requires some more dedication than other languages? or maybe i just havent got to the difficult things yet....

Dedication is the wrong word. Patience? Yes. A willingness to smash your head against a wall repeatedly, yes. I would imagine you havent gotten to the difficult things yet. They aren't insurmountable, they are just a really inefficient use of your time.

PS. After i read that article that i mentioned before i started learning C# but it really didint got my attention so much and also the books where not traditional like those of C++ which first learn you how to write "hello world" , variables ect... Most of C# books empasize fist on Visual Studio and dont get you to the basics of the language first. I would like to work on a book that first learns me how to write and then introduce me to Visual Studio.


Bad books exist for all languages. I do believe every C# book I recommended in that guide don't even mention Visual Studio.


Now for a bit of justification.

First off, there is this thing that most new developers don't and can't understand, because you learn it from experience.

The first programming language you learn is going to be by an order of magnitude the hardest programming language you learn. This is because in addition to learning the language and it's associated tools, you are also learning to program. Your goal at this stage should be to minimize complexity as much as possible. It's a pretty well established technique in teaching... you don't bombard a student with a thousand topics at once, you streamline as much as possible and learn in a more linear progression. C++ makes this exceedingly difficult, as the number of topics you need to cover in a short span of time is quite a bit larger than most other languages. For the record, this applies to C# and Java too... an absolute beginner is probably best served starting with a language with an even simpler build process.

Second, it's all about the design of C++. C++ has a design ethos of "everything is optional". C++ won't force anything on you, and for a new developer this is a very bad thing. When just starting out, as little choice as possible is actually a good thing.

C++ is 4 languages in one, and 3 of them suck. When you set out to learn C++, you are actually learning a number of languages at once. Basically there is C, C++ of yonder, templates and C++11. Before you argue this point, all 4 of those aspects are actually turing complete, and frankly, the 4 languages don't mesh extremely well. The legacy C core is because in 1983 C was the language of the day. It's inclusion was a big reason why C++ caught on, but as a language of today, its effectively 27 years old, and a kinda crappy one at that, especially in regard to security. As was said earlier, if you pick up a book and it deals with C'isms in the first half, return it. 99.999% of the time, there should be no C in your C++ code.

Now the templating aspect of the language is pure garbage for a beginner. They are difficult, have an unweildy syntax ( compare for each in C++ to , well, any other language as an example ) and even in 2012, the errors they generate are absolute garbage.

As to the two flavors of C++, C++ pre-11 and C++ post 11, well all languages suffer from this to a degree, so this ins't an exclusively C++ related issue. C# suffers it in the form of non templated collections, as well as the lack of features before a certain level ( generics are the biggest though ), while Java suffers from the fact it's initial class libraries are a mess, and the fact it hasn't aged as well as C#. C++ however is the oldest, and thus, most prone to cruft. On the brightside, the C++ mindset of "do it yourself" and "everything is optional" makes the core fo the language quite small, to a degree minimizing the cruft that has developed ( well except the entire C subsystem that is ). As was mentioned earlier though, in modern C++ you shouldn't be using new or naked arrays on a regular basis. Reading 99% of the tutorials on the web though and this sure as hell wouldn't be obvious!

Next up, the standard libraries are pure garbage. Seriously, they are freaking awful. When it comes to certain every day tasks ( data access, gui, xml handling, string manipulation, web access, etc... ) they suck or simply don't exist. This is both a strength and weakness of C++, but from a beginners perspective, it is a weakness, a gigantic one.

Then there is the linker and preprocessor. Modern languages don't really have these anymore, and for good reason. Very early on, new developers have to deal with these baffling concepts and the experience sucks. Figuring out headers and include guards, figuring out how to link your program, static vs dynamic vs static debug, vs dynamic debug linking... this isn't stuff a beginner should have to deal with, but the second they want to do something the minimalistic standard libraries dont support ( such as graphics... ), they need to conquer this mountain as well.

Then of course, there is the language itself. People often cite manual memory management as the biggest hurdle to a new C++ programmer. This is not only untrue, it's actually proof that people are learning from outdated sources! That said, memory management in C++ is a pain in the ass. So are the inheritence rules, especially around multiple inheritence. So are a few thousand other byzantine rules behind it.



Dont get me wrong, C++ has its merits. First off, and this is a big one, it is ubiquitous, which is probably the most important thing. It is used, and it is everywhere. Basically it is the current least common denomintor language on every platform ( except win phone 7 and pre BB10 devices). Next, for an expert, the everything is optional approach is a blessing, especially when you are trying to ring out every bit of performance. It has a good ecosystem, especially when it comes to games, and exceptional tooling support in the form of Visual Studio and to a lesser degree Qt Creator.

However, not a single one of those strengths is a good thing or a positive for a beginner.


Let me reinforce a point that only experience can teach, one last time. Your first language is your hardest to learn. So don't make the task harder on yourself than necisarry. You can always pick up C++ later, and will probably be a hell of a lot more successful when you do! If you do go with C++, learn C++ 11 using modern tools ( this means no DevC++ and no C or direct memory management ). I know people won't listen to me, which is why I created this tutorial. It eases the transition from simple console apps to complete games, and hopefully encourages a modern and clean style. ( By the way, there is naked memory access in the example... part 8 or so. This was always intended to be replaced in an upcoming part... that I havent written yet! ;) ).

#18 Serapth   Crossbones+   -  Reputation: 5263

Like
0Likes
Like

Posted 11 July 2012 - 09:25 AM

also it's fun to notice that the whole Mono / Xamarin group seem to be way more interested in promoting C# than MS itself is at this stage.



Yeah, this is certainly true. I have noticed a definite shift at Microsoft since Steven Sinofsky took control. Silverlight is dead, XNA is dead, DirectX is "just another library", .NET has been defocused and WinForms end of lifed ( although the writing was on this wall for a long time ), while WinRT has received focus. C# seems to be getting less emphasis, while JavaScript and C++ are getting much more, especially in Metro. They even tried to axe the Express line ( except for targeting Metro ), until there was a community backlash.

Can't say as I particularly like the change of direction, but thats just me.

Fortunately C# is mature and feature complete enough Mono can take it and champion the cause. Unlike C++ and to a lesser degree Java, there arent as many things that need fixing in C#. In some ways the current additions ( like dynamic ) feel unfocused and inappropriate, so leaving the langauge alone might not be a bad thing.

#19 rnlf   Members   -  Reputation: 1116

Like
0Likes
Like

Posted 11 July 2012 - 09:34 AM

There's nothing to add to this. Too bad people won't listen.

my blog (German)


#20 Bill Door   Members   -  Reputation: 249

Like
3Likes
Like

Posted 11 July 2012 - 09:58 AM

I find it interesting how people seem to overstate how difficult it is to learn programming from C++. I teach high school students programming using Stroustrup's Programming: Principles and Practice Using C++. This is a text book for an introductory course on computer programming.

The students have found the book to be readable, engaging, and useful. There are practical exercise in learning to solve real problems in programming. The language choice is naturally C++.

I find C++ to be fine as an introductory programming language.




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