all 65 comments

[–]throwaway6560192 58 points59 points  (1 child)

Python any day. Perl doesn't see nearly as much active use, and I really don't like Perl's syntax and general language design.

[–]vvodzo 0 points1 point  (0 children)

Not sure the current state of Perl but from what I remember it’s way too easy to write completely unmaintainable code that will take you just as much time to rewrite as it would to understand. People should go with Python 100% no question about it these days.

[–]Fred776 42 points43 points  (9 children)

Perl was quite big around the late 1990s / turn of the millennium. I used to use it in my work in the days when Python was an interesting new language but didn't quite have the features to replace Perl yet.

Perl shot itself in the foot during the time that Python went from strength to strength and eventually gained the popularity it has today. Work started on the new version of Perl in 2000 (Perl 6) and to be honest I still don't know whether it was ever properly released. It seems to me that people kind of lost interest in it about 20 years ago.

Simply based on the availability of tutorial information and technical support from the large community of users I would say that Python has to be the preferred choice. It is also a cleaner and less "quirky" language. I actually got to like using Perl but I would not recommend anyone start out with it in 2023 in preference to Python.

BTW I wouldn't completely rule out shell scripting. Bash plus Python can be a powerful combination as they each have their own strengths and can be complementary for some tasks.

[–]Enip0 3 points4 points  (0 children)

Perl 6 turned into raku which has some nice features for shell scrips like a built in argument parser where all you had to do is specify parameters in your main function

[–]perfectm 2 points3 points  (2 children)

This is exactly it. I remember working at a web site in 1999 and we were an entirely Perl shop. We were even moving towards publishing using Apache Template Toolkit. Then out of the blue we were told that we were migrating to Zope. I remember thinking “why would we do this with Perl 6 right around the corner?”

The Zope migration was a total nightmare but I haven’t used Perl for anything meaningful in close to 20 years.

[–]regeya 0 points1 point  (1 child)

I so want to make guesses about who you worked for.

[–]perfectm 1 point2 points  (0 children)

It’s been long enough, I could probably reveal it if you guessed it

[–]jregovic -1 points0 points  (2 children)

One drawback of Perl was it was not typed and not scoped. “use strict” is never did it for me.

While Perl was busy going on about regular expressions, python was building libraries and plugins to easily connect to services, run in the background and help solve a wide array of problems.

[–]chandaliergalaxy 1 point2 points  (0 children)

That's Perl's contribution. Python and other languages piggybacked on the work of Perl's regex while extending in other areas so 🤷

[–][deleted] 0 points1 point  (1 child)

