Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

Why dymanic pages as opposed to HTMl?

(Page 3 of 4)
> > > >
Quote Reply
Re: [RedRum] Why dymanic pages as opposed to HTMl? In reply to
http://evil.inetarena.com/php/DBI.php3

A site for all you Perl junkies needing to use PHP for SQL stuff.

Look how much more readable the PHP version of the regular expression is.Blush
Cheers,
Michael Bray

Last edited by:

Michael_Bray: Oct 31, 2001, 5:14 AM
Quote Reply
Re: [Michael_Bray] PHP v. Perl In reply to
I have to agree with you there. It's much easier just to write a HTML document and throw in a few extra PHP tags than it is to construct a Perl program.

I think that's why the major shift to PHP. People see it as being easier.

I blame it all on cheap domain names and cheap web hosting. The number of crap sites on the net have rocketed since the introduction of cheap hosting and cheap domains. Well, saying that, does anyone else remember the days when domain names were free?

Gone are the days of amateur sites being thrown together on Geocities, AOL and Ourworld/Sprynet.

More and more people without a clue what they're doing are getting access to PHP/MySQL and all these powerful tools for next to nothing - and in some cases for nothing.

Someone somewhere should devlelop a crafty perl program where you can not write a single line of perl code without reading the entire camel book.

Sigh.

- wil
Quote Reply
Re: [Wil] PHP v. Perl In reply to
Of course it's easier to have a html page with a few chunks of php code....that's why perl programmers are more talented Tongue
Quote Reply
Re: [RedRum] PHP v. Perl In reply to
I wouldn't go that far, Paul.

Maybe more ambitious, good looking, humourous, tall, dark, always got a nice blonde hanging off his back ....

Ugh. Gotta stop day dreaming.

Back to work ...

- wil
Quote Reply
Re: [Wil] PHP v. Perl In reply to
Quote:
Maybe more ambitious, good looking, humourous, tall, dark, always got a nice blonde hanging off his back ....

......enough about me...I don't often have blondes hanging off my back though...lol (maybe my arm)
Quote Reply
Re: [Wil] Why dymanic pages as opposed to HTMl? In reply to
In Reply To:
In fact, I'm sure that it's the most popular board on the net.

1. you meant the first locally installable software!
2. imho, simply no. google finds 1.5 Million phpBB boards, 1 million ikonboard installations, and a half a million UBB Forums.

it has been the most popular 'cause they where among the first, giving away a free board. and they "invented" the now standart "flat" view, the ubb codes, "["-markup-style.

and hey, look at this pic:

http://members.ikonboard.com/ibsearch.jpg

(beside, why not put on a img-ubb-tag? like the url, email, i tags..)

cu, Raphael.

Last edited by:

raphb: Nov 15, 2002, 4:58 AM
Quote Reply
Re: [Jagerman] Why dymanic pages as opposed to HTMl? In reply to
In Reply To:
I'd like to see a PHP cgi script (NOT mod_php) try to compete with a Perl CGI Tongue.

I'm assuming that PHP can even do cgi's though... Maybe it can't...

hum - didn't you miss the point? why wouldn't you use mod_php? nobody's runnin' php through CGI (even if it's possible.

greets, Raphael.
Quote Reply
Re: [raphb] Why dymanic pages as opposed to HTMl? In reply to
Wow, I thought that comment was long gone Wink!

My point was simply that comparing mod_php to Perl CGI is comparing apples to oranges. Many people see that mod_php is faster than Perl CGI (unless you get into long-running processes), and therefore mistakingly make the conclusion that PHP is faster than Perl. It isn't - it's actually considerably slower. So, if you want to compare actual language speed, you really need to put them on the same level - either both under CGI, or both compiled into the web server.

Would you think it fair if I compared CGI PHP with mod_perl?

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Michael_Bray] Why dymanic pages as opposed to HTMl? In reply to
Quote:
preg_replace('/foo/', 'bar', $foo);

I think you can leave "$foo = " out. Can't be bothered testing it, but I'm fairly sure that would work.

it doesn't :) every function returns a value (well, actually it doesn't have to), so if you don't do:

echo preg_replace('/foo/', 'bar', $foo);

or something with it the value gets returnet into /dev/null :)

ok, you could use:

preg_replace('/foo/', 'bar', &$foo);

wich would then modify the variable by reference. but DON't do this, as it's depreciated.

what about php & perl? perl is just plain ugly :) not readable.

