Page 1 of 1

PHP vs. Perl - Project Advice?

Posted: Fri Sep 23, 2005 2:52 pm
by Envex
Hey guys,

Ok, could use a little advice here before I end up in a situation similar to when I decided to make the "smart" move, and switch from mySQL to PostgreSQL. That little move managed to <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> off a whole lot of customers, and create me a large headache, so I would rather not repeat that. :)

I'm an excellent Perl developer, and am just working on a new project that will become our new back-bone, as the old one was developed a couple years ago. I'm just starting to use PHP, and decided to use PHP because:

1.) The new project is going to allow other developers to easily develop their own modules and applications, and there's a whole lot more PHP developers out there than Perl.

2.) Regardless, we have to provide service for our software, and it seems that qualified Perl developers are becoming scarce these days. PHP developers on the other hand seem to be a dime a dozen.

3.) This is what all customers want, and I've constantly heard that PHP is much better than Perl.

Now that I'm starting to get into the middle of the development, I'm questioning myself as to whether PHP was the right choice, or if I should just stick with Perl. I can develop in Perl 10 times quicker than PHP, but I'm sure that's just a matter of getting used to PHP.

I'm moreless worried about the resources and flexibility. What I'm developing is quite large, and at the end, I'll have a good 100,000+ lines of code, plus whatever others decide to develop. Of course, not all code will to be loaded for each process, as the software only loads what's required each time, but you get my point. Please know that there there isn't any HTML code anywhere within the PHP code. Instead, all the HTML is stored in outside templates, the mySQL database, etc. There's only maybe 3 or 4 different functions that actually return output to the web browser.

I've always heard that PHP is much quicker than Perl, but now that I'm getting into it and have a fair bit developed, it seems to be slower. The Perl programs I have which are complete and much larger, seem to be run noticeably faster then the PHP program which isn't even near completion yet.

I'm just wondering, with a program of this size, am I walking into a trap by using PHP? Once it's done and released, is there all of a sudden going to be a huge headache because the software is running slow, and taking up too many resources? Am I better off to just stick with Perl? Mainly, I'm just wondering about the server usage between the two for large programs.

I could be wrong, but it seems as though PHP is meant for smaller and more straight forward system. And PHP seems to be really good for easy user-interaction, but that part simply doesn't matter in my case. Regardless if it's PHP or Perl, the software is still going to function the exact same way. Again, could be wrong, but Perl seems like a more stable and flexible language, that is better suited for larger systems.

I know this is a pretty vague post, so please let me know if you have any questions.

Any advice would be greatly appreciated.

Matt

Posted: Fri Sep 23, 2005 3:29 pm
by feyd
Just so you know where my base comes from, I've developed in Perl, C/C++, Java, JSP, C#, and PHP (just for web stuffs). Now, it's been a few years since I've last used Perl so I am probably off base a bit, but I've found PHP to be far easier to get a grasp of and work with. Now, there are some parts that can be bottle necks in PHP particularly with selections of certain functions (ereg_* vs. preg_* comes to mind.) Since the end interface will be the same between them, I'd suggest continuing work in PHP while keeping the Perl side up to speed on new things. Now, one thing you may hit is that PHP's execution can be greatly affected by small tweaks to the configuration, functions used, extensions loaded, optimization or lack of it in your code, etc.

If you want to squeeze the most out of PHP, I'd suggest creating an extension to the language. It sounds as if the application will, internally, not change much if at all after completion, especially with the plugin system you hinted at, so why not compile the entire thing? You may also want to look at making bytecode versions of scripts, as that will help php to load the files faster because parsing has already been done on them.

I will definitely say php is very flexible and powerful. If you do have control over the built on your server, I'd suggest compiling out functionality your system (and users) don't or won't need; learn about tweaking the ini settings to speed up things; etc..

As far as resources go, you may want to use shared memory and streaming systems. Execution time should speed up considerably if php doesn't have to recreate all these objects and things every time a page is accessed.. I have yet to really hit a memory usage problem, outside of allocating a large image thus blowing out the memory limit settings.

Posted: Fri Sep 23, 2005 6:55 pm
by Christopher
I have done something similar to what you are doing and it is not easy. I created a glue code on both sides so that both the Perl and PHP shared session data, databases and could generate URLs back and forth. I then migrated in pieces. It was not very fun.

The main problem you will have is that you think in Perl (I think there might be a chromosome for that ;)). PHP is definitely for the C/C++ crowd so that will be your main problem and probably be the cause of your current slow code. I'd recommend reading the advanced PHP forums and blogs here and elsewhere.

Both languages are very good. PHP is just very web focused so you will find more stuff for that, whereas Perl is broader in its usage.

Finally, could you elaborate a little on your statements:

"it seems as though PHP is meant for smaller and more straight forward system. "

"And PHP seems to be really good for easy user-interaction, but that part simply doesn't matter in my case"

Posted: Sat Sep 24, 2005 9:39 am
by Buddha443556
Perl and PHP definitely have their uses.

I once update PHP and forget the Zend Optimizer, PHP runs atleast 10 times slower without it. Point is it could be something that simple. Although an opcode cache would be better since you seem to have server access?

talks.php.net