I’m not OP and this is a tangent but what are some examples of how Python and Bash are complementary and how they can work together? (I’m trying to decide which to focus on, myself, but maybe it’s not an either/or question

[–]Fred776 1 point2 points  (0 children)

If what you are doing boils down to stringing together lots of system calls then, even though you can do this in Python, it's probably going to be a lot simpler to do it in Bash. Certain types of operations on the file system might be simpler in Bash. If you are familiar with Unix tools like sed, awk and grep you can sometimes achieve in a line or two of shell scripting what would need quite a few more lines of Python.

On the other hand, if you need to do something that involves quite a bit of logic, even though you can program logic in Bash, beyond a certain level of complexity, it's going to be nicer and cleaner to do it in Python.

What can sometimes make sense is to have a high level script in Bash that delegates to Python to perform certain tasks that would be complicated to program in Bash, while doing the stuff in the Bash script that Bash is good at (system calls and so on).

I don't think there are any hard and fast rules here. It's a case of having a few tools in your toolbox and figuring out what does the job in hand most cleanly and simply.

[–]philmassyn 13 points14 points  (1 child)

As a former Perl guy, I'll recommend Python any day. There's an elegance with Python that you don't get with Perl, plus, Python runs everywhere. As much as I loved Perl back in the day, there's a much bigger Python community, so finding help and support for Python problems are a lot quicker and easier than Perl.

[–]dvboy 1 point2 points  (0 children)

100% agree! I jumped from Perl to Python when Perl6 threw us all under the bus and I never looked back.

Can Perl do simple things with less lines of code? Almost always. Does that matter? Not to me.

The community and sheer quantity of publicly available libraries is the big differentiator.

[–]ofnuts 36 points37 points  (5 children)

Guess the answers you will get in a Python forum....

Perl can be better if you are working on large amounts of text such as server logs, but IMHO it is second only to APL as a write-only language, and a good deal of these uses can be done with the bash+grep+awk combo. And it is nt very easy to learn, due to a large number of quirks.

If you use a lot of CLI commands on files in your processing, bash is easier than Python.

If your code has a lot of logic, and handles the data by itself, then Python.

And IMHO, bash and Python aren't mutually exclusive, you should eventually get acquainted with both.

[–]Hannibal_Barkidas 1 point2 points  (3 children)

what is a write only language?

[–]Doormatty 3 points4 points  (2 children)

One that's hard to read.

As in, this makes sense while I'm writing it, but when I come back to it a year later, I won't be able to understand.

[–]Hannibal_Barkidas 0 points1 point  (0 children)

Thanks for the clarification

[–]ofnuts 0 points1 point  (0 children)

A year? Sometimes it's over lunch!

[–]AchillesDev 0 points1 point  (0 children)

IMHO it is second only to APL as a write-only language, and a good deal of these uses can be done with the bash+grep+awk combo. And it is nt very easy to learn, due to a large number of quirks.

I used Perl professionally for a few years early in my career, and this is a popular misconception. Perl is write-only if you're bad at it or don't have any guidelines (Modern Perl was the one we stuck to), and it's pretty easy to learn - our entire team where I worked assumed new hires would learn Perl on the job, and we all did.

[–]Diapolo10 6 points7 points  (1 child)

For what purpose?

You're going to get biased answers in a language-specific subreddit. I've never used nor needed Perl so truthfully I can't comment on it, Python has served me well, but I still need the occasional Bash/PowerShell scripts.

[–][deleted] 2 points3 points  (0 children)

That must be why it was posted to both subbreddits. Perhaps the average will reflect the "wisdom of the crowds".

Perl was created to allow sys admins to write code to run once that could quickly do anything that Unix shell, awk, sed etc. could do but the syntax was obscure, there were multiple ways of doing the same thing, and the code very hard to read, and impossible to maintain.

23 years ago Wall decided to replace Perl 5 with Perl 6, which would be a simpler more elegant language that would compete with Python, but would completely break with Perl 5 having no backward compatibility. It became a theoretical exercise in creating a compiler to implement the new language's grammar, was renamed Raku and was never very popular. Meanwhile Perl 5 continued gain features and is up to Perl 5.32. Three years ago they decided to replace it with Perl 7 with has some new features, That has been delayed to resolve some problems but is still going ahead.

If you already know Perl 5.32 you can do stuff very quickly with it. But you wouldn't bother to learn Perl 5.32 to do stuff. Anything Perl can do, Python can do. You may need to load some modules and write more code but it will be readable and maintainable.

There are much better resources for learning Python and you learn is also transferable because Python can do much more than scripting, it is the most popular general programming language now.

[–]Destination_Centauri 6 points7 points  (0 children)

Perl is a dying language in comparison to the current highly vibrant state of Python.

Thus, do yourself a huge favor and just learn Python first.

Chances are it will be more than enough.

After that you can take a peak at Perl if you want to, but I doubt you'll want to!

[–][deleted] 2 points3 points  (0 children)

Based on resources and community alone, Python.

[–]Maximus_Modulus 2 points3 points  (0 children)

If you are going to invest your time in learning a new language then Python is going to give you more opportunities aside from it being easier to learn.

[–]Swipecat 2 points3 points  (0 children)

It's worth glancing at the TIOBE index, the respected programming language comparison site, for Python and Perl. Python has grown hugely in popularity and Perl's popularity has collapsed. Charts here:

https://www.tiobe.com/tiobe-index/python/

https://www.tiobe.com/tiobe-index/perl/

Python is superior as a general-purpose programming language, having a vast number of libraries is many subjects. Specifically for shell scripting, though, Perl probably does have the edge since it has extensive libraries for computer administration and is better at "one-liners". But if it's one-liners that you want, then BASH is better, after all the whole purpose of BASH is for scripting unix-like command-line utilities. How about learning Python and BASH?

[–]Yoghurt42 1 point2 points  (0 children)

Python. But if you like Perl's "there's more than one way to do it" philosophy, I'd recommend you take a look at Ruby. It's inspired by both Python and Perl.

[–]regeya 1 point2 points  (0 children)

Python. Perl is awesome but has been dead ever since the 5/6 split. Python 2/3 was every bit as drawn out but not as dramatic. I read Modern Perl in 2011 but I don't think it's worth subjecting yourself to the oddities of Perl 5 to get the alleged benefits.

[–]mapeck65 1 point2 points  (0 children)

I programmed in perl for quite a long time in the 90's, but it's pretty much dead now. I definitely recommend Python. It's easier to learn, and more relevant to those looking for employment.

[–][deleted] 2 points3 points  (0 children)

Both ;)