what about the [] in the multiple select? the return value will be placed in the
Code:
value="valuename"
- so it will be just a variable. but to get multiple values in one object-name you've simply to use arrays..

it's more logic.

cu, Raphael.
Quote Reply
Re: [raphb] Why dymanic pages as opposed to HTMl? In reply to
Quote:
perl is just plain ugly :) not readable.

I guess it depends on what you are familiar with as I could say the same about php.
Quote Reply
Re: [Jagerman] Why dymanic pages as opposed to HTMl? In reply to
In Reply To:
Would you think it fair if I compared CGI PHP with mod_perl?

eh - no :) look here:

http://www.bagley.org/...out/bench/ackermann/

so what now? yes, perl is 20 - 50 % faster. but Perl's syntax is just PLAIN UGLY. you write it quite fast, but you can't read it after.

Code:
foreach($this->result as $key => $value) {

$result[] = $this->_stripform($value);

}

$this->result = $result

pretty cool isn't it? :) but use the benchmark site above - it give's the code used too.

cu, Raphael.
Quote Reply
Re: [raphb] Why dymanic pages as opposed to HTMl? In reply to
Can you explain what that code does? It isn't intuitive enough on its own to make sense of. What is "_stripform"? And what does $result[] = ... do? (I'm guessing it pushed onto the end of the array, but it certainly isn't intuitive). And why do you assign back to $this->results at the bottom? Is it not possible to change a value inside a loop in PHP?

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [raphb] Why dymanic pages as opposed to HTMl? In reply to
Which language is uglier is not going to go very far here, I think - but I will give you that Perl can be ugly. But, the fact that Perl can be ugly is a strengh, not a weakness. One of Perl's main tenants is that there is (almost) always more than one way to do something. PHP's philosophy is a little different - basically, it tells you what the way you should do something is.

Ultimately, I suppose the biggest difference between the two comes down to how creative and intriguing you want to be with your programming. With the different interfaces you can write in a module to do the same thing - via tie()ing, autoloading, prototyping, overloading, etc. you can come up with very "cool" ways of doing things in Perl that usually don't look ugly, but rather look kindof cool.

For example, consider the following:

my $response = GT::WWW->get('http://gossamer-threads.com');
print "Response status: " . int($response->status) . "\n";
print "Response string: " . $response->status . "\n";
print "Headers: " . $response->headers . "\n";
print "Content: $response\n";

Could I do something like that in PHP? It's doubtful. Most likely, I'd have to call something that returns an array, and extract the information from various predefined positions in the array. Personally, I prefer the above - it is simple to see what it does from just looking at it. In reference to your other post, will I be able to read it 5 minutes from now? Yes. You don't know Perl, yet you can see exactly what that does. On the other hand, I can't look at your PHP example and figure out what it does.

I could write the same code so that it looked like this:

my %response = GT::Fictional::WWW->get('http://gossamer-threads.com');
print "Response status: " . $response->{status} . "\n";
print "Response string: " . $response->{string} . "\n";
print "Headers: " . join("\n", map "$_: $response->{headers}->{$_}", keys %{$response->{headers}}) . "\n";
print "Content: $response->{content}\n";

That code could do exactly the same thing - but you'd be right in this case; that is a little ugly. Many people would probably be tempted to write it that way - or worse. My point is that just because some Perl code is ugly, doesn't mean that all Perl code is ugly.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] Why dymanic pages as opposed to HTMl? In reply to
In Reply To:
Can you explain what that code does? It isn't intuitive enough on its own to make sense of. What is "_stripform"? And what does $result[] = ... do? (I'm guessing it pushed onto the end of the array, but it certainly isn't intuitive). And why do you assign back to $this->results at the bottom? Is it not possible to change a value inside a loop in PHP?


oookay *lol*. _stripform is a function inside the actual class ($self) you wrote. would have been suggested by the (), i think. $result[] adds a value to a number-indexed array. i think it's pretty intuitive.

$result[2] = 1;

puts 1 to the result array wich you can access by the index nr 2, not giving a number will simply create one for you..

i assign back "$results = $this->results" at the bottom 'cause i'm just too silly ;)

foreach($this->result as $key => $value) {

$this->result[$key] = $this->_stripform($value);

}

would be correct.
Quote Reply
Re: [Jagerman] Why dymanic pages as opposed to HTMl? In reply to
Quote:
For example, consider the following:

my $response = GT::WWW->get('http://gossamer-threads.com');
print "Response status: " . int($response->status) . "\n";
print "Response string: " . $response->status . "\n";
print "Headers: " . $response->headers . "\n";
print "Content: $response\n";


