LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-13-2003, 07:10 PM   #1
costasm
Member
 
Registered: Dec 2002
Posts: 71

Rep: Reputation: 15
Perl vs PHP


I am in quandry.

I want to use PHP but I really don't like its philosophy of having to compile it with modules you are interested in. E.g. I want to use IMAP so I have to recompile. I have to even recompile Apache so it runs with it. Or if I need mysql. Recompile again (in version 5 anyway). Also, the Zend studio which seems nice, has its own PHP. Recompilign software everytime you need a module is kind of backwards because its error prone and time consuming.

The worst part is that there is no documentation or a consistens directory structure on how to recompile everything. And there are a million flags. I hate recompiles.

On the other hand, Perl allows you to load modules at runtime. The only beef I have with Perl is that it has a quirkier language than PHP. I know it has been cleaned up and getting better but still it allows for a weird and inconsistent syntax.

What do others think about this recompile problem of PHP. Should I go with Perl?

My apps are web based but I may do minimal client side scripts too.

Thanks
 
Old 12-14-2003, 03:23 AM   #2
fr0zen
Member
 
Registered: Nov 2003
Location: 127.0.0.1
Distribution: xubuntu
Posts: 217

Rep: Reputation: 30
Well. I'm not 100% positive on this, but I believe both PHP and Apache support dynamic module loading. From your description, you sound like you are compiling all your modules statically and/or don't have DSO (dynamic shared objects) enabled.

But to answer your question: I use PHP exclusively.
 
Old 12-14-2003, 09:11 PM   #3
costasm
Member
 
Registered: Dec 2002
Posts: 71

Original Poster
Rep: Reputation: 15
Do you compile the modules or do you load dynamically. I read a brief about this DSO just today. Do all the modules support this feature?

Thanks.
 
Old 12-15-2003, 02:29 AM   #4
mbabuskov
Member
 
Registered: Nov 2003
Location: Subotica
Distribution: Slackware, Knoppix, Mandriva
Posts: 42

Rep: Reputation: 15
Re: Perl vs PHP

Quote:
Originally posted by costasm
I want to use PHP but I really don't like its philosophy of having to compile it with modules you are interested in. E.g. I want to use IMAP so I have to recompile.
You don't have to recompile at all.
Take a look at dl() function in PHP manual.

I have switched from Perl to PHP 3 years ago, and I don't regret it at all. In fact, I'm glad I did it.


Milan Babuskov
http://njam.sourceforge.net
 
Old 12-15-2003, 06:04 AM   #5
Kovacs
Member
 
Registered: Jul 2003
Distribution: FreeBSD 8.2 RELEASE
Posts: 607

Rep: Reputation: 32
I've got a couple of related questions if no one minds...

I am currently working on a script I've written in PHP that generates vast amounts of random text, and another which redirect surfers to different pages according to their IP. I wrote them in PHP because it's the only language I know, and I execute them with mod_php and apache (the first one locally and the redirect is on my webserver). I'm interested in the differences in speed and the amount of data that can be handled between using Perl and PHP, although at the moment I know very little about Perl except for having done some very basic tutorials.

I was reading on another forum earlier and someone was saying something like, "All my scripts are in perl because PHP is just too slow, even running from the binary." I assume that "the binary" would mean using PHP from the command line? Is that faster than using mod_php? And for the server based redirection script, would using mod_perl be faster than mod_php?
 
Old 12-15-2003, 08:02 AM   #6
costasm
Member
 
Registered: Dec 2002
Posts: 71

Original Poster
Rep: Reputation: 15
Re: Re: Perl vs PHP

Quote:
Originally posted by mbabuskov
You don't have to recompile at all.
Take a look at dl() function in PHP manual.

I have switched from Perl to PHP 3 years ago, and I don't regret it at all. In fact, I'm glad I did it.


