home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / object / 5079 < prev    next >
Encoding:
Text File  |  1993-01-28  |  5.4 KB  |  120 lines

  1. Newsgroups: comp.object
  2. Path: sparky!uunet!ukma!gatech!news.ans.net!cmcl2!panix!fhd
  3. From: fhd@panix.com (Frank Deutschmann)
  4. Subject: Re: Maintenance and OO -- the problems of C++
  5. Message-ID: <C1JquC.K4v@panix.com>
  6. Organization: PANIX Public Access Unix, NYC
  7. References: <1993Jan25.093100@axion.bt.co.uk> <harvey.728148390@regina> <24715@alice.att.com>
  8. Date: Thu, 28 Jan 1993 04:22:59 GMT
  9. Lines: 109
  10.  
  11. In <24715@alice.att.com> bs@alice.att.com (Bjarne Stroustrup) writes:
  12. >Let's try to keep discussions of programming and programming languages
  13. >technical.
  14.  
  15. OK, let's go!
  16.  
  17. In <harvey.728148390@regina> harvey@opl.com (Harvey Reed) writes:
  18. >pkeddie@axion.bt.co.uk (Paul Keddie) writes:
  19.  
  20. >>1) Are 00 programs harder to maintain than normal functional programs?
  21.                             ^^^^^^^^^^
  22. I assume that PKeddie really meant traditional structured programs.
  23.  
  24. >IMO a well written OO program is much easier to maintain.
  25. [...]
  26. >Maintaining OO (and C++) requires a more global understanding
  27. >of the system than with C.
  28. >[...]
  29. >so the end result
  30. >is that fixing a line of code can have impact throughout the system.
  31. >[...]
  32. >IMO debugging an OO system is more tedious than traditional C.
  33.  
  34. Isn't this exactly the OPPOSITE of what the goals of OO are?
  35.  
  36. But I agree that with C++ this is definitely the case, though that is
  37. not so with languages more in the Smalltalk and CLOS vein.  Now,
  38. before you hit the Flame key on your keyboard, let's look at why this
  39. is so; specificly, what are the differences/defects of C++ that cause
  40. this to be so?
  41.  
  42. The major flaw of C++ which causes the rippling change effect is that
  43. C++'s requirement for strong type checking leads to heavy base
  44. classes, while the Smalltalk/CLOS approach leads to lightweight super
  45. classes.  In more specific terms, C++ base classes must effectively
  46. define as their interface the UNION of all behavior of their derrived
  47. classes, while Smalltalk/CLOS super classes tend towards the
  48. INTERSECTION of subclass behavior.  Using mix-in style programming can
  49. lessen this, though the basic problem still exists, as it is a
  50. "feature" of type-safety.
  51.  
  52. (As an aside, it would seem to me that this problem would prevent any
  53. sort of mathematical model of OO from covering both Smalltalk/CLOS and
  54. C++ environments.  In other words, while we may talk about all of
  55. these languages being OO, they really embody entirely different
  56. and incompatabile concepts of what OO is.)
  57.  
  58. This problem is the dirrect cause of maintainence headaches: to add
  59. behavior, the maintainer needs to chase inheritance towards the
  60. ultimate base class, causing ripling type problems along the way.
  61. Hence, the need for deep knowledge of the system.  In Smalltalk/CLOS,
  62. the situation is entirely the opposite: there is no need to look at
  63. superclass behavior; rather the maintainer is free to change the
  64. behavior of subclasses without affecting the behavior of superclasses.
  65. I do not need intimate knowledge of the entire view heirarchy (or even
  66. source code access) just to add some new behavior to a specific view
  67. class.
  68.  
  69. Another major contributor to the rippling maintainence problem is the
  70. fact that C++ is effectively a dual-type heirarchy environment; in
  71. other words, there are two distinct categories of objects: those which
  72. are atomic types, and those which are aggregate types.  The fact that
  73. the behavior of the atomics and aggregates can not be made equavallent
  74. leads to an inconsistent language.  Intrestingly, C does not have this
  75. problem -- while C presents aggregate types to the programmer,
  76. internally they are handled simply as collections of atomics.  No
  77. matter how the programmer writes the element/pointer reference, it is
  78. still handled in a consistent way by the compiler, always in terms of
  79. simple pointer arithmetic.  A good demo of C++'s problems in this area
  80. is the pointer to member: with the introduction of this special type,
  81. C++ has created a pointer which is address arithmetic incompatabile
  82. with other pointers.  This is not a good situation!
  83.  
  84. Additional C++ maintainence problems include the idea that typedef's
  85. are not real types, but rather simply synonyms (thereby providing
  86. transparent but rather confusing unless you are intimate with the
  87. system type promotion), while enum's are real types.  This is all
  88. compounded by the notion that the atomics and certain base operations
  89. not be modifiable as an "escape hatch/safety mechanism" -- a seriously
  90. flawed idea that prevents people from building consistent type
  91. heiarchies in C++.
  92.  
  93. IMO, these problems lead not only to maintainence problems, but also
  94. prevent the original goals of OO: simplified systems maintainence to
  95. keep up with evolving systems needs, and reuse of completed
  96. development effort.
  97.  
  98. >I've been using C++ since 1987-88, Modula-2 before that. I enjoy the
  99. >C++ language, but understand peoples frustrations. I would never 
  100. >go back though.
  101.  
  102. This, I have to agree with.  If we get used to the concept of C++ as a
  103. better C (as I read Bjarne Stroustrup state in one of his articles),
  104. then C++ is much easier to swallow.  However, I think we are deluding
  105. ourselves if we attempt to place C++ in the same category as languages
  106. like Smalltalk and CLOS.
  107.  
  108. >++harvey
  109. >===========================================================================
  110. >internet:       harvey@opl.com  /  hreed@cs.ulowell.edu  /  h.reed@ieee.org
  111. >voice/fax:      617-965-0220    /  617-965-7599
  112.  
  113. -frank
  114.  
  115. (OK, *NOW* you can hit the Flame key on your newsreader! :-)
  116. -- 
  117. EMail: fhd@panix.com         |  Do or do not, there is no try.
  118. Phone: 1 - 212 / 765 - 2050  |                                 -- Yoda
  119.  
  120.