Re: which should i learn c or c++ ?
From: Leor Zolman (leor_at_bdsoft.com)
Date: 01/04/04
- Next message: Jason: "Re: [C or C++] Is this legal? sizeof *p"
- Previous message: Chris \( Val \): "Re: which should i learn c or c++ ?"
- In reply to: zc: "which should i learn c or c++ ?"
- Next in thread: Martijn Lievaart: "Re: which should i learn c or c++ ?"
- Reply: Martijn Lievaart: "Re: which should i learn c or c++ ?"
- Reply: jeffc: "Re: which should i learn c or c++ ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 04 Jan 2004 16:06:15 GMT
On Sun, 04 Jan 2004 14:41:32 -0500, zc <zeff@zc2002.free-online.co.uk>
wrote:
>I'm new to computer programming.
>So, should I learn C or C++ ?
>I have a book to learn the C language, but also I have some ebooks to
>learn C++.
>So I have a real problem.
>can someone help ?
Hi,
Since I missed the boat on some of the recent postings on this topic,
I'll take the opportunity to chime in here with my opinion (and with
this question, there are nothing *but* opinions).
As you're approaching this from an academic point of view right now
(rather than having a project you immediately need to ramp up for, so
that the choice of language you learn is based on which one you
actually need to use), here are some trade-offs:
C is a much simpler language, and it is possible to get your brain
completely wrapped around it very quickly (this is perhaps the only
language in modern use where the Standard syntax and libraries can
actually be fully covered in one of those "Learn it in N days"
books...not that I necessarily have any to recommend.) There'll be a
feeling of at least reaching a stable plateau (if not mastery) as you
assimilate C, before you begin the steep ascent of C++ and its OOP
concepts, idioms, more elaborate library (to put it mildly) and
portability issues. I believe that the major benefit of learning C
before C++ is that this approach leaves a bit less of C++ to have to
learn, making it easier to focus on the C++-specific features as you
tackle them. A bonus is to also come away with a cogent view of C's
distinct identity as separate from C++.
As a contract C/C++ instructor teaching courses in week-long chunks,
I'd much rather teach C++ by spending a week on C and then spending
another week on a "C++ for C Programmers" course (my favorite being
one written by Dan Saks I've been teaching for about a decade now). If
all the client has the time (or budget) for is a single week of
training, we'd have to use a "C++ for non-C Programmers" course (I
wrote one organizaionally based on Stephen Prata's "C++ Primer Plus"
book, so it is gratifying to see that book recommended in this group.)
Since you're probably not constrained by a corporate training budget,
you have the luxury of basing the "C or C++ first?" decision on other
things.
Traditionally, the sequence of C followed by C++ begins the "C++" part
by introducing classes, then incorporating your C pointer knowledge by
making the classes to lots of dynamic allocation (e.g., the
ubiquitous simple "string" class), and perhaps only at the end (and
only in fairily up-to-date courses) delving into templates, STL,
exception safety, etc. Now there's a better option, though; after
learning C, go right to a *modern* introductory C++ book, such as
"Accelerated C++" by Koenig and Moo, or Stan Lippman's "Essential C++"
(a book that gets nowhere near the good press it deserves, in my HO).
They'll jump right into using STL, and from your knowledge of C you'll
actually be able to take pretty good guesses at what's going on "under
the covers" of the class implementations even before the books get to
that topic.
Now, the "competing" view says that it is better to start right off
with C++, and there are good reasons for that as well. A few C-isms
have to be unlearned when moving to C++ -- but if you really "get" the
philosophy of C and the history of its rise, those features (such as
the printf family, weaker type-checking, prototype rules, etc.) make
perfect sense for C, and perfect sense to *drop* for C++ as you move
into the C++ mind-set.
Arguably the most confusing aspect of learning C *or* C++ "from
scratch" is mastering pointers. The books above show how to write
productive code before even delving into pointers (by using STL
interfaces that hide their pointer-based impelmentations). I've never
personally taught an introductory C++ course that way, but I'm
seriously looking forward to an opportunity to do it.
The only down-side I can think of to learning C++ the "modern" way is
that in the real world, many C++ shops haven't yet embraced the "Use
STL first if you can, else fall back to data structure design from
scratch with pointers" approach, so the "old" way may actually
represent a better match to production code you'll end up being
involved with. I just hope industry sticks with C++ long enough to
allow the modern approach to become the norm.
Good luck!
-leor
Leor Zolman
BD Software
leor@bdsoft.com
www.bdsoft.com
C++ users: Download BD Software's free STL Error Message
Decryptor at: www.bdsoft.com/tools/stlfilt.html
- Next message: Jason: "Re: [C or C++] Is this legal? sizeof *p"
- Previous message: Chris \( Val \): "Re: which should i learn c or c++ ?"
- In reply to: zc: "which should i learn c or c++ ?"
- Next in thread: Martijn Lievaart: "Re: which should i learn c or c++ ?"
- Reply: Martijn Lievaart: "Re: which should i learn c or c++ ?"
- Reply: jeffc: "Re: which should i learn c or c++ ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|