Does PHP really need interfaces?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Daniel Klein

    Does PHP really need interfaces?

    Seeing as PHP is a dynamic language (like Python and Smalltalk), I don't see
    what use an Interface has other than to satisfy a contract.

    Why were they even added to the language? Can anyone think of any reason
    that that they would be required?

    I guess these are more rhetorical questions, but I woke up this morning and
    it bothered me so much that I felt like starting a discussion :-)

    Daniel Klein
  • Jerry Stuckle

    #2
    Re: Does PHP really need interfaces?

    Daniel Klein wrote:
    Seeing as PHP is a dynamic language (like Python and Smalltalk), I don't see
    what use an Interface has other than to satisfy a contract.
    >
    Why were they even added to the language? Can anyone think of any reason
    that that they would be required?
    >
    OO.
    I guess these are more rhetorical questions, but I woke up this morning and
    it bothered me so much that I felt like starting a discussion :-)
    >
    Daniel Klein
    >

    They can be very handy, especially when you don't have multiple inheritance.

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • Michael Fesser

      #3
      Re: Does PHP really need interfaces?

      ..oO(Jerry Stuckle)
      >Strongly typed has its uses. And programs written in strongly typed
      >languages typically have fewer errors. But there is a limit where the
      >typing becomes more of an interference than a help (i.e. PASCAL). I
      >wish PHP were more strongly typed - but not as strong as PASCAL.
      Can you elaborate on that (just a bit, I know it's OT)? I've learned
      programming with Pascal and I've never found it to be too restrictive.

      On the contrary, I really liked its rules, the additional compiler
      checks and enforcements, which helped to avoid many bugs right from the
      beginning, because they could often be found at compile time already.
      Can you give a short example where you think that Pascal's strong typing
      becomes more of an interference?

      Micha

      Comment

      • Jerry Stuckle

        #4
        Re: Does PHP really need interfaces?

        Michael Fesser wrote:
        .oO(Jerry Stuckle)
        >
        >Strongly typed has its uses. And programs written in strongly typed
        >languages typically have fewer errors. But there is a limit where the
        >typing becomes more of an interference than a help (i.e. PASCAL). I
        >wish PHP were more strongly typed - but not as strong as PASCAL.
        >
        Can you elaborate on that (just a bit, I know it's OT)? I've learned
        programming with Pascal and I've never found it to be too restrictive.
        >
        On the contrary, I really liked its rules, the additional compiler
        checks and enforcements, which helped to avoid many bugs right from the
        beginning, because they could often be found at compile time already.
        Can you give a short example where you think that Pascal's strong typing
        becomes more of an interference?
        >
        Micha
        >

        To keep it short: Pascal puts you in a straitjacket. Without getting
        into details, data types must match *exactly*. No implicit conversions
        and very limited explicit conversions. C is on the other end - you can
        convert almost anything to almost anything, whether it is correct or not.

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • Michael Fesser

          #5
          Re: Does PHP really need interfaces?

          ..oO(Jerry Stuckle)
          >To keep it short: Pascal puts you in a straitjacket. Without getting
          >into details, data types must match *exactly*.
          IIRC they just have to be compatible, so you can easily cast one int
          type into another. But I haven't used Pascal for years ...
          >No implicit conversions
          >and very limited explicit conversions. C is on the other end - you can
          >convert almost anything to almost anything, whether it is correct or not.
          Yes, and we know the results. Many things that you can do in C are
          simply not possible in Pascal - for good reasons. I liked that.

          But OK, that's completely OT here.

          Micha

          Comment

          • The Natural Philosopher

            #6
            Re: Does PHP really need interfaces?

            Michael Fesser wrote:
            .oO(Jerry Stuckle)
            >
            >Strongly typed has its uses. And programs written in strongly typed
            >languages typically have fewer errors. But there is a limit where the
            >typing becomes more of an interference than a help (i.e. PASCAL). I
            >wish PHP were more strongly typed - but not as strong as PASCAL.
            >
            Can you elaborate on that (just a bit, I know it's OT)? I've learned
            programming with Pascal and I've never found it to be too restrictive.
            >
            Ruddy nightmare. I had to (re write in C eventually) a Pascal program to
            decode a stream of mixed bits, bytes and blocks of data.

            I didn't succeed.

            Thats why I rewrote it in C. Possibly it is posible to create the
            equivalent of a uninin in Pascal, but I didn't have time to work out how,

            On the contrary, I really liked its rules, the additional compiler
            checks and enforcements, which helped to avoid many bugs right from the
            beginning, because they could often be found at compile time already.
            Can you give a short example where you think that Pascal's strong typing
            becomes more of an interference?
            >
            See above.
            Micha

            Comment

            • The Natural Philosopher

              #7
              Re: Does PHP really need interfaces?

              Jerry Stuckle wrote:
              Michael Fesser wrote:
              >.oO(Jerry Stuckle)
              >>
              >>Strongly typed has its uses. And programs written in strongly typed
              >>languages typically have fewer errors. But there is a limit where
              >>the typing becomes more of an interference than a help (i.e.
              >>PASCAL). I wish PHP were more strongly typed - but not as strong as
              >>PASCAL.
              >>
              >Can you elaborate on that (just a bit, I know it's OT)? I've learned
              >programming with Pascal and I've never found it to be too restrictive.
              >On the contrary, I really liked its rules, the additional compiler
              >checks and enforcements, which helped to avoid many bugs right from the
              >beginning, because they could often be found at compile time already.
              >Can you give a short example where you think that Pascal's strong typing
              >becomes more of an interference?
              >>
              >Micha
              >>
              >
              >
              To keep it short: Pascal puts you in a straitjacket. Without getting
              into details, data types must match *exactly*. No implicit conversions
              and very limited explicit conversions. C is on the other end - you can
              convert almost anything to almost anything, whether it is correct or not.
              >
              C is in the middle. You can convert anything to anything, but very
              seldom IMPLICITLY.

              PHP converts anything to anything invisibly and implicitly, which means
              you have to KNOW the rules of its implicit conversions.

              Comment

              • Tim Roberts

                #8
                Re: Does PHP really need interfaces?

                Daniel Klein <danielk@feathe rbrain.netwrote :
                >Seeing as PHP is a dynamic language (like Python and Smalltalk), I don't see
                >what use an Interface has other than to satisfy a contract.
                >
                >Why were they even added to the language? Can anyone think of any reason
                >that that they would be required?
                >
                >I guess these are more rhetorical questions, but I woke up this morning and
                >it bothered me so much that I felt like starting a discussion :-)
                My uneducated guess is that they were added to allow PHP to play more
                directly in the CORBA/COM world.
                --
                Tim Roberts, timr@probo.com
                Providenza & Boekelheide, Inc.

                Comment

                Working...