IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New How?
By using an efficient memory model for storing objects and then making everything an object with a minimal useful protocol. (there's a lot of fat in the C++ memory model in places - using 32 bits to store a boolean for instance and lots of stuff are padded up for the convenience of the memory bus - makes for very wasteful space usage).













C++ type sizes in bytes
bool:4
char:1
short:2
int:4
long:4
long long:8
float:4
double:8
void*:4
EmptyClass:1
EmptyVirtualClass:4


So a boolean is mostly wasted space! Minimum "Object" size is 4 bytes (pointer for to vtable). The empty class has no virtual method so its the size of the sum of its elements with a lower bound of 1 byte. Certainly most C++ has lots of unused memory space in little fragments all over the place.

Smalltalk OTOH uses "a variable-length header format which seldom requires more than a single 32-bit word of header information per object. The format is given in Tables 1 and 2.
Table 1: Format of a Squeak object header offset contents occurrence
-8 size in words (30 bits), header type (2 bits) 1%
-4 full class pointer (30 bits), header type (2 bits) 18%
0 base header, as follows...
storage management (3 bits)
object hash (12 bits)
compact class index (5 bits)
object format field (4 bits, see below)
size in words (6 bits)
header type (2 bits) 100%


Table 2: Encoding of the object format field in a Squeak object header 0 no fields
1 fixed pointer fields
2 indexable pointer fields
3 both fixed and indexable pointer fields
4 unused
5 unused
6 indexable word fields (no pointers)
7 unused
8-11 indexable byte fields (no pointers):
low 2 bits are low 2 bits of size in bytes
12-15 compiled methods: low 2 bits are low 2 bits of size in bytes.
The number of literals is specified in method header, followed by the indexable bytes that store byte codes.

Our design is based on the fact that most objects in a typical Smalltalk image are small instances of a relatively small number of classes. The 5-bit compact class index field, if non-zero, is an index into a table of up to 31 classes that are designated as having compact instances; the programmer can change which classes these are. The 6-bit size field, if non-zero, specifies the size of the object in words, accommodating sizes up to 256 bytes (i.e., 64 words, with the additional 2 bits needed to resolve the length of byte-indexable objects encoded in the format field). With only 12 classes designated as compact in the 1.18 Squeak release, around 81% of the objects have only this single word of overhead. Most of the rest need one additional word to store a full class pointer. Only a few remaining objects (1%) are large enough to require a third header word to encode their size, and this extra word of overhead is a tiny fraction of their size. "

From here: [link|ftp://st.cs.uiuc.edu/Smalltalk/Squeak/docs/OOPSLA.Squeak.html|ftp://st.cs.uiuc.edu...OPSLA.Squeak.html]

So which language is more type safe at runtime? The one where you can tell what the bits mean that you are looking at or the one that struggles to prevent the creation of instructions that misinterpret the bits and thus makes assumptions with every memory access?

C++ is a naive hack that got way out of hand.

Edit - fixed html table



It has been discovered that C++ provides a remarkable facility for concealing the trival details of a program -- such as where its bugs are. (David Keppel)
Expand Edited by tuberculosis May 2, 2003, 03:28:52 PM EDT
Expand Edited by tuberculosis May 2, 2003, 07:01:38 PM EDT
Expand Edited by tuberculosis Aug. 21, 2007, 06:23:01 AM EDT
New Erm?
C++ type sizes in bytes
bool: 4 [...]

What compiler are you using?!?

There isn't a C++ compiler That I'm aware of (Visual C++ 4.2 notwithstanding) that uses more than a byte to hold a bool (and that includes g++ 2.9x.x)
jb4
"We continue to live in a world where all our know-how is locked into binary files in an unknown format. If our documents are our corporate memory, Microsoft still has us all condemned to Alzheimer's."
Simon Phipps, SUN Microsystems
New GNU CPP version 2.95.2 19991024 (release)



"Packed like lemmings into shiny metal boxes.
Contestants in a suicidal race."
    - Synchronicity II - The Police
Expand Edited by tuberculosis Aug. 21, 2007, 06:38:43 AM EDT
New Sorry to hear that...:-(
Interesting...the 2.95.2 version I was using with QNX used a single byte to represent a bool.
jb4
"We continue to live in a world where all our know-how is locked into binary files in an unknown format. If our documents are our corporate memory, Microsoft still has us all condemned to Alzheimer's."
Simon Phipps, SUN Microsystems
     C++ File I/O: Windows vs. Linux - (tjsinclair) - (85)
         Wild guess - (JayMehaffey) - (1)
             Nope - (tjsinclair)
         Permissions problem? - (tuberculosis) - (16)
             Possibly - (tjsinclair) - (15)
                 The only dumb question is... - (jbrabeck) - (14)
                     Thanks - (tjsinclair) - (13)
                         I'd second the permissions... - (jbrabeck) - (12)
                             Played with error bits - (tjsinclair) - (11)
                                 C++ for real work - (tuberculosis) - (10)
                                     telco's use lots of c++ -NT - (boxley) - (7)
                                         on UNIX? - (tjsinclair) - (6)
                                             well several softswitches and other software (added link) - (boxley) - (2)
                                                 Yeah - OS level code I think - (tuberculosis) - (1)
                                                     Stacked based types? - (deSitter)
                                             some more info on c++ Unix and Telcos and jobs - (boxley) - (2)
                                                 CORBA == Objects, so makes sense - (tjsinclair)
                                                 Resume mailed -NT - (tuberculosis)
                                     Someone somewhere must be using it - (tjsinclair)
                                     Network Management software - (Arkadiy)
         I don't know C++ but... - (ben_tilly) - (6)
             Seems like it ought to raise an exception on failure -NT - (tuberculosis) - (5)
                 It does - (tjsinclair) - (4)
                     Erroring out? - (tuberculosis) - (3)
                         I checked the ios error flags - (tjsinclair) - (2)
                             Thats not raising an exception - (tuberculosis) - (1)
                                 Agreed - (tjsinclair)
         Got it! - (tjsinclair) - (58)
             Now, this is really scary - (Arkadiy) - (53)
                 Even scarier - (tjsinclair) - (52)
                     At this point, one wants to,, - (deSitter) - (3)
                         Ross, do we need a refresher... - (jb4) - (2)
                             I would completely agree with you except - (tjsinclair) - (1)
                                 Wow! - (jb4)
                     Which version of gcc? - (admin)
                     So, let me get this straight... - (Arkadiy) - (46)
                         Something like that, yes - (tjsinclair) - (44)
                             I've been trying to do that for years - (tuberculosis)
                             Barney is not responsible... - (jb4) - (42)
                                 Move farther up the food chain - (tuberculosis) - (41)
                                     OK, I'll bite... - (jb4) - (39)
                                         Errr... - (admin) - (34)
                                             I've heard strong typing called several different things... - (jb4) - (33)
                                                 Strict typing is like training wheels. - (admin) - (32)
                                                     Re: Strict typing is like training wheels. Or Helmuts? - (jb4) - (31)
                                                         You have much to learn - (tuberculosis) - (23)
                                                             Irony - (ben_tilly) - (22)
                                                                 Additionally... - (admin) - (21)
                                                                     That's the C++ propaganda - (tuberculosis) - (20)
                                                                         Wrong usage - (Arkadiy) - (7)
                                                                             Return value problem - (tuberculosis) - (6)
                                                                                 I'll take a look for the solution for ret value - (Arkadiy)
                                                                                 Re: Return value problem - (deSitter) - (4)
                                                                                     In the end - (Arkadiy) - (3)
                                                                                         A better statically typed language - have you tried Haskell? -NT - (ben_tilly) - (1)
                                                                                             Read the tutorials - (tuberculosis)
                                                                                         Today's link at /. - (Arkadiy)
                                                                         Interesting example, Todd - (jb4) - (11)
                                                                             Umm... - (Simon_Jester) - (5)
                                                                                 And what would you cast the void* back to afterwards? -NT - (tuberculosis) - (4)
                                                                                     Yeah, you'd have to test for the type... - (Simon_Jester) - (3)
                                                                                         Aaaaaahhhhhhh! - (tuberculosis) - (2)
                                                                                             *chuckle* - (Simon_Jester) - (1)
                                                                                                 Oh, you illustrated several problems - (tuberculosis)
                                                                             Your code should crash - (tuberculosis) - (4)
                                                                                 My code does crash, but not as often as you think. - (jb4) - (3)
                                                                                     Re: My code does crash, but not as often as you think. - (admin) - (1)
                                                                                         Replies coming - (jb4)
                                                                                     Re: My code does crash, but not as often as you think. - (tuberculosis)
                                                         Finally, something other than hand-waving. - (admin) - (6)
                                                             Hey I know Java - (tuberculosis) - (3)
                                                                 Whoops, forgot that one. - (admin) - (2)
                                                                     I always sit on a towel when using it - (tuberculosis) - (1)
                                                                         Interesting... I find I get more use out of... - (admin)
                                                             I've done it - (Arkadiy) - (1)
                                                                 Re: I've done it - (admin)
                                         How? - (tuberculosis) - (3)
                                             Erm? - (jb4) - (2)
                                                 GNU CPP version 2.95.2 19991024 (release) -NT - (tuberculosis) - (1)
                                                     Sorry to hear that...:-( - (jb4)
                                     Well said, exactly correct -NT - (deSitter)
                         This is frigging runtime lib bug, not language - (Arkadiy)
             You were mis-using the flags... - (Simon_Jester) - (3)
                 I thought of that - (tjsinclair) - (2)
                     For what it's worth, code also runs... - (a6l6e6x) - (1)
                         Figured that -NT - (tjsinclair)

If a doctor ever tells me I only have a week to live I am going to spend it in a meeting.
138 ms