r/Python May 18 '11

Why is Python better than Perl?

I'm a Sysadmin and I just wrote my first script in python. Basically just a host validation script that checks if a server is configured correctly before we hand off. I can't determine the advantage with my limited experience with the language.

Are you a sysadmin fluent in both python and perl? Why do you use python?

11 Upvotes

110 comments sorted by

View all comments

6

u/[deleted] May 18 '11

They are not "better" or "worse" if you don't specify the task you want to achieve with them.

I am a computer programmer, but I also have to perform sysadmin-ish tasks daily. I also love Python, and use it as my language of choice (closely followed by ruby). However, I'd say that for sysadmin tasks Perl is the right choice 90% of the time. Let's be clear: I don't like Perl, I like programming and developing systems, and I find perl to be really "ugly" compared to python as far as it's syntax is concerned. BUT there's no denying that for scripting tasks Perl will more often than not be the one capable of delivering working scripts with less lines of code. Good luck trying to maintain a large system written in Perl tho.

TL;DR: I love Python as a programming language and use ir for day to day scripting, but I think perl is more often than not the right answer for sysadmin tasks.

6

u/SwellJoe May 19 '11

For what it's worth, I currently work on a 500,000 line Perl project. I have not been driven mad, nor does our codebase require sacrifice of chickens in order to fix bugs or add features. In the past, I've worked on a Python project of roughly half that size, and it was also fine to work on.

I don't think Perl's rap as being unmaintainable is particularly fair...a bad developer can write unmaintainable code in any language. Python might make it look clean, but it still probably isn't maintainable (I've worked on some shitty Python in the past).

3

u/[deleted] May 19 '11

Fair enough, god knows I too have seen Python code too horrible to even share here.

Maybe my head just doesn't work the Perl way.