C++ first so bad???

Started by
27 comments, last by Captain Logic 19 years, 5 months ago
well c++ was my first language too because I heard it's a widely used and optimum language for games (and very widely used in the industry, which is where i've wanted to be since elementary school :)). I mean the only other language i've touched now is assembly for debugging purposes and further understanding of computers and how they work :) I mean now a days it seems to be a trend to know like all kinds of languages, so I might have to extend my knowledge to a few more things.. which I probably could've gotten out of the way a while ago.
Advertisement
I started whit c++ too and it was hard learning to me because I had no idea how applications work. But when you get the hang of it its not bad because you dont have to know every single keyword or about dynamic memory allocation or class polymorphism, templates etc at the first place.

You can code some easy text game whit simble code in c++.

And when you have the basic idea you just move forwards. Im just saying this because my mistake was to try and understand the whole language before I coded anything.
Jesus loves you!
Quote:Original post by Polymorphic OOP
I was defending C++ for all of the bashing it normally gets as an introductory language. Its foundation as a multiparadigm language makes it a great learning opportunity. It gives an early programmer a chance to experiment with procedural, object oriented, and functional programming, as well as allow them to see low-level details. This is something that very few other languages can provide.

Scope? If one really wants to understand low-level details, C is better choice. Why? It's simpler and closer to assembly language. BTW, I wouldn't consider C++ a functional programming language just because you can define recursive functions. It's an imperative language after all, not a declarative or relational one. What you meant is procedural programming, which you indeed cannot do in a simple way using C#, Java or Eiffel. Still I don't see that as an advantage over Python or Object Pascal, both of which being much more straight forward and beginner-friendly.
Quote:
Also, there's a difference between using object oriented patterns and actually using a language designed to handle the object oriented paradigm. In other words, you're not going to do too well teaching someone object oriented programming by having them learn assembly, even though you can create object oriented design patterns. With C++ or other languages that directly support the paradigm, it makes things much easier.

That wasn't my point. If I want to teach OOP, I'd choose Eiffel. Why? Because this language allows me to learn OOP by defining ADTs first with pre- and post conditions as well as invariants and implement these directly (e.g. the language defines constructs for pre-/post conditions and invariants). Plus no hassle with compiler settings, header files and the like.
Quote:
But you can use simulated lambda expressions and delegates in C++ as well (see boost), which many people actually do -- myself included. With C++, you can pull in a lot of concepts from other languages making it a nice way to learn a variety of concepts that would otherwise usually require you to learn several different languages at once. Even then, you don't get the chance to use them together easily, which is a great benefit in its own right.

Agreed. But these are rather advanced things implementation-wise - so what meaning oes this have to a beginner who doesn't even know 'how to split my project into .h and .cpp files'? You see, things that are pretty basic in some language can be done one or the other way in similar languages, too. If and only if you have a deep knowlegde of that particular language already. So what's the point of regarding the possibility to simulate these non-native constructs as a benefit to beginners?
Quote:
I talk primarily about C++ because it was the language mentioned in the original topic, it is the language I personally have the most experience in, and also because it is one of the most versitile languages around.

Gotcha! [smile] That's the whole point of it. You talk about the language you know best. IMHO, learning how to program is learning how to formalise and structure an idea. And learning works best if you stay motivated. C++ can discurage and even scare away beginners who are just starting to understand what the fundamentals are. To me these fundamentals are not necessarily bound to a specific paradigm or language syntax. The friendlier and straight forward the language is, the easier it is to pick up these things I believe.
And languages like Wirth's Pascal have been created just for this purpose, while still enabling the programmer to create anything from 'hello world' to a full-blown FPS game. And that's why I wouldn't recommend a complex language like C++ to start programming with. Once you have some experience with programming itself it's so much easier to switch to any language you like.

And because there is no language that is best suited for all purposes you will have to look at other languages sometimes and there's nothing wrong with it as it broadens your horizon.

