Prototype-based programming

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hung Jung Lu

    Prototype-based programming

    Hi,

    Description of PBP (Prototype-based programming) can be found at:



    ("Self" is an example of a PBP language:
    http://research.sun.com/self/language.html)

    The most naive PBP would imply a overwhelming redundancy in namespace
    entries. (E.g: all object instances carry bindings for their methods.)
    Efficient in time, but not very efficient in space (memory usage). But
    I am sure people have looked at lookup-precedence strategies, much
    like how Python finds names first in the local, then the global, then
    the built-in namespace, or how instance attributes are looked up in
    multiple inheritance.

    I got looking into PBP because Python starts to look evil when you use
    descriptors, metaclasses, etc. And that's not just Python: the
    fundamentals of most well-known languages are getting more and more
    complicated. The current programming world reminds me of the situation
    of the time when RISC came up against CISC. I mean, it's OK for a lot
    of additional features to be built on top of the fundamentals, but
    nowadays the fundamentals themselves are getting too complicated. Is
    it time to take a break and say: "there is gotta be a simpler way!"?
    From the little I read about Haskell it seems that it's possible to
    keep the fundamentals clean and do complex things at the same time.
    The usage of classes is just weird... it's a concept from the 1970s
    and should probably be retired by now. Because you use classes, you
    then hit upon metaclasses, (and meta-metaclasses... ad-infinitum), and
    also come up with funny "patterns" like Singletons, or define "static"
    class attributes. I mean, aren't all these the symptoms that we are
    doing something wrong?

    regards,

    Hung Jung
  • Rene Pijlman

    #2
    Re: Prototype-based programming

    Hung Jung Lu:[color=blue]
    >From the little I read about Haskell it seems that it's possible to
    >keep the fundamentals clean and do complex things at the same time.[/color]

    Perhaps it should be the other way around: allow complex fundamentals to
    be able to do elegant things :-)
    [color=blue]
    >The usage of classes is just weird... it's a concept from the 1970s[/color]

    The wheel is a concept from 4000 BC (http://en.wikipedia.org/wiki/Wheel).

    Pardon my ignorance, but what is the next great thing to replace
    OO/classes?

    --
    René Pijlman

    Comment

    • Bruno Desthuilliers

      #3
      Re: Prototype-based programming

      Hung Jung Lu wrote:[color=blue]
      > Hi,
      >
      > Description of PBP (Prototype-based programming) can be found at:
      > http://en.wikipedia.org/wiki/Prototype_based
      > http://www.dekorte.com/Proto/Chart.html
      >
      > ("Self" is an example of a PBP language:
      > http://research.sun.com/self/language.html)
      >
      > The most naive PBP would imply a overwhelming redundancy in namespace
      > entries. (E.g: all object instances carry bindings for their methods.)
      > Efficient in time, but not very efficient in space (memory usage). But
      > I am sure people have looked at lookup-precedence strategies, much
      > like how Python finds names first in the local, then the global, then
      > the built-in namespace, or how instance attributes are looked up in
      > multiple inheritance.[/color]

      You may want to have a look at Io


      (snip)

      Bruno

      Comment

      • Hung Jung Lu

        #4
        Re: Prototype-based programming

        Bruno Desthuilliers <bdesth.nospam@ removeme.free.f r> wrote in message news:<3fd7bf36$ 0$28702$626a54c e@news.free.fr> ...[color=blue]
        >
        > You may want to have a look at Io
        > http://www.iolanguage.com/
        >[/color]

        Thanks. That was a good dose of adrenaline shot. :)

        It's amazing to see how people are converging. It's also refreshing to
        see some brains out there. I am over 1 year late in knowing about the
        existence of Io (it came out last year) and over 2 years late in
        hitting upon some concepts. But that's all right. Better catch up late
        than never. :)

        When I saw that Io was prototype-based, I told myself: "OK, smart".
        When I saw statements were message-based, I told myself: "OK, more
        than smart". When I saw that it was designed with full awareness of
        Python and Ruby, I told myself: "OK, very smart". When I saw that it
        has codeblocks ("block" in Io syntax) and weaklinks, I told myself:
        "OK, really smart". When I saw that it can print the source code of a
        block, I told myself: "OK, extremely smart". :)

        Of course, all the fundamentals have been out there before. But it is
        refreshing to see people heading in the right direction.

        regards,

        Hung Jung

        Comment

        • John J. Lee

          #5
          Re: Prototype-based programming

          hungjunglu@yaho o.com (Hung Jung Lu) writes:
          [...][color=blue]
          > I got looking into PBP because Python starts to look evil when you use
          > descriptors, metaclasses, etc. And that's not just Python: the
          > fundamentals of most well-known languages are getting more and more
          > complicated. The current programming world reminds me of the situation
          > of the time when RISC came up against CISC. I mean, it's OK for a lot
          > of additional features to be built on top of the fundamentals, but
          > nowadays the fundamentals themselves are getting too complicated. Is[/color]

          In principle, I agree, though I can't say it's ever actually bothered
          me in practice with Python.

          [color=blue]
          > it time to take a break and say: "there is gotta be a simpler way!"?[/color]
          [...]

          JavaScript (no, don't run away!) is actually quite similar to Python
          and is prototype-based.

          JavaScript (ECMAScript, now) has a global object (that happens to be
          window in web browsers) that functions rather like the global
          namespace in other languages.


          John

          Comment

          • Michele Simionato

            #6
            Re: Prototype-based programming

            hungjunglu@yaho o.com (Hung Jung Lu) wrote in message news:<8ef9bea6. 0312111011.6a49 053d@posting.go ogle.com>...[color=blue]
            > When I saw that it
            > has codeblocks ("block" in Io syntax) and weaklinks, I told myself:
            > "OK, really smart". When I saw that it can print the source code of a
            > block, I told myself: "OK, extremely smart". :)[/color]

            Why do you want to print out the source code of a block? Are you thinking
            about dynamic modification of the source code and recompilation of the
            code block on the fly? If you want those features then lisp-like languages
            are a natural choice. Or do you have something else in mind ?

            Michele

            Comment

            • Hung Jung Lu

              #7
              Re: Prototype-based programming

              michele.simiona to@poste.it (Michele Simionato) wrote in message news:<95aa1afa. 0312112228.7f0e 09e8@posting.go ogle.com>...[color=blue]
              > hungjunglu@yaho o.com (Hung Jung Lu) wrote in message news:<8ef9bea6. 0312111011.6a49 053d@posting.go ogle.com>...
              >
              > Why do you want to print out the source code of a block? Are you thinking
              > about dynamic modification of the source code and recompilation of the
              > code block on the fly? If you want those features then lisp-like languages
              > are a natural choice. Or do you have something else in mind ?
              >[/color]

              The latter. Keeping reference to the source code means that you have
              taken into account the needs of debugging/tracing: you can step
              through the code, set break points, etc., even if the pieces are
              dynamically assembled. Dynamically compiling code is piece of cake,
              even C# does that. But have you thought about break points and
              debugging issues?

              regards,

              Hung Jung

              Comment

              • Douglas Crockford

                #8
                Re: Prototype-based programming

                > JavaScript (no, don't run away!) is actually quite similar to Python[color=blue]
                > and is prototype-based.
                >
                > JavaScript (ECMAScript, now) has a global object (that happens to be
                > window in web browsers) that functions rather like the global
                > namespace in other languages.[/color]

                Right you are, John. For example,


                Comment

                Working...