Is PHP still slower than Perl?

B

Berislav Lopac

Much as I respect evolutionary approaches to design - if you were
planning on building a rocket ship in 1995 - it would have been
best not to have started with a steam engine - and to have attempted
a series of gradual changes once the thing was going along.

True. But, as Chris said above, they never planned to build a rocket ship
-- PHP was originally just a simple wheelcart made for pushing some earth
around. That it evolved into the transgalactic cargo hauler it is today is
simply amazing.

Berislav
 
B

Brad Shinoda

John Bokma said:
That's mySQL, not PHP.

I mean something like:

$query = "INSERT INTO table VALUES(?, ?, ?)";
mysql_bla( $query, $a, $b, $c );

Hence without the quote_she_bang_garbage

I can't believe you can't actually write such a function yourself???

People should always be writing wrapper functions or classes to handle
db connections, to remove such stuff as addslashes()ing. Use
func_num_args() to find out the number of arguments passed to a php
function and func_get_arg([number]) to get the [number]th argument
passed. I've written such a function for myself. Well in fact I use
three classes for handling databases - one abstract "Database" class
for any database, one Database specific class (eg mysql_db for mysql
databases) and a Query class for handling queries in the manner you
suggest. Now I do this:

$sql = "SELECT foo, bar
FROM table
WHERE a = ?
AND b = ?";
$db->query(new Query($sql, $a, $b), __LINE__, __FILE__);

And all query preprocessing is handled by the Query class, and
database connection/query processing/error handling is handled by the
database-specific class.

I use such classes in all my developments. They're written once then
forgotten about, and simply reused where needed.

All I'm saying is that it's really pretty easy to implement many
things yourself, without moaning that the language hasn't done them
for you.
 
J

John Bokma

(e-mail address removed) (Brad Shinoda) wrote in
I can't believe you can't actually write such a function yourself???

Sure. I can even write my own improved PHP clone. What's the point?
People should always be writing wrapper functions or classes to handle
db connections, to remove such stuff as addslashes()ing. Use
func_num_args() to find out the number of arguments passed to a php
function and func_get_arg([number]) to get the [number]th argument
passed. I've written such a function for myself.

Yes, and everybody has to write wrapper functions. You get the point
now, or do you want it spelled out?
Well in fact I use
three classes for handling databases - one abstract "Database" class
for any database,

Yes, in Perl that is called DBI. You don't have to write it yourself.

one Database specific class (eg mysql_db for mysql
databases) and a Query class for handling queries in the manner you
suggest. Now I do this:

$sql = "SELECT foo, bar
FROM table
WHERE a = ?
AND b = ?";
$db->query(new Query($sql, $a, $b), __LINE__, __FILE__);

And all query preprocessing is handled by the Query class, and
database connection/query processing/error handling is handled by the
database-specific class.

I use such classes in all my developments. They're written once then
forgotten about, and simply reused where needed.

Wonderful. With Perl it's put on CPAN and used (and tested) by many
people.
All I'm saying is that it's really pretty easy to implement many
things yourself, without moaning that the language hasn't done them
for you.

Programming shouldn't be about reinventing wheels, and worse reinventing
bugs.
 
T

Tony Marston

John Bokma said:
(e-mail address removed) (Brad Shinoda) wrote in
I can't believe you can't actually write such a function yourself???

Sure. I can even write my own improved PHP clone. What's the point?
People should always be writing wrapper functions or classes to handle
db connections, to remove such stuff as addslashes()ing. Use
func_num_args() to find out the number of arguments passed to a php
function and func_get_arg([number]) to get the [number]th argument
passed. I've written such a function for myself.

Yes, and everybody has to write wrapper functions. You get the point
now, or do you want it spelled out?

But different developers will write wrapper functions in different ways.
Whish one should I choose? Why?
Yes, in Perl that is called DBI. You don't have to write it yourself.

Yes, but what happens if I don't like the way it works?
Wonderful. With Perl it's put on CPAN and used (and tested) by many
people.


Programming shouldn't be about reinventing wheels, and worse reinventing
bugs.

But it is about reinventing wheels. A pram wheel is no good for a sports
car, so you have to invent one that works under those circumstances.

I have stopped using other people's solutions for the following reasons:
(a) There are too many solutions from too many people. The people have
various skill levels (from pathetic to passable), and the solutions are
tailored for specific purposes.
(b) It takes too much time to go though all the possible solutions to find
one that is applicable to the problem in hind. I find it much quicker to use
my decades of experience in devising my own solution.

Just my personal opinion.
 
J

John Bokma

Tony Marston said:
"John Bokma" <[email protected]> wrote in message

