Jump to content

Talk:Object-oriented programming/Archive 3

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Lowercase sigmabot III (talk | contribs) at 00:32, 19 September 2016 (Archiving 2 discussion(s) from Talk:Object-oriented programming) (bot). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Archive 1Archive 2Archive 3

Physical existence of an "object" - is it unecessary baggage? - can occams razor help?

Try as I might, I have not yet come across any instance (definition) of what an object is - in physical terms. I understand that OOP defines objects in some physical sense (rather than a virtual data definition) but I have yet to come across an actual example of how this manifests itself internally in the OOP language. I think I have seen these objects in an 'exported' sense - with seemingly long strings of (comma separated?) text attributes - but what of its internal representation? For example -

  • how large is a (typical) object definition (in bytes)?,
  • does it have an inherent or implied structure or OOP standard? (and is this portable?),
  • who decides what attributes it holds and in what (optimized?) form?,
  • how much data is involved when accessing an object?
  • how much processing is involved in decoding the object at execution time?

Since conventional programs can (and do) perform the same tasks as any OOP written program - without the need for any physical objects - this seems to imply that the physical objects themselves are a case of unecessary 'baggage' (requiring additional processing themselves). Using occams razor therefore, these pieces of baggage can therefore be safely removed and a more optimum solution used to provide algorithmic efficiency. This optimum solution, I would suggest, is the much simplified "conventional" programming paradigm that grew up around the first computers - unsurprisingly - as the most 'natural' way to program them.

If someone has a real life example of how an object manifests itself physically (in a particular language) perhaps they would be good enough to highlight a simple example of it here for everyone to compare with a conventional solution. It would be useful to answer the questions above in relation to their example also. If the example is good enough to serve as a generic illustration, of an OOP object perhaps they might also include it into the article itself to educate all of us? It would also be nice if the example refrained from the much overused animal metaphores and restricted itself to more real-life scenarios such as simple addition of two values (unless of course you think I am 'barking up the wrong tree' or just simply barking!) ken (talk) 11:11, 21 August 2009 (UTC) Two weeks have passed since my post above. No sign yet of a response! Isn't there anyone who can defend the OOP 'paradigm' with a concrete example of what constitutes an object in reality (at least in one language) and then go on to explain the mechanics of how this is superior to a more conventional imperative programming approach using a real life example. Since I posted the above, the thought occurs to me that such a physical object must, of necessity, be an object itself - leading to a "vicious" infinite regression of objects, each describing themselves. See also my comments in Talk: Object(computer science) Can we implement OO in any language?!!ken (talk) 09:33, 5 September 2009 (UTC).

Nobody replied because it's not worth replying to. See the banner at the top of this talk page? This discussion page is meant strictly to improve this article. Wikipedia is not a forum for debating hot topics. Do you have some concrete improvement to propose? Pcap ping 10:57, 5 September 2009 (UTC)

I would have thought that an example of what an 'object' is, is quite central to the concept of object-oriented programming. If nobody can provide one it is, to say the least, quite peculiar. Presumably if you are so confident that there is no improvement that can be made to the article, you can either provide a link to what I am asking for on some other published site or can point to the place in the existing article that answers my question.ken (talk) 15:05, 6 September 2009 (UTC)

Where does this article discuss the "physical existence" that you debate? I'm unable to find it... Pcap ping 15:52, 6 September 2009 (UTC)

That is precisely the point! The article linked to in the introduction (i.e. object (computer science)) describes the OO concept of "'physically' bringing together the data components with the procedures that manipulate them". In any case, it would be difficult to see how an (OO) object could have any reality without this being the case (essentially being a combined data description and a function pointer). However, how this exactly is implemented is not shown by example - in any language in either article - despite the fact that (OO) objects obviously can be manipulated independently of the underlying 'target' object (the data) and therefore must have some physical existence. —Preceding unsigned comment added by Kdakin (talkcontribs) 19:07, 6 September 2009 (UTC) Two weeks later! On my tedious search for an answer to my question, I came across this java topic [1]which seems to at least confirm my belief that OOP objects do indeed have a physical existence. If they have a length in bytes they surely must contain something! The obvious question, which I am still short of an answer to is, precisely what? It reminds me of the question "How long is a piece of string" - at least I now know it has a length - now please what is the string made of? (and please no flippant answers like green cheese or quantum soup or quarks!) ken (talk) 09:19, 21 September 2009 (UTC)

