473,503 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Will php ever do strong typing?


Will php 6 do strong typing and/or namespaces?

I was shocked to find out today that there are some people who actually
argue that weak typing is somehow better. I didn't even know there was
a debate. Shocking. That's like arguing that square tires are better
than round.

Anyway if anyone knows that php is going to intentionally stay weak in
the future let me know so I can jump ship, thanks,

mrb

Jul 17 '05 #1
53 9897
On 23 May 2005 15:33:58 -0700, dt******@hotmail.com wrote:
Will php 6 do strong typing and/or namespaces?
AFAIK there's no decided feature set for PHP 6 yet.
I was shocked to find out today that there are some people who actually
argue that weak typing is somehow better. I didn't even know there was
a debate. Shocking. That's like arguing that square tires are better
than round.

Anyway if anyone knows that php is going to intentionally stay weak in
the future let me know so I can jump ship, thanks,


If PHP ever went strongly typed it would be a fundamental change to the
language. It's not at all likely to happen IMHO. (You probably want to stay
away from Perl as well).

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2
dt******@hotmail.com wrote:
Will php 6 do strong typing and/or namespaces?

I was shocked to find out today that there are some people who actually argue that weak typing is somehow better.
I completely agree. Strong typing makes far more sense due to the
compile-time constraints it enforces. Anyone who thinks otherwise is
lazy, quite frankly, and isn't thinking in terms of long-term
maintainability and debugging.

It also buggers up the fundamental point of OOP, i.e. polymorphism.
Anyway if anyone knows that php is going to intentionally stay weak in the future let me know so I can jump ship, thanks,


Scripting langauges are not compiled, in general. Therefore most don't
seem to use strong typing, because there's no compiler to catch this
sort of thing. e.g. PHP, Perl, VB, VBscript, Javascript. I don't think
this is likely to change in the future. As Andy says, this would be a
fundamental paradigm shift in any language.

Also, I think languages like PHP are designed for people who don't know
much about "proper" programming. It's designed for people who just want
to throw something together that does the job. No need to worry about
algorithm optimisation, memory allocation or deallocation, hash-table
searching, string handling, type-casting, or indeed typing in general.

--
Oli

Jul 17 '05 #3
Oli Filth wrote (in part):
Also, I think languages like PHP are designed for people who don't know much about "proper" programming. It's designed for people who just want to throw something together that does the job. No need to worry about
algorithm optimisation, memory allocation or deallocation, hash-table
searching, string handling, type-casting, or indeed typing in

general.

Them thar's fight'en words.... :-)

I use PHP because it's easy to program and to get the job done.

<dating myself on>
I have been involved with computers since 1969! Pre Internet, Pre
ARPAnet, Pre OOP, almost Pre CRTs, Pre PCs, Pre MAC, PRE WEB ... the
punch-card era. I've seen the introduction of OOP, I've see "Go To"
less programming, I've seen the "Come From" counter rebellion...
<dating myself off>

Fine, if you don't like PHP because it isn't OOP and strongly typed,
don't use it, but don't expect everyone to agree with you. Find a
programming language you like, use it to interface to the WEB servers
as a CGI. Or, create your own language that can be used with the web
servers, prove to everyone that it is better than what is already out
there. And while you're at it, make sure that it does an excellent job
at catching array overflows and boundary checking. Make sure no one can
use it to write malicious code.

Ken

Jul 17 '05 #4
Ken Robinson wrote:
Oli Filth wrote (in part):
Also, I think languages like PHP are designed for people who don't know
much about "proper" programming. It's designed for people who just

want
to throw something together that does the job. No need to worry about algorithm optimisation, memory allocation or deallocation, hash-table searching, string handling, type-casting, or indeed typing in

general.

Them thar's fight'en words.... :-)

I use PHP because it's easy to program and to get the job done.

<dating myself on>
I have been involved with computers since 1969! Pre Internet, Pre
ARPAnet, Pre OOP, almost Pre CRTs, Pre PCs, Pre MAC, PRE WEB ... the
punch-card era. I've seen the introduction of OOP, I've see "Go To"
less programming, I've seen the "Come From" counter rebellion...
<dating myself off>

Fine, if you don't like PHP because it isn't OOP and strongly typed,
don't use it, but don't expect everyone to agree with you.


I'm not disagreeing with you! I like PHP for the same reason you do: it
gets stuff done *very* quickly.

But you can't deny that PHP hides one hell of a lot of nitty-gritty
low-level (and even standard high-level) stuff from you, so that the
average PHP user can safely assume that, for instance, arrays can
safely be indexed by strings (even though this isn't done natively in
any compiled language that I can think of). But sometimes this stuff is
important. Especially in large, non-trivial systems.
Find a
programming language you like, use it to interface to the WEB servers
as a CGI. Or, create your own language that can be used with the web
servers, prove to everyone that it is better than what is already out
there. And while you're at it, make sure that it does an excellent job at catching array overflows and boundary checking. Make sure no one can use it to write malicious code.


