Right... except for the use case I pointed out. That being that perl is available on virtually every unix like operating system, not just Linux, and python isn't.
Also, perl has other uses. Perl is much more competent at awk/sed/grep like tasks than python, and it can also be much faster. More people should be writing perl, imo. There's a ton of programs written in C that should just be perl.
The perl regex is more flexible, but that comes with a pretty substantial overhead: compare the speed of "grep -E" to "grep -P" and you'll see what I mean. I wouldn't be surprised if the RE module in modern python is faster than perl... but I also don't really care enough to check :)
Many languages use perls regex engine, like PHP. And PHP is definitely faster than python, but that's a low bar and honestly no idea how the regex performance is.
But, I do know perl regex are very fast because they're compiled at build time. They can have high time complexity if you use lookback, but that's true of most regex implementations. Dynamic regex is definitely slower, but this is somewhat rare in most perl programs.
But, in general, perl is going to be much faster than python or bash. Bash because bash is one of the least efficient languages ever designed, forking for basic functionality, and python because python has truly awful performance characteristics.
But, I would argue, if you have a system with python, you should probably write PHP. It's faster than both and very convenient for shell scripting like things.
But if you don't have python or can't assume it, use perl. For the love of God, don't use bash.
Python has many uses, I just don't think system scripts or system utilities is one of them. That's C, perl, or bash land, and perl is clearly the frontrunner there.
That certainly depends on exactly what you're doing...
> But, I would argue, if you have a system with python, you should probably write PHP.
That's a new one, I've never heard anybody seriously advocate for PHP as a system scripting language before...
> Python has many uses, I just don't think system scripts or system utilities is one of them. That's C, perl, or bash land, and perl is clearly the frontrunner there.
Having written plenty of all of those in my life, I really disagree. Python is easier and faster to write, and for scripting that matters more than just about anything else. Performance is almost irrelevant.
Python is really not faster or easier to write than perl. It might be if you don't know perl, but if you do know perl, you basically can't get more expressive and terse than that.
The main problem with python is getting it on systems is the biggest pain in the ass imaginable. Even deploying C++ is simpler.
If you're making the script for yourself then sure, fine. As soon as you're distributing to systems you don't 100% control, drop python. It's just annoying and it's not worth it. That 150 like python script could've been a 100 line perl script, or a 150 line one if you want. And then, you can just plop the file on basically any unix-like and run it.
I should have said "accessible" not "easier to write", that's what I was trying to say. A much larger portion of programmers have meaningful experience writing python than perl or php. I'm more likely to get patches and/or good bug reports from users when the scripts break if the scripts are written in a language they have experience with.
> The main problem with python is getting it on systems is the biggest pain in the ass imaginable.
Just avoid external dependencies and use /usr/bin/python, most scripting doesn't need any external dependencies. Or maybe I'm not understanding what you mean?
> A much larger portion of programmers have meaningful experience writing python than perl or php
Yes, I would agree, and this has value. But if you're in the position of making the decision of what to use and you know both, then that changes things. It's the same thing with Bash. Lots of people, and sysadmins, know bash, so they write bash. But bash is still not the optimal choice for, I'd say, 90% of the stuff it's chosen for. And it's a self-eating beast. Shoving bash where it doesn't go only strengthens it's grip. You're feeding the gremlin, you know?
> Just avoid external dependencies and use /usr/bin/python
I think this is easier said than done and it's also partially cultural. I have seen many, many system scripts that assume a very recent version of python AND assume a bunch of python libraries. This is bad, and people need to stop doing this. At least have the decency to bundle the libraries or, better yet, statically link them using C or C++ or Rust or Zig or whatever. And if that seems overkill to people, I think that means they haven't considered what they're actually doing and if they even need those external libraries.
Bash has this problem, too, and much worse, because it just calls system utilities. So it assumes a very specific running environment.
Anyway, all of that being said, if you're not using any libs than maybe Python is fine, if you know the systems you're targeting will have Python. If not though, I stand by Perl. Just use 5.10 or whatever and boom, that shit will run truly anywhere.
Also, perl has other uses. Perl is much more competent at awk/sed/grep like tasks than python, and it can also be much faster. More people should be writing perl, imo. There's a ton of programs written in C that should just be perl.