Milan Babuskov
http://njam.sourceforge.net
So, if I want to use IMAP or mysql in PHP 5 (I understand that the module won'ty be compiled into it by default), then I can use dl()?

Costas
 
Old 12-16-2003, 08:42 AM   #7
mbabuskov
Member
 
Registered: Nov 2003
Location: Subotica
Distribution: Slackware, Knoppix, Mandriva
Posts: 42

Rep: Reputation: 15
Re: Re: Re: Perl vs PHP

Quote:
Originally posted by costasm
So, if I want to use IMAP or mysql in PHP 5 (I understand that the module won'ty be compiled into it by default), then I can use dl()?

Costas
Exactly.

However, you will have to take php source and compile modules you need. The modules are plain .so files. Then just install (copy) these modules to the directory specified in php.ini file, and you're done.

HTH
 
Old 12-17-2003, 06:07 PM   #8
CamelofCamelot
Member
 
Registered: Aug 2003
Distribution: Slackware, ClusterKnoppix, Gentoo
Posts: 85

Rep: Reputation: 15
Perl is the ruler of the scripting language universe.

Perl>Java-tie-PHP>Python>Ruby>everything else>VBS

I realize that Java is compiled, but it's still just in time compiled or interpreted, so there.
 
Old 12-18-2003, 03:13 AM   #9
mbabuskov
Member
 
Registered: Nov 2003
Location: Subotica
Distribution: Slackware, Knoppix, Mandriva
Posts: 42

Rep: Reputation: 15
Quote:
Originally posted by CamelofCamelot
Perl is the ruler of the scripting language universe.

Perl>Java-tie-PHP>Python>Ruby>everything else>VBS

I realize that Java is compiled, but it's still just in time compiled or interpreted, so there.
How about giving some agruments?

I know that Perl has much more features and stuff, but it isn't best for all uses. For example, I would never use Perl again for web apps. PHP is just easier and adjusted to that. And what about GUI apps. I would never use PHP for it, but Java and Python beat Perl on that field.

I'm trying to make the point that all depends on the task at hand. Use the right tool to for the situation. Fly with airplane, drive the car on road. Don't drive the airplane on the road just because it can do that...

One more thing: the best tool is always the one you know to use the best
Since I don't know Ruby, everything is better than it for me... but who knows, if I was to learn it I might change my opinion. So, if you really have a lot of experience with Perl, Java, PHP, Python, Ruby ... then give some arguments, why do you think Perl is "the ruler"
 
Old 12-18-2003, 07:17 AM   #10
costasm
Member
 
Registered: Dec 2002
Posts: 71

Original Poster
Rep: Reputation: 15
My biggest problem with PHP is that you have to keep recompiling it for this option and for that option.

E.g. I am using PHP 4.3 that came with Zend Studio. I tried to use the socket functions. It says no such functions. Ok, so now I have to recompile with some --enable all of PHP instead of either a simple INI file change or even better at runtime to just load it (like Perl and Python do) .

This is the biggest downside of PHP. Its silly to have to recompile modules or put them in INI files. It should be runtime loads and thats it.
 
Old 12-18-2003, 07:53 PM   #11
GaijinPunch
Member
 
Registered: Aug 2003
Location: Tokyo, Japan
Distribution: Gentoo
Posts: 130

Rep: Reputation: 22
Here's another issue to look at. Will you ever need a scripting language for anything else in your life? If you do, Perl will most likely be the one you need. I learned Perl for work-related tasks. After that, just learning the CGI and DBI modules were the matter of a few tutorials, and I could make a pretty nice dynamic website.

I like Perl.
 
Old 12-19-2003, 03:58 AM   #12
mbabuskov
Member
 
Registered: Nov 2003
Location: Subotica
Distribution: Slackware, Knoppix, Mandriva
Posts: 42

Rep: Reputation: 15
Quote:
Originally posted by costasm
My biggest problem with PHP is that you have to keep recompiling it for this option and for that option.

E.g. I am using PHP 4.3 that came with Zend Studio. I tried to use the socket functions. It says no such functions. Ok, so now I have to recompile with some --enable all of PHP instead of either a simple INI file change or even better at runtime to just load it (like Perl and Python do) .

This is the biggest downside of PHP. Its silly to have to recompile modules or put them in INI files. It should be runtime loads and thats it.
Not really, read the posts above.

What I do: get php sources, and ./configure --with-everything-possible
I get all modules as .so files and just install them.

At runtime I just call those I need with dl() funcition. Just like in "import" in Python.
 
Old 12-19-2003, 09:24 AM   #13
costasm
Member
 
Registered: Dec 2002
Posts: 71

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by mbabuskov
Not really, read the posts above.

What I do: get php sources, and ./configure --with-everything-possible
I get all modules as .so files and just install them.

At runtime I just call those I need with dl() funcition. Just like in "import" in Python.
I didn't know you could do the recompile with everything possible. But if you are recompiling with everything, why is there a need to use dl() function?

Shouldnt' dl() function work with say a new module that was not part of the original compile?
 
Old 12-22-2003, 08:14 AM   #14
mbabuskov
Member
 
Registered: Nov 2003
Location: Subotica
Distribution: Slackware, Knoppix, Mandriva
Posts: 42

Rep: Reputation: 15
Quote:
Originally posted by costasm
I didn't know you could do the recompile with everything possible. But if you are recompiling with everything, why is there a need to use dl() function?
Dl() is needed since the php executable doesn't have module functions compiled in, they are rather .so files.

Quote:
Shouldnt' dl() function work with say a new module that was not part of the original compile? [/B]
Dl() works with any module that is compiled as shared, i.e. is outside of main php executable.


I just take sources and compile all modules as shared! That way I've got all modules as .so files. I don't touch the php executable, I just install these modules, and call them with dl() as needed.
 
Old 12-22-2003, 02:40 PM   #15
costasm
Member
 
Registered: Dec 2002
Posts: 71

Original Poster
Rep: Reputation: 15
Do you ever have problems with compiling this stuff?

Here is a typical problem thats driving me crazy. I need to recompile IMAP (for email) because the pre installed version doesn't work. It seems to compile (if you specify no OpenSSL) but then it creates a bunch of .o files. How do I make something into the single .so from all these .o files? Is there some utility that does that?

Thanks
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and Perl ---Help please ridge321 Linux - Newbie 1 02-10-2005 08:01 PM
Problem with perl module for w3c validator to work on my local Apache+PHP+perl instal tbamt Linux - Software 0 12-16-2004 05:37 PM
PHP/PERL Solution ganninu Programming 6 09-12-2003 07:40 AM
chrooting apache v2 (php, ssl, perl support) ; perl configuration markus1982 Linux - Security 3 01-26-2003 06:15 PM
perl/php help Syncrm Programming 1 10-22-2001 05:45 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration