home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 19957 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  6.3 KB

  1. Xref: sparky comp.lang.c++:19957 comp.object:5071
  2. Path: sparky!uunet!gatech!darwin.sura.net!paladin.american.edu!howland.reston.ans.net!spool.mu.edu!olivea!pagesat!spssig.spss.com!uchinews!alex!dave
  3. From: dave@alex.uchicago.edu (Dave Griffith)
  4. Newsgroups: comp.lang.c++,comp.object
  5. Subject: Re: Pros and cons of C++
  6. Message-ID: <1993Jan26.145454.21534@midway.uchicago.edu>
  7. Date: 26 Jan 93 14:54:54 GMT
  8. References: <1993Jan13.215141.14487@informix.com> <TMB.93Jan14144656@arolla.idiap.ch> <C1G9H4.HsA@unix.portal.com>
  9. Sender: news@uchinews.uchicago.edu (News System)
  10. Organization: University of Chicago
  11. Lines: 100
  12.  
  13. In article <C1G9H4.HsA@unix.portal.com> samantha@shell.portal.com (Samantha Atkins) writes:
  14. >In article <TMB.93Jan14144656@arolla.idiap.ch> tmb@idiap.ch writes:
  15. >>In article <1993Jan13.215141.14487@informix.com> cshaver@informix.com (Craig Shaver) writes:
  16. >>
  17. >>   We have been fed strong type checking for some time via Nick Wirth and
  18. >>   the original pascal teaching language.  This led to ADA which is still-born
  19. >>   in the commercial world.
  20. >>
  21. >>Pascal's, Ada's, and C's type systems are quite antiquated. Many
  22. >>modern "strong" type checkers (static type checkers) are very
  23. >>expressive and flexible; for much of the code written for such type
  24. >>checkers, you wouldn't even be able to tell whether the code is
  25. >>statically or dynamically typed.
  26. >>
  27. >>                    Thomas.
  28. >
  29. >Hmmmm.  It seems to me that a couple of problems exist with all the static
  30. >type languages (compile time checking) that I am familiar with.
  31. >
  32. >The first problem is that such languages require recompilation of any and
  33. >all affected code whenever the type hierarchy is reworked even if this 
  34. >results in no changes at all to the behavior of any objects in the application.
  35. >In practice for larger projects this is an unholy terror.  I may be wrong
  36. >but I thought that one of the blessings of OO was being able to refine a
  37. >design even with working code in the field with little or no impact.  
  38. >
  39.  
  40. No question, better tools for this sort of thing are clearly needed.  A lot 
  41. of the problem is that it is tough to reconcile the needs of being able to
  42. dynamically restructure the heirarchy with the needs of separate compilation.
  43. We'll probably have to go to some sort of managed incremental compilation
  44. regime to get the effects you want.
  45.  
  46. >The second problem is related in that most such languages use type based
  47. >checking.  It seems to me that what we are really concerned with is:
  48. >    a) does this object understand the message we are sending?
  49. >    b) does its behavior conform to what we intended in response?
  50. >No object language I am aware of does a message based much less a decent
  51. >semantic based check.  So in what way has safety been assured really?
  52. >Only in that the type understands the message.  OK.  So if I want to get
  53. >the maximum flexibility I would probably tend to factor my class hierarchy
  54. >very highly with lots and lots of mix-in classes for every reasonable 
  55. >set of behaviors.  Then for working classes I would mix and match to 
  56. >produce just what I need.  Here we run into some sticky situations in that
  57. >not only would I need all these little mixins but I would also quite likely
  58. >need various equally abstract classes that represent various combinations
  59. >of them as my typing of say, parameters, is only class based and I want to
  60. >leave maximum flexibility and reuse in.  Now it seems pretty obvious to me
  61. >that over time I'm going to want to change this around or add more combinations
  62. >as I can't just declare the whole exponential mess right the first time.  
  63. >Also we would have to contend with the unpleasant fact that all this churning
  64. >through this exponentially growing hierarchy takes real CPU time and resources
  65. >that eventually will get very seriously strained.
  66. >
  67. >Am I going askew here or is it as it seems to me that so called strong typing
  68. >creates an untenable mess if you seriously attempt its use now and for the
  69. >future?
  70. >
  71.  
  72. I'm not sure what you mean by message based checking.  If you just mean that
  73. every reciever of a message is gauranteed to respond to the message we are
  74. sending, with the arguments given it, such languages do exist.  Eiffel is
  75. one, and even C++ will act this way if you don't try to fool the type checker.
  76. Semantic checks are rare, but can also be had (runtime, not compile-time).  
  77.  
  78. As to the problem with mixins, the problem exists, but it is not with
  79. strong typing per se.  It is with the current fashion of conflating the
  80. type heirarchy and the class heirarchy.  There is no reason, particularly,
  81. that all of your little mixins need to be full fledged types.  There is no
  82. reason to declare a variable to be of one of those mixin's, for instance.
  83. Many of them will be just different (possibly partial) implementations of 
  84. certain types (protocol might be a better word here, type is dreadfully 
  85. overloaded in language discussions).  What I want to see, is a language 
  86. where protocols and implementations are definable independently.  Protocols
  87. may for a heirarchy by subtyping, implementations form a heirarchy by
  88. inheritance.  Inheritance can thus be just a form of code-sharing, possibly
  89. not the only such form in the language.  There will no longer be as much 
  90. danger of "spaghetti inheritance" because the chief danger of using inheritance
  91. for code-sharing, namely corruption of the subtype heirarchy, will be gone.
  92. Factoring based on implementation will no longer conflict with factoring on
  93. protocol, and the exponential mess you describe will just disappear.  Types
  94. may have more than one implementation, and implementations may fulfill more
  95. than one type.
  96.  
  97. (For my fans, Rorschach has precisely this sort of type system.)
  98.  
  99. Strong typing is certainly necessary, as it seems to cut down debug time and
  100. system integration time and increase runtime safety.  It is also the case
  101. that type systems to date have been far too inflexible, requiring workarounds
  102. to acheive the desired program semantics at reasonable efficiency.  These
  103. workarounds damaged the integrity of the type system, and added to language
  104. complexity.  It is my belief that strong behavior-based type systems might
  105. solved this problem, as strong structure-based type systems (C (if you don't
  106. cheat), Ada, ML) seem not up to it.
  107.  
  108. -- 
  109. Dave Griffith, Information Resources, University of Chicago,
  110. Department of Surgery                       dave@alex.bsd.uchicago.edu
  111. When buying and selling are controlled by legislation, the first things bought
  112. and sold are legislators.
  113.