Again, I'm not disagreeing with you. But from a progammatic point of
view (i.e. "what is my script *actually* doing?"), PHP is not the best
answer. If you are used to a language where compile-time and link-time
catch a large number of syntax errors, silly mistakes and algorithmic
boo-boos (e.g. comparing a string with an integer, which doesn't make
sense in e.g. C), then PHP is going to look pretty basic. If this check
isn't even performed at load-time, then debugging becomes a very
hit-and-miss affair.

And when you consider that many PHP programmers consider eval() to be
an acceptable way of achieving things, the problem becomes even worse.

Like I said before, PHP (along with many scripting languages such as
Javascript and Perl) seems to be designed to get stuff done in an
extremely high-level, abstract way, where even things like object types
are (essentially) irrelevant. Except at run-time, when they bite you in
the arse 6 months down the line if you've screwed up. If only they bit
you in the arse at compile-time (which doesn't exist)...

(P.S. IMO, any language without pointers (and pointer arithmetic) isn't
a real language!!)

--
Oli

Jul 17 '05 #5
Great, just what we need, flame bait.

Jul 17 '05 #6
Oli Filth wrote:
Also, I think languages like PHP are designed for people who don't know much about "proper" programming.


I should probably point out that by this, I do *not* mean that everyone
who uses PHP is some kind of retard. Far from it. I am just stating
that one of its original design objectives was to be a language that
anyone could pick up, with little (or no) programming experience.
Therefore, lots of typical programming issues have been made completely
transparent to the PHP programmer.

--
Oli

Jul 17 '05 #7
I would also not mind if they would somehow inplement strong typing in
PHP, but I really don't see that happening. It is one of the things I
like about C++ (and Java) and in this area I would like it if PHP was
more like those languages. I am kind of using strong typing already by
prefixing any variable-name with a letter (i for int, s for string, a
for array...).

I would also like to see the OOP and pointers of C++, although I hate
pointers, but that's just because I'm appearantly to stupid to use them
effectively.

One thing I really really like about PHP however, is how it handles
arrays. I hate the C++ mechanism where you have to specify the length
of the array and it is then fixed... I hope they never touch that in
PHP.

Jul 17 '05 #8

Jordi wrote:
One thing I really really like about PHP however, is how it handles
arrays. I hate the C++ mechanism where you have to specify the length
of the array and it is then fixed... I hope they never touch that in
PHP.


Pretty much every other modern language besides C and cpp will let you
freely add and delete from arrays. perl, java, php, python, javascript,
c#, whatever.

Jul 17 '05 #9
Use === instead of ==.

Jul 17 '05 #10
Oli Filth wrote:
dt******@hotmail.com wrote:
Will php 6 do strong typing and/or namespaces?

I was shocked to find out today that there are some people who actually
argue that weak typing is somehow better.


I completely agree. Strong typing makes far more sense due to the
compile-time constraints it enforces. Anyone who thinks otherwise is
lazy, quite frankly, and isn't thinking in terms of long-term
maintainability and debugging.


"We will encourage you to develop the three great virtues of a programmer:
laziness, impatience, and hubris."

-- LarryWall, ProgrammingPerl (1st edition), O'Reilly & Associates

Sorry, but I just don't get it. Why is enforced strong typing a benefit?

I like the way PHP works. I freely admit there are times when I want to make
sure of the type of a variable but in PHP I can *choose* to do that by
various mechanisms ('===', if ($test==(integer)$test), ...) and if I want
to record the type of a variable I use comments(1).

IMHO Hungarian notation and SOAP do major damage to the readability of code.

It also buggers up the fundamental point of OOP, i.e. polymorphism.
Nope. I don't see that either. If the base types are (to most intents and
purposes) polymorphic, how does that undermine polyorphism in user classes?

IMHO the only design issues with PHP in its current form are:

- namespace collisions - implementing seperate namespaces is one solution to
this

- erm, that's about it really.
Also, I think languages like PHP are designed for people who don't know
much about "proper" programming. It's designed for people who just want
to throw something together that does the job. No need to worry about
algorithm optimisation, memory allocation or deallocation, hash-table
searching, string handling, type-casting, or indeed typing in general.

( not to mention null pointer dereferencing, buffer overflows, failed build
cycles...)

There are no BAD programming languages(2) - just bad programmers ;)

Certainly I want to get things done with a minimum of effort however I have
written network protocol stacks and AI engines in PHP (and no, not because
it was the only programming language I know).

The most expensive component in most computer systems is programmer time.
Have a look at the Great Computer Language Shootout. PHP consistently
scores well in requiring fewer lines of code. It's not the most
minimalistic, but OTOH, I've yet to find someone that thinks PHP is not a
VERY easy language to learn. Add to this the flexibility of what can be
acheived with PHP and it starts to look like a language which excels at
being understood. This kind of transparency (despite my comments below - 1)
is therefore the most valuable asset of any programming language - want to
talk about maintainability and debugging?

But I am more than happy to be educated / proved wrong.

C.

1 - don't even think about posting a reply containing the string
'self-documenting code'
2 - except maybe brainf**k - but it's meant to be bad
Jul 17 '05 #11
Happy to hear that.

I don't know a lot about other languages. I've had a basic course in
Java a couple of years ago, but I don't remember much of it. I can
usually understand JavaScript, but that's it.

I'm studying Artificial Intelligence and they are teaching us to
program in C++, but I really hate their array-system.

