Loading ...
Sorry, an error occurred while loading the content.

Re: [XP] book on oop and what's going on under the hood

Expand Messages
  • yahoogroups@jhrothjr.com
    From: eorbill Sent: Sunday, July 04, 2004 2:01 AM Subject: [XP] book on oop and what s going on
    Message 1 of 9 , Jul 4, 2004
    • 0 Attachment
      From: "eorbill" <mattfrechette.at.yahoo.com@...>
      Sent: Sunday, July 04, 2004 2:01 AM
      Subject: [XP] book on oop and what's going on under the hood


      > I'd like to find a book that talks about object oriented programming
      > from a machine
      > level. That is, how does object oriented code get stored in memory? An
      > object is a
      > type, also like a data structure. How does an object get stored in
      > memory?

      Different languages (and different versions of the same language)
      do it differently - there is no "one way" of doing it.

      The best simple implementation I know of is Python -
      expecially the material in these reference manuals shipped
      with the full installation: "Python/C API" and
      "Extending and Embedding".

      Many other languages optimize out the class structures,
      C++ is a good example of this. There's a lot of material
      on the net about C++ method dispatching - look for
      'vtable'.

      >
      > What is actually going on 'under the hood' so to speak?
      >
      > What is a class, in regards to memory, IO mechanisms, behavior?
      > What is a method, in regards to how it compares to a function? How
      > does it act on an
      > object, that is how is it bound to the object in memory?

      It's easier to understand this in terms of a function pointer
      than a raw function.
      Then a method is simply a struct that contains a function
      pointer and an instance pointer. For a bound method, the
      instance pointer is filled in, for an unbound method, the
      instance pointer is Nill (Null, None, etc...)

      > Does anyone know of a book that discusses these things?

      I don't know of a good survey of implementation
      techniques.

      John Roth
    • Stephen Swope
      ... You may find Stan Lippman s book, _The C++ Object Model_, to be useful. ===== -- Steve Swope technical manager, retail data warehouse Reynolds & Reynolds
      Message 2 of 9 , Jul 4, 2004
      • 0 Attachment
        > Does anyone know of a book that discusses these things?

        You may find Stan Lippman's book, _The C++ Object Model_, to be useful.



        =====
        --
        Steve Swope
        technical manager, retail data warehouse
        Reynolds & Reynolds
        http://www.reyrey.com




        __________________________________
        Do you Yahoo!?
        New and Improved Yahoo! Mail - 100MB free storage!
        http://promotions.yahoo.com/new_mail
      • Tony Byrne
        Hello Ron, RJ A method is just a function (or procedure) that takes the object as a RJ hidden parameter. In class Foo we write a method bar(int mumble), and
        Message 3 of 9 , Jul 4, 2004
        • 0 Attachment
          Hello Ron,

          RJ> A method is just a function (or procedure) that takes the object as a
          RJ> hidden parameter. In class Foo we write a method bar(int mumble), and the
          RJ> procedure is implemented with two parameters, the first hidden:

          RJ> procedure bar ( Foo this, int mumble)

          RJ> Thereafter, inside the procedure, "this" refers to the instance to whom the
          RJ> message was sent.

          FWIW, Perl has an interesting twist on this. Although as above, the
          object is not explicitly mentioned in the parameter list, it actually
          becomes the first parameter in the list and is accessed like any other
          parameter by the method. For example, say I have an instance of
          clas Foo referenced by $fooInstance. A Perl method call on
          $fooInstance looking like:

          $fooInstance->bar($mumble);

          would effectively translate to this:

          &Foo::bar($fooInstance, $mumble);

          which is very similar to Ron's example. However, the method might actually
          be implemented like this:

          sub bar
          {
          $self = shift; # $self is Perl idiom for 'this'. Note how you
          # must explicitly retrieve the instance from the parameters.

          $mumble = shift; # retrieves $mumble;

          # do stuff.
          }

          Not exactly mind blowing stuff, I'll admit. However, seeing the
          object as a not-so-hidden parameter to a method, was a light bulb
          moment for me when I was first getting my head around OO.

          Regards,

          Tony.

          --
          Tony Byrne
        • Toivo Lainevool
          ... If your you interested in Java, the Java Virtual Machine Spec is the definitive source. Its available online at: http://java.sun.com/docs/books/vmspec/ --
          Message 4 of 9 , Jul 4, 2004
          • 0 Attachment
            eorbill wrote:

            >I'd like to find a book that talks about object oriented programming
            >from a machine level.
            >
            If your you interested in Java, the Java Virtual Machine Spec is the
            definitive source. Its available online at:
            http://java.sun.com/docs/books/vmspec/

            --

            Toivo Lainevool
            http://www.XMLPatterns.com - Develop effective DTDs and XML Schema documents for your XML using structural design patterns.
          • Tony Nassar
            Thanks for the Perl example; I didn t know it worked that way! On the other hand, how else would it work... I second the recommendation of Stanley Lippman s
            Message 5 of 9 , Jul 5, 2004
            • 0 Attachment
              Thanks for the Perl example; I didn't know it worked that way! On the other hand, how else would it work...

              I second the recommendation of Stanley Lippman's Inside the C++ Object Model; ESPECIALLY if you're a converted C programmer (as I was), and you find yourself unable to trust the C++ object model. If you (or colleagues) just refuse to believe that C++ is as "fast" as C (whatever that means), definitely read this book. I found it invaluable for teaching C++: I now knew *why* things worked a certain why, and not some other way, and could explain / justify them. Knowing how things worked under the hood helped me write more idiomatic code, as odd as that may seem.

              > -----Original Message-----
              > From: Tony Byrne [mailto:yahoogroups@...]
              > Sent: Sunday, July 04, 2004 11:56 AM
              >
              > FWIW, Perl has an interesting twist on this. Although as above, the
              > object is not explicitly mentioned in the parameter list, it actually
              > becomes the first parameter in the list and is accessed like any other
              > parameter by the method. For example, say I have an instance of
              > clas Foo referenced by $fooInstance. A Perl method call on
              > $fooInstance looking like:
              >
              > $fooInstance->bar($mumble);
              >
              > would effectively translate to this:
              >
              > &Foo::bar($fooInstance, $mumble);
              >
              > which is very similar to Ron's example. However, the method
              > might actually
              > be implemented like this:
              >
              > sub bar
              > {
              > $self = shift; # $self is Perl idiom for 'this'.
              > Note how you
              > # must explicitly retrieve the
              > instance from the parameters.
              >
              > $mumble = shift; # retrieves $mumble;
              >
              > # do stuff.
              > }
            • Colin Strasser
              ... One that reads very easily is /A Little Ruby, A Lot of Objects/: http://www.visibleworkings.com/little-ruby/ The author only finished three chapters, but
              Message 6 of 9 , Jul 6, 2004
              • 0 Attachment
                eorbill wrote:

                >I'd like to find a book that talks about object oriented programming
                >from a machine
                >level. ...
                >
                >Does anyone know of a book that discusses these things?
                >
                >
                >

                One that reads very easily is /A Little Ruby, A Lot of Objects/:

                http://www.visibleworkings.com/little-ruby/

                The author only finished three chapters, but they're worth reading. The
                book even has its own Yahoo! Group at
                http://groups.yahoo.com/group/little-ruby/ . Perhaps with enough
                encouragement, the author will resume where he left off.

                -Colin
              Your message has been successfully submitted and would be delivered to recipients shortly.