So to sum up why I would not recommend C++ as introductury language in general:


  • When learning programming, concepts are more important that syntax. Languages that resemble natural language (e.g. Pascal/to a certain extend Eiffel, even BASIC dialects) or are easy to use (e.g. Python) are better suited for this purpose.

  • I don't consider low-level details to be important for learning programming concepts - these are merely implementation details that are required in certain situations only.

  • Multi-paradigm is a Good Thing™ if you already know at least one way of doing things well. That's why I see no problems with learning languages that do not have native support for different paradigms.

  • I do not consider compiler switches, linker options and knowlegde of pre-processor commands a necessity when starting to learn programming (even if an IDE is at hand that hides some of these things).

  • A complex language might (and too often will) shift the focus away from the concept to implementation details, which I do consider a Bad Thing™ when beginning programming.

  • Quote:C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg. (Bjarne Stroustrup)
    Sorry, couldn't resist [smile]


  • And while I'm at it, another one:
    Quote:
    I view the landslide of C use in education as something of a calamity. (Nicklaus Wirth)
    [grin]


  • So we already heard Stroustrup and Wirth, let's see what Knuth once said.
    Quote:
    Whenever the C++ language designers had two competing ideas as to how they should solve some problem, they said, "OK, we'll do them both". So the language is too baroque for my taste. (Donald E Knuth)



  • And finally:
    Quote:
    Eiffel borrows quite heavily from some earlier programming languages and I am sure that if we had found a good programming construct in C we would have used it as well. (Bertrand Meyer)



Please note that the quotes are not necessarily reflecting my views on C++. I just found them funny and they somehow back my reasons [wink]. Absolutely no offense intended.

And Polymorphic, please don't take this personally - I just wanted to provide some constructive criticism and give some reasons why not everybody considers C++ to be easy to learn or being a good choice for an introductory language.

Best regards,
Pat.
I personally have no particular opinion about C++ as an introductory language. As long as some specific features are not taught at the beginning, it's fairly functional as an OOP language. Perhaps a bit low level, but it's still reasonable.

Where you really start running into trouble is when you introduce operator overloading, multiclassing, and templates too early. While the core of C++ is reasonably comprehendable, each of these topics bring up problems which require you to know what the compiler intends to do with it. Someone who's starting is probably struggling with the topic of pointers, let alone machine code generation and binary representation of their programs.

For instance (be patient for those of you who know it well), multiclassing is a technique to make a single class C derive from two or more classes, such as class A and class B. This is pretty straightforward as long as you're using well-typed programs, where pointers are used as black boxes. But it is the nature of C++, since its designed for high-performance code, to do type unsafe things with pieces of data, like cast that nice C * to a void *. Woe be unto a beginner if he tries to cast that void * back to a B*. If you don't understand why this is, be sure not to use multiclassing until you do. God forbid if he decides to create a class D which both class A and class B derive from.

This kind of can-of-worms scenario seems to be more a rule for most C++ features than an exception. Each new vital feature brings up a host of possible incompatabilities with other features, which have to be dealt with promptly. Its these components which beginners to programming must initially avoid, to prevent being swept away by a metaphorical river of knowledge.

In summary, as a basic, single inheritence, no frills kind of way, C++ is fine as a beginners language. Just don't slip them Stroustrup's "The C++ Programming Language" too early :-).
I learned Applesoft BASIC as my first language.

It's where I learned how to use GOTO and spaghetti code was the order of my day. GOSUBs didn't help too much.

I used QBasic for few years before learning C++ at my university. It was easier for me to understand strings since QBasic had a string type, but the difference between char and string threw me for small loop. Still my previous programming knowledge helped me get better aquainted with the new language and paradigms.

I think it is clear that C++ isn't so bad as a first language. Lots of people have gone through it. A good book I believe is Accelerated C++. A dialect of BASIC is ok to learn, but it is way too easy to fall into bad habits, even with VB.

Some people suggest learning Python (not Phyton B-) as a first language, then moving onto C++ or Java.

I also think that having low-level knowledge of the internal workings of a computer is a big help. How does C++ get translated into assembly and then subsequently get translated into binary? Why does tail recursion allow for more efficient programs? Assembly is probably a good pre-first language if only to show how things work at a low level before allowing someone to work at a higher level. But then, that's the hacker mindset in me. Some people might object that if they don't have to know how a PC works to program it, they shouldn't have to. I personally believe the knowledge will allow for more efficient programming.
-------------------------GBGames' Blog: An Indie Game Developer's Somewhat Interesting ThoughtsStaff Reviewer for Game Tunnel
Quote:Original post by darookie
Scope? If one really wants to understand low-level details, C is better choice. Why? It's simpler and closer to assembly language.

