Xref: utzoo comp.lang.c++:12350 comp.lang.objective-c:206 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!usc!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!emory!gatech!udel!cis.udel.edu From: carroll@cis.udel.edu (Mark Carroll) Newsgroups: comp.lang.c++,comp.lang.objective-c Subject: Re: Static typing, OOP efficiency, and programmer error Message-ID: <48311@nigel.ee.udel.edu> Date: 20 Mar 91 16:24:27 GMT References: <1860@news.tcs.com> <47199@nigel.ee.udel.edu> <27E17FD1.7241@tct.uucp> Sender: usenet@ee.udel.edu Followup-To: comp.lang.c++ Organization: University of Delaware Lines: 68 Nntp-Posting-Host: sol.cis.udel.edu In article <27E17FD1.7241@tct.uucp> chip@tct.uucp (Chip Salzenberg) writes: >According to carroll@cis.udel.edu (Mark Carroll): >>Most of the time, Objective-C is used in a way which could be trivially >>translated into a fully static language like C++. In those cases, Objective-C >>COULD catch any of the errors which C++ could catch. > >The key difference, as I understand it, is that the Objective-C >language does not require the programmer to make available to the >compiler that information that would make possible a complete check of >message vs. object type. > You're not listening to what I said: "Most of the time, Objective-C is used in a way which could be trivially translated... IN THOSE CASES, Obj-C COULD catch any of the errors. If Objective-C is used to do things in the same way in which they would be done in C++, the necessary information to perform error checking is available. It's not explicitly available as in C++ - but a good compiler, by using dataflow, could gather the same information that the C++ compiler has, and could catch any error that the C++ compiler could catch. But note the condition: "If Obj-C is used to do things the same as C++"! >>... by using dataflow analysis to bind statically whenever possible, >>any of the errors that could be caught statically in C++ could be caught >>statically in Objective-C. > >I think that the above statement is incorrect. The C++ language is >incapable of compiling a program that results in an object receiving a >message it can't handle. Objective-C, on the other hand, is. Whether >a given Objective-C compiler can sometimes, or even usually, notice >that error is beside the point. In Objective-C the error is possible; >in C++ it isn't. > The question isn't: is the error possible. Certainly, it's possible to write erroneous code in ANY language. The question is, when is the error going to be caught, and how is it going to be handled? C++ specifies that most errors be caught at compile time. Objective-C doesn't specify when they are caught. Is that a reason to believe that C++ is a "better" language than Objective-C? No. Is that a reason to believe that C++ is a "safer model" that Objective-C? Again, no. Because there is not any safety check possible in the C++ model that could not be performed in the Objective-C model. >> Static versus dynamic binding is a matter of personal taste. > >That's an important issue, and one that doesn't get a lot of air time. >But it's a significant factor in the early success or failure of any >language. > >>I think that my programs are much more elegant written in a dynamic style ... > >I am not willing to sacrifice type safety for elegance. But is that really what's going on? Or are you really just saying that you're willing to sacrifice elegance for compiler simplicity? >Chip Salzenberg at Teltronics/TCT , -- ---------------------- Mark Craig Carroll: ------------------------ ------ U of Del. Grad Student in CIS ------ EE/CIS LabStaff Hacker ------ -- Resident Wierdo @ 105 E Cleveland Ave, Newark DE - carroll@udel.edu -- ---------------------- Shalom Achshav - Peace NOW! ----------------------