in reply to Re: Coding styles: OOP vs. Subs
in thread Coding styles: OOP vs. Subs

They just needed to get used to thinking in terms of objects (which actually quite amazes me - because, in my mind, we deal with objects every day outside the context of programming, so why is it such a tough sell inside programming?)

Because the concept of an object in programming is not closely related to the concept of an object in the real world. The concept of an object in programming is related to the concept of an object in math. People who have not had math beyond the secondary level tend not to have been exposed to the concept of an object in this sense at all.

The exception is the way objects are typically used in the Inform programming language. Now, Inform objects *are* programming-concept objects, and can be used as such, but in a typical Inform program, an Inform object represents a real-world object, such as a chair or a box or a door. This is a consequence of the problem domain, but it makes an *excellent* introduction to OOP, because it builds on something people are already familiar with and then introduces programming concepts to it (properties and so forth).

I don't think this could be handled in the same way with the Perl object model, however, because the Perl object model (even, as near as I can tell, in Perl6) does not provide the object forest, which really is essential for elegantly dealing with Inform's particular problem domain (i.e., the chair is in a certain room, and the player can set the box on the chair (because the chair has the supporter attribute) and place the amulet in the box, and so forth, and that containment tree is built into the object model at the vm level as well as at the language level; it is, incidentally, generally useful for other kinds of problems as well.)

When you program in a language like Inform, where the objects represent real-world objects, you see how *different* traditional programming objects are from objects in the real world.


"In adjectives, with the addition of inflectional endings, a changeable long vowel (Qamets or Tsere) in an open, propretonic syllable will reduce to Vocal Shewa. This type of change occurs when the open, pretonic syllable of the masculine singular adjective becomes propretonic with the addition of inflectional endings."  — Pratico & Van Pelt, BBHG, p68

Replies are listed 'Best First'.
Re^2: Coding styles: OOP vs. Subs
by TimToady (Parson) on Nov 16, 2005 at 17:05 UTC
    Well, I do have a soft spot in my heart for that style of language, having once upon a time hacked in (and on) a language called Dungeon Definition Language. I've also once wrote a "dungeon" in Prolog, though it was actually a space ship...

    It would be relatively easy to define objects in Perl 6 with a role or set of roles that define spatial relationships, and those roles can mix in various one-to-many relationships, so it'd be pretty easy to do physical containment and delegation to contained or nearby items. Perl 6 is not intended to match up exactly with every problem domain. It's merely intended to be easily mutable into a different language (also called Perl 6) that matches up with your current problem domain. At worst you'd have to say "use Physical;" at the top of your program, or some such.

      Hey. No fair. I thought I'd done a thorough job of purging the musical "works" of Olivia Newton-John from my brain...