[ snip ]
People should always be writing wrapper functions or classes to
handle db connections, to remove such stuff as addslashes()ing. Use
func_num_args() to find out the number of arguments passed to a php
function and func_get_arg([number]) to get the [number]th argument
passed. I've written such a function for myself.

Yes, and everybody has to write wrapper functions. You get the point
now, or do you want it spelled out?

But different developers will write wrapper functions in different
ways. Whish one should I choose? Why?

The one that solves your problem the most efficient.

Imagine everybody writing wrapper functions all the time instead of
doing real work...
Yes, but what happens if I don't like the way it works?

In that rare case you can write a wrapper, and make it available on
CPAN.
But it is about reinventing wheels. A pram wheel is no good for a
sports car, so you have to invent one that works under those
circumstances.

If you want to screw something in the wall, do you make your own custom
screws or do you go to the hardware store?
I have stopped using other people's solutions for the following
reasons: (a) There are too many solutions from too many people. The
people have various skill levels (from pathetic to passable), and the
solutions are tailored for specific purposes.

With PHP, Perl or in general?
(b) It takes too much time to go though all the possible solutions to
find one that is applicable to the problem in hind. I find it much
quicker to use my decades of experience in devising my own solution.

I use my decades of experience to select a library or module, or consult
the right people. It has always saved me a lot of time and trouble.
 
T

Tony Marston

John Bokma said:
Tony Marston said:
"John Bokma" <[email protected]> wrote in message

[ snip ]
People should always be writing wrapper functions or classes to
handle db connections, to remove such stuff as addslashes()ing. Use
func_num_args() to find out the number of arguments passed to a php
function and func_get_arg([number]) to get the [number]th argument
passed. I've written such a function for myself.

Yes, and everybody has to write wrapper functions. You get the point
now, or do you want it spelled out?

But different developers will write wrapper functions in different
ways. Whish one should I choose? Why?

The one that solves your problem the most efficient.

Imagine everybody writing wrapper functions all the time instead of
doing real work...

Image using the wrong wrapper function. Besides, even if you do write your
own wrapper function you only ever do so once. Then you re-use it, and
re-use it, and re-use it.
In that rare case you can write a wrapper, and make it available on
CPAN.


If you want to screw something in the wall, do you make your own custom
screws or do you go to the hardware store?

If I want to fix something to a wall then a screw is not necessarily the
only method. What about a nail or even glue? There are different possible
fixings for different types of wall, so just because someone has invented
one type of fixing does mean that it is the only type of fixing.
With PHP, Perl or in general?

With PHP, UNIFACE, COBOL and a few other languages I have used in the past.
I don't touch perl.
I use my decades of experience to select a library or module, or consult
the right people. It has always saved me a lot of time and trouble.

When there are thousands of competing libraries out there, how do I know
which is the right one? Should I spend weeks looking and comparing, or days
in writing my own?

Who are the "right people"? I have come across too many people who class
themselves as "experts" who turn out to be charlatans and quacks.
 
J

John Bokma

Tony Marston said:
"John Bokma" <[email protected]> wrote in message

[ snip ]
Image using the wrong wrapper function.

Yeah, I can. And I can even more imagine the same person writing his/her
own "software"...
Besides, even if you do write
your own wrapper function you only ever do so once. Then you re-use
it, and re-use it, and re-use it.

Yes, that is why there is CPAN. To re-use it. I understood that PHP has
something along these lines too.
If I want to fix something to a wall then a screw is not necessarily
the only method. What about a nail or even glue?

So you make your own nails, and brew you own glue. Probably dig your own
metal, and herd your own cows.
There are different
possible fixings for different types of wall, so just because someone
has invented one type of fixing does mean that it is the only type of
fixing.

And hence, CPAN doesn't have one module called Screw.pm
With PHP, UNIFACE, COBOL and a few other languages I have used in the
past. I don't touch perl.

That sounds like "I don't use glue, ever! Because I have experience with
nails and screws, and hey, I make them myself"
When there are thousands of competing libraries out there,

Sure, there are thousands of competing modules on CPAN...
There are in total 7057 modules ( 2004-10-07, http://cpan.org/ )
You really think that are 7057 similar and competing libraries?
how do I know which is the right one?

Little research, asking. Some modules come with the "core" distribution
of Perl. And sometimes you learn some new ones. Staying in touch with
the languages you use is always important. You can't learn a language
and it's important libraries in a weekend.
Should I spend weeks looking and
comparing, or days in writing my own?

Yep, days writing your own, and tweaking for each new project, bug
fixing, and testing backwards compability. The looking needs only to be
done once. Or you write the perfect library from scratch?
Who are the "right people"?

Read usenet, you learn fast. Also some right people in the Perl group
recommend modules now and then.
I have come across too many people who
class themselves as "experts" who turn out to be charlatans and
quacks.

Yeah ;-)
 
B

Brad Shinoda