C++ can get just as close to a low-level language as C can.

Quote:Original post by darookie
BTW, I wouldn't consider C++ a functional programming language just because you can define recursive functions.

Did I even say anything about recursive functions? No. I was actually referring to C++'s template metaprogramming facilities.

Quote:Original post by darookie
Agreed. But these are rather advanced things implementation-wise - so what meaning oes this have to a beginner who doesn't even know 'how to split my project into .h and .cpp files'? You see, things that are pretty basic in some language can be done one or the other way in similar languages, too. If and only if you have a deep knowlegde of that particular language already. So what's the point of regarding the possibility to simulate these non-native constructs as a benefit to beginners?

Because you don't have to know exactly how to make a tool to know how to use it. I don't suggest a beginner go out and create code which lets you simulate lambda expressions, but that doesn't mean they can't use them. For example, most of what's in the STL, or libraries in other languages for that matter, provide objects and functions which a beginner wouldn't understand how to implement. Does this mean they can't use a linked-list or red-black tree because they don't know how to make them? Not at all!

Quote:Original post by darookie
Gotcha! [smile] That's the whole point of it. You talk about the language you know best. IMHO, learning how to program is learning how to formalise and structure an idea. And learning works best if you stay motivated. C++ can discurage and even scare away beginners who are just starting to understand what the fundamentals are. To me these fundamentals are not necessarily bound to a specific paradigm or language syntax. The friendlier and straight forward the language is, the easier it is to pick up these things I believe.

Gotcha? What are you getting :p For some reason it seems like you are trying to attack me for writing a reply about a language which I know well. The point of this thread is to ask whether or not C++ is okay for a first language. C++ was my first language and the language I know the best. I also know several other people who started with C++ and many who didn't and make many observations about their styles of coding. Are you saying that it doesn't make sense for me to reply about C++ as being a good introductory language because it is the language I started with and it has impacted my experiences as a programmer considerably? That's first hand experience regarding the question asked in the original post and you're claiming it's bad!

Also, note that you are making claims that the language can discourage and scare off newcomers. I'm not saying that C++ is an appropriate language for everyone to learn first, particularly to people who always want to see immediate results, but if they are dedicated and willing to get passed a potentially steep learning curve, it can pay off well later on. C++ doesn't scare everyone off as you claim -- again, I started with it, I know several people who started with it, and the original poster of this thread is starting with it, and we all are perfectly fine with the language as an introduction to programming.

Again, knowing C++ well makes it much easier to switch to languages of different paradigms. For instance, it's usually much easier for a C++ programmer to switch to a functional language than it would be for a Java programmer since they may be using many functional concepts already in C++. As well, a C++ programmer can usually more easily jump down to a lower-level language, or to a strictly object-oriented language. C++ is a great window into the world of programming taking in a multitude of paradigms, which makes it a powerful language to have a basis in.
I firmly believe that teaching "programming" and teaching a language are two different. If you learn to program first, then you should be able to apply that knowledge to any new language you want to learn. Learning new languages becomes easy.

C is arguably more difficult to learn than some other more high-level languages. It's syntax is somewhat cryptic and non-english like. It makes sense that while teaching how to program to newbies to use the most simple language possible.
Quote:Original post by Polymorphic OOP
Again, knowing C++ well makes it much easier to switch to languages of different paradigms.


I don't know if that's ENTIRELY true. When I started writing with VB after using nothing but C for a couple of years I felt crippled. No pointers. No declare initializations (int x = 0;). No pointers. I wrote some embarrasingly bad code at first. The no pointers thing really messed me up. There were some things that I just couldn't figure out how to do without pointers. It took me a couple of weeks just to retrain myself to design without them.
Speaking from expirience here....

I started with VB6 and after 4-5 years started learning c++ and it was so hard to get my head around the differences. I know it's all very idealistic to say "learn a 'simpler' language first' but in reality why? Why does BASIC syntax help you learn C syntax? Why does Pascal syntax help you learn Java syntax? Answer: It doesn't.

You can learn the different programming paradigms from ANY language. Btw, you don't have to allocate and free memory in C/C++ to learn _any_ of the basics involved with programming.