By the way, do all of the languages you mentioned have associative
arrays? I kind of like that about PHP too.

[/offtopic]

Why do you think it is necessary for PHP (or any other language) to
have strong typing? I've been thinking a little bit about this today
and I'm not so eager to see it implemented anymore. I mean: what's the
big advantage? If you are a good programmer, chances are that you won't
be bitten in the arse 6 months down the line.
I don't think there are a lot of scenario's where strong typing are
essential and if you really want to check for a specific type, just use
the === operator.

Also, Oli Filth pointed out that PHP doesn't worry about a lot of
things. He mentioned algorithm optimisation, memory allocation,
hash-table searching, string handling and type-casting. I could be
wrong and/or I didn't understand the comment properly, but doesn't PHP
do a lot of these things automatically? I thought PHP had it's own
garbage collector (memory allocation) and you can also unset variables
yourself. I read somewhere that PHP arrays where actually hashes, so
who needs hash-table searching when it's already there? String handling
in PHP rocks IMO and you can optimize your algorithms (why not?).

Jul 17 '05 #12
The question of strong vs weak typing was discussion in a roundtable
discussion with representative from Perl, PHP, and Rudy:

http://www.devsource.com/article2/0,1759,1778141,00.asp

Jul 17 '05 #13
IMHO the complexity introduced by namespace is not worth the benefit.
Suddenly people learning PHP have yet another feature to learn. Books
will have an additional chapter. In general PHP code would become more
complicated, since people will start using namespace just because it's
there and not because it's necessary in a given circumstance.

A more useful solution I think would be the ability to create separate
execution contexts, something similiar to the component system in
Flash/Actionscript. You would run a third-party script in its own
context, with separate namespace, variable-space, and settings. That
would eliminate other sorts of conflicts you may encounter in sharing
code, in additional to namespace collisions.

Jul 17 '05 #14
NC
dt******@hotmail.com wrote:

Will php 6 do strong typing and/or namespaces?
I hope not...
I was shocked to find out today that there are some people
who actually argue that weak typing is somehow better.
But it IS better, sometimes at least.

Strong typing was advocated by Niklaus Wirth for one and only
one reason: the lack of transparent and well-documented rules
for handling type mismatches and out-of bounds errors. Say
we have:

if ($a == $b)

How should an interpreter/compiler go about it if $a is a float
and $b is a string? Wirth's preferred approach was to throw
a type mismatch error and refuse to complie/execute. PHP provides
both a transparent rule-based alternative for handling the type
mismatch without halting and an alternative strict comparison
operator (===).

Another problem which Wirth suggested should be solved with
strong typing is this:

It must be guaranteed that no [array] element can be accessed
with an invalid index, despite the fact that the resulting
address computation would point to some existing storage cell
-- probably holding another variable.

(Quoted from Witrh's 1997 interview to Software Development
magazine)

The problem is real enough. But the truth is, it DOESN'T have
to be solved with strong typing. And PHP is a good example of
an alternative solution; indeed, you can't get anything other
than NULL if you access a non-existing element of an array.
Moreover, you can check if this element exists before you
attempt to acces it...

Also, Wirth did not anticipate that distributed computing will
eventually come to a point when data will be exchanged between
distributed components not in their internal presentation, but
rather, in their STRING presentation. If you need to send an
argument whose value is 10 to a Web service, you will have to
send it as string '10', not as byte 0A. In this situation,
strong typing begins to smack of a headache; indeed, you need
to explicitly convert every string you receive via Web service
input into its appropriate type...
I didn't even know there was a debate. Shocking. That's
like arguing that square tires are better than round.
Not really. Rather, it's like arguing that wide tires are
better than narrow ones on some vehicles in some circumstances.
Anyway if anyone knows that php is going to intentionally stay
weak in the future let me know so I can jump ship, thanks,


Happy jumping. :)

Cheers,
NC

Jul 17 '05 #15
NC,
Will php 6 do strong typing and/or namespaces?

I hope not...

I was shocked to find out today that there are some people
who actually argue that weak typing is somehow better.

But it IS better, sometimes at least.

Strong typing was advocated by Niklaus Wirth for one and only
one reason: the lack of transparent and well-documented rules
for handling type mismatches and out-of bounds errors. Say
we have:

if ($a == $b)

How should an interpreter/compiler go about it if $a is a float
and $b is a string? Wirth's preferred approach was to throw
a type mismatch error and refuse to complie/execute. PHP provides
both a transparent rule-based alternative for handling the type
mismatch without halting and an alternative strict comparison
operator (===).

Another problem which Wirth suggested should be solved with
strong typing is this:

It must be guaranteed that no [array] element can be accessed
with an invalid index, despite the fact that the resulting
address computation would point to some existing storage cell
-- probably holding another variable.

(Quoted from Witrh's 1997 interview to Software Development
magazine)

The problem is real enough. But the truth is, it DOESN'T have
to be solved with strong typing. And PHP is a good example of
an alternative solution; indeed, you can't get anything other
than NULL if you access a non-existing element of an array.
Moreover, you can check if this element exists before you
attempt to acces it...

