LinuxQuestions.org
Visit Jeremy's Blog.
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 10-27-2006, 07:36 AM   #16
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 52

I meant the runtime execution not the development time
 
Old 10-27-2006, 12:03 PM   #17
introuble
Member
 
Registered: Apr 2004
Distribution: Debian -unstable
Posts: 700

Rep: Reputation: 31
Anyway, to save you the time of checking out other threads on this forum and what not others, I'll make a long story short:

Python > Perl.


[Joking!.. well.. not to say it's not.]
 
Old 10-27-2006, 01:29 PM   #18
krizzz
Member
 
Registered: Oct 2004
Location: NY
Distribution: Slackware
Posts: 200

Rep: Reputation: 30
Definitely Perl.
First of all - much faster.
You can prove it yourself by writing some classic test and comparing the results. You can also find comparisons in the Internet.
 
Old 10-27-2006, 07:06 PM   #19
slantoflight
Member
 
Registered: Aug 2005
Distribution: Smoothwall
Posts: 283
Blog Entries: 3

Rep: Reputation: 35
Quote:
Originally Posted by krizzz
Definitely Perl.
First of all - much faster.
You can prove it yourself by writing some classic test and comparing the results. You can also find comparisons in the Internet.
So I found this
http://shootout.alioth.debian.org/gp4/python.php

These examples are scientific in nature, and come the closest to being 'practical' benchmarks.

And it really doesn't seem to support you're argument, "much faster".

Outside of a few suspicpious spikes, they really seem comparable

Removing the two largest deviations

n-body test(which neither languages did a particularly good job on).
fasta(python executes 1.5 fasters but uses 10.9x the memory)

Python has 19 instances of being 'x' faster whereas perl has 19 instances.

averaging the speeds on x faster.
Python was 1.8 whereas perl was 1.873684211.

The only 2 benchmarks that place perl dramatically ahead of python
where the same benchmarks that proved either language was impractical if speed was the primary concern.

Besides if you chose either, python or perl, chances are the speed of execution is not on the top of your concern list.

If it is though, and you really want the fastest interpreter, you must ask yourself this question.

Is perl's minute speed advantage worth dealing with its idosyncrasies? Are you going to like the way it looks, after realising a few months later you need to make some changes.
 
Old 10-29-2006, 07:29 PM   #20
krizzz
Member
 
Registered: Oct 2004
Location: NY
Distribution: Slackware
Posts: 200

Rep: Reputation: 30
How about this benchmark http://furryland.org/~mikec/bench/
 
Old 10-30-2006, 03:37 AM   #21
slantoflight
Member
 
Registered: Aug 2005
Distribution: Smoothwall
Posts: 283
Blog Entries: 3

Rep: Reputation: 35
Quote:
Originally Posted by krizzz
How about this benchmark http://furryland.org/~mikec/bench/

This page is outdated, ran by one person, no longer maintained and some of the results are clearly erroneous.

for example the console test is waaaaaaaaaay off.

simple verification(i'm assuming this is what the author did as well)

time perl console.pl >> /dev/null
real 0m1.580s
time python console.pl >>/dev/null
real 0m3.295s



this test shows, atleast on my computer, perl leading by a whopping two seconds.

I got similar results with i/o
real 0m1.865s perl
real 0m3.461s python


The "speed" test shows the interpreters being near identical in speed on my computer.

In the self-deprecating intro paragraph, the author even admits these are flawed benchmarks.

Plus this all without compiling the python script to intermediate code and using the pysco module.

You've been misinformed about perl, I believe. It does not have any significant speed advantages over python.
 
Old 10-30-2006, 05:56 AM   #22
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
For the console test,
if i change the python code to
Code:
x = 0
for i in xrange(1000000):
        x = x + i
and the perl one to

Code:
$x=0;
for $i (0 .. 1000000-1) {
        $x=$x + $i;
}
the speed of execution is almost comparable.

output
Code:
bash-2.03$ time perl console.pl >>/dev/null

real    0m0.761s
user    0m0.760s
sys     0m0.020s
bash-2.03$ time python -S console.py >>/dev/null

real    0m1.280s
user    0m1.240s
sys     0m0.030s
I suspect its the different implementaion of print() function.
what are your views?
 
Old 10-30-2006, 10:43 AM   #23
soggycornflake
Member
 
Registered: May 2006
Location: England
Distribution: Slackware 10.2, Slamd64
Posts: 249

Rep: Reputation: 31
Quote:
Definitely Perl.
First of all - much faster.
It may execute a few % faster, but it's an order of magnitude slower to write and maintain. Computers get faster, humans don't (much). I find writing Perl tedious, which is an adjective I could never imagine using about Python
(except in relation to not having it). I guess that sound extremely biased, but that is just my experience.

Quote:
Originally Posted by ghostdog74
Quote:
Originally Posted by R00ts
The only thing I dislike about Python is the forced indentation (I feel that's not the job of a programming language), but its much more sane than Perl IMHO.
Welcome to Python
and you shouldn't have to dislike it because of the indentation. After a while you will get used to it.
Indeed. Initially I didn't like the language screwing with my indentation preferences, but after a few weeks, you forget about it.

Quote:
Originally Posted by ghostdog74
Sometimes when i switch back to writing Perl or other languages, my fingers automatically will press the tab key to indent every time i reach a new line..haha
Ha. A feeling I know well. The subconcious soon absorbs a languages idiosyncracies (except for perl, of course, which is just absurd).
 
Old 10-30-2006, 04:59 PM   #24
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 52
Python is simple, easier but slower. If speed isn't a concern, I suggest Python. I am starting to learn Perl as well. It is good to learn how to read it as lots of people are written in Perl. I am converting few applications from Java to Python in the meantime : enough libraries to develop with, simple to use + to maintain.
When your program requires lots of performance(graphics drawing, etc.) and runtime speed/processing is the main concern, use C or C++, not Java, Python, Perl, etc.

Last edited by mrcheeks; 10-30-2006 at 05:02 PM.
 
Old 10-31-2006, 06:45 PM   #25
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 52
A simple benchmark shows that pure C is faster. For the other languages it depends on how you code it, compile it(optimisations flags), if you run precompiled code, etc.
Code:
mrcheeks:~/Tests/Perl> time $cwd/test.pl
hello
0.006u 0.001s 0:00.00 0.0%      0+0k 0+0io 0pf+0w
mrcheeks:~/Tests/Perl> time $cwd/testcpp
hello
0.002u 0.000s 0:00.00 0.0%      0+0k 0+0io 0pf+0w
mrcheeks:~/Tests/Perl> time $cwd/testcpp
hello
0.001u 0.000s 0:00.00 0.0%      0+0k 0+0io 0pf+0w
mrcheeks:~/Tests/Perl> time $cwd/testcc
Hello, world!
0.000u 0.001s 0:00.00 0.0%      0+0k 0+0io 0pf+0w
mrcheeks:~/Tests/Perl> time $cwd/test.pl
hello
0.003u 0.005s 0:00.00 0.0%      0+0k 0+0io 0pf+0w
mrcheeks:~/Tests/Perl> time python $cwd/test.py
hello
0.018u 0.006s 0:00.00 0.0%      0+0k 0+0io 0pf+0w
mrcheeks:~/Tests/Perl> time java test
hello
0.119u 0.041s 0:00.42 35.7%     0+0k 0+0io 7pf+0w
The C version
Code:
#include <stdio.h>
#include <stdlib.h>

/* Main Function
*   Purpose: Controls our program, prints Hello, World!
*   Input: None
*   Output: Returns Exit Status
*/

int main() {
	(void)printf("Hello, world!\n");
	return EXIT_SUCCESS;
}
The C++ version
Code:
#include <iostream>
using namespace std;

int main(){
        cout << "hello" << endl;
        return 0;
}
The Perl version
Code:
#!/usr/bin/env perl
printf "hello\n";
The Python version
Code:
#!/usr/bin/python
print 'hello'
The Java version
Code:
public class test{
        public static void main(String argv[]){
                System.out.println("hello");
        }
}
 
Old 11-01-2006, 03:57 PM   #26
Fred_213
LQ Newbie
 
Registered: Oct 2006
Location: Long Island, New York
Distribution: Debian
Posts: 3

Rep: Reputation: 0
Thumbs up As a final note...

Being a python programmer in industry for testing aerospace equipment, I found that python is merely precompiled C libraries where upon execution, byte-code is generated the first time through and subsequent runs are just that much faster. If speed is an issue one must eliminate the abstracted interpreter layer and work at the os level and using compiled native code. Python excels for time-to-market coding speed and extensibility via custom package creation. I believe I read a post that python lacks libraries which is hardly the case. It actually has available, quite an array of packages that allow a programmer to interface to all types of databases, applications etc. Love the neat coding standard of indenting since I've seen such horid coding practices which are not permitted in python. These are all good things that make it easier and less risky to implement. You can also build a windows executable out of your python scripts and run them like a native program.
 
Old 11-03-2006, 09:55 AM   #27
soggycornflake
Member
 
Registered: May 2006
Location: England
Distribution: Slackware 10.2, Slamd64
Posts: 249

Rep: Reputation: 31
Quote:
Originally Posted by mrcheeks
I am starting to learn Perl as well. It is good to learn how to read it as lots of people are written in Perl.
Lots of people are written in perl !!!???
 
Old 11-03-2006, 01:58 PM   #28
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 52
hehehe.... I must have been tired. .... I meant programs...
 
Old 12-22-2006, 01:11 AM   #29
xlinuks
Member
 
Registered: Jan 2006
Location: White House
Distribution: Ubuntu 8.10
Posts: 39

Rep: Reputation: 15
mrcheeks
Quote:
When your program requires lots of performance(graphics drawing, etc.) and runtime speed/processing is the main concern, use C or C++, not Java, Python, Perl, etc.
Anyone knows that, however, Java 6 has been newly released, and, surprisingly I'm quite happy (for the first time!) with its speed, especially with the GUI (and ImageIO) performance. There are significant changes between Java 5 and 6. I was thinking to start learning C just because the GUIs didn't work fast enough, now, however, at least for me, the Java (Drawing and other GUI stuff) speed seems pretty fast (not to mention the other new features). The only BIG thing I'm really missing - rich DESKTOP libraries (to use pure Java to make transparent windows, make the app launch at system startup and a few important issues), I guess I'll create a thread on this issue.
 
Old 12-22-2006, 09:54 AM   #30
eerok
Member
 
Registered: Nov 2005
Location: Canada
Distribution: Mint, Debian
Posts: 168

Rep: Reputation: 32
Python and perl are both good languages. I was writing text-processing utilities in C because I was familiar with it, but then I decided I'd try perl since it's designed for the tasks I'm doing. It's working out very well. I could've gone with python, too, and in fact it was a close decision.

It's true that perl code can be baroque and opaque, but it doesn't have to be. I think it's also true that it's easy to get started with perl and difficult to master it. For someone just wanting to learn a language for it's own sake, I'd recommend python. But with perl, if you have a task at hand that's well-represented in CPAN, you have the advantage of having a lot of your work already done by experts.

So, as usual in questions like this, it depends on tastes and specifics.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Python or Perl? Boby Programming 2 06-12-2005 10:54 AM
bash, perl, or python? s_siouris Linux - Software 11 05-13-2005 03:15 PM
Perl or Python JJX Programming 6 10-27-2004 03:58 AM
Perl or Python ! linuxlover1 Programming 13 04-19-2004 07:33 AM
Perl vs PHP, PYTHON shebang Programming 5 02-14-2004 12:13 PM

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

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

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