Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!samsung!uunet!mcsun!ukc!warwick!estdwha From: estdwha@warwick.ac.uk (CrisP) Newsgroups: comp.sys.amiga.misc Subject: Re: Object Oriented Programming Message-ID: <1991Jan30.144546.10478@warwick.ac.uk> Date: 30 Jan 91 14:45:46 GMT References: <42954@nigel.ee.udel.edu> <749@caslon.cs.arizona.edu> Sender: news@warwick.ac.uk (Network news) Organization: Computing Services, Warwick University, UK Lines: 52 In article <749@caslon.cs.arizona.edu> dave@cs.arizona.edu (Dave P. Schaumann) writes: >In article <42954@nigel.ee.udel.edu> NJ_GOKEM%FANDM.BITNET@pucc.princeton.edu writes: >|Hi out there, >| >|I am taking a seminar in Object Oriented Programming, and now the class >|seems to believe that OOP is slower than Procedure-programming. >|An article in Byte in 86 argues that it could be 50 % slower. >| >|I want to help this belief out of the world! >| Does anyone have any comments? >|Or is C++, and Smalltalk slower than regular C ??? > >Yes, it is true. Object oriented programming languages are generally slower >than more traditional languages. Additionally, many OOPL (like Smalltalk) >are traditionally interpreted (slowing them down more). > >|The basic argument is that the computer would spend too much time trying to >|find the right "METHOD" in the tree of inherited "METHODS", since OBJECTS >|inherit a lot of "METHODS". Is this TRUE? > >The designers of C++ took the course of getting OO functionality with the >minimum amound of cost at execution time. They got it down to the cost >of an extra indirection for every function call. Eg., a call like >bar->foo() in C++ translates to something like (*bar->foo)() in actuality. >(modulo the hidden 'self' parameter, of course). Not quite. bar->foo() in C++ translates to something like foo(bar) in C. Actualy it doesn't use foo but a symbol that is "unique" to a call the foo in that perticular class. ( Whatever class bar may be. ) So in theory a C++ program should execute just as fast as a C program. The style of object oriented programming sacrifices some executing speed for development speed. In reality the C++ compilers arn't as good as the C compilers alough there is no reson why the can't be. I don't know how the C++ to C interpreters produce less efficent code than code written C in an similar style, but CC-2.1 on a Sun3 seems to do it. > >The moral of the story is There Aint No Such Thing As A Free Lunch. >(say, that sounds familiar...) > >|Nils Gokemeijer >|(NJ_GOKEMEIJE@FANDM.bitnet) > > >Dave Schaumann | And then -- what then? Then, future... >dave@cs.arizona.edu | -Weather Report ~CrisP. -- ------------------------------------------------- crisp@uk.ac.warwick.cs | estdwha@uk.ac.warwick.cu -------------------------------------------------