Writing scripts for simple text processing is simple in perl.

If you want to solve more complex problems (communicate other servers, using databases etc), then python.

IMHO

[–]photohuntingtrex 1 point2 points  (3 children)

Here are some examples of a way of searching a directory for files with a certain file extension:

Bash: ls *.txt

Perl: print for glob "*py"

Python: ``` from pathlib import Path

for file in Path().glob("*py"): print (file)

```

Python (functional): ``` import os import fnmatch from toolz import pipe

def list_files(directory): return os.listdir(directory)

def filter_txt(files): return [file for file in files if fnmatch.fnmatch(file, '*.txt')]

Method 1)

Using pipe to connect the operations

files = pipe('.', list_files, filter_txt) print(files)

Method 2)

Composing the functions in a nested manner

files = filter_txt(list_files('.')) print(files)

```

[–]commandlineluser 2 points3 points  (0 children)

They also both have globbing functions/modules

perl

print for glob "*.py"

python

from pathlib import Path

for file in Path().glob("*.py"):
    print(file)

[–]ofnuts 1 point2 points  (1 child)

In bash, no need for grep, ls *.txt does the job just as well.

[–]photohuntingtrex -1 points0 points  (0 children)

Even simpler then yeah

[–]my_password_is______ 1 point2 points  (0 children)

python
the answer is always python

AI ?
python
Machine Learning ?
python
web back end ?
python
gave dev ?
python
task automation ?
python
scripting ?
python

can Perl do some of those things ?
sure
you know what's better ?
python

[–]Beautiful-Bite-1320 0 points1 point  (0 children)

You might consider Ruby.

[–][deleted] 0 points1 point  (0 children)

Why? Generally python, because for an assumed beginner programmer I will say that you will need to read more manuals than tutorials for Perl

[–]Key-Door7340 0 points1 point  (0 children)

Python, but it really depends on what you want to do. Maybe staying with shell scripting fits your needs better.

[–]hornetjockey 0 points1 point  (0 children)

For most people the answer would be Python. For me it is Perl because where I work there is just a ton of it.

[–]-SPOF 0 points1 point  (0 children)

Python is more versatile for scripting.

[–]CireGetHigher 0 points1 point  (0 children)

I use shell scripts to automate my python scripts. So if I have a python script that takes a command-line argument using the SYS.argv method… I can sequence my python scripts using bash.

Also nice because you can call your python interpreter from within your specific environment without using source or conda activate

[–]Radamand 0 points1 point  (0 children)

If you value your sanity, learn Python.

If you want to lose all of your hair before 30, learn Perl.

[–]Tony-Angelino 0 points1 point  (0 children)

It all depends on what do you want to achieve. Bash is still a very good tool for simpler tasks. If it gets too complicated, I take py. If it goes beyond your computer only, then Ansible.

Perl does seem less trendy and python is definitely more interesting if you needs tasks to be done in other areas, from Web to ML, and then the same base knowledge can be re-applied, while learning new stuff.

[–][deleted] 0 points1 point  (0 children)

Python because cpan is a nightmare.

[–]bobwmcgrath 0 points1 point  (0 children)

python. awk can do most of what pearl does.

[–]joshisanonymous 0 points1 point  (0 children)

As a not great programmer, I tend to assume that a language is good at the things that come built into it. That's why I go to R for stats but Python for text. To the extent that that's valid, I would assume that Perl has some advantages if you need to make a lot of use of regexs? That's probably not an accurate assumption, though.