Its data members, and a vptr, is one possible answer. But these are implementation details, and not really important to such an abstract topic as this. Regards, decltype (talk) 09:49, 21 September 2009 (UTC)

Sorry Decltype, but I think telling me that there are pointers (rather obviously!) embedded within 'objects' is not the answer I am looking for. I also believed that objects pointed to 'data members' and did not actually contain them. Why do you think this is an 'abstract topic' and not a real one? The whole point of the question is to ask why there appears to be no example of what EXACTLY an object is - when implemented (and incidentally - how much memory and processing overhead this represents). To explain it by saying it is 'abstract' and just an 'implementation detail', is avoiding the very relevant question of precisely that. If you don't actually personally KNOW the answer (from the experience of a compiler writer for instance), why bother to attempt a 'possible' answer?ken (talk) 18:13, 21 September 2009 (UTC)

That's not so obvious to me. An object need not contain any pointers, and most certainly not a vptr. However, this is one common way of implementing virtual functions (which some would say are vital to OOP), and causes an overhead the size of a pointer. However, as the vtable article (hopefully!) tells you, this is just one possible way of implementing late binding. Now, in most C++ implementations, there will be no overhead except for the vptr (in the presence of virtual functions), and the caveat that even an object of class type with no member subobjects must occupy at least one byte (with one exception). Apart from that, the objects contain their base class(es), and their member subobjects, and not pointers, unless the member subobjects are themselves pointers. However, even the simplest class may (or may not) contain unnamed padding. Most compilers allow you to manually adjust alignment. Thus, the object layout can be completely different even for two executables created from the same source code with the same compiler, and the answer to the question of how much memory overhead there is for each object remains the same: It is entirely up to the implementation. Regards, decltype (talk) 06:25, 22 September 2009 (UTC)

Thank you Decltype, I am now (ever so slowly) getting a beakdown of an 'object'

So, now I know that:-

  1. objects are at least one byte long (except in one case apparently)
    true, but this is very C++-specific. The exception is the Empty base class optimization. The fact that not even I have bothered to create an article on it yet, indicates that it's not that significant.
  2. objects may have automatic, or manually specified, padding
    Yes. The article seems to give a good overview, so no additional comments
  3. objects 'contain' their base class(es), and their member subobjects, (- whatever that implies? ) and not pointers
    Member subobject = data member.

I also strongly suspect (but do not know for sure) that:-

  1. they have a physical name (in the form of a character string equal to its string length) - not mentioned by you
    No, this would be incredibly wasteful. Type identification can be facilitated for instance by examining the vptr.
  2. most objects have pointers to at least one method (multiple methods implying multiple pointers)
    Typically, member functions are implemented like normal functions, except that a pointer to the object ("this") is passed as a hidden argument to the function.
  3. not all methods are virtual functions - fair enough
    This is certainly not true for other languages. In many OO languages (such as Java), methods are "virtual" by default.
  4. different implementations imply different 'object' structures (- which I would venture is a little inconsistent for an entire new paradigm!)
  5. the actual implementation of an 'object' is not itself derived using OOP mechanisms for the 'objects' datastructure

I also suspect that:-

  1. the attributes of an 'object' are held within the object in one form or another - not mentioned by you
    I'm not sure what attributes you are referring to, but a conforming implementation need not put anything but the raw data of the data members (+ base class instances) inside an object.
  2. 'subobjects' are chained from base classes (and to one another) by some pointer mechanism - not mentioned by you
    No.
  3. objects require 'creation' and usually 'initialization' before being used - not mentioned by you
    I didn't realize you were asking about this, but sure, see constructor.

