From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,724ec2348205c52c X-Google-Attributes: gid109fba,public X-Google-Thread: fac41,b87849933931bc93 X-Google-Attributes: gidfac41,public X-Google-Thread: 1108a1,b87849933931bc93 X-Google-Attributes: gid1108a1,public X-Google-Thread: 103376,b87849933931bc93 X-Google-Attributes: gid103376,public X-Google-Thread: 114809,b87849933931bc93 X-Google-Attributes: gid114809,public From: Mike Stark Subject: Re: OO, C++, and something much better! Date: 1997/06/28 Message-ID: <33B5181C.667F@gsfc.nasa.gov>#1/1 X-Deja-AN: 253219376 References: <32ED02EE.22E2@netright.com> <32ED2448.685A@parcplace.com> <32EE20A3.755D@netright.com> <5cm364$dc2@topdog.cs.umbc.edu> <5cr068$gpa@uni.library.ucla.edu> <33B43B2F.5D9F@corp.mot.com> Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA Newsgroups: comp.object,comp.lang.c++,comp.lang.ada,comp.lang.smalltalk,comp.lang.eiffel Date: 1997-06-28T00:00:00+00:00 List-Id: David Shang wrote: > > Jay Martin wrote: > > > > Heh. Look at Microsofts API's, requires casts everywhere. The COM > > model, their ultimate "object-oriented model", requires a cast just > > call a method on a object. Since, Wintel is on like 90%(?) of > > installed machines, thats practically everyone. C/C++ programmers > > "cast" more than programmers of other languages. > > Please be specific on what sitiuations that C++ requires more casts > than other languages such as Java and Eiffel? > > The fact that a system that happens to use C++ has a lot of casts > does not mean that C++ requires more casts. The system may use the same > amount of casts if it is implemented in other languages in the same way. > > There are two cases that we need casts: > > 1. The type of the object from the outside of an open world is > unknown and must be verified. > > 2. The type of a declared variable within the world is not precise > enough to exclude bad cases. > > We cannot avoid the first case. But the second case should be avioded > as much as possible. > > Unfortunately, C++ as well as other languages does not deal with the > second case perfectly, especially in the csae where types are dependent. > > Transframe does better on this issue. It requires fewer casts than any > other languages. > > David Shang Another situation (or maybe a variation of one of the above) is in languages such as Java that lack generics -- then you are required to have lists and queues of class java.lang.Object, and are required to check "instanceof" and then cast once you start looking at an item from that container. I find that most annoying. Ada generics solve this by allowing you to define precisely what type is contained, including a type at the root of a class hierarchy to allow heterogeneous data. C++ and Eiffel also provide this (or so I'm told, I haven't used C++ templates, or Eiffel at all), and while I like a lot of things about Java, the lack of generics and the consequences is most annoying. Mike -- -------------------------------------------------------------------------------- Michael Stark NASA/GSFC Phone: (301) 286-5048 Code 551 Fax: (301) 286-0245 Greenbelt, MD 20771 e-mail: michael.e.stark@gsfc.nasa.gov "I don't give them hell. I tell the truth and they THINK it's hell!" Harry S. Truman --------------------------------------------------------------------------------