LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Perl vs PHP (https://www.linuxquestions.org/questions/programming-9/perl-vs-php-125607/)

costasm 12-13-2003 07:10 PM

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

fr0zen 12-14-2003 03:23 AM

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.

costasm 12-14-2003 09:11 PM

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.

mbabuskov 12-15-2003 02:29 AM

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

Kovacs 12-15-2003 06:04 AM

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?

costasm 12-15-2003 08:02 AM

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

mbabuskov 12-16-2003 08:42 AM

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

CamelofCamelot 12-17-2003 06:07 PM

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.

mbabuskov 12-18-2003 03:13 AM

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"

costasm 12-18-2003 07:17 AM

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.

GaijinPunch 12-18-2003 07:53 PM

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. :)

mbabuskov 12-19-2003 03:58 AM

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.

costasm 12-19-2003 09:24 AM

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?

mbabuskov 12-22-2003 08:14 AM

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.

costasm 12-22-2003 02:40 PM

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


All times are GMT -5. The time now is 04:19 AM.