I am, in fact, only asking for a breakdown of ONE implementation so that I (and others using wikipedia) can see 'what makes OOP tick' at its basic level. Just one example of the Data structure of a couple of 'objects' (in their entirity) complete with names, init. & method pointers and object attributes would suffice, along with a narrative of how the objects are created, processed (and destroyed?) in a typical scenario like adding two integers together. This does not have to be in hexadecimal, Pseudocode will be good enough to get a rough idea of the sizes of data and processes involved.ken (talk) 07:06, 23 September 2009 (UTC)

I am going to break the normal conventions of the talk page to address your points individually. Unless otherwise noted, my answer holds true for most common C++ implementations, but may be blatantly wrong for other programming languages. decltype (talk) 07:28, 23 September 2009 (UTC)

The more I learn about OOP, the more I realize that even its protagonists appear not to understand it sufficiently to give a clear and concise definition of what it is. Here [2] is a link to the OOP article in wikibooks that is about as clear as mud. Why is it so difficult to show a simple example of precisely how the memory is mapped for adding two values together? Let me make it easy for someone and put my wish into the form of a question perhaps set at GCE 'O' level.

Q.There are two 32 bit integers in contiguous memory locations A and B. The integers were read in together from some external I/O device as a single record and some general register points to the start of the record as the program is given control. It is required that the program adds the two input values together and passes the resultant value as a return. Draw a diagram to show the necessary memory 'blocks' used by the program and describe each step in the process using pseudocode (show ALL your workings). Do this for a conventional program and an OOP program.

6 months later and still nobody has responded to the challenge! Meanwhile I discover myself some more of the hidden awkward truths behind OOP implementations - heap storage used to create new "objects", calls to constructors to initialize them and heap storage used for message passing - containing (largely unecessary) exact copies of parameters; "getters" and "setters" instead of direct assignments; serialization/marshalling - breaking both so called encapsulation and data hiding. Return values provided from sent messages (instead of waiting for a result message in response) - making a mockery of the concept of true message passing. More getarounds than rats in a maze. Proprietory data mappers to automate multiple conversions between object and binary formats. Free format human readable character text strings of data and attributes used to describe data objects externally. Discussions about whether binary XML solves the newly created data compression problem or not. Parsing, parsing and yet more parsing seems to be all the rage these days. The abstraction penalty - written large - is, it seems, most evident in OOP. When will it all end - and sanity once again prevail? —Preceding unsigned comment added by 86.142.16.251 (talk) 11:14, 21 April 2010 (UTC)

okay, I'll byte.. or at least take a nibble at this  ;-) You are thinking much too low level and perhaps paradoxically, not low level enough. vptr is a good answer to your original question, you just (appear to) lack the background to be able to understand the answer, perhaps a better answer would be to tell you that it's "42". The high level understanding is that an object is a private name-space referenced by a public interface. What an object does is that it groups together zero or more data items, and provides standard methods for accessing and modifying that data. The relationship of the data items to each other and to the world is defined by the object itself via zero or more associated program routines (usually) called methods. Everything else is an implementation detail and is totally language specific. The bottom line is that an object encapsulates things that the programmer has decided are useful to be packaged together, the end goal is to manage both memory and complexity. To ask questions about the storage size of an object is to display a complete lack of understanding of computer programming (obviously the size is data+overhead). --- (hey ken, I looked at your talk page, youre not ignorant, so I guess you are flame-baiting?) --- Which then brings up the question of who is this article written for? If it is intended to be useful to non-programmers than considerably more explanation is needed. But if that were done I suspect the article would be encumbered to such an extent that it was no longer of interest to programmers.... codeslinger_compsalot 67.40.8.215 (talk) 08:39, 9 December 2010 (UTC)

