Solved

new development: PHP or Perl

Posted on 2004-10-10
8
279 Views
Last Modified: 2010-04-06
Hello Experts,

I am starting a new web development and the question is what to choose - PHP or Perl? The site will contain 50+ pages with HTML templates, database - PostgreSQL, webserver - Apache, operating system - Linux. I am curious what is best choice considering time for development, performance with few thousands users simultaneously, support, etc.
0
Comment
Question by:Ivanov_G
8 Comments
 
LVL 5

Expert Comment

by:php-webdesign
ID: 12274391
Well... i think both languages have their advantages and disadvantages. About the 1000 users using it simaltaniously, the preformance of you application will still be dependent on the way YOU will write your application.

If you really want to be sure read the following article:

http://www.thesitewizard.com/archive/phpvscgi.shtml
0
 
LVL 5

Accepted Solution

by:
php-webdesign earned 150 total points
ID: 12274395
and:

http://php.weblogs.com/php_versus_perl
http://perl.about.com/library/weekly/aa040500a.htm

[quote]
The biggest advantage of PHP over Perl is that PHP was designed for scripting for the web where Perl was designed to do a lot more and can because of this get very complicated. The flexibility / complexity of Perl makes it easier to write code that another author / coder has a hard time reading. PHP has a less confusing and stricter format without losing flexibility. PHP is easier to integrate into existing HTML than Perl. PHP has pretty much all the 'good' functionality of Perl: constructs, syntax and so on, without making it as complicated as Perl can be. Perl is a very tried and true language, it's been around since the late eighties, but PHP is maturing very quickly.
[/quote]
0
 
LVL 2

Expert Comment

by:pmosinskis
ID: 12279827
PHP for sure. Integrates with the web environment more easily.
Also tops in terms of performance.

--pete
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 12

Author Comment

by:Ivanov_G
ID: 12295872
I made some test 5 time executing 10 mln loops:

  PHP : for ($i=0; $i<10000000; $i++)
          {
            $a = 1;
          }

  Perl : for (my $i=0; $i<10000000; $i++)
          {
            my $a = 1;
          }

Perl
  3.914818 s
  3.574317 s
  3.604372 s
  3.754552 s
  3.584347 s

Php
  5.13295507431 s
  5.14524912834 s
  5.19279384613 s
  5.30360507965 s
  5.20312786102 s

It seems that Perl is faster...
0
 
LVL 18

Expert Comment

by:arantius
ID: 12314081
That's a relatively poor test, it concentrates on one tiny thing (assigning value to a variable).  You were also probably running scripts (at least perl) from the command line rather than web server environment.

I would say PHP hands down.  Technically Perl can be a bit faster, but coding technique has significantly more impact than programming language.  Development time, though, will be significantly lower with PHP, as it is designed for the task.  PHP does web pages, and well.

If performance is an issue, there are free and commercial optimizers that claim (and show benchmarks) for 10 or more times speed increase.
0
 
LVL 12

Author Comment

by:Ivanov_G
ID: 12332221
I ran the tests from a web page... It shows that PHP is slower ... I don't know why. The top issue here is the performance...
0
 
LVL 2

Assisted Solution

by:Adesso21
Adesso21 earned 100 total points
ID: 12345717
PHP might be a bit slower.. but may a suggest something that you should rather be looking at.. MySQL instead of PostgreSQL

In due time you will have a rather large DB structure and if you choose rigth now.. that will not become a problem later..

If you want to have a test .. try this .. PHP script and see if you can make your server crash..

Just make a DB with one table MDtable that has an Auto incrament ID and a varchar(255) field

Then see if you can do the same in perl.. in essance this is the diffrence between PHP and Perl.. PHP is much faster to develop  and easyer to understand..

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Nail the server</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
      DIV {
            border : 1px solid black;
            width : 800px;
      }

</style>
</head>
<body>
Attempting to crash the server with too many records.. <br>

<?
set_time_limit(8000000000);
function open_db() {
        $db = "nail";
            $dbuser = "{username}";
             $dbpass = "{pass}";
            $dbhost = "{host}";
      if (!isset($link)) {
            $_SESSION['link'] = mysql_connect ($dbhost,$dbuser,$dbpass) or die ("Error: Could not connect.");
            mysql_select_db ($db) or die (print_r($_SESSION)."Error: Could not select database: $db, $dbhost, $dbuser, $dbpass");
      }
}

function close_db() {
      if (isset($link)) {
            mysql_close($link);
      }
}

function timenow() {
      $today = getdate();
      $hours = $today['hours'];
      $minutes = $today['minutes'];
      $seconds = $today['seconds'];
      
      $newtime = $hours.":".$minutes.":".$seconds;
      return $newtime;
}
?>
<div>
<?
$startTime = timenow();
for($i=0; $i < 1000000; $i++) {
      print "+ \n";
      for($j=0; $j < 1000000; $j++) {
            $MDstr = md5(timenow());
            open_db();
                  $Qinsert = "INSERT INTO MDtable VALUES(NULL,'$MDstr');";
                  mysql_query ($Qinsert) or die("$Qinsert \n\n");
            close_db();
            print ". ";
      }
      print " ";
      flush;
}
?>
</div>
<?
$endTime = timenow();
print "<br><br><strong>started</strong> $startTime";
print "<br><br>Added <strong>".$i*$j."</strong> records";
print "<br><br><strong>ended</strong> $endTime";
?>
</body>
</html>

0
 
LVL 12

Author Comment

by:Ivanov_G
ID: 12345837
Adesso21, I agree that PHP will have less development time, but what I want is top performance. Since Perl seems faster, I will choose it...

About the DB - MySQL vs. PostgreSQL - there are a lot of articles on this issue. Postgres offer more functional SQL language with sequences, stored procedures, triggers, etc. The new versions of PostgreSQL are not so slow... In fact the performance is almost the same as MySQL transactional tables.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question