Connecting Tech Pros Worldwide Help | Site Map

Does PHP really need interfaces?

 
LinkBack Thread Tools Search this Thread
  #1  
Old March 17th, 2008, 04:45 PM
Daniel Klein
Guest
 
Posts: n/a
Default 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

  #2  
Old March 17th, 2008, 06:45 PM
Jerry Stuckle
Guest
 
Posts: n/a
Default Re: Does PHP really need interfaces?

Daniel Klein wrote:
Quote:
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.
Quote:
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@attglobal.net
==================

  #3  
Old March 18th, 2008, 12:25 AM
Michael Fesser
Guest
 
Posts: n/a
Default Re: Does PHP really need interfaces?

..oO(Jerry Stuckle)
Quote:
>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
  #4  
Old March 18th, 2008, 12:45 AM
Jerry Stuckle
Guest
 
Posts: n/a
Default Re: Does PHP really need interfaces?

Michael Fesser wrote:
Quote:
.oO(Jerry Stuckle)
>
Quote:
>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@attglobal.net
==================

  #5  
Old March 18th, 2008, 02:25 AM
Michael Fesser
Guest
 
Posts: n/a
Default Re: Does PHP really need interfaces?

..oO(Jerry Stuckle)
Quote:
>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 ...
Quote:
>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
  #6  
Old March 18th, 2008, 10:05 AM
The Natural Philosopher
Guest
 
Posts: n/a
Default Re: Does PHP really need interfaces?

Michael Fesser wrote:
Quote:
.oO(Jerry Stuckle)
>
Quote:
>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,

Quote:
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.
Quote:
Micha
  #7  
Old March 18th, 2008, 10:05 AM
The Natural Philosopher
Guest
 
Posts: n/a
Default Re: Does PHP really need interfaces?

Jerry Stuckle wrote:
Quote:
Michael Fesser wrote:
Quote:
>.oO(Jerry Stuckle)
>>
Quote:
>>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.
  #8  
Old March 19th, 2008, 07:05 AM
Tim Roberts
Guest
 
Posts: n/a
Default Re: Does PHP really need interfaces?

Daniel Klein <danielk@featherbrain.netwrote:
Quote:
>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.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.