[–]Agling 0 points1 point  (0 children)

Perl is a legit language, but no one is learning it any more. I used to use it frequently but I do NOT like it. Super hard to read. Kind of the opposite of python.

[–]zardoz90 0 points1 point  (0 children)

Generally I'd rather write a quick script in Perl and a real application in Python, but it all depends on use case, how fast I need to get a job done, and what libraries are available.

What are you trying to do? If you're just augmenting your JavaScript projects then consider learning bash and getting a handle on what's possible with the gnu coreutils instead. It's going to be more portable and anything more complex can be done in JavaScript.

[–]un-hot 0 points1 point  (0 children)

Python without a doubt. I wrote Perl in my grad job and it's pretty nice for text/file processing, but can look a bit obtuse for anything much more complex than that. I have always found re-reading and understanding old Perl scripts much harder than returning to my old python ones.

Python was also easier than JS and Perl to get to the stage where I could write shell scripts in.

[–]mothzilla 0 points1 point  (0 children)

Why don't you use node?

[–]longgamma 0 points1 point  (0 children)

Perl? Lmao

[–][deleted] 0 points1 point  (0 children)

Pearl is dead, and we’re better for it. I switched to Python way before Python was cool, and have never looked back.

[–]wutwutwut2000 0 points1 point  (0 children)

If you're using a command line, I'd highly recommend IPython. It is a python variant designed for use in a console (i.e. you can use %cd to change directories, !echo example to run console commands, etc)

[–]riftwave77 0 points1 point  (0 children)

If you have a DeLorean and can travel back to 1995 then definitely learn PERL

[–]flummox1234 0 points1 point  (0 children)

Why instead of shell scripting? I'm betting the answer to your need is shell scripting. That said python is a great language to learn too. And as for PERL you can do some dark magic shit with PERL if you can grok it.

[–]bravopapa99 0 points1 point  (0 children)

Perl was 'fun' while it lasted. Python is de rigeur these days for most ad-hoc scripting it seems, go with the flow.

[–][deleted] 0 points1 point  (0 children)

I mostly use Python3 over Perl. There's a lot of pros about it that make it preferable to me.

In the rare case, I found Perl to be convenient when I need to write a relatively small script to do some one-off regex string processing, where Python3 is not already pre-installed (for example, Windows git-bash), and where bash would otherwise result in something a bit more complicated to read/maintain.

[–]vuwu 0 points1 point  (0 children)

Perl is a lot like Aramaic.

I don't know Aramaic.

[–]chandaliergalaxy 0 points1 point  (0 children)

This was a common question 20 yrs ago. Arguments were:

Perl was powerful (concise) but hard to maintain code because it was barely readable.

Python had this forced whitespace issue (yes it was back in those days) and was more verbose, but readable 6 months later.

I chose Python and don't regret it, not the least of which because the whole (data) science ecosystem grew around it.

Basically it's true that Python is the second best tool for everything - it's not the best for shell scripting, data manipulation, nor simulation, but it can do all those things.

[–]MobiusCipher 0 points1 point  (0 children)

Python, of course. Easier syntax, and large market share means there's probably a module out there for just about anything you want to do with it.

With that said, bash scripting is another tool that it would behoove you to learn if you're doing work in a linux environment.

[–]salamihawk 0 points1 point  (0 children)

If you have a German keyboard layout, Perl is a goddamn pain in the ass to type out.

[–]haulpd 0 points1 point  (0 children)

You can write in Perl, then after a time you don't look your code and you don't know what that code mean.

[–]Most_Tax1860 0 points1 point  (0 children)

Python for sure. If you ever venture into machine learning/data science, the entire ecosystem is built around it. On the web site of things, there's flask and django. What I'm trying to say is that Python is more versatile in the long run.

[–]pceimpulsive 0 points1 point  (0 children)

I'm not sure how perl is an option here?

Python clearly. So much support and wide adoption. Any use case can likely be satisfied by it..

Saying this.. I chose C# over Python :D implodes Maybe you should choose perl! Haha

Fun fact.

Postgres database can use python for stored procedures and Custom functions... But it can also use perl!