-neurokaotix
Quote:Original post by Polymorphic OOP
Quote:Original post by darookie
Scope? If one really wants to understand low-level details, C is better choice. Why? It's simpler and closer to assembly language.

C++ can get just as close to a low-level language as C can.

I was referring to the language as a whole, not a particular subset such as the C parts found in C++.
Quote:
Quote:Original post by darookie
BTW, I wouldn't consider C++ a functional programming language just because you can define recursive functions.

Did I even say anything about recursive functions? No. I was actually referring to C++'s template metaprogramming facilities.

That still doesn't turn C++ into a fuctional programming language - the remark was just added to clear up terminology, regardless of the fact that you did not mention recursive functions (which, BTW most template meta-programming techiques actually are - just executed at compile time[wink]).
Quote:
Because you don't have to know exactly how to make a tool to know how to use it. I don't suggest a beginner go out and create code which lets you simulate lambda expressions, but that doesn't mean they can't use them. For example, most of what's in the STL, or libraries in other languages for that matter, provide objects and functions which a beginner wouldn't understand how to implement. Does this mean they can't use a linked-list or red-black tree because they don't know how to make them? Not at all!

What has this to do with the fact that actually learning how the algorithms work still encourages actually implementing it? If it is so much easier in other languages, what's the advantage of knowing that it can be done in C++, too even though it might be much harder to implement than to understand?
Quote:
Gotcha? What are you getting :p For some reason it seems like you are trying to attack me for writing a reply about a language which I know well.

What makes you think that is? The OP asked if anyone else feels that C++ is easy to learn as the first programming language and the thread title implies that he wants to know why or why not C++ is a good choice for that. If I know a language very well and have an in-depth knowlegde of it, it might happen that I forget about the difficulties beginners may be faced with when starting with it. That's all. You were all about the - indeed - great features and flexibility of the language and it just seemed to me that it was necessary to also state the that this is bound to the complexity of the language.
Quote:
Are you saying that it doesn't make sense for me to reply about C++ as being a good introductory language because it is the language I started with and it has impacted my experiences as a programmer considerably? That's first hand experience regarding the question asked in the original post and you're claiming it's bad!

No. I'm not. At least I was not intending to do so. If I did - I apologise.
Quote:
Also, note that you are making claims that the language can discourage and scare off newcomers. I'm not saying that C++ is an appropriate language for everyone to learn first, particularly to people who always want to see immediate results, but if they are dedicated and willing to get passed a potentially steep learning curve, it can pay off well later on. C++ doesn't scare everyone off as you claim -- again, I started with it, I know several people who started with it, and the original poster of this thread is starting with it, and we all are perfectly fine with the language as an introduction to programming.

I didn't say that it scares everyone off, so futher arguing about that is useless in my eyes. The fact that you, the OP and several others you (and even I) know are perfectly fine with C++ as an introduction to programming doesn't render any of my counter-arguments pointless.
Quote:
Again, knowing C++ well makes it much easier to switch to languages of different paradigms. For instance, it's usually much easier for a C++ programmer to switch to a functional language than it would be for a Java programmer since they may be using many functional concepts already in C++. As well, a C++ programmer can usually more easily jump down to a lower-level language, or to a strictly object-oriented language. C++ is a great window into the world of programming taking in a multitude of paradigms, which makes it a powerful language to have a basis in.

Agreed. But opening that window into the world of programming can be so much simpler with other languages - that's all I intended to make clear. I still don't and won't regard C++ as a good choice for a first programming language and I also presented a number of reasons.
To quote a few much more creditable people than me [smile]:
Quote:
Pointers are like jumps, leading wildly from one part of the data structure to another. Their introduction into high-level languages has been a step backwards from which we may never recover. (Tony Hoare)

Quote:
It has been discovered that C++ provides a remarkable facility for concealing the trival details of a program -- such as where its bugs are. (David Keppel)


And again, it's not that I'm not comfortable with C++ or dislike it. And I in no way wanted to attack you or your personal experience with C++ as your first language. As I already mentioned, learning how to program with C++ as first language might work very well for some - but you just won't convince me that it works for most. I also commented that motivation is important and a steep learning curve cannot be generally considered good motivation, or can it?

Cheers and don't get mad at me [smile],
Pat.

PS: Seems I really have to work hard on my communication skill[grin].

This topic is closed to new replies.

Advertisement