John Bokma said:
(e-mail address removed) (Brad Shinoda) wrote in


Sure. I can even write my own improved PHP clone. What's the point?

You're the one who wants the functionality. That's what the "point"
is.
People should always be writing wrapper functions or classes to handle
db connections, to remove such stuff as addslashes()ing. Use
func_num_args() to find out the number of arguments passed to a php
function and func_get_arg([number]) to get the [number]th argument
passed. I've written such a function for myself.

Yes, and everybody has to write wrapper functions. You get the point
now, or do you want it spelled out?

I see what you mean, you're saying that you'd rather it be
incorporated into the language rather than something you have to do
yourself. Misunderstanding on my part.
Yes, in Perl that is called DBI. You don't have to write it yourself.



Wonderful. With Perl it's put on CPAN and used (and tested) by many
people.

I dunno what CPAN is but I'll assume it's some kind of equivilant to
PEAR?
Programming shouldn't be about reinventing wheels, and worse reinventing
bugs.

I suppose, but at the same time doing it yourself gives you more
control, and more scope for customisability.
 
J

John Bokma

(e-mail address removed) (Brad Shinoda) wrote in
You're the one who wants the functionality. That's what the "point"
is.

No, I want less garbage, and less error prone code, *that's* the point.
I see what you mean, you're saying that you'd rather it be
incorporated into the language rather

Nooooo... please don't incorporate more functions in the language. By
know PHP must be the language with the biggest function clutter *in* the
language, combined with the worst naming scheme (or lack of) ever.
than something you have to do
yourself. Misunderstanding on my part.

Have a look at DBI, or JDBC. It's not that difficult to understand what
I mean. Once you understand the basics, you get my point ;-)
I dunno what CPAN is but I'll assume it's some kind of equivilant to
PEAR?

It's most likely the other way around. And I am afraid PEAR doesn't come
close to CPAN.
I suppose, but at the same time doing it yourself gives you more
control, and more scope for customisability.

What do you want to customise about prepared statements? It's like
saying, let's not include geometrical functions, but let's write them
ourselves, so we can customise them...

Everytime I look at PHP I am afraid to discover one day that + has been
replaced with

add_two_positive_integers( $a, $b )
negative_integer_add_positive_integer( $a, $b )
addnegativeintegers( $a, $b )
get_sumof_positiveandnegative_integer( $a, $b )
integer_add( $a, $a_is_positive, $b, $b_is_positive )
:
:
:)
 
C

Chris Hope

Brad said:
I dunno what CPAN is but I'll assume it's some kind of equivilant to
PEAR?

CPAN is a huge repository of prebuilt and reusable packages. I think I saw
someone mention that there's currently about 7000 packages available. So it
is sort of the equivilent of PEAR, but PEAR's still in its infancy compared
to CPAN and many PHP developers don't seem to know about it.

One difference between this aspect of Perl vs PHP (and I'm speaking here as
someone who used to develop Perl about 6 years ago and then switched to
PHP) is that all the Perl developers seem to know about CPAN and it sounds
like it's easy to contribute to, whereas the reverse seems to be true for
PHP.
 
E

Eric J. Roode

I'd say it is because C does not have strings as a native data type.
Other than initializing an array of char, the C compiler has no
string manipulation built in; it requires library functions to do that.
-Joe

I'm surprised that there aren't any open-source CGI libraries out there for
doing things like parsing CGI variables, getting/setting cookies, etc.

Every now and then, I think of writing one, but I hardly use C any more....

--
Eric
`$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=(
$!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++;
$_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++
;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=`
 
B

bruno modulix

Tassilo v. Parseval a écrit :
Also sprach Joe Smith:




That's a distinction in C that's moot. It has no built-in IO mechanisms
either. You have to include a header to get this functionality.

Including the header won't do much more than having correct
prototypes... You can also put the proto by yourself, it's just more
error prone.
But
nonestheless, it's still part of the language.

Of the ANSI/ISO standard, not of the core language. I/O are not builtin
constructs of the language, nor part of the language grammar. You don't
have to care about I/O when writing a C compiler. You can write a C
implementation without I/O, it won't of course be ISO/ANSI compliant but
still be legal and unmodified C syntax.

Bruno
 
J

John Postlethwait

This kind of garbage shouldn't be here. I never understood the my
language is better than your language crap. This is a PHP Newsgroup, if
you idolize Perl so much, go join their newsgroup, but I am pretty sure
"omg perl rawks my world" would be equally unwanted there as it is
here.

Who cares what language you prefer to use as your CGI Gateway, they all
essentially serve a purpose, although that purpose may be similar to
another language's.

Really, this doesn't belong here, and I honeslty don't think anyone
here is out to conquer a whole market. Besides perhaps the original
poster.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top