Actually PHP does support classes, and the syntax in this case is practically the same. You just need to make sure you have the appropriate GT::WWW class written in PHP.

Or, without using a class in php...

$fp = fopen('http://www.yahoo.com/','r');
print_r(stream_get_meta_data($fp));
fpassthru($fp);
fclose($fp);

:)

Joe
--
Christianity.com Forums
Quote Reply
Re: [raphb] Why dymanic pages as opposed to HTMl? In reply to
Code:
foreach($this->result as $key => $value) {

$this->result[$key] = $this->_stripform($value);

}

There's nothing special about that. In perl it would be:

Code:
while (my ($key, $value) = each %{$this->result}) {

I'm not sure about your next bit as you seem to be treating "result" as a class method but you then treat it as an array. Oh well.

Either way I consider the perl version to be more readable (and I'm not just saying that) - I find words mixed in with code to be more confusing.

Btw, how would you go about modifying every element in an array in php?

Say for example, what would the code be to create an array with 100 elements set to "1" and then modify them all to "11"?

Last edited by:

Paul: Nov 15, 2002, 6:40 AM
Quote Reply
Re: [Paul] Why dymanic pages as opposed to HTMl? In reply to
hmm, pretty forum, handles things pretty much like you except :)

Code:
while (my ($key, $value) = each %{$this->result}) {

In Reply To:
I'm not sure about your next bit as you seem to be treating "result" as a class method but you then treat it as an array. Oh well.

uh - methods are allways called with "()".. i don't see what your "my" does. and what does your "%"? and what does your "{" do?

in my humble opinion this can't get be understood wrong after some thoughts:

Code:
foreach($this->result as $key => $value) {

$this->result[$key] = $this->_stripform($value);

}

foreach creates a loop, runs through the {} code for every line, and there are new variables called $key and $value.


In Reply To:
I find words mixed in with code to be more confusing.

hey, i found YOUR "my" confusing Cool

In Reply To:
What would the code be to create an array with 100 elements set to "1" and then modify them all to "11"?

Code:
for($a = 0; $a > 100; $a++) {

$array[] = 1;

}

foreach($array as $key => $value) {

$array[$key] = $value * 11; // or simply "= 11;"

}

and how would YOU do that? Laugh
Quote Reply
Re: [raphb] Why dymanic pages as opposed to HTMl? In reply to
Quote:
uh - methods are allways called with "()".

Not in perl they aren't ;)

$this->is_a_method
$this->is_a_method_too()

Quote:
i don't see what your "my" does.

It declares the listed variables to be lexically confined to the enclosing block which means it prevents conflicts and pollution and allows you to do things like this (not that it is advisable):

Code:
sub foo {

print header;

my $var = 1;
print $var;
{
my $var = 2;
print $var;
{
my $var = 3;
print $var;
}
print $var;
}
print $var;
}

That will print: 12321

Code:
and what does your "%"? and what does your "{" do?

That tells you that the return value from the "result" method is a reference to a hash and so %{} dereferences the hashref into a normal hash.

Code:
and how would YOU do that?

Well the php version is just laborious :)

I could show you 5 or more variations in perl but how about this (for shits and giggles):

Code:
my @array = map { $_+=10 } map { 1 } 1..100;

Tongue

Last edited by:

Paul: Nov 15, 2002, 7:12 AM
Quote Reply
Re: [Jagerman] Why dymanic pages as opposed to HTMl? In reply to
In Reply To:
PHP's philosophy is a little different - basically, it tells you what the way you should do something is.

yes. like 500 years before: there was no "right" way to write correctly. everyone wrote simply like he wanted to.. i hope you agree the model today with having one way to write "tomorrow" is better.


In Reply To:
For example, consider the following:

my $response = GT::WWW->get('http://gossamer-threads.com');
print "Response status: " . int($response->status) . "\n";
print "Response string: " . $response->status . "\n";
print "Headers: " . $response->headers . "\n";
print "Content: $response\n";

Could I do something like that in PHP? It's doubtful.

no, evern better Tongue

$snoopy = new Snoopy; // snoopy is a class..
$snoopy->fetch("http://raphb.ch/");

echo "headers: <pre>";
print_r($snoopy->headers);
echo "</pre>";
echo "status: " . $snoopy->status;
echo "content: " . $snoopy->results; // "." is concarnation..

and hey, if you don't want the headers, you could even do:

$fp = fopen("http://raphb.ch/", "r");
$content = file($fp); // loads the filepointer fp into array content
foreach($content as $value) {
echo $value;
}

In Reply To:
Yes. You don't know Perl, yet you can see exactly what that does. On the other hand, I can't look at your PHP example and figure out what it does.

i'd say the opposite Unsure


In Reply To:
I could write the same code so that it looked like this:
[.]
Many people would probably be tempted to write it that way - or worse. My point is that just because some Perl code is ugly, doesn't mean that all Perl code is ugly.

yes. but of course if you can't write ugly, you won't write ugly. there is NO reason to write ugly, never.

In Reply To:
But, the fact that Perl can be ugly is a strengh, not a weakness.
Basicly i think you should force the user to write in a good style. you should never support users wich write ugly code. i'm reading pretty much code the hole day. i don't think having various ways to solve something is pushing creativity. it rahter stops it, 'cause you've to hold more things in your mind. more code. more ways to solve something.. ok, this really may be discutable Crazy (even if i'd never agree..)

cu, Raphael.

Last edited by:

raphb: Nov 15, 2002, 7:27 AM
Quote Reply
Re: [raphb] Why dymanic pages as opposed to HTMl? In reply to
I love the irony Tongue

Quote:
Basicly i think you should force the user to write in a good style.

You totally mis-spell "basically" and then go on to use "hole" instead of "whole"

Sly
Quote Reply
Re: [Paul] Why dymanic pages as opposed to HTMl? In reply to
In Reply To:
Not in perl they aren't ;)

$this->is_a_method
$this->is_a_method_too()

uh bad :) hey you HAVE to agree that this MUST be wrong - allowing both ways to do it? we're able to simply differ a class variable and method by looking if there are parantheses, but you have to ..?

Code:
print $var;
{
// things here in
}

uh - that's ugly :) what does the "{" stand for? basically they are a block wich should either be repeated (loops) or called by name (functions, methods). having a more straight defined ways to do something allows different behavior on little code change.

In Reply To:
I could show you 5 or more variations in perl but how about this (for shits and giggles)..

so are you proud of? ;)

PHP has less language to learn, wich is then more readable, easyer to learn, and easyer to write, as you have to learn less.

Wink
Quote Reply
Re: [Paul] Why dymanic pages as opposed to HTMl? In reply to
In Reply To:
Quote:
Basicly i think you should force the user to write in a good style.

You totally mis-spell "basically" and then go on to use "hole" instead of "whole".

*lol*. yeah, let's write german or even french Cool
Quote Reply
Re: [raphb] Why dymanic pages as opposed to HTMl? In reply to
Quote:
easyer to learn, and easyer to write, as you have to learn less.

It sounds like you just need/want something easy....so yes, I'd recommend php for you Wink

Perl is for big boys.
Quote Reply
Re: [Paul] Why dymanic pages as opposed to HTMl? In reply to
In Reply To:
Perl is for big boys.

You're not beein' logical Smile

the more complicated the language, the more your script will be buggy, hard to write, hard to read. you'll not be able to do write the most complicated thing with the most complicated language.

with less and clearer, more logical rules you're able to do more sophisticated. Citing' Eric Raymond if he maybe has more weight in his writings (as you sayd, my english sucks..):

Quote:
This kind of thing is called metaclass hacking and is generally considered fearsomely esoteric--deep black magic. Most object-oriented languages don't support it at all; in those that do (Perl being one), it tends to be a complicated and fragile undertaking. I had been impressed by Python's low coefficient of friction so far, but here was a real test. How hard would I have to wrestle with the language to get it to do this? I knew from previous experience that the bout was likely to be painful, even assuming I won, but I dived into the book and read up on Python's metaclass facilities. The resulting function is shown in Listing 3, and the code that calls it is in Listing 4.

Listing 3: http://www.linuxjournal.com/...ue73&file=3882l3

Listing 4: http://www.linuxjournal.com/...ue73&file=3882l4

That doesn't look too bad for deep black magic, does it? Thirty-two lines, counting comments. Just from knowing what I've said about the class structure, the calling code is even readable. But the size of this code isn't the real shocker. Brace yourself: this code only took me about ninety minutes to write--and it worked correctly the first time I ran it.
Quote Reply
Re: [raphb] Why dymanic pages as opposed to HTMl? In reply to
I think this debate is futile. Whether perl or php is easier to read/write is all subjective and based on personal opinion so a definitive answer will never be reached.
> > > >