C or C++?
ImmaGNUMan: C++ contains the C standard library, so there is no need to learn C.
quote:
Original post by null_pointer
ImmaGNUMan: C++ contains the C standard library, so there is no need to learn C.
I think he is just pointing out that a lot C++-From-The-Beginning programmers don''t ever realize it exists, until someone beats them over the head with them. I find that to be very true, that''s the main reason I tell people to learn C first: so that they figure out the C libraries, and remember them when they use C++.
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said

http://druidgames.cjb.net/
quote:
Original post by Null and Void
I think he is just pointing out that a lot C++-From-The-Beginning programmers don''t ever realize it exists, until someone beats them over the head with them.
How many "C/C++" programmers realize that the C++ standard library exists and actually know how to use it correctly? *whistles nonchalantly* - C++ stream I/O...vector...for_each...

quote:
Original post by Null and Void
I find that to be very true, that''s the main reason I tell people to learn C first: so that they figure out the C libraries, and remember them when they use C++.
That would be nice if many "How to use C" books simply taught C, but they don''t - they teach you a lot of hacks and workarounds that you have to unlearn later, simply because there are much better solutions in C++.
I''m refering to the atof, rand, and qsort, type of functions, the ones that are simplistic enough where people should learn them, but I still see people asking fairly often "How do I convert a string to a float?" et cetera
. I''m not going to bring up the whole argument of whether the C standard library or C++ standard library style functions are better, that''s just a matter of opinion 99% of the time.
"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said

http://druidgames.cjb.net/

"Finger to spiritual emptiness underlying everything." -- How a C manual referred to a "pointer to void." --Things People Said

http://druidgames.cjb.net/
quote:
Original post by Null and Void
I'm refering to the atof, rand, and qsort, type of functions, the ones that are simplistic enough where people should learn them, but I still see people asking fairly often "How do I convert a string to a float?" et cetera.
And what about sort, find_if, for_each, mem_fun, etc. - how many times do you see C++ programmers who don't know that the C++ standard library exists? Don't you see that there is just as much tendency for C++ programmers to remain ignorant of the C standard library as there is for C programmers who move to C++ to remain ignorant of the C++ standard library?
quote:
Original post by Null and Void
I'm not going to bring up the whole argument of whether the C standard library or C++ standard library style functions are better, that's just a matter of opinion 99% of the time.
People tend to confuse ignorance with subjectivity, especially with regards to programming styles. But this is not what I meant when I said that a lot of C techniques have to be unlearned if you wish to take full advantage of C++'s features.
Here is a small list of things that need to be removed:
- Notation.
- Return value chains.
- Many intrusive data structures.
- Use of the preprocessor to define "functions" and "constants" for use in source code.
- Function pointers, when the functions passed can be resolved at compile-time.
- Certain C standard library functions that make use of these techniques, especially qsort vs. std::sort.
When a newbie learns C first (as you advise), he acquires these techniques and adjusts his thinking to make better use of them. This hinders his ability to understand and thus use code from other paradigms, because when he learns C++, he starts with imaginary limitations on C++'s capabilities.
If you only intend to program in C++, there is no reason to learn C.
If you intend to program in both C and C++, I would advise learning C++ first. This enables you to recognize which C coding habits are good in both languages, and which are not. C++ books are typically written with more awareness of the differences between C and C++ than C books.
Edited by - null_pointer on April 16, 2001 11:15:05 AM
I never said don''t learn both, I said learn the C standard library, and of course, learn the C++ standard library.
My advice is this: learn C if you want to become a systems programmer (OS, device drivers, low level stuff), and C++ if you are more interested in high level programming (applications like word processors, spreadsheets, and games).
Also, realize that all languages are good for their purpose and using them for things contrary to that(i.e. creating extra work for yourself) is stupid. The right tool for the job. And don''t let anyone convince you otherwise.
-----------------------------
A wise man once said "A person with half a clue is more dangerous than a person with or without one."
The Micro$haft BSOD T-Shirt
My advice is this: learn C if you want to become a systems programmer (OS, device drivers, low level stuff), and C++ if you are more interested in high level programming (applications like word processors, spreadsheets, and games).
Also, realize that all languages are good for their purpose and using them for things contrary to that(i.e. creating extra work for yourself) is stupid. The right tool for the job. And don''t let anyone convince you otherwise.
-----------------------------
A wise man once said "A person with half a clue is more dangerous than a person with or without one."
The Micro$haft BSOD T-Shirt
-----------------------------A wise man once said "A person with half a clue is more dangerous than a person with or without one."The Micro$haft BSOD T-Shirt
quote:
C++ contains a large set of highlevel constructs while most c construct are relatively straightforward to convert to asm.
Same goes for C++ constructs. The vtble is just an array of function pointers, and overloads are just name mangled functions.
It''s gotta be straight forward to get to the asm, otherwise how would the compiler do it?
I believe Carmack meant he could predict the asm from C better than C++...
Magmai Kai Holmlor
- The disgruntled & disillusioned
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
quote:
Original post by ImmaGNUman
I never said don''t learn both, I said learn the C standard library, and of course, learn the C++ standard library.
You said learn them both; I said there is no reason to learn them both. I don''t recall anyone saying that you said not to learn both. What is your point?
quote:
Original post by ImmaGNUman
My advice is this: learn C if you want to become a systems programmer (OS, device drivers, low level stuff), and C++ if you are more interested in high level programming (applications like word processors, spreadsheets, and games).
BS
quote:
Original post by ImmaGNUman
Also, realize that all languages are good for their purpose and using them for things contrary to that(i.e. creating extra work for yourself) is stupid. The right tool for the job. And don''t let anyone convince you otherwise.
Correct but irrelevant, considering the relationship between C and C++.
Hi,
Most of the time I end up using c++ only for the reason that it supports initialization of data at any time. Not possible in C.
Although I find classes more of a pain in situations such as games etc. So most of my code ends up in C-like but I do like to make use of the few if not all the extra abilities of c++.
If c++ can support whatever C can do then can''t systems programming, Device drivers etc be done in c++ ?
This is more of opinion - both can be used for games, just go with what you like more.
It will always end up in I like C, so I use C or I like C++ so use C++, or learn both. :-).
From my opinion - take the best of both.
Most of the time I end up using c++ only for the reason that it supports initialization of data at any time. Not possible in C.
Although I find classes more of a pain in situations such as games etc. So most of my code ends up in C-like but I do like to make use of the few if not all the extra abilities of c++.
If c++ can support whatever C can do then can''t systems programming, Device drivers etc be done in c++ ?
This is more of opinion - both can be used for games, just go with what you like more.
It will always end up in I like C, so I use C or I like C++ so use C++, or learn both. :-).
From my opinion - take the best of both.
Hello from my world
April 16, 2001 01:25 PM
I learned C first (ahem, ok BASIC before that) and then a couple of years after I learned C++. I use C++ over C all the time now and I think I''ve learned to use it almost as it was intended
.
I don''t use C anymore because I''m very familiar with C++ and I can write trivial programs as quickly in C++. (And non-trivial ones I find easier in C++.)
Some people have said that C++ isn''t very natural. At first I thought C++ was a bit strange but I got a couple of books written by enthusiasts which taught me what makes C++/OOP good (including The C++ Programming Language 3rd Ed, Bjarne Stroustrup). I found that it actually does make sense.
For games programming I use OOP for the larger objects, making good use of constructors, destructors and data hiding. But, as an example, if I was writing a tile-based game I wouldn''t go class heavy on representing the tiles. I''d want to load them ultra fast, taking short cuts wherever possible when loading and displaying them. A constructor safely initialising each one would be inappropriate. On the other hand, tasks like saving and loading games with OOP are a breeze.
I have seen some people try to use OOP in C. I just don''t see what the gain is.
I''d sum up these benefits for C++:
+ It can do anything useful that C can do; it''s a good superset
+ Calling C++ methods on well designed classes makes sense and gives simpler code. Bloating does not necessarily result.
+ Classes take care of themselves. Bugs are more local to classes and easier to track.
I''d say these are the worst bits:
+ You need to be alert when you''re data hiding and playing with OOP ideas to make sure you''re not slowing down anything that is time critical.
+ C++ isn''t foolproof. You can use it improperly. For example, you can use its features to do tricks the language wasn''t intended for.
+ Abusing C++ can result in larger and slower programs.
+ You have to know C++ well to track down obscure bugs caused from such events as failing constructors.
On the topic of future programming languages - I think the anonymous poster is wrong who said that it makes more sense for a language to be suited to the computer than the human. Compilers are for making human code into computer code; the computer doesn''t have to think like a human at all. A good programming language helps you to write code that feels right when you - and other people - use it and that becomes good machine code when it is compiled.
-- Ian Fleeton

