473,407 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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
Mar 17 '08 #1
7 1276
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.
js*******@attglobal.net
==================

Mar 17 '08 #2
..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
Mar 18 '08 #3
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.
js*******@attglobal.net
==================

Mar 18 '08 #4
..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
Mar 18 '08 #5
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
Mar 18 '08 #6
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.
Mar 18 '08 #7
Daniel Klein <da*****@featherbrain.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, ti**@probo.com
Providenza & Boekelheide, Inc.
Mar 19 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

38
by: Martin Marcher | last post by:
Hi, I've read several questions and often the answer was 'C knows nothing about .' So if C knows that little as some people say, what are the benefits, I mean do other languages know more...
4
by: Uchiha Jax | last post by:
Hello everyone, I am a plenty silly person who is trying to learn .NET remoting through trial and error (all articles I read are going over my head at the moment (mostly) so I thought i'd give...
58
by: Larry David | last post by:
Ok, first of all, let's get the obvious stuff out of the way. I'm an idiot. So please indulge me for a moment. Consider it an act of "community service".... What does "64bit" mean to your friendly...
2
by: Lucian Wischik | last post by:
Does ReadOnlyCollection<T> really implement IList<T>, like it claims to do? ... When I right-click on ReadOnlyCollection and look at its definition, it says this: public class...
45
by: salad | last post by:
I'm curious about your opinion on setting relationships. When I designed my first app in Access I'd go to Tools/Relationships and set the relationships. Over time I'd go into the window and see...
2
by: drew.ferraro | last post by:
Hi, I am trying to build a .DLL file that uses "'Microsoft.ApplicationBlocks.ExceptionManagement.Interfaces'". I am trying to build this .DLL as fully signed. However, when I try to build, I...
3
by: pratham | last post by:
Hi, I was seeing code of PetShop 2.0 and find is quite .. differnet design and architecture .. too much of clutter in classes .. order class using and Iorder and Iorder using an orderInfo and...
9
by: Jonathan Wood | last post by:
I found the following class on the Web: public class LoginRewriter : IHttpModule { void IHttpModule.Dispose() { } void IHttpModule.Init(HttpApplication app) { app.AuthorizeRequest += new...
162
by: Sh4wn | last post by:
Hi, first, python is one of my fav languages, and i'll definitely keep developing with it. But, there's 1 one thing what I -really- miss: data hiding. I know member vars are private when you...
18
by: Stephan Beal | last post by:
Hi, all! Before i ask my question, i want to clarify that my question is not about the code i will show, but about what the C Standard says should happen. A week or so ago it occurred to me...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.