Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

new development: PHP or Perl

Posted on 2004-10-10
8
Medium Priority
?
289 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 450 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 300 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

927 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