Article View: comp.os.msdos.programmer
Article #6230Re: Newbie Wants Advice on C-Programming
From: Ralph W. Trickey
Date: Wed, 30 Dec 1992 17:29
Date: Wed, 30 Dec 1992 17:29
105 lines
6353 bytes
6353 bytes
I would like to add my $.02 to this discussion In article <1992Dec30.055154.22465@grebyn.com>, malak@grebyn.com (Michael Malak) writes: |> In article <24506@alice.att.com> bs@alice.att.com (Bjarne Stroustrup) writes: |> > |> >Consider a few common questions: |> > |> > I don't know C or C++, should I learn C first? |> > |> >No. Learn C++ first. The C subset of C++ is easier to learn for C/C++ |> >novices and easier to use than C itself. The reason is that |> >C++ provides better guarantees than C (stronger type checking). |> >In addition, C++ provides many minor features, such as the `new' |> >operator, that are notationally more convenient and less error-prone |> >than their C alternatives. Thus, if you plan to learn C and C++ (or |> >just C++) you shouldn't take the detour through C. To use C well, |> >you need to know tricks and techniques that aren't anywhere near |> >as important or common in C++ as they are in C. Good C textbooks |> >tends (reasonably enough) to emphasize the techniques that you |> >will need for completing major projects in C. Good C++ textbooks, |> >on the other hand, emphasizes techniques and features that lead |> >to the use of C++ for data abstraction and object-oriented programming. |> >Knowing the C++ constructs, their (lower-level) C alternatives are |> >trivially learned (if necessary). |> > |> |> This is where I respectfully disagree with you. While programmers |> undoubtedly do well under your personal tutelage, my experience has been |> that FORTRAN programmers who teach themselves C commit the cardinal sins |> against good programming practice that I listed in a previous post. In |> my opinion, structured programming, style, and good habits must be |> taught by a teacher. And since most structured programming teachers |> prefer Pascal, I recommended taking a college structured programming |> Pascal course. This is where I have to respectfully disagree with both of you. It is vital to learn structured programming first. The problem is that there are no courses that teach structured programming, and I don't think an introductory Pascal course would really cover structured programming either. I haven't been in college for a while, but I don't remember any specific course that taught structured programming, style, and good habits, it was more something that happened from reading a large number of samples in magazine articles, and making my own mistakes. I think that you would learn as much from a modern C course, and it looks better on a resume. If the only option is to learn from books, I would start with a few good books that covered ANSI C, not C++. The C++ books that I have seen make a lot of assumptions about what the reader knows, and throw too many new ideas at you at once. Your mileage may vary. Look through the first couple of chapters in the available books, if they seem understandable, then get the one that you prefer, whether it is for C or C++. If it is a toss-up, then go for the C++ book. Remember that you are learning more than one thing, you are learning both the C syntax and customary usage. Any book will teach you the syntax, but programming style is more difficult, remember back to the first programs you wrote, and expect to feel the same way about your first C or C++ programs next year. You are starting at the bottom of the curve again. |> |> Your points about the superior subset of C in C++ are good, but I don't |> see anywhere in your book where you caution novices against jumping into |> class creation right away and just learning the traditional features. |> Again, one could benefit from having a teacher such as yourself, but the |> one who is trying to teach himself does not have such guidance and could |> quickly get mired in the advanced features of C++. I recommended |> self-teaching C before C++ because the trick to C++ is when _not_ to |> create a class, and I've found this mentioned only in articles and never |> in any textbooks. It depends, if the person is working on a critical project, he should definitely use C++ as a better C, and avoid classes except for using them for data hiding. I learned C++ on my own and made the mistake of going whole-hog with classes. Luckily, the project wasn't critical. I learned a lot more from making my own mistakes than I did from reading books. Especially about the design issues that aren't covered. There is too much black magic involved in class design on a non-trivial project. |> |> I think the suggestion of a FORTRAN programer jumping into C on his own |> is a very bad one, and the idea of him getting into C++ is ludicrous. |> I agree that it would be a great idea for someone to go through an intermediate language like Pascal first so they can learn structured programming, but that won't be practical most of the time. I think that a programmer would be a lot better off in going to C++ as a better C instead of C. The problem is that there are better textbooks out for C than there are for using C++ as a better C. Over half of a typical C++ book is given to teaching about classes. But he should use C++ only as a better C until he is comfortable with the syntax. C++ will protect the programmer from a lot of simple mistakes, and there are a lot more friendly tools for C++ (like math.h++, and the streams libraries) that aren't available for C. I agree that he shouldn't jump right into Object-Oriented Analysis and Design. -- Ralph Trickey | (513) 865-6800 | Mead Data Central | x4870 | Disclaimer P.O. Box 933 | ralpht@meaddata.com | My opinions are my own Dayton, Ohio 45401 | ...!uunet!meaddata!ralpht |
Technical Details
Message-ID:
<1hsma7INNsrt@meaddata.meaddata.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!meaddata!ralphtReferences:
<1992Dec25.073517.16089@grebyn.com> <1992Dec29.003005.27059@ucc.su.OZ.AU> <24506@alice.att.com> <1992Dec30.055154.22465@grebyn.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!meaddata!ralpht From: ralpht@meaddata.com (Ralph W. Trickey) Newsgroups: comp.os.msdos.programmer,comp.lang.c++,comp.lang.c Subject: Re: Newbie Wants Advice on C-Programming Date: 30 Dec 1992 17:29:43 GMT Organization: Mead Data Central, Dayton OH Lines: 107 Distribution: world Message-ID: <1hsma7INNsrt@meaddata.meaddata.com> References: <1992Dec25.073517.16089@grebyn.com> <1992Dec29.003005.27059@ucc.su.OZ.AU> <24506@alice.att.com> <1992Dec30.055154.22465@grebyn.com> NNTP-Posting-Host: retina.meaddata.com