Also, Wirth did not anticipate that distributed computing will
eventually come to a point when data will be exchanged between
distributed components not in their internal presentation, but
rather, in their STRING presentation. If you need to send an
argument whose value is 10 to a Web service, you will have to
send it as string '10', not as byte 0A. In this situation,
strong typing begins to smack of a headache; indeed, you need
to explicitly convert every string you receive via Web service
input into its appropriate type...


Thanks for taking the time to post this, I was getting ready to type a
huge reply on this and you spared me the time ;)

I completely agree with your viewpoints, also on how PHP handles these
problems is extremely nice. I came from C++ and Java so I completely
understood the point of strong typing. The first few times I was
looking at PHP I was a bit intimidated by it, but came to find out how
nice it actually was.

A couple of examples that make this nice is:

$var1 = '10';
$var2 = 10;

now when you do a if ($var1==$var2) this will become true because of how
PHP will switch in between types. For instance where this is really
nice is getting information from an API where you are expecting a number
but you decided not to typecast it because you where simply comparing
its numeric values.

I could just as easily typecast it by doing a if ((int)$var1===$var2)
but as you can see we can get into some messy stuff which was not needed
in this circumstance.

Mike
Jul 17 '05 #16

Jordi wrote:
By the way, do all of the languages you mentioned have associative
arrays? I kind of like that about PHP too.

[/offtopic]
Yes. Really, you have to realize just how old C++ is. PHP may seem to
have all kinds of fancy features by comparison, but it's really just
average.

Why do you think it is necessary for PHP (or any other language) to
have strong typing? I've been thinking a little bit about this today
and I'm not so eager to see it implemented anymore. I mean: what's the
big advantage? If you are a good programmer, chances are that you won't
be bitten in the arse 6 months down the line.


I completely don't see the logic of people who oppose strong typing.
If you're going to have types at all, why wouldn't you want the
language to tell you when you used the wrong type by accident. If you
have a function that wants an XYZObject as its first agument and I pass
it a ABCObject somewhere by accident, don't you want it to throw an
error? How is this even a debatable point?

Let me phrase it to you like this. When writing Java and C#, I have
made many type mistakes and received type errors as a result. Not
once, ever, have I been unhappy to have received the error. In every
case, the type error was informing me of a mistake on my part. A
mistake which, if it had gone to the live site, I might never have
known about until a customer stumbled on it. And then customer says
"it's not working", which tells you absolutely nothing about what went
wrong or how to fix it. A good percentage of these type errors might
not be noticable without strong typing warnings, until the customer
experiences it. This is a non-debate.

Jordi since you're relatively new, here's the dirty secret behind the
whole pro-weak-typing arguments. The fact is, all the languages that
do weak typing do it because they compile on the fly at run time. So
for example, php code is read and interpreted and executed each time
the user visits the page. Same with perl (weak typing), javascript
(weak), python (weak). If those languages did do strong typing, then
all of the type errors would be runtime errors. They have no middle
step. For java and C# and c++, the language interpreter runs ahead of
time; in other words, they compile before they run. For those three,
type errors can be caught during compilation, rather than at run time.

Now I know you already know that, but the reason I'm pointing it out is
these two summation sentences right here which is where I rest my case:

All the languages that have the option of doing strong typing, do it.
All the languages that don't have the option (because typing errors
would be runtime errors), don't.

Yet you don't hear the pro-weak-typing people saying "gee, I wish we
could but we can't". Instead you hear them coming up with absurdities
"well we wouldn't even if the language could, because weak typing is
really better." It's like the guy that asks a girl out and she says no
so he says "well I didn't really like here anyway."

It's laughable.

Show me a language that does have a compilation step, before runtime,
that still chooses to do weak typing. (good luck!)

Jul 17 '05 #17
dt******@hotmail.com wrote:

: Will php 6 do strong typing and/or namespaces?

: I was shocked to find out today that there are some people who actually
: argue that weak typing is somehow better. I didn't even know there was
: a debate. Shocking. That's like arguing that square tires are better
: than round.

: Anyway if anyone knows that php is going to intentionally stay weak in
: the future let me know so I can jump ship, thanks,

But that is wrong, php is strongly typed - at runtime.

At runtime php "knows" a great deal about the type of data it is handling,
and can use its well defined rules to handle the data in a consistent and
reliable way.

Compare that to a language like C, or C++, or Pascal. Those languages are
very weakly typed - at runtime. It is essential that the programmer has
setup the program with the correct data types because otherwise the
program will not work correctly. That is why the compile time typing is
so essential in those languages. The compile time typing helps to
overcome the runtime limitations of the languages.

In case you think this is an bad use of the term "data typing", let me
point out that there are languages are weakly typed at both compile time
and runtime - assembler and forth come to bind.

All these languages have their place, their strengths, and their
weaknesses, but you shouldn't assume that the "strengths" of a language
would be strengths in other situations - a language's strengths are
relative to the language's weaknesses, and to the history that lead to the
language. As the technologies diverge, it becomes less and less
meaningful to make direct comparisons between them, anymore than you could
compare the strengths of a lawnmower engine with an aeroplane engine.
$0.04

--

This space not for rent.
Jul 17 '05 #18
NC
dt******@hotmail.com wrote:

