Hacker News new | ask | show | jobs
by stjohnswarts 1378 days ago
I would argue that ruby as almost all the strengths of perl and conciseness with more coherency if you want a perl-like fluidity and terseness. I personally like python for anything that becomes more than a 100 lines of bash.
3 comments

Due to poor coding practices (eg monkeypatching) and a weaker testing culture (by default Ruby does not run unit tests when installing libraries) I've found Ruby to be substantially less reliable than Perl.

However the world has moved on to Python. So I curse every time I again have to look up how subprocess works for what I'd do in Perl with backticks.

The documentation for that says, "Specifically, Windows is not supported."

My use case was for scripting git operations. And the list of target environments included Windows.

So no, that wouldn't have worked for me.

To be fair to Python subprocess is not simply a substitute for backticks in Perl or Ruby. It's supposed to protect you from some of the more obscure problems which can happen with shell expansion.
Check out plumbum: https://plumbum.readthedocs.io/en/latest/

It supports mac, Linux and windows.

TIL (as a light Perl user alternative to awk) CPAN runs test on install. Is there any other language package manager runs tests by default?
that is super dangerous, just like some other dangerous parts of perl where it can run code during the compilation phase
A lot of languages allow the running of arbitrary code on install, so it is not particularly dangerous that Perl allowed it.

However you have no idea how many bugs got caught because the test run uncovered platform specific bugs. This is exactly what gave Perl a good name for being portable. Doubly so given that Perl always did this, starting back in the 1980s.

Even better is cpan testers who will run your cpan package on the widest variety of platforms I have ever seen. To my knowledge no other package ecosystem will do this.
Does Ruby come pre-installed on virtually every Unix-like system out there?
No, and if it is, who knows what version it is.

I think that's the main thing preventing one from using ruby like this. It is otherwise preferable in pretty much every way.

Perl is kind of pre-installed on virtually every Unix-like system for what are at this point historical/legacy reasons. It is unlikely any other language can ever achieve this at this point.

Indeed. As much as I would like to use Ruby or Raku for this type of stuff, I keep coming back to Perl because it's simply... there.

Sure, I could probably install Ruby on any machine I want it, but it's not just technical availability. Socially, Perl serves as a quite obvious Schelling point. I don't have to convince four other people to learn Ruby, because Perl is what everyone would gravitate to even in isolation, again because it's just... there.

(That said in recent years I've had to switch to Python for some things aimed at a younger audience. Oh well.)

AFAIR, Red Hat stopped including Perl by default since RHEL8 (
RHEL 9.0 provides the following dynamic programming languages:

    Node.js 16
    Perl 5.32
    PHP 8.0
    Python 3.9
    Ruby 3.0
Preinstalled?
Just a data point — Ruby, Perl and Python have all been deprecated [0] in macOS.

[0] https://developer.apple.com/documentation/macos-release-note...

If it's not installed already, Ruby will be installed ASAP on any machine I use.
You're confusing perl with ruby there.
For that, there is Next Generation Shell. Also works like a charm even before 100 lines. For example when structured data is needed. Some other advantages over bash are error handling, automatic command line arguments parsing (similar to Raku, btw), standard library with functions like warn(), log(), debug(), retry(), etc that you have likely implemented hundreds of times in your bash scripts.

Disclosure: I'm the author.