I'm not so sure that the overhead for C++ objects is quite a bad as everyone's
making them out to be. Most of it boils down to simple pointer math and in other cases the
compiler itself can abstract away some of the offset calculations. If variables live on
the stack anyway, you'd have to do these offset calculations to get the data as well.
________________________________
From: Sean Conner <spc at conman.org>
To: General Discussion: On-Topic and Off-Topic Posts <cctalk at classiccmp.org>
Sent: Tue, February 9, 2010 4:18:31 PM
Subject: Re: Algol vs Fortran was RE: VHDL vs Verilog
It was thus said that the Great Dave McGuire once stated:
On Feb 9, 2010, at 3:49 PM, Josh Dersch wrote:
Template programming is another paradigm
altogether, it's basically
C++ specific and it has very little to do with OO. (It's also an
abomination along with most of C++.)
C# has a form of templates, if memory serves. I believe they're
called "generics". Name one non-OO language that has such a
construct. I don't know of any.
Heh ... I've done templates in C. Portably too! Of course, it would win
the "Biggest Abuser of the C Preprocessor" Award, but I did it (back in
college---it seemed like a good idea at the time).
I beleive tha
in Objective C, ints are still registers, no magical
Integer objects here. Sounds like Mail.app is poorly written. I'm
running Outlook here (written in a mix of c and c++) and it's using
100mb (with an inbox size of 10gb...).
Again I'm going to try to find the in-memory representation of
those integer objects. Regardless, however, this was just an
example...I'm sure you see my point. You're suggesting that OO
programming involves no runtime overhead over procedural/imperative
languages when run on processors whose architecture is arguably
procedural/imperative.
It really depends upon the implementation of objects. I've done enough
"manual object oriented programming in C" to guess what C++ does under the
hood. For the "objects" that had fixed methods (not real sure of the
terminology here, as I don't program in C++) the overhead is just one
additional parameter (the object itself, or "this"). If the compiler can
figure out the method to call at compile time, there's very little overhead.
You really
think these same programmers would somehow write better
code if only they would stop using OO?
Yes, absolutely. Most OO languages give bad programmers more code-
inflating features to misunderstand and abuse. If they don't know
how to write good code in C, which is a tiny, very fast, very low-
overhead, very simple language with very few features, how can they
be expected to write good code in C++, C# or Java, which are anything
but?
I counter that argument with PHP pre 5x. Not OO at all, and the code
quality, is ... um ... let's just say that osCommerce (a shopping cart
written in PHP) has been stuck at version 2.2 for several years because it's
too hideous to maintain ...
-spc (Might even suggest Perl, but then the counter to that is Forth ... )