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 (... continuing from the previous message)
Sorry, the mouse slipped before I finished the previous posting. I was trying to address some of your questions ... I'll finish here...

CRC: What the [bleep] is wrong with the destructor of an object just simply being called when you actually CALL it?!?

Depending on the context, explicitly calling a destructor could be a good or bad thing. If the language automatically called destructors, then manually calling it might not be a great idea. But refering to the context of the original poster: automatically called at scope exit, I am assuming the destructor is called automatically. Manually calling the destructor is uninteresting in this context.

CRC: [...] you C++ people [...think...] "Only in C++ can you be THIS advanced!"

I'm not sure where you got the idea that I thought RAII was an advanced concept. It is using C++'s rather primitive memory management facilities for uses beyond memory management. This seems to me to be a bad idea, forgivable in C++ only because C++ has little else to offer in its place. Those that used the RAII idiom in Python will have problems running their code in Jython because the memory management is different. As Ben pointed out, assumptions about the behavior of memory management is causing great discussions about the move in Perl 6 to a true GC approach.

CRC: Doesn't your fixation on "end of scope" [...]

The reason for the "end of scope" fixation is merely because that is the context of the original posters statement.

CRC: If they [Smalltalk, Eiffel, Ruby, Jython] don't support this trivial OO concept, maybe they aren't so "strongly" OO after all, eh? Who said they were? Based on which criteria -- and who got to choose those criteria?

I've heard people dismiss C++ as non-OO, but this is the first time I've ever heard anyone claim that Smalltalk was non-OO. My only claim was that these languages are generally accepted as being OO languages, yet don't support a RAII style idiom, then how critical can the RAII idiom be to the OO concept. If you wish to argue against these languages being OO, then I for one would like to see that (but probably in a different thread).