I don''t use C anymore because I''m very familiar with C++ and I can write trivial programs as quickly in C++. (And non-trivial ones I find easier in C++.)
Some people have said that C++ isn''t very natural. At first I thought C++ was a bit strange but I got a couple of books written by enthusiasts which taught me what makes C++/OOP good (including The C++ Programming Language 3rd Ed, Bjarne Stroustrup). I found that it actually does make sense.
For games programming I use OOP for the larger objects, making good use of constructors, destructors and data hiding. But, as an example, if I was writing a tile-based game I wouldn''t go class heavy on representing the tiles. I''d want to load them ultra fast, taking short cuts wherever possible when loading and displaying them. A constructor safely initialising each one would be inappropriate. On the other hand, tasks like saving and loading games with OOP are a breeze.
I have seen some people try to use OOP in C. I just don''t see what the gain is.
I''d sum up these benefits for C++:
+ It can do anything useful that C can do; it''s a good superset
+ Calling C++ methods on well designed classes makes sense and gives simpler code. Bloating does not necessarily result.
+ Classes take care of themselves. Bugs are more local to classes and easier to track.
I''d say these are the worst bits:
+ You need to be alert when you''re data hiding and playing with OOP ideas to make sure you''re not slowing down anything that is time critical.
+ C++ isn''t foolproof. You can use it improperly. For example, you can use its features to do tricks the language wasn''t intended for.
+ Abusing C++ can result in larger and slower programs.
+ You have to know C++ well to track down obscure bugs caused from such events as failing constructors.
On the topic of future programming languages - I think the anonymous poster is wrong who said that it makes more sense for a language to be suited to the computer than the human. Compilers are for making human code into computer code; the computer doesn''t have to think like a human at all. A good programming language helps you to write code that feels right when you - and other people - use it and that becomes good machine code when it is compiled.
-- Ian Fleeton
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement