Forum Moderators: phranque

Message Too Old, No Replies

Perl or PHP?

To Use with MySQL

         

Jane_Doe

3:25 pm on Sep 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I want to learn how to set up my own MySQl database to make dynamic pages for one of my websites. The local bookstores have books on Perl/MySQL and PHP/SQL.

Any suggestions on which one would be best to start out with? Any specific books you would recommend?

Thanks in advance for any info.

Nick_W

3:29 pm on Sep 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Bigger online support for PHP - More docs too though the Perl module is solid I beleive.

PHP/MySQL ----> just do a search, tons and tons of info out there, they were practcally made for each other ;)

Nick

txbakers

4:27 pm on Sep 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I use ASP with mySQL on a Windows server and it works very well.

You could also use JSP. The database is a distinct entity from the scripting language.

httpwebwitch

7:16 pm on Sep 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Of all the server languages out there...
I've worked on projects in PHP, ASP, JSP, Frontpage (yuk!), Perl CGIs, and ColdFusion.

Of them all, I like PHP best.

The syntax of PHP is the most similar to Javascript (EMCAscript), so if you're a browser-manipulating JS jockey or even a Flash Actionscripting whiz, you're going to pick up PHP in no time flat.

And since you're using MySQL, you'll find the built-in MySQL functions in PHP will make your work much easier.

The Web is filled with open-source PHP scripts that do everything except wash your shorts.

and PHP is open source. Free. No $$.

Need I say more?

Nick_W

7:19 pm on Sep 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>everything except wash your shorts

Actually, I've got a script written in PHP that does that. I have it running from the command line as a cron job ;)

Nick

Jane_Doe

7:34 pm on Sep 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Okay, thanks for all of the advice and the witty remarks. :-)

My husband went to buy a PHP-MySQL book last week and found all they had was Perl-MySQL, so he was wondering if Perl was more popular.

Then I went to a different bookstore over the weekend and all they carried was PHP-MySQL books and no Perl-MySQL books. So we thought we'd turn to all you the sages at WebmasterWorld to see what was more popular.

Thanks again for the advice!

moltar

8:00 pm on Sep 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I choose Perl.

claus

8:55 pm on Sep 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can do the same things with both languages, php is definitely easier to learn.

I'm a Perl addict myself and i've got a script that washes the shorts of the entire block, brews coffee on the space shuttle and makes sure the rain is wet. No cron needed, it runs off a wristwatch as it's just one line of code.

Although this might sound impressive i have recently - last week actually - bought a few books on php and mysql myself. I can do things in perl (one never even "knows" it, it seems), but lately i have found that i need mysql. I don't know any mysql in advance, so i basically had the choice between learning a whole new language (PHP) or learning a new side of Perl to query and manage databases. I chose PHP as i do think it will be easier for me to learn mysql and php (from scratch) than mysql and some more perl.

>> popular

Php is definitely more popular in some circles than Perl. Otoh, Perl is more powerful and flexible. Don't let that influence your decision though. Perl is a pain to learn, as there's so many ways of doing the same things and that's just not what you need when you want to learn something new. Plus if you plan on working with others, go for PHP - in Perl your code tends to become personal and hard to read for others (oh, and for yourself too if it's been some time since you wrote it).

/claus

Jane_Doe

10:22 pm on Sep 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Okay, thanks for the additional input, Claus and Moltar. We just need something simple and don't want to spend a lot of time on a learning curve, so it seems like for what we need PHP might work out the best.

moltar

10:35 pm on Sep 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



lol! that is so true, claus! :)

MonkeeSage

12:15 am on Sep 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is the funniest progressive commentary I think I've ever read:

"The Web is filled with open-source PHP scripts that do everything except wash your shorts." --httpwebwitch

"Actually, I've got a script written in PHP that does that. I have it running from the command line as a cron job ;)" -- Nick_W

"I'm a Perl addict myself and i've got a script that washes the shorts of the entire block, brews coffee on the space shuttle and makes sure the rain is wet. No cron needed, it runs off a wristwatch as it's just one line of code." -- claus

ROFLWTIME! ;..D

Jordan

Netizen

10:27 am on Sep 4, 2003 (gmt 0)

10+ Year Member



How I use these are:

* PHP/MySQL for web
* perl/MySQL for offline processing

PHP was designed for use as a web scripting language and as such is easier to get into quickly.

perl is very good for processing log files and producing summary data.

Both have good interfaces to MySQL.

Just my $0.02 worth

BlueSky

10:48 am on Sep 4, 2003 (gmt 0)

10+ Year Member



I also recommend you go with PHP. As others have said already, it's far easier to learn than Perl. The error messages are much less encryptic. Perl use to be very popular but was overtaken by PHP which is now the preferred language for webpage development. Perl definitely has its strengths though, but it's a real bear for a newbie to learn.

ShawnR

11:14 am on Sep 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I need a shorts washing script. Anyone know where I can find one? Anyone care to post one that they have handy?

To add my vote: Go for php. I love perl, but I'd suggest php to ease the learning curve and get up to speed quickly. I don't think it is true taht perl has dwindled in popularity and php has taken over; I think Perl is as popular as it ever was for certain sorts of developments. e.g. For general development such as integration of legacy systems (not saying it is not powerful for web development). But for integration with a database using opensource, the defacto standard combination competing with Microsoft ASP is LAMP (Linux, Apache, MySQL, Php).

BlueSky

12:18 pm on Sep 4, 2003 (gmt 0)

10+ Year Member



So, you think php has not overtaken perl in popularity for webpage development? That is the sentence you took objection to right?