Show me a language that does have a compilation step, before runtime,
that still chooses to do weak typing. (good luck!)


How about PHP? :) Compilers are avaiable, weak typing is still
in place.

Cheers,
NC

Jul 17 '05 #19

You know what I'm going to say to that, right!

"Compilers are available", yea. And like .1% of php programs use them.

Jul 17 '05 #20
> You know what I'm going to say to that, right!

"Compilers are available", yea. And like .1% of php programs use them.


*raises hand* ;)

Sometimes its nice to use. But yet again sometimes I run to the C++ ;)

Mike
Jul 17 '05 #21


Jordi wrote:
One thing I really really like about PHP however, is how it handles
arrays. I hate the C++ mechanism where you have to specify the length
of the array and it is then fixed... I hope they never touch that in
PHP.


Basically, you shouldn't be using arrays in C++ unless you have a
situation where there is a need for a simple, fixed-size data
construct. You should instead be using the appropriate standard
container that fits the need.


Brian

Jul 17 '05 #22


Jordi wrote:
Happy to hear that.

I don't know a lot about other languages. I've had a basic course in
Java a couple of years ago, but I don't remember much of it. I can
usually understand JavaScript, but that's it.

I'm studying Artificial Intelligence and they are teaching us to
program in C++, but I really hate their array-system.
As I mentioned in a reply to another message, you probably shouldn't be
using arrays in C++. The language has much more powerful and
user-friendly constructs in the standard library.
By the way, do all of the languages you mentioned have associative
arrays? I kind of like that about PHP too.


C++ has associative containers (map and multimap). They differ from
arrays in PHP because they store their contents in sort order rather
than insertion order, so you can't use both numeric indexes and
associative ones.

Brian

Jul 17 '05 #23
dt******@hotmail.com wrote:
Will php 6 do strong typing and/or namespaces?

I was shocked to find out today that there are some people who actually
argue that weak typing is somehow better. I didn't even know there was
a debate. Shocking. That's like arguing that square tires are better
than round.

Anyway if anyone knows that php is going to intentionally stay weak in
the future let me know so I can jump ship, thanks,

mrb


Lots of terminology confusion in this thread. Suggest you all read
<http://premshree.seacrow.com/writings/typing>.
Jul 17 '05 #24
Frank wrote:
Lots of terminology confusion in this thread. Suggest you all read
<http://premshree.seacrow.com/writings/typing>.


The terminology bit is about halfway through. It's all relevant to this
discussion, though.
Jul 17 '05 #25
Chung Leong <ch***********@hotmail.com> wrote:
Great, just what we need, flame bait.


You seems to have switched to GG2. But, please quote when you reply
(it's possiblein GG2: show options->Reply). BTW, I appreciate your
intuitive idea to show email address:)

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #26

"Oli Filth" <ca***@olifilth.co.uk> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
dt******@hotmail.com wrote:
Will php 6 do strong typing and/or namespaces?

I was shocked to find out today that there are some people who actually
argue that weak typing is somehow better.
What's so shocking about it? I much prefer a language where I can use
variables without having to declare them first. I also love the ability to
test for and change a variables's type. Very convenient.
I completely agree. Strong typing makes far more sense due to the
compile-time constraints it enforces. Anyone who thinks otherwise is
lazy, quite frankly, and isn't thinking in terms of long-term
maintainability and debugging.
Absolute rubbish!
It also buggers up the fundamental point of OOP, i.e. polymorphism.
Absoute Rubbish!
Anyway if anyone knows that php is going to intentionally stay weak

in
the future let me know so I can jump ship, thanks,


Scripting langauges are not compiled, in general. Therefore most don't
seem to use strong typing, because there's no compiler to catch this
sort of thing. e.g. PHP, Perl, VB, VBscript, Javascript. I don't think
this is likely to change in the future. As Andy says, this would be a
fundamental paradigm shift in any language.

Also, I think languages like PHP are designed for people who don't know
much about "proper" programming.


Yet it can still be used by people who know a great deal about 'proper'
programming. I used various 2nd, 3rd and4th generation languages for 25+
years before I switched to PHP.
It's designed for people who just want
to throw something together that does the job. No need to worry about
algorithm optimisation, memory allocation or deallocation, hash-table
searching, string handling, type-casting, or indeed typing in general.


So what?

Tony Marston
http://www.tonymarston.net
Jul 17 '05 #27
I think people have to agree that PHP gives developers the means to
develop stuff lightning quick, in comparison to say JSP/JavaBeans.

I code in both - personally I much prefer using Java as I like strong
typing and I find the use of objets and classes better.

HOWEVER, PHP development is generally much, much quicker.

I would prefer to use JSP and Java for bigger projects or ones that are
likely to expand over time, however for smaller scale stuff PHP is a
great option because of features such as weak typing (not to mention
all of the HTML/Web related functions built in)

I think a choice of language should comes down to project spec in most
cases.

Rick
www.e-connected.com

Jul 17 '05 #28
Hi,

In case some of you are not aware of the difference between strong/weak
and static/dynamic typing and their consequences I found the following
quite enlightening:

<http://www.artima.com/weblogs/viewpost.jsp?thread=7590>
<http://mindview.net/WebLog/log-0025>

