Xref: utzoo comp.lang.c++:12231 comp.object:2728 comp.lang.objective-c:197 Path: utzoo!attcan!uunet!hsi!stpstn!kermit!andyk From: andyk@kermit.UUCP (Andy Klapper) Newsgroups: comp.lang.c++,comp.object,comp.lang.objective-c Subject: Re: Static typing and OOP efficiency Message-ID: <6494@kermit.UUCP> Date: 1 Mar 91 14:50:14 GMT References: <1991Feb16.121825.15353@gpu.utcs.utoronto.ca> <27BFDF44.3EA6@tct.uucp> <27C523A2.2155@tct.uucp> <66645@brunix.UUCP> Reply-To: andyk@kermit.UUCP (Andy Klapper) Organization: The Stepstone Corporation, Sandy Hook, CT 06482 Lines: 47 In article <66645@brunix.UUCP> sdm@cs.brown.edu (Scott Meyers) writes: >In article pcg@cs.aber.ac.uk (Piercarlo Grandi) writes: >| First, the speed on non dynamically overloaded messages is exactly the >| same in C++ and Objective C, and as you note later, this is the >| prevalent case. > >Do either of you have a reference for this (presumably empirical) >observation? Frankly, I'm skeptical. Based purely on a seat-of-the-pants >feeling, my guess would be that the dynamic type of a pointer/reference in >C++ frequently differs from its static type, and that most function calls >are to virtual functions. Or did I misunderstand the claim? The Objective-C uses a table of function pointers to handle what we call 'staticly' bound messages (ie. where the compiler knows the type of the object and the name of the selector(method) at compile time). If I understand how C++ works (and I could well be wrong), this means that Objective-C staticly bound messages are just as fast as C++ virtual functions. While slightly slower than C++'s name mangleing scheme it does allow you to change any header files you like without haveing to recompile the world. In addition I would like to state that it is POSSIBLE to make dynamic binding (type and/or selector(method) name are UNKNOWN at compile time) as fast as a compare and an indirect function call 85% of the time. (I hope to get these optimizations added to the Stepstone version of Objective-C at some point in time. I really don't know what changes to the compiler NeXT made or is planning to make). How much messageing do you guys do relative to the rest of your application ? Did you know that the function calling sequence used by Pascal is faster AND smaller than the one used in C ? Why aren't you using Pascal ? My much biased point is that concentrating on this one issue is myopic. The overall hit to your system is small and it can be made smaller. If you are that close to the edge 1) You most likely shouldn't be using Objective-C , 2) you are most likely spending an additional 40% of your time just trying to make your application fit/fast enough than if you were not so close to the edge. I hope the first paragraph at least was informative. -- The Stepstone Corporation Andy Klapper 75 Glen Rd. andyk@stepstone.com Sandy Hook, CT 06482 uunet!stpstn!andyk (203) 426-1875 fax (203)270-0106