LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Perl vs. Ruby vs. Python (https://www.linuxquestions.org/questions/programming-9/perl-vs-ruby-vs-python-486533/)

vargadanis 09-24-2006 01:30 PM

Perl vs. Ruby vs. Python
 
Hi all!

I want to learn perl or ruby or python but I do not know which one is the best. I know quite much about these languages, escpecially about perl and ruby but I have already heard of python. So the most important thing for me is the speed. I do not know which one is the fastest. And it was great if I could compile the source code into a native executable. I do not know whether is it possible or not but it was great.
So please help me to answer rhese questions..

makyo 09-24-2006 01:44 PM

Hi.

There is a comparison chart at http://en.wikipedia.org/wiki/Compari...ming_languages

and there are benchmarks results at http://shootout.alioth.debian.org/

Best wishes, and let us know what you finally choose and why ... cheers, makyo

vargadanis 09-24-2006 04:13 PM

So I won't learn Ruby tough it is quite simple but hardly readable, like perl. Python is very very easily readabla but a lot slower. I do not know why but I do not care. I do not want to write an OS in perl or python so probably I will learn python because it is OOP not like perl. Perl is much rather like PHP and I do not think I need one more sripting language. ^_^ So Python is the final choice. Somebody said that harware is cheap, programmer is expensive. Python, python, python. I hope I do not do too big mistake.

vargadanis 09-24-2006 04:19 PM

I have one more question:
Is there a good IDE for Python? Or a module for Eclipse?

slantoflight 09-24-2006 04:56 PM

Quote:

Originally Posted by vargadanis
Hi all!

I want to learn perl or ruby or python but I do not know which one is the best. I know quite much about these languages, escpecially about perl and ruby but I have already heard of python. So the most important thing for me is the speed. I do not know which one is the fastest. And it was great if I could compile the source code into a native executable. I do not know whether is it possible or not but it was great.
So please help me to answer rhese questions..

Before you bother, take a look at these articles.

http://www.perl.com/pub/a/2001/06/27/ctoperl.html
http://www-128.ibm.com/developerwork...y/l-psyco.html

This is a universal truth in life, easy always has a cost.
In this case, the flexibility and expressiveness per line ratio have increased because other programmers have already done some of the hard work for you, but you loose some performance.

But if its any comfort, I will refer to this quoute here.

Quote:

Python is usually fast enough for what you want it to do. Ninety percent of the concerns that novice programmers express about the execution speed of an interpreted/byte-compiled language like Python are simply naive. On modern hardware, most non-optimized Python programs run as fast as they need to, and there is really no point in spending extra programming effort to make an application run faster.
If the differences in speed between any of these interpretations are more than academic to you, then you would be using C.

On the other hand, theres always a desire for the ease of use from a language like python, but the speed execution of a C program. While it would be nice in certain respects if perl/python produced native executables, it would'nt necessarily be any faster unless some things hinted in http://www.perl.com/pub/a/2001/06/27/ctoperl.html
were to happen. Considering what it took just to make the interpreters, it doesn't look like an overnight effort. To put things perspective look at GCC. That was built using a small language. Perl/Python/Ruby are'nt exactly small.

However that doesn't prevent from extending the language with speed-optimized C modules. Python, in particular makes this easy to do.

Take a look at
http://www.geocities.com/foetsch/pyt...thon.htm#intro

Ofcourse I'm a being a bit biased. You can also do this in perl. In fact theres a whole thick book on it.
http://www.manning.com/jenness/
You'll notice that perl is pretty good for producing thick books.

extrasolar 09-24-2006 05:10 PM

I'm just about to start learning Python. Python seems like a good choice: it's easy to read, fairly powerful and, compared to some other languages (such as C, C++ and Java), it doesn't seem too complicated.

I've started learning C, C++, C# and Java but I always find that they get too complex for a beginner such as myself.

So I'm gonna learn Python and then move up to perhaps C++ or Java.

slantoflight 09-24-2006 05:18 PM

Quote:

Originally Posted by vargadanis
So I won't learn Ruby tough it is quite simple but hardly readable, like perl. Python is very very easily readabla but a lot slower. I do not know why but I do not care. I do not want to write an OS in perl or python so probably I will learn python because it is OOP not like perl. Perl is much rather like PHP and I do not think I need one more sripting language. ^_^ So Python is the final choice. Somebody said that harware is cheap, programmer is expensive. Python, python, python. I hope I do not do too big mistake.

You must have posted that in the middle of my big post. But I happy you picked your language. And you picked python.

You are right about python programs generally being more readable. One thing I've noticed between programming in perl and python. Its very easy to write a perl program, which is why they're pretty much a dime a dozen. But reading one on the other hand...it can be painful.
Its almost like a version of C++, thats easier to program with, but without the discipline carried over from learning a less forgiving language. And if you've seen novice C++ programmers writing 500 lines for an 80 line homework assignment, you'll know what I'm talking about. Not a language flaw really. Just noticing habits from typical perl programmers. Having 20 different obscure operators that do the same thing doesn't appear to aid readability.

makyo 09-24-2006 05:20 PM

Hi.
Quote:

Originally Posted by vargadanis
I have one more question:
Is there a good IDE for Python? Or a module for Eclipse?

See http://en.wikipedia.org/wiki/Compari...t_environments
which points also to
http://en.wikipedia.org/wiki/List_of...t_environments

Wikipedia and Google are your friends ... cheers, makyo

vargadanis 09-24-2006 07:24 PM

Quote:

Originally Posted by slantoflight
You must have posted that in the middle of my big post. But I happy you picked your language. And you picked python.

You are right about python programs generally being more readable. One thing I've noticed between programming in perl and python. Its very easy to write a perl program, which is why they're pretty much a dime a dozen. But reading one on the other hand...it can be painful.
Its almost like a version of C++, thats easier to program with, but without the discipline carried over from learning a less forgiving language. And if you've seen novice C++ programmers writing 500 lines for an 80 line homework assignment, you'll know what I'm talking about. Not a language flaw really. Just noticing habits from typical perl programmers. Having 20 different obscure operators that do the same thing doesn't appear to aid readability.

I am sorry. I did not want to interrupt you. :)
Painful reading... That is what I want to avoid. I have some experience in reading other people's PHP code and it is usually much more complicated and less readable than they should be. So this was the primary motivating force to learn python. And I know how painful it is to learn C and C++. I am quite good at C (just the basics, like I/O, file management) but sometimes I cannot read my own codes and it takes time to see what is happening now. But I am used to it now. I am thinking in C not in python so the first 200 lines of program code I wrote today were really painful but I am quite satisfied with the result. But! I am not sure this is what I am seeking.
To compare I tried out Perl too. I used the std libraries and wrote the same program. The difference is shocking. As I am used to C and the "{}" marks, it wasn't less readable for me than the python code. I accept that these marks makes it a bit difficult to read but I learned to ignore them. But it seems to be more logical to use the for(i=0; i<10; i++){} than using the for i in range(0,9): staff... or sth similar
So now I decided something new... I won't learn any of these languages. I know how to use pearl. Or at least the basics. I know PHP so now it is time to learn something very complicated.
I decided I am gonna dig into C and C++. I wanna learn these because they are the most powerful programming languages so far.
They are platform independent and everything important is written in C or C++. Have you ever seen a kernel module or a driver written in Pearl or Python or even in Ruby? Sound strange, doesn't it? The next step is gonna be asm.
So what do you think? Is there a point in learning Pearl or Python if I can learn C with the same effort?

slantoflight 09-24-2006 11:17 PM

Quote:

Originally Posted by vargadanis
So what do you think? Is there a point in learning Pearl or Python if I can learn C with the same effort?

Learn as many languages as you can. And no, learning Perl/Python is not the same effort as C. Not by a long shot.

bulliver 09-25-2006 05:16 AM

My opinion: Perl is a PITA plain and simple. Always had troubles with it. I have tried repeatedly to 'get it' but it always just hurts my head, and I never get anywhere.

Python and Ruby however are both a joy. I learned Python first and I love the syntax (including forced indentation which most hate) but have found myself writing everything in Ruby lately because I love the 'everything is an object' paradigm. You may think Python is OOP til you try Ruby...

Both languages are great for writing complex apps in a ridiculously small amount of LOC. And as for speed, don't get caught up in premature optimization. If it runs fast enough, it's fast enough, no matter what.

pankaj99 09-25-2006 06:53 AM

I know how to program in C and c++.
how much time it will take me to learn perl or python?

bulliver 09-25-2006 07:00 AM

Quote:

I know how to program in C and c++.
how much time it will take me to learn perl or python?
5 minutes... here is a great introduction to Python for those who know how to program:
http://linux.duke.edu/~mstenner/free.../html/toc.html

The question is how long will it take you to unlearn all that C/C++ damage ;)

X.Cyclop 09-25-2006 07:23 AM

Why Python?
Python IDEs

;)

slantoflight 09-25-2006 09:03 AM

Apparently I'm not the only that likes python. :)


All times are GMT -5. The time now is 11:14 AM.