Thanks for trying 67.40.8.215, but I don't think you address the issues that I have raised, dismissing them as "implementation detail". Why shouldn't I (and everyone else) know the implementation detail for heavens sake? If I was engineering Formula 1 cars I would be extremely interested in the implementation details of my competitors cars (and also for reasons of curiosity and knowledge building).
It is only by having implementation details that will allow serious comparisons of two or more "methods" (techniques). Implementation details are available for most other entities in the real world, why ignore/censor them for OOP?
I have recently read a humorous blog "Execution in the Kingdom of Nouns" by Steve Yegge(see here) that encapsulates a lot of the problems with OOP - even at the conceptual level (although he doesn't go nearly far enough imho!) let alone the implementation.ken (talk) 10:29, 31 December 2010 (UTC)

I'll be brief since this is off topic for a talk page, but I think you are confusing a paradigm with an implementation. I realized this today as I was talking with a co-worker who has some similar objections. When someone is talking about OOP, they are talking about a system for organizing data and processing and associating them together. This can be done in an object oriented language or any other language. The level of detail you are concerned about is the implementation. The reason nobody can answer you is that OOP design can be implemented any of a large number of different ways. A particular language may implement it with waste and overhead in storage to support other compiler optimizations, but an OOP design could be implemented in assembly if you really wanted to. In the example of taking two fields that come in next to each other, it could be as simple as setting up an object that encapsulates them and has a function pointer to add the values at the offsets. Perhaps no OO language would implement it that cleanly, but at that point you are comparing RAD to compilers to machine code instead of paradigms.Ajh16 (talk) 16:38, 22 April 2011 (UTC)

In a pure OO implementation (no unboxed numbers) you'd need some primitive i/o routine that reads the integer values from memory:

Integer add_two_words(Address loc) {
   Integer a, b;
   a = read_int32_from_loc(loc);
   b = read_int32_from_loc(loc+4);
   return a+b;
}

The above isn't actual Java, it's OO pseudocode that I used the java template for. 69.111.194.167 (talk) 03:20, 26 April 2011 (UTC)

Regarding "implementation details" and how important or otherwise they are, see Whitaker et al. "Software engineering is not enough" ken (talk) 06:02, 6 August 2011 (UTC)

This article is confusing because

There are several flavors of object oriented programming concepts.

A recent object oriented concept was MS Windows objects. Specific action routines were associated with the object. Double click action. Redrawing the object etc. The specifics of implementation are not what is important. The interface between windows and a programed object allowed an abstraction that makes the objects purpose independent of windows functioning. I.E. clicking on the object caused some action specific to the object. The action routines could be coded in any of several programming languages. Assembly included.

A different type of an object is used in LISP 2. LISP 2 is a procedural block structured language having several built-in types. LISP 2 was meant to combine the efficiency of languages like ALGOL working on typed data with the general list manipulations of LISP. It was vastly superior to LISP in computational efficiency. It doesn't fit the criteria set down in the article as it's object types were were part of the language specification. — Preceding unsigned comment added by Steamerandy (talkcontribs) 18:10, 5 November 2014 (UTC)

Programming Paradigm

I have been programming for 40 years and I do not know what a programming paradigm is. I have read the Wikipedia explanation but that does not help. I have never heard the term used in this context. There has got to be a more useful and relevant term to define what OOP is. Sam Tomato (talk) 22:59, 27 January 2015 (UTC)

If you google "paradigm" the first definition is: "a typical example or pattern of something; a model." or if you look at the Wikipedia definition of paradigm it is: " a distinct concept or thought pattern." So, it's a model or pattern for programming. Beyond that I'm not sure what to say paradigm is such a common term in science and engineering it seems like a perfectly acceptable way to describe it. Surely you've heard the term "paradigm shift" in relation to science? It's the same idea, going from one model of how to analyze or solve problems to another. The idea is that the essential problem (describing how the solar system works for example) is still the same but the model or paradigm used to solve it (Netwonian => Relativity) is the thing that changes. Other programming paradigms would be: functional programming, structured programming, etc. --MadScientistX11 (talk) 01:19, 28 January 2015 (UTC)

Extendable types

C++ obkects with operator overloading simply makes it an extendable language.

Object oriented programming is hard to pin down.

I think there several types of object oriented programming.

One is the old definition of which lisp is an example. In this class of oop an object carried it's type with it. Variables were nutral as they usually were a pointer to an object. These were usually list processing languages.

Then came the structured data object languages. COBOL falls into that class. Records and items could be copied. This class of OOPs directly manipulat container objects. Pascal is another example.

The third generation is C++ (operator overloading) being able to define operations on defined opjects. Making a string operation and defining + to be string concatenation. Defining object ts based on objects.

But a general object that are in a way language independent are the Windows interface objects. Here we have an object thet implements functions that effect the object and call back functions that report those changrs.

Object oriented programming had been applied to so many things over the years it's hard to define what it really means. The ones I listed are just the stand outs I remembered.

The Window interface object is not all that different then a lisp object.

A good example of curent thinking is the Windows interface. Here we have objects with defined actions and reporting methods. I wouldn't exclude the older ones as the are historically significant. Steamerandy (talk) 00:31, 28 January 2015 (UTC)

There are no objects in the true OO sense in basic Lisp. There are structures but not true objects in the OO sense. However, Lisp is so easy to extend that many OO languages: Flavors, LOOPS, KEE, CLOS have been built on top of it. I'm not sure what you mean by Windows objects vs. Lisp objects. Are you talking about Windows as an OS or Windows as a UI paradigm that can (and almost always is) modeled and implemented using OO modeling and programming? --MadScientistX11 (talk) 01:24, 28 January 2015 (UTC)
BTW, I disagree that COBOL or Pascal are Object Oriented. There is a standard definition of object-orientation and it requires inheritance, polymorphism, and message passing. Now, if you are saying that you can get many of the same advantages of OO using a procedural language like COBOL and just following good design practices I agree with that. In fact when I used to give talks to programmers who knew COBOL I used to say the same thing. I actually would like to add more detail along those lines to the article, I had a boss who used to really drill that into us, that OO was just a natural evolution of things that good developers had been doing at least since structured programming and I completely agree. The problem is my saying "this very bright guy I knew who used to be a lead scientist at Bell Labs said..." doesn't count as a reference. If you can find some good references for that idea feel free to edit the article or just leave the refs here and I will edit it. --MadScientistX11 (talk) 03:57, 28 January 2015 (UTC)

Overview is misleading

The overview seems to confuse OO with modularity and encapsulation. Although this is a common mistake by beginners, who tend to extrapolate from a small exposure to different languages, we should aim for more precision. In addition there is plenty of weaseling about. Other things like run-time checking of data is by no means typical of OO. Reusability has been a goal of many software technologies, and it's far from clear that OO is any more successful than others.

Perhaps the overview should just be discarded, and a summary of the current situation could be added to the history section, which I think is much better? — Preceding unsigned comment added by Ketil (talkcontribs) 13:15, 28 April 2011 (UTC)

I'm not a beginner and I think OO absolutely IS all about encapsulation and modularity. If it's not about that what is it about? MadScientistX11 (talk) 01:00, 10 December 2013 (UTC)
Encapsulation and inheritance, perhaps? Imperative code module doesn't inherit in the sense that OOP do. The9muse (talk) 03:48, 11 February 2015 (UTC)

PowerBuilder

No mention of PowerBuilder at all? It should be included among OO languages with some procedural elements. — Preceding unsigned comment added by 162.254.173.91 (talk) 14:15, 9 April 2015 (UTC)

OOP with ANSI-C

"ANSI-C is a full-scale object-oriented language" Object-Oriented Programming With ANSI-C by AT Schreiner - 1993

It would be nice to have a section on OOP techniques in non-OOP languages.

more official link to the identical file: Object-Oriented Programming With ANSI-C 78.14.33.54 (talk) 19:36, 16 August 2015 (UTC)

Lisp is not OO

Currently the article says: "Languages with most of the features of objects (classes, methods, inheritance, reusability), but in a distinctly original form" and includes Lisp as such a language. Common Lisp had none of this except reusability which pretty much every language strives to deliver. There were lots of extensions to Lisp (e.g. Flavors, CLOS) that were OO but the base language definitely was not. I'm going to change this. MadScientistX11 (talk) 00:47, 10 December 2013 (UTC)

I just noticed this is said in the History section as well, claiming that Common Lisp is an object-oriented language. Common Lisp WITH CLOS is an OO language but common Lisp or most Lisp dialects are FUNCTIONAL programming languages not OO. I'm going to change the history section to take out the claim that Lisp (without CLOS) is OO. MadScientistX11 (talk) 18:06, 11 December 2013 (UTC)


Object orianted programming originally was simply programming with objects. This article is more about encapsulation then objects. And most of what is not about objects or the automation of object creation district. management.


In common lisp every thing is an object. Even the program. There was not all this specific limits set on object orianted languages. I can not see were lisp is not an objected orianted language. There is no data or program element that are not objects in the lisp language. A list element can be an atom or a list. Both are dynamic objects. An atom is an object that is dynamically allocated and released. Lists are also dynamically allocated and released. Every thing in lisp is a dynamically allocated and released object including programs.


EVERY THING IS AN OBJECT IN LISP. THAT SEAMS PRETTY FRAKEN OBJECT ORIANTED.


This topic is including cryteria outside of the basic object orianted concept. Lisp can process it's own code which is a lisp object. Code is stored in a list.


Lisp is more object orianted then any other example given in this artical.


This topic should cover all forms of object orianted programming current and historical. Historically there published papers and books with different views.


Now with this curent definition of OOP. What as a language in which everything is a dynamic object. Except program code. Say a procedural language in which all variables may contain any data type. All data is contained in objects that carry their type. A variable X may contain an integer at one point or1 a string another. An object is addressed by the variable containing it. These are high over head objects as the validity of most operations must be checked at runtime. How would LISP 2 be classed to day. In 1970 it was called an object language.
.FOR X .IN Y .DO 
    .IF X:INTEGER .THEN ....
    .ELSE .IF X:FLOAT .THEN ...
    .ELSE .IF X:STRING .THEN ...
In the above code snippet we have for loop iterating through a list's elements and processing each ellement depending on its type. Not sure of exact type names any more. LISP 2 was implemented at SDC in the late 60's. The above is a dialect used in the CWIC compiler compiler. Research has shown the stand alone LISP 2 had typed and un-typed variables.
Steamerandy (talk) 03:44, 1 March 2015 (UTC)
Without sources, the above is just WP:OR. What sources support Lisp as OOP? Are they in Lisp (programming language)? --A D Monroe III (talk) 00:14, 17 August 2015 (UTC)

OOP creator Bjarne Stroustrup did say that he thougt C++ for solving special problems but not as general programming model today working on solutions if using OOP in general

New programming model POG by Kay Uwe Böhm was never published and made so most programmers have to use C++ on etching C base at daily work worldwide so tortchered. POG is standing for Persons and Objects in Groups for natural modeling with persons who have abilities related to objects working in coordinated groups together. Syntax is most like in modula. What is normally a procedure, function or operator definition are all together "ability" (keyword) definitions with no ore a result or for operators two parameter lists left and right for predifined one or two sign or named operators with multiple overlays possible for different types and called also with possible endless different types parameter list seperated by special sign and possible predifined values that can be over written like in special Pascal write statement now general and orthogonal. Instead special assigning operators with different priorities just a replacement symbol like # multiple usable for the left side of an assignement at right side. Instead nonsense short writings like = for assignements and then == for comparisons back to <- or :=. General LOOP END statement with exit or leave statement inside but also with WHILE, REPEAT... and named loops for special named exits also for IF THEN ELSIF END are names possible. CASE and FOR statement left additional vector operators etc. at the end less complex with high orthogonality for features using but all inside needed for making operating systsems and a decreased feature interpreter version like VBA and JAVA. kayuweboehm(at)yahoo.de (continued latest next life) Informatiker UNI Karslruhe. — Preceding unsigned comment added by 93.221.208.149 (talk) 12:13, 21 March 2016 (UTC)

Minor historical / date correction

The article currently reads: "The formal programming concept of objects was introduced in the 1961s..." Should be 1960s? Probably a minor detail but I'm a bit averse to quickly change an article that's been around for so long and that so many eyes have pored over. Jcoplien (talk) 21:07, 22 March 2016 (UTC)