Great question, I used to wonder the same thing until I learned how C++ was implemented using vtables and whatnot. Basically, code only needs to be in memory once, and objects are just pointers to data structures that the interpreter/compiler knows how to deal with. Having a bunch of objects is basically the same thing as having a bunch of structures; the effective difference being that the the order of the function/method name and it's first parameter is swapped. Consider how in perl, the following two are almost identical:
$obj->meth(@args);
and
meth($obj, @args);
The relevent difference is that perl can work some magic knowing what $obj is blessed as, such as finding it's "meth" method in superclasses.
So basically, don't worry about memory overhead: it's not an issue. Code performance is the more serious problem, because of the added indirection in OO architectures and added abstraction inherent in OO designs.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.