--
-- Jim Weirich jweirich@one.net [link|http://onestepback.org|http://onestepback.org]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
New Combining replies into a single (bigger) slice of humble pie
Jim W. writes:
It[']s obvious that we are not communicating for some reason, but if you want to drop the vitr[i]ol and one-upmanship [...]
Ah, uhm... I'm sorry. I was cranky, misread you and misremembered the thread, and went out of line in my reply; please forgive me.


[...] and continue in a more professional manner, I'm willing to give it a try.
And I'll be delighted to try and behave in a more civilised manner, if that's good enough for you.[1]


Perhaps some of our confusion lies in the languages we are famili[a]r with. I confess that I don't know Delphi, but perhaps you could educate me in the following areas:
Sure.

Can you allocate objects that are stored on the stack (as opposed to an object that is allocated on the heap, but has a reference on the stack)?
Nope.

If (1) is YES, are destructors run on stack based objects when the stack frame is deallocated?
As Rick M. would say, "Mu".

(Well, come to think of it, there may actually have been some deep-OO hacks in this direction, but I can't remember for sure if that's really what my vague recollection of something I read on the Web years ago was about... If you really, really want to know, google for the phrase "Halvard Vassbotn" and some suitable keywords.)

Does Delphi provide any automated heap management (either GC or ref-counted), or does it rely on manual recl[am]ation of heap objects[?]
The answer to this is slightly messy, but with a strict literal interpretation of the question ("...any..."), the short-version reply boils down to: Yes.

The reason why the longer answer is a bit messy is because Delphi has two ways to refer to objects; i.e, two different kinds of types to declare object variables as: Object classes, or interfaces. (Rather like Java, no?) Straight class-type references have no GC whatsoever; interface references are managed by ref-counted garbage collection. Here's an example from the Delphi 7 Help files:
The Delphi compiler provides most of the IInterface memory management for you by its implementation of interface querying and reference counting. Therefore, if you have an object that lives and dies by its interfaces, you can easily use reference counting by deriving from TInterfacedObject. If you decide to use reference counting, then you must be careful to only hold the object as an interface reference, and to be consistent in your reference counting. For example:

procedure beep(x: ITest);
function test_func()
var
  y: ITest;
begin
  y := TTest.Create; // because y is of type ITest, the reference count is one
  beep(y);           // the act of calling the beep function increments the reference count
                     // and then decrements it when it returns
  y.something;       // object is still here with a reference count of one
                     // (Though presumably it'll be gone after the "end;". -- CRC)
end;


This is the cleanest and safest approach to memory management; and if you use TInterfacedObject it is handled automatically.
This, together with the fact that you can refer to the same object either as a class-type or an interface reference, has interesting consequences (on which more below).


And if the above questions don't make sense in the context of Delphi, I would be interested in hearing why. Thanks.
Of course they did, and you're welcome. (How could they not make sense?)


In addition to Delphi, what other OO languages are you famili[a]r with? I ask in order to find some common ground for better communication.
The usual: C++, Java; Visual Basic and JavaScript, to the extent you want to count those as OO. Smatterings of others; mostly just what I've picked up from books, or, more recently, code samples on the 'Net: Ada, Modula-2/3, Eiffel, C#, maybe some others I forget... Oh yeah: Rudimentary Smalltalk and LISP, though only to the extent that I've been able to conclude that they're syntactically, uh... weird. (There, has that at least somewhat allayed your fears that I'm so totally one-track I know nothing but Delphi? :-)


[Jim's answers to some of my earlier questions:]
Yes, a local object in C++ is stack allocated (unless the static keyword is used ... let's not go there).
Why not -- ya think it would just be another occasion for me to say, "That's one of the reasons C++ sucks"? :-)

CRC: If so: Don't heap-based ones count, or what?
From the original Poster: [...] a function that is automatically (or automagically) called at scope exit. Since the lifetime of a heap variable is independent of scope, then they aren't pertinent to the question.
Ah, yes, one of the things I forgot; why I should have re-read the thread... :-(

OTOH, "a function that is automatically (or automagically) called at scope exit" doesn't necessarily have to mean object destruction, does it? (cf Scott's post, and some of my earlier comments, about "finally".) Anyway, from what I understand of Delphi's mixed class / interface model, a scope exit can actually kill a heap-allocated object. Delphi's Help continues:
If you do not follow this rule, your object can unexpectedly disappear, as demonstrated in the following code:

function test_func()
var
  x: TTest;
begin
  x := TTest.Create; // no count on the object yet
  beep(x as ITest);  // count is incremented by the act of calling beep
                     // and decremented when it returns
  x.something;       // surprise, the object is gone
end;
And, since all Delphi objects, "local" or not, are allocated on the heap, TInterfacedObject or some other Interface implementation ought to be able to kill a non-"local" object, too. That is, if the "x := TTest.Create;" bit had been outside this function (but executed some time before it was called, preferably... :-) , then after this function returned, "x" would be gone. So, no, apparently: Heap variables "aren't pertinent to the question" only if one insists on limiting oneself to C++ (and similar languages).


[ oops ... I hit save before I finished this ... I'll continue in separate posting]

Sorry, the mouse slipped before I finished the previous posting. I was trying to address some of your questions ... I'll finish here...
Uh, why did you do it that way? I mean, you'd obviously discovered the Edit function here, so why didn't you just use that -- not in order to make me have to eat two separate slices of humble pie, I hope? :-)

CRC: What the [bleep][1] is wrong with the destructor of an object just simply being called when you actually CALL it?!?
Depending on the context, explicitly calling a destructor could be a good or bad thing. If the language automatically called destructors, then manually calling it might not be a great idea. But refer[r]ing to the context of the original poster: automatically called at scope exit, I am assuming the destructor is called automatically. Manually calling the destructor is uninteresting in this context.
Hmm... Yeah, probably.

(OTOH, Delphi's class libraries (the VCL and CLX frameworks) are to quite a considerable extent "semi-automatic" in this respect: The network of "Owner" relationships in, for example, a TForm descendant, make sure that when the top-level object is destroyed (possibly by some Interface-brokered trick as per above) all its "Owned" components are destroyed (in order, and each executing its destructor), too. Quite "manual", in the sense that the calls are explicitly there in the framework source-code -- as opposed to, say, C++ with its spontaneous compiler-black-magic auto-generated creation and destruction of objects -- but "automatic" in the sense that to the user (not end-user; framework user, application programmer), when he's done with something and gets rid of it, all its dependent objects go away too, almost "as if by magic".)

CRC: [...] you C++ people [...think...] "Only in C++ can you be THIS advanced!"
I'm not sure where you got the idea that I thought RAII was an advanced concept.
Well, if everybody thought it was perfectly obvious and trivial, they wouldn't have gone to the trouble of inventing an acronym for it, would they? But, of course I shouldn't have blamed you, personally, for this, and I'm sorry it came out that way.


It is using C++'s rather primitive memory management facilities for uses beyond memory management. This seems to me to be a bad idea, forgivable in C++ only because C++ has little else to offer in its place. Those that used the RAII idiom in Python will have problems running their code in Jython because the memory management is different. As Ben pointed out, assumptions about the behavior of memory management is causing great discussions about the move in Perl 6 to a true GC approach.
Allow me to take this opportunity to say, "That just goes to show the whole idea of garbage collection sucks." Thank you.


CRC: Doesn't your fixation on "end of scope" [...]
The reason for the "end of scope" fixation is merely because that is the context of the original poster[']s statement.
Ah, yes; forgot that; sorry.

(Then again, ever heard of how discussions tend to wander a bit from where they started? Ever thought of letting them do so, and just go with the flow...?)

CRC: If they [Smalltalk, Eiffel, Ruby, Jython] don't support this trivial OO concept, maybe they aren't so "strongly" OO after all, eh? Who said they were? Based on which criteria -- and who got to choose those criteria?
I've heard people dismiss C++ as non-OO, but this is the first time I've ever heard anyone claim that Smalltalk was non-OO. My only claim was that these languages are generally accepted as being OO languages, yet don't support a RAII style idiom, then how critical can the RAII idiom be to the OO concept. If you wish to argue against these languages being OO, then I for one would like to see that (but probably in a different thread).
A: No, that wasn't your "only" claim -- you used the expression "strongly OO", and whether that terminology was your own invention or not, the mere act of using it does imply something more: That you agree that these languages are somehow "more strongly" OO than others. My questions about where this comes from remain unanswered.

B: Who said the RAII idiom was supposed to be "critical to" the OO concept? Judging from Greg's original post, he saw it as a major benefit of using (at least some) OO languages, which AFAICS is another thing altogether.

(B 2: Still and again, if Smalltalk, Eiffel, Ruby, and Jython can't provide even this apparently so obvious and trivial and "primitive" benefit of OO, doesn't that speak at least against them being more "strongly OO" than others, that do provide this benefit?)

C: I didn't say Smalltalk, Eiffel, Ruby, and Jython are non-OO; I only objected to your painting them as somehow "more OO", or "better OO", than, for instance, C++ or Delphi. (And please don't try to hide behind someone else, who[ever] may have coined your "strongly OO" expression -- I've let that slide on the "RAII idiom" thing above, and that should be enough -- your using these expressions is enough of an endorsement of their connotations that you are intellectually obliged to stand up for them.) That's not quite the same thing.

C 2: This constantly pisses me off from the proponents of... Uh, how do I put this in a single phrase... The proponents of what I will have to call, for lack of a better catch-all, "Weird-OO" -- advocates of Smalltalk, Java, Lisp... (and perhaps Eiffel, Ruby, and Jython too) -- languages with weak typing, garbage collection, bass-ackwards syntax (and just generally "weirdo" ["weirdoo"?] concepts like "closures" and whatnot), etc, etc... Whenever one tries to discuss the merits of various OO languages with these guys, the discussion sets out from their pre-conceived reality, where "MyWeirdOOLanguage is more-and-better-OO than YourNonWeirdOne", if it isn't an axiom, at least follows immediately from the axioms "The less typing and structure a language has, the more-and-better-OO it is" and "The more weird and incomprehensible features, and the less natural-language-like syntax, a language has, the more-and-better-OO it is"... One has to fight against these preconceptions for ages, before one gets to non-slanted ground where a discussion could even start on something approaching an even footing... It's a bit like talking to Bryce, only in reverse.

(C 2 b: Yes, you've probably noticed a strong overlap between the set of languages in my preceding paragraph and those you mentioned yourself, above; and therefore might be tempted to suggest that there is already a catch-all phrase for them: "Strong OO". But, that's precisely my point: Why should the discussion be conducted in your [collective or personal "you"; take your pick] prejudicial terms? That's pretty much declaring them "more" or "better" OO; a tacit -- but rather obvious -- acceptance-as-axiom of what we set out to prove or disprove.)

C 3: So, if we ever do get around to starting that other thread (there is a check-box and a combo-box for this very purpose just below the reply-text edit box; you're perfectly free to start it from this) on whether Smalltalk, Eiffel, Ruby, and Jython really are OO, then can we please have that discussion on my terms -- where the proponents of "weird-OO" get to start from the disadvantaged position of defending themselves against my (arbitrary, but no more so than their opposite) accusation of "Ha! How can that even hope to be OO, when it doesn't even have strong typing?"; and only after they've successfully defended their favourite languages against that (and other similar percieved-strikes-against), then they get to try to argue that their candidates are somehow better than mine? If not, then why not?



[1]: I don't know if you followed that discussion a while ago on what kind of place it actually is we have here; my standpoint -- declared, if not in that thread, then earlier (repeatedly, IIRC) -- was that since I hang out here on my time, I am not willing to subscribe to some arbitrary "professional" code of behaviour, whatever that may mean in your (collective "you"; and overwhelmingly American, with all what that entails of political-correctness- or religion-based prudery) vocabulary. IOW, I swear in my free time; if you have a problem with that, too bad... OTOH, I do object to having my words altered by someone else, even in my free time: If you can't bring yourself to even quote someone without inserting silly "[bleep]"-ing in what they say, then please don't even quote me at all. (As a slight revenge, I've taken the liberty of correcting your spelling in places... Does that annoy you? If yes, then maybe you see my point... If not, please try to understand that your "[bleep]"-ing does annoy the fuck out of me, regardless, and then maybe you'll see my point anyway.)


   [link|mailto:MyUserId@MyISP.CountryCode|Christian R. Conrad]
(I live in Finland, and my e-mail in-box is at the Saunalahti company.)
Your lies are of Microsoftian Scale and boring to boot. Your 'depression' may be the closest you ever come to recognizing truth: you have no 'inferiority complex', you are inferior - and something inside you recognizes this. - [link|http://z.iwethey.org/forums/render/content/show?contentid=71575|Ashton Brown]
New Lots of Comments ...
Wow, lots of stuff to reply to ...

CRC: Ah, uhm... I'm sorry. [...]

Thanks. We've had good conversations in the past, I'm glad we can continue to do so. And I'll refrain from gratuitous editing of your quotes too.

Thanks for the Delphi answers. Other than knowing that is is a object-oriented Pascal, my knowledge of Delphi is almost nil. I'll probably have some followup questions or comments after I digest the material.

Regarding background, my major languages are C, C++, Java, Ruby, Eiffel (though C++ and Eiffel are a bit rusty). Along the way I've picked up some Perl, Forth Haskel, Modula 2 (no Modula3), Smalltalk, Python, TCL, Lisp/Scheme and (pre-object) Ada. I've probably left out something. I think I once knew FORTRAN, but I won't admit to it any more.

Regarding the word "strong"...

CRC: No, that wasn't your "only" claim -- you used the expression "strongly OO", and whether that terminology was your own invention or not, the mere act of using it does imply something more: That you agree that these languages are somehow "more strongly" OO than others. My questions about where this comes from remain unanswered.

I probably would have done better to leave off the word "strong". My argument was can be paraphrased as follows: If we have a list of languages that everyone agrees are OO languages, and none of these languages support feature X, then calling feature X a "benefit of OO" is a bit of a stretch.

The use of the phrase "strongly OO" was meant in the sense that the OO support in these languages is strong enough that no one would call them non-OO languages. "Better" was not implied. Indeed, the object models of these languages are so different that to argue that one is better would most likely exclude the others from the list.

CRC: [...] he saw it as a major benefit of using (at least some) OO languages [...]

Then a better subject line would have been "Great OO Argument Closer for a small number of OO languages".

Regarding Weird-OO (clever catch phrase) Languages ...

CRC: This constantly pisses me off from the proponents of [...] "Weird-OO" -- advocates of Smalltalk, Java, Lisp... (and perhaps Eiffel, Ruby, and Jython too) -- languages with weak typing, garbage collection, bass-ackwards syntax (and [...] "closures" and whatnot), [...]

You are again painting with a broad brush. I tried to include a variety of languages in the list. Some are dynamically typed, some are statically typed (we can argue the definitions of strong/weak typing some other time).

Weird syntax? Eiffel's syntax has strong roots in the Pascal family (via Ada). Ruby is more inline with the Pascal family than the C, Smalltalk or Lisp family.

Garbage collection technology is over 40 years old and is a component of many major production languages, both OO and non-OO. Calling it weird-OO is just, well, weird.

Closures are just one tiny step away from nested procedures in Pascal. In fact, scratch that. I think I could argue that nested procedures in Pascal are closures. They just aren't anonymous closures.

I do believe that you have run up against language evangelists, and I probably have probably played the role of one in the past (and will again in the future if I feel like it). But I think you are reading way too much in my posting in this thread. I think I've been more or less advocacy free and just reporting verifiable facts (e.g. RAII works in language X, it doesn't work in language Y, etc).

CRC: Ha! How can that even hope to be OO, when it doesn't even have strong typing?

In Chapter 2 of Object Oriented Software Construction, Bertrand Meyer lays forth the criteria of object orientation. On page 25 he names a criteria Static Typing: "A will-defined type system wshould, by enforcing a number of type declartion and compatibility rules, guarantee the run-time type safety of the systems it accepts". It sounds like you and the Eiffel language designer are on the same page.

--
-- Jim Weirich jweirich@one.net [link|http://onestepback.org|http://onestepback.org]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
New You remind me of the blub paradox
From [link|http://www.paulgraham.com/avg.html|Beating The Averages], your complaints about "wierd languages" reminded me of it very strongly.

As for defending the right of dynamically typed languages to call themselves OO, well that is a silly requirement. The phrase "object oriented" was coined (AFAIK) by Alan Kay, and he went on to design the first intentionally object-oriented language, which he called Smalltalk. I say intentionally, because he found a lot of the ideas in an earlier language known as Simula.

Any decent discussion of the history of OO acknowledges this, and goes on to point out that other OO languages such as C++ then borrowed heavily from Smalltalk.

Seriously, can you find me any discussion anywhere where someone with any semblance of a clue refers to Smalltalk as not being really OO? Can you find any reasonable discussions of OO that list strong-typing as needed for the concept? Or are you just trying to define convenient pre-conditions for discussion with no concern for reality?

Cheers,
Ben
"good ideas and bad code build communities, the other three combinations do not"
- [link|http://archives.real-time.com/pipermail/cocoon-devel/2000-October/003023.html|Stefano Mazzocchi]
New Speaking of PL History
Here's my collection of [link|http://www.angelfire.com/tx4/cus/people/|Mug Shots]. :-)

As to the question, I would that Kay has had second thoughts about using the term "Object", much prefering the concept of "Message" these days.
New Kay's thinking
I've seen him say something to the effect, because he thinks people have largely missed the point. Its not so much that there are classes and objects, but that there is a messaging system and every object may be thought of as a server. This is markedly different from the function calling behavior of the so-called "normal" (which are actually rather abnormal from my point of view) languages.

Strong static typing, ugly algolish syntax, lack of decent garbage collection in many cases, makes for a poor cousin to true OO languages.



Smalltalk is dangerous. It is a drug. My advice to you would be don't try it; it could ruin your life. Once you take the time to learn it (to REALLY learn it) you will see that there is nothing out there (yet) to touch it. Of course, like all drugs, how dangerous it is depends on your character. It may be that once you've got to this stage you'll find it difficult (if not impossible) to "go back" to other languages and, if you are forced to, you might become an embittered character constantly muttering ascerbic comments under your breath. Who knows, you may even have to quit the software industry altogether because nothing else lives up to your new expectations.
--AndyBower
Expand Edited by tuberculosis Aug. 21, 2007, 05:40:24 AM EDT
New xlnt
-drl
     Great OO arguement closer - (folkert) - (33)
         Re: Great OO arguement closer - (JimWeirich) - (32)
             Danke... -NT - (folkert)
             Huh? - (ben_tilly) - (29)
                 Re: Huh? - (JimWeirich) - (28)
                     Dunno, but I have a guess... - (CRConrad) - (27)
                         Guaranteed destructor timing explained - (ben_tilly) - (26)
                             OK, Jim, add one more: Delphi. (And rename the concept!) - (CRConrad) - (25)
                                 Introducing The Magic Of HTML - (pwhysall) - (11)
                                     Yeah, yeah, but not when I'm in a hurry. - (CRConrad) - (1)
                                         Well, slow down, then. - (pwhysall)
                                     Asterisks don't bother me -NT - (tablizer) - (8)
                                         It -NT - (deSitter)
                                         It -NT - (deSitter) - (6)
                                             STOP SAYING THE WORD!! -NT - (admin) - (4)
                                                 Suffice to say... - (FuManChu) - (3)
                                                     was it Nye or Ni? - (Simon_Jester) - (2)
                                                         Ni! - (pwhysall) - (1)
                                                             Sh! -NT - (FuManChu)
                                             WTF? -NT - (deSitter)
                                 Re: OK, Jim, add one more: Delphi. (And rename the concept!) - (JimWeirich) - (9)
                                     Ah; the problem seems to be I didn't take into account... - (CRConrad) - (8)
                                         Wow, are we in the same universe? - (JimWeirich) - (7)
                                             (... continuing from the previous message) - (JimWeirich) - (6)
                                                 Combining replies into a single (bigger) slice of humble pie - (CRConrad) - (5)
                                                     Lots of Comments ... - (JimWeirich)
                                                     You remind me of the blub paradox - (ben_tilly) - (3)
                                                         Speaking of PL History - (ChrisR) - (2)
                                                             Kay's thinking - (tuberculosis) - (1)
                                                                 xlnt -NT - (deSitter)
                                 Why are you so upset? - (ben_tilly) - (2)
                                     Caw, caw: My own fault, mostly, mis-remembering the thread. - (CRConrad) - (1)
                                         Just responding to the GC point... - (ben_tilly)
             Scope exit vs. object cleanup - (admin)

Not sure if that makes your statement true or false...
94 ms