Very interesting, because that's an area where php performs better than perl. It's takes less "overhead", runs faster, and can handle more simulatenous users. Perl has its strengths but in other areas.

karmov

2:19 pm on Sep 4, 2003 (gmt 0)

10+ Year Member



PHP is basically the right tool for the right job when it comes to MySQL and the web. Perl is more of a swiss army knife from hell.

I like both. But I tend to keep my web development in PHP and server scripts in Perl or shell.

Netizen

3:24 pm on Sep 4, 2003 (gmt 0)

10+ Year Member



...a swiss army knife that has 10 different attachments that all open a can but in subtly different ways

Jane_Doe

4:33 pm on Sep 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



> Perl is more of a swiss army knife from hell.

LOL. That conveys a pretty clear picture. :-)

I still remember having have bad dreams about registers and branch instructions from my college assembler class assignments not working right. So these days I'm interested in languages that are not excessively complex to learn.

claus

9:02 pm on Sep 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



LAMPPP? (*)

>> can handle more simulatenous users

Nope. Perl is superior, no doubt at all, it's just not as easy. And PHP can definitely handle more simultaneous programmers, at least a lot easier ;)

/claus


(*) ..and python ;)

ShawnR

11:25 am on Sep 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So, you think php has not overtaken perl in popularity for webpage development

No, what I wrote was it has not overtaken perl for general integration type development, not web.

Very interesting, because that's an area where php performs better than perl. It's takes less "overhead", runs faster, and can handle more simulatenous users

I don't believe that any of those points are true. The major advantage of php is ease of learning. In any of the technical aspects such as execution speed, overhead, simultaneous users perl wins. Having said that, both are making good head-way. The Zend engine for php is doing great things to the performance of Php, and on the other hand some of what is going into perl 6 will make perl even faster and more efficient

karmov

12:57 pm on Sep 5, 2003 (gmt 0)

10+ Year Member



As it stands PHP is faster than Perl over the web in most cases. Most cases being that people are running Perl through CGI and people using PHP are generally not. Makes a HUGE scalability difference. Can't speak for future developments of Perl or people running PHP through CGI, but as far as what the masses are doing, PHP is faster and FAR more scalable then Perl.

ShawnR

1:10 pm on Sep 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd say it again, but Andreas says it better:

[webmasterworld.com...]

karmov

1:38 pm on Sep 5, 2003 (gmt 0)

10+ Year Member



Andreas makes a very well expressed point, however it has nothing to do with what I posted.

I pointed out that most people are using Perl through CGI where most people who use PHP are not. That's why PHP is generally accepted as being faster. Please re-read my post for a better understanding of what I said.

ShawnR

2:09 pm on Sep 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, so educate us... What's so good about mod_perl

karmov

6:00 pm on Sep 5, 2003 (gmt 0)

10+ Year Member



Nothing... That's why I use PHP.

Filipe

9:56 pm on Sep 5, 2003 (gmt 0)

10+ Year Member



::groan::

Let me be a (but not *the*) voice of reason:

In the end, it comes down to preference. I prefer PHP, but Perl is actually not too different. There are differences - but knowing PHP you should be able to read most Perl code and vice-versa -- or at least get an inkling about what's going on.

People will go on for days about performance differences. It will be a minute difference for most applications. Just rest assured that PHP and Perl (w/ MySQL or Postgres) on a Unix/Linux/Sun server will run faster than ASP/ASP.NET on a Microsoft server.

I recommend PHP for beginners. Perl is handy to know, and if you choose to administer your own server, or have to doll up scripts you grab off the Web, it's practically a must. You can survive without it.

ShawnR

10:16 pm on Sep 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"...Nothing... That's why I use PHP...."

Sorry for being cryptic. What I meant was: You write as though you agree that the speed of perl is at least equiv to php when run as a webserver module (or stand-alone), but not when run as cgi. So please educate us, what are the differences?

claus

9:54 am on Sep 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To properly compare speed or any other feature you have to write two programs that are so identical that they do exactly the same things, or are as close to each other in function and scope as possible. Then, they have to run in an identical software environment (eg. both using the same build of the Apache web server on the same build of the same OS) and they have to run off identical hardware. Last, you have to stress them both using the exact same amount of load and the same distribution of that load over an identical timeframe.

Before all that, though, the test setup will have to be working in such a way that it measures what you are intending to measure, and nothing else. So, there's two sides to this (as to all research): Measuring accurately, and measuring the right thing.

Calling perl off a cgi and not calling php off a cgi is comparing two things that are not equal. You will want to device a method for measurement in stead that does not depend on the way the program is called, but on the progam itself. If this is not feasible for some reason you cannot compare directly, in stead you have to make indirect measurement.

Here, you can eg. compare the amount of code-lines required to perform same tasks, or the amount of running processes and the memory allocation on the server during program execution.

I have just recently gone from being php-ignorant to being php-newbie, so of course i do not know phps abilities in these areas but i know that advanced perl code can do a very good job on all. Nevertheless, if php should turn out to have limited possibilities here, you'll have to write a perl program that is just as limited to compare properly.

My claim, in stating that Perl was definitely faster, was not a direct comparison either, i have to admit that. What i should have said was, that whatever application one chooses to build in php and however it's built, there will be a way to build it in perl that will be more efficient. I firmly believe that Perl simply has more methods for doing all kinds of (and more) things than php and that alone tells me that Perl will continue where php stops.

Most of the good people in here will never-ever find themselves in a situation where it's really necessary to choose perl in stead of php. But it might be so the other way round, as when working in teams with others, where php definitely has advantages (more structured and hence more readable code, cvs, and so on).

/claus