October 14th, 2002, 07:49 PM
New to Programming (C++ question)
After ready a few posts similar to mine, I have seen that you guys reccomend C before learning C++. I would just like to comfirm that this is the route to go for someone new to programming (aside from html, but I dont think that counts hehe). Just double checking for myself because i remember seeing in a C++ tutorial that C "poisons" your mind for C++.
Also, if C is necissary, whats a good book to start with? Thanks!
October 14th, 2002, 08:42 PM
Personally, I'd say it's the other way around. To a certain degree, C++ is a superset of C, meaning that most C code is also valid C++ code. So syntactically they can appear to be very similar. C++ is the more complicated of the two languages though, as opposed to C which is a fairly "simple", more minimalistic language.
However, since every programming language is based on certain philosophies, ideas and a certain design, each language comes with its own "mind-set", so to speak. To program C effectively, you need to approach both the language and the problems in a certain way.
C is more like a thin layer on top of assembly; it's a rather low-level, strictly procedural language.
C++ on the other hand incorporates object oriented programming, introducing abstract concepts such as classes, objects and templates. Also, C++ does some of its magic at run-time instead of compile-time.
So, given a problem of at least some complexity, an implementation in C would look quite different from a C++ implementation.
My point is that C and C++ are actually two quite distinctive languages, once you've mastered them. And since C is the more minimalistic of the two, I think it'd be more suited as a first programming language than C++. If you insist on learning object oriented programming right away, you might consider Java, which is a very clean language.
Regarding books on C, I recommend the following:
The C Programming Language, by Kernighan and Ritchie, with Ritchie being the "inventor" of the language. This is a classic, and considered the C bible by many. Some find it hard to read, or have trouble with the exercises, but it is very thorough. It's commonly refered to as K&R.
Expert C Programming, by Peter van der Linden. Once you feel comfortable using C, and think you know pretty much everything, give this a read. Not only are pointers and arrays explained in excruciating detail, but the author also has a great sense of humour :)
C: A Reference Manual, by Harbison & Steele. This is the C reference manual for nitpickers. It even covers trigraphs (of all things) in-depth. Covers the standards, and, unlike most reference manuals, has exercises.
I can't recommend any other introductory books, since I haven't read any of them except for K&R. But I'm sure someone else knows one or two :)
"A poor programmer is he who blames his tools."
October 14th, 2002, 08:50 PM
Ok, thanks so much for the reply!!! I will be going with the K&R book. At www.barnesandnoble.com it got an average rating of 4.5/5 and its only 40$, which from what I have seen is a decent price :). And a follow up question: would Visual C++ 6.0 be good to compile C programs? Thanks again!
October 15th, 2002, 05:14 AM
IMHO I wouldn't bother learning C before C++ unless you wanted to start working with legacy C systems?
Go straight ahead with C++, get a book, "The C++ programming language - Bjarne Stroustrup" the guy who wrote C++ its an invaluable resource.. Also get any books you can (esp Effective C++, and More effective C++) by Scott Meyers, who is a superb C++ writer!
Oh and yes VC++ 6.0 will be fine to compile C programs, but a little bit of overkill to be honest ;)
October 15th, 2002, 09:24 AM
It's rather too much. You can of course use it, but you won't need most of the features. And it's (too) expensive.
My suggestion is, if you're a Wintendo type, that you get Cygwin, read the DOS-Win-to-Linux-HOWTO (chapters 2, 3, 10, 11.4, 11.6, 11.7, 11.8, 11.9, the rest is worth reading too but less important since you haven't actually started using Linux) and use Cygwin (especially, gcc) for your C exercises. If you use Linux, BSD or UNIX anyway, go on using it since you've probably already got a C compiler there. (If you're using Wintendo but are willing to invest a bit more time and HD space, get a Linux distro.)
The advantage of programming in a UNIX-like environment is that a) it's cheap, b) you get a better feeling for the language (C was used on UNIX before Wintendo was born), c) the K&R book is (afaik - I've never read it) rather UNIX-centric (although everything will also work in VC++, since it's ANSI C) and d) Wintendo is for lusers ;)
October 15th, 2002, 01:26 PM
Well I got visual studio 6 for 40$ on student discount, so I think ill use it. That way when I start doing C++ I will be more familiar with the IDE. Thanks so much for the replies!
October 16th, 2002, 07:05 AM
it can be annoying to see c code used in a c++ program instead of the C++ counter parts, learn c++ first to avoid this, then stepping to c is easy if u good at c++
October 16th, 2002, 09:10 AM
Why buying a book when you can get one for free. An excelent C++ book (actually two books: Volume 1 is basics, Volume 2 is advanced) from Bruce Eckel, Thinking in C++, can be downloaded from here: http://www.mindview.net/Books/TICPP/...ngInCPP2e.html
By the way, I agree that learning C before C++ is a good idea (it is like learning to walk before you lear to run), and I fully recommend K&R book.
October 16th, 2002, 02:29 PM
I ordered the K & R book. Thanks for the replies everyone. Correct me if I am wrong, but now that I think about it, I believe it was the Bruce Eckel, "Thinking in C++" that said C ruins your mind for C++.
October 16th, 2002, 02:42 PM
But, my mind is already ruined.
How could having experience is such a similar language ruin your brain for C++? It seems to be all about object orientation in C++, where C is strictly procedureal. Please correct me if I'm wrong, but aren't they about 90% the same?
October 16th, 2002, 02:45 PM
Re: But, my mind is already ruined.
dont ask me :). Ask Bruce Eckel, or read the first few chapters of his eBook lol.
October 17th, 2002, 02:58 AM
Every approach is a meter of taste and personal preferences. C is indeed procedural language, very close to the machine architecture, whose base has not changed in the last 40 years. By learning it one gets closer to the machine, which I found positive (it is like a car driver that is also a bit mechaniker). While C++ is also "quite low" it forces you to concentrate on more complex things (overloading, inheritance, virtual functions, etc.) One notable example is pointers. In C++ they could be substituted (in many cases) with references, in C they are one of the strongest expressions and keep you thinking on the memory level.
My advice would therefore be the following. If you have enough time and want a kind of academic approach, learn C before C++. If, however, you want to be productive as fast as possible (though this could be dangerous) go straight to C++.
November 7th, 2002, 01:28 PM
Lots of conflicting replies :-) Just to add to them, I'd suggest not learning C before C++. In my experience it takes a long time to get out of the 'bad habits' (in C++; perfectly acceptible in C).
As for book recommendations, I'd suggest "Accelerated C++" by Koenig and Moo.
November 13th, 2002, 06:55 AM
i'd say learn c first. your knowledge in c will be valuable in learning c++. c is still very commonly used in OS development.
November 15th, 2002, 02:15 AM
I am using VC++ for 2-3 years working with C++. When I had to compile programs that my students had to write in C the result was broken nerves. C++ is in many ways a superset of C but is stricter. And this makes the difference in projects that C should be used (writing a driver). Therefore, if somebody is serious about learning anu using C should use a C compiler. KDevelop for example has different project settings for C projects. I would sugges cygwin along with an editor you like. Well that's my two pennies.