At uni we went straight into C++, and I think its the best way to go. C++ is kind of an extension of C, containing, as a subset, most of the features of C that you will need. By learning C++, you will also learn the features of C that were carried through to C++.
pan narrans
Study + Hard Work + Loud Profanity = Good Code
Ahh C or C++
Minister of Propaganda : leighstringer.com : Nobody likes the man who brings bad news - Sophocles (496 BC - 406 BC), Antigone
Learning the basics of C++ IS learning C. I mean come on, all that is left are a few typdefs and other added keywords. C++ basics are just suited for the lazier programmer.
If the book you learn from is structured well, it should teach you the basics first, so it shouldn''t matter which you learn first. As I see it, learning C first is great, but pointless if you have the right book. Just stay out of advanced topics like templates, classes and such, until you''re ready.
If the book you learn from is structured well, it should teach you the basics first, so it shouldn''t matter which you learn first. As I see it, learning C first is great, but pointless if you have the right book. Just stay out of advanced topics like templates, classes and such, until you''re ready.
C:
#include <stdio.h>
void main ()
{
printf ("Hello world.");
}
C++
#include <iostream>
int main ()
{
std::cout << "Hello World";
return 0;
}
Yep, they are exactly the same.
struct Vector
{
int x,y,z
};
void VectorAdd (struct Vector *A, struct Vector *B);
class Vector
{
protected:
int x, y, z;
public:
Vector & operator += (Vector & B);
};
Yep, again, the same...
And lets forget about RTTI, polymorphism, inheritance, exceptions.
Basically, anyone that says C++ is like C is because they are enough idiotic to use the C part of the language and think they are using C++ part.
Except for the standard library (math and stuff like that) everyhing is different in C++ than in C, not to mention that the way to program in C++ (OOP) is completly different than in C (procedural). If you people are using global function all over the place, using fopen's printf' etc, you not using C++, your using the C subset of C++. C++ is a language, and the way to correctly program it is using OOP (yes, prodecural C++ is also correct, but thats not the objective of the language, is like driving a car always in reverse, its possible, but doesn't means it should be done).
Bruno
[edited by - Akura on October 11, 2002 11:56:22 AM]
#include <stdio.h>
void main ()
{
printf ("Hello world.");
}
C++
#include <iostream>
int main ()
{
std::cout << "Hello World";
return 0;
}
Yep, they are exactly the same.
struct Vector
{
int x,y,z
};
void VectorAdd (struct Vector *A, struct Vector *B);
class Vector
{
protected:
int x, y, z;
public:
Vector & operator += (Vector & B);
};
Yep, again, the same...
And lets forget about RTTI, polymorphism, inheritance, exceptions.
Basically, anyone that says C++ is like C is because they are enough idiotic to use the C part of the language and think they are using C++ part.
Except for the standard library (math and stuff like that) everyhing is different in C++ than in C, not to mention that the way to program in C++ (OOP) is completly different than in C (procedural). If you people are using global function all over the place, using fopen's printf' etc, you not using C++, your using the C subset of C++. C++ is a language, and the way to correctly program it is using OOP (yes, prodecural C++ is also correct, but thats not the objective of the language, is like driving a car always in reverse, its possible, but doesn't means it should be done).
Bruno
[edited by - Akura on October 11, 2002 11:56:22 AM]
It's good to be an outcast, you don't need to explain what you do, you just do it and say you don't belong there.
quote: Original post by Jiia
Learning the basics of C++ IS learning C. I mean come on, all that is left are a few typdefs and other added keywords. C++ basics are just suited for the lazier programmer.
If the book you learn from is structured well, it should teach you the basics first, so it shouldn''t matter which you learn first. As I see it, learning C first is great, but pointless if you have the right book. Just stay out of advanced topics like templates, classes and such, until you''re ready.
Teaching you the basics first... now ask yourself, ''what are the basics?'' is it if-else structures, while/for-loops, etc. or is it how to use your programming language? Staying away from classes to start with? How do you plan to write hello world without using classes in C++? Using printf? hah!
#include <iostream>using std::cout;using std::endl;int main() { cout << "Hello World!" << endl; return 0;}
There you''ve already managed to use a class or two. Classes are an integral part of object-oriented programming and there is no need to alienate you from them to learn how to use the language in any way. One of the books that are much preferred by professionals to let beginners teach themselves C++ is "Koenig & Moo: Accelerated C++" and this book focuses on actually using the Standard C++ Library from the very beginning in a way that feels natural.
So saying that a well-structured book would teach you the basics of C as well isn''t necessarily right - any book on programming should at least focus partially from the start on the main programming paradigm of the language.
Now, there are a lot of recurring themes in C and C++, loops, statements, conditionals, etc., but you do not have to learn them in the same order to be efficient in the two languages. For instance learning about the switch statement isn''t really necessary in C++ as you can usually make a nice, modular design in C++ that eliminates the need for the switch statement (usually! not always!).
Also, saying that C++ keywords are suited for the lazier programmer... what the <censored> are you talking about? Is it lazy that in comparison to C:
struct A { ... };struct A myvar;
you can write this in C++:
struct A { ... };A myvar;
? If you honestly think so then you obviously haven''t programmed in any larger projects. True you might do some funky typedefs in C so that you can leave out the struct before variable declarations, but that might just be as lazy as C++ programmers are?
Again, C and C++ require two different mind-sets and while their fundamental basics do not differ they are very different in how you apply them for actual programming. Mixing them is bad code style and should be avoided where possible. If you want the more natural way into programming, pick an object-oriented language (not because it''s a buzzword but because it to most human beings fall more natural ever since Aristoteles introduced classifications of objects), if you don''t want all sorts of technicalities bothering you from early on (pointers, memory management, etc.) then pick a garbage collected language like Java or C# and learn from.
There are no best ways to learn how to program, personally I think people should be given a functional programming language and learn the mathematical foundations of programming, but people would run away screaming if they were forced to. There is no ''right way'' to program things, for every solution you can think of there are probably a few more you haven''t thought of. Learn the language you think will be most useful for you, some are easier, some are harder.
Yours truly,
Henrik Stuart
--I am not a church numeral, I'm a free variable!
I don''t know about DirectX, however OpenGL''s API is C-style(ie. functions, not objects). As for learning C++, Stroustrup said that C is NOT a prerequesite for C++( http://www.research.att.com/~bs/bs_faq.html#prerequisite ).
IMHO, you should learn C++. Be sure to pick up a copy of ''The C++ programming language'' by Bjarne Stroustrup BTW. It really comes in handy if you need some light shed on some language feature(eg. templates).
IMHO, you should learn C++. Be sure to pick up a copy of ''The C++ programming language'' by Bjarne Stroustrup BTW. It really comes in handy if you need some light shed on some language feature(eg. templates).
-MoonJihad
Staying away from classes to start with? How do you plan to write hello world without using classes in C++? Using printf? hah!
Except the idea I was shooting across was to avoid creating classes. And really just meant to avoid deriving and such. Classes in the simplest form are no more complicated than structures with functions.
Classes are an integral part of object-oriented programming and there is no need to alienate you from them to learn how to use the language in any way.
Well, I did say "until you''re ready".
Also, saying that C++ keywords are suited for the lazier programmer... what the are you talking about? Is it lazy that in comparison to C:
struct A { ... };
struct A myvar;
you can write this in C++:
struct A { ... };
A myvar;
Ha ha, maybe I''m the only one that notices it. What is the point in removing the struct keyword from c++? Was there a specific reason? Why not require that struct and class keywords be used everywhere the variables are declared? Being the lazy type programmer, I can tell you that removing one keyword here and there helps much in something typed so often. And if it''s not made to be suited to lazy programmers, it is STILL suited to lazy programmers. How can you argue with that? And why try? Unless you dare to think you''re lazier than me?
If you honestly think so then you obviously haven''t programmed in any larger projects.
The way I look at it, the larger the project, the more it helps to use lazy tactics. 2500 less keys I had to press. That''s enough energy to turn on my monitor. Twice even.
I learned C++ from C, which I learned from javascript. I''ve been coding with C++ for 4 years. It''s my biggest time waster, and I love it to death. Don''t go poking at my experience just because you feel your point is more valid.
Except the idea I was shooting across was to avoid creating classes. And really just meant to avoid deriving and such. Classes in the simplest form are no more complicated than structures with functions.
Classes are an integral part of object-oriented programming and there is no need to alienate you from them to learn how to use the language in any way.
Well, I did say "until you''re ready".
Also, saying that C++ keywords are suited for the lazier programmer... what the are you talking about? Is it lazy that in comparison to C:
struct A { ... };
struct A myvar;
you can write this in C++:
struct A { ... };
A myvar;
Ha ha, maybe I''m the only one that notices it. What is the point in removing the struct keyword from c++? Was there a specific reason? Why not require that struct and class keywords be used everywhere the variables are declared? Being the lazy type programmer, I can tell you that removing one keyword here and there helps much in something typed so often. And if it''s not made to be suited to lazy programmers, it is STILL suited to lazy programmers. How can you argue with that? And why try? Unless you dare to think you''re lazier than me?
If you honestly think so then you obviously haven''t programmed in any larger projects.
The way I look at it, the larger the project, the more it helps to use lazy tactics. 2500 less keys I had to press. That''s enough energy to turn on my monitor. Twice even.
I learned C++ from C, which I learned from javascript. I''ve been coding with C++ for 4 years. It''s my biggest time waster, and I love it to death. Don''t go poking at my experience just because you feel your point is more valid.
quote: Original post by MoonJihad
I don''t know about DirectX, however OpenGL''s API is C-style(ie. functions, not objects). As for learning C++, Stroustrup said that C is NOT a prerequesite for C++( http://www.research.att.com/~bs/bs_faq.html#prerequisite ).
I already covered this.
quote: Original post by MoonJihad
IMHO, you should learn C++. Be sure to pick up a copy of ''The C++ programming language'' by Bjarne Stroustrup BTW. It really comes in handy if you need some light shed on some language feature(eg. templates).
Using Stroustrup''s book as a learning book is not recommended. It covers many of the ins and outs of the language and is generally written to someone who has managed to get a solid grasp on the language already. However, it is invaluable as a reference at a later point of time. So is "ISO/IEC 14882:1998" for that matter. :o) See my earlier posts for reasonings on learning... wait, you should already have read them considering you posted... hmm!
Yours truly,
Henrik Stuart
--I am not a church numeral, I'm a free variable!
"Classes are an integral part of object-oriented programming and there is no need to alienate you from them to learn how to use the language in any way.
Well, I did say "until you''re ready"."
What the f**k are you talking about?? If you are learning printf and fopen and #include <stdio.h> your not learning C++, your learning C, so until you''re ready means don''t learn this language until your ready. Which is the same as I can say don''t learn C until you''re ready, or don''t go driving until youre ready. C and C++ are different programming languages. Here is a good example, try to redo you code removing all references to stdio.h, printf, fopen, etc that have class equivalents in C++ and then compiling in a Strict C compiler, you will see that the only thing that remains of ''C'' code is while/if/for Statements and the token syntax. All the rest will be errors.
"C++ basics are just suited for the lazier programmer"
For 4 years of experience, I think you confuse lazy with useful. Noone liked to do struct Vector Point; it was a waste, not not being lazy, was a WASTE. Lazy is doing
InitModeAndDoGameForMe (ModeX, GameY);
not removing a keyword that affects nothing on the language or its syntax.
Well, I did say "until you''re ready"."
What the f**k are you talking about?? If you are learning printf and fopen and #include <stdio.h> your not learning C++, your learning C, so until you''re ready means don''t learn this language until your ready. Which is the same as I can say don''t learn C until you''re ready, or don''t go driving until youre ready. C and C++ are different programming languages. Here is a good example, try to redo you code removing all references to stdio.h, printf, fopen, etc that have class equivalents in C++ and then compiling in a Strict C compiler, you will see that the only thing that remains of ''C'' code is while/if/for Statements and the token syntax. All the rest will be errors.
"C++ basics are just suited for the lazier programmer"
For 4 years of experience, I think you confuse lazy with useful. Noone liked to do struct Vector Point; it was a waste, not not being lazy, was a WASTE. Lazy is doing
InitModeAndDoGameForMe (ModeX, GameY);
not removing a keyword that affects nothing on the language or its syntax.
It's good to be an outcast, you don't need to explain what you do, you just do it and say you don't belong there.
quote: Original post by Jiia
Staying away from classes to start with? How do you plan to write hello world without using classes in C++? Using printf? hah!
Except the idea I was shooting across was to avoid creating classes. And really just meant to avoid deriving and such. Classes in the simplest form are no more complicated than structures with functions.
Well, considering that in C you cannot give structures functions this is a moot point. Furthermore, you have the benefit in C++ that you can encapsulate data so that it isn''t visible to the outside world (one of the great benefits of OOP).
quote:
Classes are an integral part of object-oriented programming and there is no need to alienate you from them to learn how to use the language in any way.
Well, I did say "until you''re ready".
Do you understand the term ''fish'', or ''corn'', or ''houses'', then you''ve understood and is ready to use classes. Really, it''s a real-life concept, as I stated earlier, invented by one of our favourite Greek philosophers.
quote:
Ha ha, maybe I''m the only one that notices it. What is the point in removing the struct keyword from c++? Was there a specific reason? Why not require that struct and class keywords be used everywhere the variables are declared?
I don''t know the specific reasoning of the Standards work-group, but that doesn''t mean I cannot speculate. :o) In C++ everything is in reality an object, even the integral types. int''s have constructors, destructors and everything else that user-defined classes have, it''s just hidden from you within the language, conceptually. Furthermore, a struct (non-POD if you want to be pedantic) is merely a class where all its contents are public (not accounting for using access specifiers), so in many places a struct and class will be the same thing.
quote:
Being the lazy type programmer, I can tell you that removing one keyword here and there helps much in something typed so often. And if it''s not made to be suited to lazy programmers, it is STILL suited to lazy programmers. How can you argue with that? And why try? Unless you dare to think you''re lazier than me?
First you attack C++ programmers as being lazy then you say you''re lazy? Make up your mind.
quote:
If you honestly think so then you obviously haven''t programmed in any larger projects.
The way I look at it, the larger the project, the more it helps to use lazy tactics. 2500 less keys I had to press. That''s enough energy to turn on my monitor. Twice even.
I learned C++ from C, which I learned from javascript. I''ve been coding with C++ for 4 years. It''s my biggest time waster, and I love it to death. Don''t go poking at my experience just because you feel your point is more valid.
I wouldn''t say it helps to use lazy tactics for larger projects as a lazy tactic is not commenting your code (a religious debate should not ensue, please), following coding standards, however, does help a lot on larger projects.
And when trying to guide others on what to learn, how to learn and where to learn from it usually pays off to have some experience. A beginner in the language might suggest that one use "Sams: Teach Yourself C++ in 21 days", while an experienced C++ programmer who knows the ins and outs of the language will discard the book as being bad, inconsistent and at places blatantly misleading and thus recommend an alternate book that will probably ease the introduction to the language considerably.
If you don''t want me to question your experience don''t make presumptions on what works and what does not in corporations.
Yours truly,
Henrik Stuart
--I am not a church numeral, I'm a free variable!
*Sigh*
Here we go..
Well, considering that in C you cannot give structures functions this is a moot point
I never mentioned trying to "write C-compatible code". I mearly said that it would not be much more difficult than learning standard C structures. As in it''s okay to use classes up to the point of using member functions, until you feel comfortable enough to use the advanced features of them. Perhaps you just misunderstood.
Do you understand the term ''fish'', or ''corn'', or ''houses'', then you''ve understood and is ready to use classes. Really, it''s a real-life concept, as I stated earlier, invented by one of our favourite Greek philosophers.
Perhaps you are of a more intellegent nature, but I had trouble grasping all of the features of classes right away. Maybe I''m the only one. Or maybe you''re too far into your greatness to remember.
First you attack C++ programmers as being lazy then you say you''re lazy? Make up your mind
I consider myself to be a lazy C++ programmer. So the change is suited to lazy programmers. Where did I say that everyone that uses it is lazy? Where did I change my mind?
I wouldn''t say it helps to use lazy tactics for larger projects as a lazy tactic is not commenting your code (a religious debate should not ensue, please), following coding standards, however, does help a lot on larger projects.
Ah, yet a true lazy programmer knows that commenting your code excessively prevents the need to scurry through it later to figure out what something does. The less work needed, the more can be done. Not commenting is either genious or inexperienced. Anyway, perhaps we should drop this issue before someone breaks out the definition of lazy.
If you don''t want me to question your experience don''t make presumptions on what works and what does not in corporations.
Eh? My post was to help someone learn something new, not master the language. Corporations? Eh? I think I''ll stop here before even more things are thrown in.
Here we go..
Well, considering that in C you cannot give structures functions this is a moot point
I never mentioned trying to "write C-compatible code". I mearly said that it would not be much more difficult than learning standard C structures. As in it''s okay to use classes up to the point of using member functions, until you feel comfortable enough to use the advanced features of them. Perhaps you just misunderstood.
Do you understand the term ''fish'', or ''corn'', or ''houses'', then you''ve understood and is ready to use classes. Really, it''s a real-life concept, as I stated earlier, invented by one of our favourite Greek philosophers.
Perhaps you are of a more intellegent nature, but I had trouble grasping all of the features of classes right away. Maybe I''m the only one. Or maybe you''re too far into your greatness to remember.
First you attack C++ programmers as being lazy then you say you''re lazy? Make up your mind
I consider myself to be a lazy C++ programmer. So the change is suited to lazy programmers. Where did I say that everyone that uses it is lazy? Where did I change my mind?
I wouldn''t say it helps to use lazy tactics for larger projects as a lazy tactic is not commenting your code (a religious debate should not ensue, please), following coding standards, however, does help a lot on larger projects.
Ah, yet a true lazy programmer knows that commenting your code excessively prevents the need to scurry through it later to figure out what something does. The less work needed, the more can be done. Not commenting is either genious or inexperienced. Anyway, perhaps we should drop this issue before someone breaks out the definition of lazy.
If you don''t want me to question your experience don''t make presumptions on what works and what does not in corporations.
Eh? My post was to help someone learn something new, not master the language. Corporations? Eh? I think I''ll stop here before even more things are thrown in.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement