FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

I find python is still not as popular as perl

 


liuxu
Actually, I think python is better than perl. But I nearly can't find a free web host site which supports python cgi. Many of them support perl cgi.

In my company, many test scripts and building scripts are written in Perl. I have to study perl instead of python. However, perl is too strange to study.

Who can tell me which script is better and why?
qebab
Different tools for different tasks, different flavours for different people.

Python has a very readable syntax, much more so than Perl in my opinion. Python enforces indendation f. ex.
Code:

#This is not valid.
def add(x,y):
return x+y
#This is
def add(x,y):
    return x+y

Python works under the philosophy that there should only be one obvious way to do it, Perl works under the philosophy that there should be many ways to do it. Python is 'natively' OO (It was always object-oriented), Perl has been extended with OO. Python has list comprehensions, which I don't know if Perl has (you can do things like somelist = [somefunct(i) for i in range(1,100) if is_valid(i)] or someotherlist = map(somefunct(x),range(1,100)), and so on.

There's no obvious answer to which is the better, it depends on what you want to do and how you want to do it. Want to write everything OO? Then it's probably a good idea to go with Pythons 'Everything is an object'. Are you into regular expressions? Perl excels at that. Do you need things like || && or ternary operators? Python doesn't have them, Perl does.

I think you should take a look at some example codes around the web, or try to code a bit in both and then decide which fits you better.
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.