--
Cheers,
- Jacob Atzen
Jul 17 '05 #29
Just to add some more to this list:
In case some of you are not aware of the difference between strong/weak
and static/dynamic typing and their consequences I found the following
quite enlightening:

<http://www.artima.com/weblogs/viewpost.jsp?thread=7590>
<http://mindview.net/WebLog/log-0025>


http://www.artima.com/weblogs/viewpost.jsp?thread=4639
http://www.paulgraham.com/hundred.html
http://www.paulgraham.com/hp.html
http://java.sun.com/features/2003/05/bloch_qa.html

Some are pro some are against as always ;)

Things like this always come down to personal preference. Me I
completely agree with the first link I posted. Much of the argument has
been about people not creating programs well....

I think this never solves the problem as in the first link above. You
need to do solid checking of your programs with unit testing and all the
above. Most of the errors I see in PHP are logic errors. You will find
those just about anywhere.

Mike
Jul 17 '05 #30
"Oli Filth" <ca***@olifilth.co.uk> wrote:
I completely agree. Strong typing makes far more sense due to the
compile-time constraints it enforces. Anyone who thinks otherwise is
lazy, quite frankly, and isn't thinking in terms of long-term
maintainability and debugging. [...]


There may be a third way: meta-code to direct a code checker. Think about
something like this, where the meta-code is given inside comments:

/*.void.*/ function PrintStrings(/*.string.*/ $s, /*.int.*/ $n)
{
/*. int $i; .*/
for($i=1; $i<=$n; $i++){
echo $s;
}
}

The meta-code declare the type of the returned value and the type of
the formal arguments using a syntax symilar to the C language. A source
code checker may use this information to report invalid usages of the
function, exactly as a strong typed language do. This is the direction
I taken developing phplint (www.icosaedro.it/phplint/), a source parser,
semantic and style validator for the PHP language.

Using the meta-code:

- the PHP language do not need to be modified
- the PHP interpreter do not need to be modified
- the meta-code may be added to the source after the prototyping phase,
just to check the source before the final release

Ciao,
___
/_|_\ Umberto Salsi
\/_\/ www.icosaedro.it

Jul 17 '05 #31

"Umberto Salsi" <sa***@icosaedro.italia> wrote:
meta-code is given inside comments:
The meta-code declare the type of the returned value and the type of
the formal arguments using a syntax symilar to the C language.
I taken developing phplint (www.icosaedro.it/phplint/), a source parser,
semantic and style validator for the PHP language.

That's very interesting, but www.phpdoc.org also defines meta-code inside
comments. Do I have to declare every variable, function, parameter twice,
i.e once for phpline and once for phpdoc or more awful will the comment of
one type confuse the other engine?

Christian

Jul 17 '05 #32


Umberto Salsi wrote:
"Oli Filth" <ca***@olifilth.co.uk> wrote:
I completely agree. Strong typing makes far more sense due to the
compile-time constraints it enforces. Anyone who thinks otherwise is
lazy, quite frankly, and isn't thinking in terms of long-term
maintainability and debugging. [...]


There may be a third way: meta-code to direct a code checker. Think about
something like this, where the meta-code is given inside comments:

/*.void.*/ function PrintStrings(/*.string.*/ $s, /*.int.*/ $n)
{
/*. int $i; .*/
for($i=1; $i<=$n; $i++){
echo $s;
}
}

The meta-code declare the type of the returned value and the type of
the formal arguments using a syntax symilar to the C language. A source
code checker may use this information to report invalid usages of the
function, exactly as a strong typed language do. This is the direction
I taken developing phplint (www.icosaedro.it/phplint/), a source parser,
semantic and style validator for the PHP language.

Using the meta-code:

- the PHP language do not need to be modified
- the PHP interpreter do not need to be modified
- the meta-code may be added to the source after the prototyping phase,
just to check the source before the final release

Ciao,
___
/_|_\ Umberto Salsi
\/_\/ www.icosaedro.it


This looks like it could be perfect for what I need. But does it only
work with base types like string and int, or can it check object types
that I define?

