home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / msdos / programm / 11701 < prev    next >
Encoding:
Internet Message Format  |  1992-12-30  |  6.2 KB

  1. Xref: sparky comp.os.msdos.programmer:11701 comp.lang.c++:18545 comp.lang.c:19031
  2. Path: sparky!uunet!meaddata!ralpht
  3. From: ralpht@meaddata.com (Ralph W. Trickey)
  4. Newsgroups: comp.os.msdos.programmer,comp.lang.c++,comp.lang.c
  5. Subject: Re: Newbie Wants Advice on C-Programming
  6. Date: 30 Dec 1992 17:29:43 GMT
  7. Organization: Mead Data Central, Dayton OH
  8. Lines: 107
  9. Distribution: world
  10. Message-ID: <1hsma7INNsrt@meaddata.meaddata.com>
  11. References: <1992Dec25.073517.16089@grebyn.com> <1992Dec29.003005.27059@ucc.su.OZ.AU> <24506@alice.att.com> <1992Dec30.055154.22465@grebyn.com>
  12. NNTP-Posting-Host: retina.meaddata.com
  13.  
  14. I would like to add my $.02 to this discussion
  15.  
  16. In article <1992Dec30.055154.22465@grebyn.com>, malak@grebyn.com (Michael Malak) writes:
  17. |> In article <24506@alice.att.com> bs@alice.att.com (Bjarne Stroustrup) writes:
  18. |> >
  19. |> >Consider a few common questions:
  20. |> >
  21. |> >    I don't know C or C++, should I learn C first?
  22. |> >
  23. |> >No. Learn C++ first. The C subset of C++ is easier to learn for C/C++
  24. |> >novices and easier to use than C itself. The reason is that
  25. |> >C++ provides better guarantees than C (stronger type checking).
  26. |> >In addition, C++ provides many minor features, such as the `new'
  27. |> >operator, that are notationally more convenient and less error-prone
  28. |> >than their C alternatives. Thus, if you plan to learn C and C++ (or
  29. |> >just C++) you shouldn't take the detour through C. To use C well,
  30. |> >you need to know tricks and techniques that aren't anywhere near
  31. |> >as important or common in C++ as they are in C. Good C textbooks
  32. |> >tends (reasonably enough) to emphasize the techniques that you
  33. |> >will need for completing major projects in C. Good C++ textbooks,
  34. |> >on the other hand, emphasizes techniques and features that lead
  35. |> >to the use of C++ for data abstraction and object-oriented programming.
  36. |> >Knowing the C++ constructs, their (lower-level) C alternatives are
  37. |> >trivially learned (if necessary).
  38. |> >
  39. |> 
  40. |> This is where I respectfully disagree with you.  While programmers
  41. |> undoubtedly do well under your personal tutelage, my experience has been
  42. |> that FORTRAN programmers who teach themselves C commit the cardinal sins
  43. |> against good programming practice that I listed in a previous post.  In
  44. |> my opinion, structured programming, style, and good habits must be
  45. |> taught by a teacher.  And since most structured programming teachers
  46. |> prefer Pascal, I recommended taking a college structured programming
  47. |> Pascal course.
  48.  
  49. This is where I have to respectfully disagree with both of you. 
  50. It is vital to learn structured programming first. The problem is that
  51. there are no courses that teach structured programming, and I don't
  52. think an introductory Pascal course would really cover structured
  53. programming either. I haven't been in college for a while,
  54. but I don't remember any specific course that taught structured
  55. programming, style, and good habits, it was more something that
  56. happened from reading a large number of samples in magazine articles,
  57. and making my own mistakes. I think that you would learn as much from
  58. a modern C course, and it looks better on a resume.
  59.  
  60. If the only option is to learn from books, I would start with a few
  61. good books that covered ANSI C, not C++. The C++ books that I have
  62. seen make a lot of assumptions about what the reader knows, and throw
  63. too many new ideas at you at once. Your mileage may vary.
  64.  
  65. Look through the first couple of chapters in the available books, if
  66. they seem understandable, then get the one that you prefer, whether it
  67. is for C or C++. If it is a toss-up, then go for the C++ book.
  68. Remember that you are learning more than one thing, you are learning
  69. both the C syntax and customary usage. Any book will teach you the
  70. syntax, but programming style is more difficult, remember back to the
  71. first programs you wrote, and expect to feel the same way about your
  72. first C or C++ programs next year. You are starting at the bottom of
  73. the curve again.
  74.  
  75. |> 
  76. |> Your points about the superior subset of C in C++ are good, but I don't
  77. |> see anywhere in your book where you caution novices against jumping into
  78. |> class creation right away and just learning the traditional features.
  79. |> Again, one could benefit from having a teacher such as yourself, but the
  80. |> one who is trying to teach himself does not have such guidance and could
  81. |> quickly get mired in the advanced features of C++.  I recommended
  82. |> self-teaching C before C++ because the trick to C++ is when _not_ to
  83. |> create a class, and I've found this mentioned only in articles and never
  84. |> in any textbooks.
  85.  
  86. It depends, if the person is working on a critical project, he should
  87. definitely use C++ as a better C, and avoid classes except for using
  88. them for data hiding. I learned C++ on my own and made the mistake of
  89. going whole-hog with classes. Luckily, the project wasn't critical. I
  90. learned a lot more from making my own mistakes than I did from reading
  91. books. Especially about the design issues that aren't covered. There
  92. is too much black magic involved in class design on a non-trivial
  93. project.
  94.  
  95. |> 
  96. |> I think the suggestion of a FORTRAN programer jumping into C on his own
  97. |> is a very bad one, and the idea of him getting into C++ is ludicrous. 
  98. |> 
  99.  
  100. I agree that it would be a great idea for someone to go through an
  101. intermediate language like Pascal first so they can learn structured
  102. programming, but that won't be practical most of the time.
  103.  
  104. I think that a programmer would be a lot better off in going to C++ as
  105. a better C instead of C. The problem is that there are better
  106. textbooks out for C than there are for using C++ as a better C. Over
  107. half of a typical C++ book is given to teaching about classes. But he
  108. should use C++ only as a better C until he is comfortable with the
  109. syntax. C++ will protect the programmer from a lot of simple mistakes,
  110. and there are a lot more friendly tools for C++ (like math.h++, and
  111. the streams libraries) that aren't available for C. I agree that he
  112. shouldn't jump right into Object-Oriented Analysis and Design.
  113.  
  114. -- 
  115. Ralph Trickey       | (513) 865-6800                  |        
  116. Mead Data Central   | x4870                           |  Disclaimer
  117. P.O. Box 933        | ralpht@meaddata.com             |  My opinions are my own
  118. Dayton, Ohio  45401 | ...!uunet!meaddata!ralpht       |
  119.  
  120.  
  121.