LinuxQuestions.org

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

Laserbeak 04-25-2017 10:43 PM

Python vs. Perl
 
I'm wondering what people's thoughts are about Python vs. Perl as a scripting language? I consider myself a quite good Perl programmer (self-taught and a lot of on-the-job experience) and I took a Python class at NYU.

Frankly, Python didn't really do anything for me. I'd rather code in Perl any day. What is the attraction so many have to Python? It's a bit stricter and therefore easier to debug, but that's my only thought...

dugan 04-25-2017 10:45 PM

Quote:

Originally Posted by Laserbeak (Post 5702238)
easier to debug

That's an incredibly significant advantage in the real world.

Laserbeak 04-25-2017 10:47 PM

Quote:

Originally Posted by dugan (Post 5702239)
In addition to that, it also has an unusually well-thought-out and comprehensive standard library.

Yeah, but Perl has libraries for practically everything! Except maybe making you a cup of coffee!

dugan 04-25-2017 10:49 PM

Quote:

Originally Posted by Laserbeak (Post 5702241)
Yeah, but Perl has libraries for practically everything! Except maybe making you a cup of coffee!

Yeah, I deleted that point because I knew the counterargument was CPAN.

Laserbeak 04-25-2017 10:58 PM

I think the one thing I really HATED about Python was its reliance on whitespace for blocks of code instead of the usual braces or BEGIN and END.

Turbocapitalist 04-26-2017 02:10 AM

Yeah, python would be ok if not for the whitespace problems. For me, that stops me from enjoying it enough to use it. I really appreciate the flexibility of perl and, of course, the scope of what's in CPAN.

notKlaatu 04-26-2017 02:16 AM

I'm interested in learning Perl, but I really don't know where to begin. Perl 5 ? Perl 6 ? Not sure.

Otherwise, Perl is probably quite good.

I personally find Python a little bit overkill for many tasks, and fall back on BASH for system tasks that I want to script. It may or may not be as fast, but sometimes it just makes more sense.

Turbocapitalist 04-26-2017 02:20 AM

Quote:

Originally Posted by notKlaatu (Post 5702305)
I'm interested in learning Perl, but I really don't know where to begin. Perl 5 ? Perl 6 ? Not sure.

Perl 5 and Perl 6 are actually different languages. If you're looking just to get started, I'd say Perl 5 and focus on perl regular expressions. That's what it's best at and those are the most useful and are going to be mostly portable anyway as nearly all languages now have 'PCRE' either as modules or built-in.

hydrurga 04-26-2017 02:25 AM

Quote:

Originally Posted by Laserbeak (Post 5702244)
I think the one thing I really HATED about Python was its reliance on whitespace for blocks of code instead of the usual braces or BEGIN and END.

I thought this at first, having been programming for nigh on 30 years before I met Python, but have now come to enjoy the way Python is laid out. Much simpler and cleaner to my eyes. Each to his/her own. :)

Laserbeak 04-26-2017 03:12 AM

Quote:

Originally Posted by notKlaatu (Post 5702305)
I'm interested in learning Perl, but I really don't know where to begin. Perl 5 ? Perl 6 ? Not sure.

Perl 5 definitely. Perl 6 is nowhere near becoming mainstream and there's a question whether it ever will.

camp0 04-26-2017 04:59 AM

I have experience working with perl and python and I would say that I will never use perl on a project, and if I found perl code I will rewrite to python :D

notKlaatu 04-26-2017 05:10 AM

Quote:

Originally Posted by camp0 (Post 5702350)
I have experience working with perl and python and I would say that I will never use perl on a project, and if I found perl code I will rewrite to python :D

Any particular reason why?

My only "issue" with Python is its lack of scope. I really wish Py3k had introduced at least the *option* to use scope delimiters. I don't care how pretty Python code is, after a few levels of indentation, it gets confusing to figure out what parents what.

syg00 04-26-2017 05:19 AM

Quote:

Originally Posted by notKlaatu (Post 5702305)
I'm interested in learning Perl, but I really don't know where to begin. Perl 5 ? Perl 6 ? Not sure.

I went to LCA in early 2000's and asked the same question. Got basically the same answer you just did.

Mind, python also has a incompatible release cross-over.

As if there aren't enough new languages coming out all the time.

camp0 04-26-2017 08:08 AM

Quote:

Originally Posted by notKlaatu (Post 5702352)
Any particular reason why?

My only "issue" with Python is its lack of scope. I really wish Py3k had introduced at least the *option* to use scope delimiters. I don't care how pretty Python code is, after a few levels of indentation, it gets confusing to figure out what parents what.

The main reason is that I find hard to read the code. I remember that we got a script of 300.000 lines of perl and was a pain and nobody wanted to touch it. Another reason to not use perl is that if you want to mix with other libs I found more useful libs under python and if you need to mix with c or c++ is easy than in perl.

sundialsvcs 04-26-2017 08:30 AM

The languages are subtly different – indentation aside. :)

It's clear that Python's designer was familiar with LISP. There is a lot of list-processing mojo built into it.

Likewise, Perl shows an unmistakable influence of awk, which it was (in one sense) "built to replace."

Functionally, both languages are efficient ... well, except for Perl-6, which decidedly isn't :rolleyes: ... and are well-supported by contributed libraries.

The contributed libraries are really "what the fuss is about." Many applications are constructed by piecing together objects and subsystems which are built and maintained by other people. (So you can "write a complete HTTP server using one line of code," for instance.) Perl, in particular, will not only install a package but rigorously test it on your machine before making it available for your use.

I simply believe that you should make it your business to familiarize yourself with present and emerging languages – because, well, "it is 'your business!'" :) (Programming languages happen to be a special interest of mine.) You can fully expect to encounter a wide variety of programming languages in use, simultaneously, at any "shop" you might work for or set up. At some point when beginning a new project you'll make the "fateful decision" of which language to use. (And every programmer who follows you will throw darts at your picture on their wall.) But, most of the time, there is no meaningful "versus." You'll continue the project in whatever language was originally picked – most of the time. (However, sometimes several tools are used in the context of a single project, both client-side and server-side. It can get nasty.)


All times are GMT -5. The time now is 02:12 PM.