/*MyObject*/ function getthing(/*MyThing*/ mt, /*MyArrayList/* arl) {

etc etc ?

Jul 17 '05 #33
The most expensive component in most computer systems is reliability,
not programmer time. I'm all in favor of preserving programmer time,
that's why I want strong typing. If you want to make something
reliable, and you don't have strong typing, then your programmer is
going to spend a hell of a lot more time. Anyway my whole argument is
summed up in this response on this thread:

http://tinyurl.com/74v59

Jul 17 '05 #34
You are missing the point abbot dynamic typing - it SAVES programmer time
because you don't have to declare a variable before using it. As for it
allowing errors to fall through - PIFFLE! Any such errors will be trapped
during unit testing. You DO test you code, I presume? Or are you one of
these jokers who assumes that if it compiled OK then it doesn't need
testing?

--
Tony Marston
http://www.tonymarston.net

<dt******@hotmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
The most expensive component in most computer systems is reliability,
not programmer time. I'm all in favor of preserving programmer time,
that's why I want strong typing. If you want to make something
reliable, and you don't have strong typing, then your programmer is
going to spend a hell of a lot more time. Anyway my whole argument is
summed up in this response on this thread:

http://tinyurl.com/74v59

Jul 17 '05 #35
"Oli Filth" <ca***@olifilth.co.uk> writes:

(P.S. IMO, any language without pointers (and pointer arithmetic) isn't
a real language!!)


Like say Lisp?

--Zach

Jul 17 '05 #36
> Anyone who thinks otherwise is lazy, quite frankly,
and isn't thinking in terms of long-term maintainability
and debugging.
1. Programmers are by nature lazy. That's the point of writing a
program to do a job.
2. Arguing that strong typing helps long-term maintainability is
rediculous. Have you ever tried to maintain a program written in
Hungarian notation where all of a sudden you are dealing with a float
instead of an int?

No need to worry about algorithm optimisation, memory
allocation or deallocation, hash-table searching, string handling,
type-casting, or indeed typing in general.
Is it a bad thing that the programmer does not have to worry about
these things? You like allocating memory? Call me crazy, but I think
that's exactly what the memory management section of the kernel is
supposed to do, not the user.
And assuming that PHP programmers do not optimize their algorithms is
stretching. Do you write PHP? Do you optimize your algorithms? So do
I.
String handling - would you have us use a string that is not actually a
string, but is instead maybe a null-terminated array of characters?
The only thing that is good for is nostalgia. Doesn't it seem logical
that a language specifically invented for use on the internet (which
uses strings pretty heavily, if you hadn't noticed) should have a
natively supported comprehensive string type?
Type casting - doubleval, floatval, gettype, intval, settype, strval -
is there something you are missing? Saying that PHP lacks "typing in
general" is being completely ignorant of how PHP works:
http://us3.php.net/manual/en/function.gettype.php While it is not
"strict typing", I think it is certainly "typing in general".

But you can't deny that PHP hides one hell of a lot of nitty-gritty
low-level stuff from you
You are arguing that is a bad thing, correct? I would argue the exact
opposite, the computer can and should do that more quickly and
efficiently than I can, and I don't have to pay the computer for its
time. As an exercise, take a look at, for example, the main config
file for phpMyAdmin, and see if you can figure out a more logical way
to organize config settings without using an associative array.

If you are used to a language where compile-time and link-time catch
a large number of syntax errors, silly mistakes and algorithmic boo-boos
(e.g. comparing a string with an integer, which doesn't make sense in e.g. C)
Like I explained before, for internet programming, where everything is
a string, comparing 4 with "4" makes perfect sense. And true, if you
ARE used to a system where compiling catches all the errors you make,
then yes, something that assumes you know what you're doing may give
you trouble.

debugging becomes a very hit-and-miss affair.
That depends on the quality of your code in the first place. Debugging
for me is a very hit-and-hit affair.

lots of typical programming issues have been made completely
transparent to the PHP programmer.


Again, I'm wondering why this is necessarily a bad thing. Unless you
like core dumps.

Jul 17 '05 #37
On Mon, 23 May 2005 15:33:58 -0700, dterrors wrote:

Will php 6 do strong typing and/or namespaces?

I was shocked to find out today that there are some people who actually
argue that weak typing is somehow better. I didn't even know there was
a debate. Shocking. That's like arguing that square tires are better
than round.


I guess you've never tried coding Lotus Note's OLE API in C++ have you?

Jul 17 '05 #38
>I guess you've never tried coding Lotus Note's OLE API in C++ have you?

I don't know about anyone else, but that wasn't an assigment in MY
college classes.

Jul 17 '05 #39
On Thu, 26 May 2005 16:40:35 -0700, Steve wrote:
I guess you've never tried coding Lotus Note's OLE API in C++ have you?


I don't know about anyone else, but that wasn't an assigment in MY
college classes.


Notes wasn't around when I was at college, but it's a REAL WORLD problem
that I've had to deal with this week.

The Visual Basic examples made the job look so easy .. we wept buckets!

Jul 17 '05 #40
> The Visual Basic examples made the job look so easy .. we wept buckets!

That reminds me of programming for Goldmine, which is truly a
nauseating experience.

Jul 17 '05 #41
It seems there are knowledgeable people watching this topic. If
someone could take a minute to help me with a setup issue, I would
appreciate it:

"Some extensions loading, some not"

http://groups-beta.google.com/group/...eef672cbd11dd2

Jul 17 '05 #42
dt******@hotmail.com wrote:
Will php 6 do strong typing and/or namespaces?

I was shocked to find out today that there are some people who actually
argue that weak typing is somehow better. I didn't even know there was
a debate. Shocking. That's like arguing that square tires are better
than round.

Anyway if anyone knows that php is going to intentionally stay weak in
the future let me know so I can jump ship, thanks,

mrb

PHP was developed for the web, which assumes "everything is a string", whereas,
C assumes "everything is an int". Perl was adapted to the web, PHP was built
for the web from the ground up. Perl and PHP certainly depend on C or C++ but
the whole point is that you don't have to master C to program with PHP or Perl,
instead you master the art of programming these languages for the most part
using strings, not ints.

C is a great language to build a language like PHP, but C or C++ will never be
the right language for the web, simply because it requires a programmer to think
too much about the program guts and not about the behavior of the program. Most
C programmers that are in love with the glow of C-programming don't get how difficult
it really is to develop applications with it--especially how ridiculous to think you
want to develop web applications with a compiled language--too retarded to even go
there... The web is about strings, not about ints. And C with all of its defines,
voids, and other arcaneness, is this what I really want to spend time on?

PHP allows people to be successful quickly with C-like programming, without having to
deal with the arcane inconsistencies of C, but get the added benefit of associative
arrays. This is so amazing, you need to write C to appreciate PHP. PHP is also more
successful than Java because it doesn't require a lot of abstraction or object programming,
unless you really want it.

Step back and look at Java or C, and all the things you must do to be successful. To be
sure, Java and C have their place, but PHP is more appropriate to building web applications
simply because you can focus on the art of building an application and not whether or not
you got your pointers right, or types correct. Save that for the low-level building of libs
and toolkits and languages.

PHP succeeds because it allows the best of both worlds, the world of drop-through
programming or object programming, no compiler, simple, intuitive logic constructs,
and associative arrays, they are simply awesome. What a great language in PHP. It
appeals to my laziness.

Perl ain't bad either, hashes are fantastic, and save me from having to write
arcane C code to build difficult-to-read linked-lists, geezus what pain to read
and follow compared to simple hashes and hashes-of-hashes in Perl. Imagine the
effort required to write a C or C++ program with hashes-of-hashes. It would be
so unenjoyable and unproductive as to make me want to take up another career.

Jul 17 '05 #43


Steve wrote:
It seems there are knowledgeable people watching this topic. If
someone could take a minute to help me with a setup issue, I would
appreciate it:

"Some extensions loading, some not"

http://groups-beta.google.com/group/...eef672cbd11dd2

Don't hijack my thread, asshole.

Jul 17 '05 #44
Why are you talking about C? Is anyone arguing that C is better for
web dev than PHP? Did you write this response to the wrong thread by
accident or something?

Jul 17 '05 #45
dt******@hotmail.com wrote:
Why are you talking about C? Is anyone arguing that C is better for
web dev than PHP? Did you write this response to the wrong thread by
accident or something?

Your assumptions are written around the mindset of someone who writes
compiled languages, and does not get PHP, as if it needs corrective
surgery to be "complete" like a compiled language like C or C++, or
whatever. If you want to "jump ship" it suggests that you are trying
to put PHP into a compiled language mindset where it doesn't really
fit. Web application programming is about the moment, not about the
story. Compiled languages are all about the story not the moment.

Stay with it for a spell, and write a complete web application with
PHP, and you will understand. You make the implied assumption that
somehow PHP is weak because it's weakly typed--in the classic sense,
but let's not assume that weakly-typed makes the language weak, to the
contrary it is a strongly string-typed language ideally suited for the
web.

The next step will be a PHP script that runs in the browser instead
of just server-side as an alternative to Javascript--now THAT would
be really fantastic--simply because of the messiness of Javascript.
Jul 17 '05 #46
Gee you think I should write a complete web application? Another one?
I already have like 30 running as we speak. Well, type. One of which is
a company is (unfortunately) build around.

Try writing a complete java web app "and then you will understand".
(And don't do jsp, do servlets).

Jul 17 '05 #47
Actually, try to write a complete java app that 10 programmers work on.
That's how you'd learn the need for strong typing...

Jul 17 '05 #48
dt******@hotmail.com wrote:
Actually, try to write a complete java app that 10 programmers work on.
That's how you'd learn the need for strong typing...

ding!
Point goes to dterror... :-)

The point being that if you have a team of programmers the completed
project is as strong as the weakest link. But it might be instructive
that PHP eliminates the inherent weakness of depending on strong
typing, by eliminating the strong typing in the first place.

On balance though, a great PHP team can still make mistakes and can
still get things wrong, but it typically is other issues besides
type errors. In fact, most of the PHP programmers I know have
been careful to manage type issues out of sheer terror that their
peers will shame them, perhaps this is something you missed in the
grand scheme of things. :-) Of course that means without a team
you might miss something without peer review, but maybe it makes
your code even more challenging to do things right.
Jul 17 '05 #49


dt******@hotmail.com wrote:
Steve wrote:
It seems there are knowledgeable people watching this topic. If
someone could take a minute to help me with a setup issue, I would
appreciate it:

"Some extensions loading, some not"

http://groups-beta.google.com/group/...eef672cbd11dd2

Don't hijack my thread, asshole.


This thread belongs to you as much as any other part of the internet
belongs to you, Mr. Troll. I was asking for help of the knowledgeable
people reading this thread, which apparently does not include you, so
don't bother yourself.

Jul 17 '05 #50

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

Similar topics

94
4610
by: Gabriel Zachmann | last post by:
Is it correct to say that strong/weak typing does not make a difference if one does not use any pointers (or adress-taking operator)? More concretely, I am thinking particularly of Python vs C++....
5
2660
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/callnetfrcom.asp The Joy of Interoperability Sometimes a revolution in programming forces you to abandon all...
0
7201
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
7083
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
7278
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
7328
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
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5011
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...
0
3153
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1510
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.