Live data from Hacker News

Ruby: A great language for shell scripts

lucasoshiro.github.io

81–90 of 368 posts

Re: Ruby: A great language for shell scripts

#81
post #9

I sometimes wonder why we don't see ruby used for shell stuff more often. It inherited most of the good stuff for shell scripting from Perl, and Perl took a lot of it's syntax from sh and sed and awk, so almost anything you can do in shell script you can do in ruby, but with an option of making it gradually less terse and more readable, while having sane variables and data handling from the start. Also ruby is great…

What tooling do you use that’s written in Go? I’d have said that Python is the most popular language for tooling, by a country mile.

The only tooling I know that’s written in Go is Docker.

Re: Ruby: A great language for shell scripts

#83
To simulate “types” in complex shell scripting I typically involve a lot of json objects acting as my data structures and the file system for a rudimentary database. They’re horrifying ugly, but they tend to work pretty reliably.

This is probably easier.

Re: Ruby: A great language for shell scripts

#85
post #9

I sometimes wonder why we don't see ruby used for shell stuff more often. It inherited most of the good stuff for shell scripting from Perl, and Perl took a lot of it's syntax from sh and sed and awk, so almost anything you can do in shell script you can do in ruby, but with an option of making it gradually less terse and more readable, while having sane variables and data handling from the start. Also ruby is great…

Instability. Ruby has not been the same language for very long. Migrating to 1.9 was a huge hassle for many firms. This may seem like a long time ago in tech years; but then there was Ruby 2.0; and shell scripts, meanwhile, have stayed the same the whole time. A secondary reason is that Ruby has been very slow for much of its life, which means that for situations where you need to run a huge stack of scripts -- init…

Your first two points don’t seem valid, in my experience.

The Ruby 2.0 migration wasn’t that interesting from a compatibility perspective; it certainly wasn’t anything like Python 2 -> 3.

And Ruby is __not__ slow compared to bash. I don’t where these myths get started, but someone needs to justify the Ruby-is-slow thing with actual data.

Re: Ruby: A great language for shell scripts

#86

Hell yeah! I’ll never forget being fooled by HN that you have to use Perl if you want portable scripts that aren’t bash, writing a whole script with it, and having a coworker politely, yet firmly, tell me that I am dumb and it should just be Ruby… and it was a script I was checking into a Rails app! It’s even trivial to include dependencies with bundler inline https://bundler.io/guides/bundler_in_a_single_file_ruby_s…

this is… somewhat horrific, right? would anyone do this without explicit version pinning?

loosely pinned deps installed on execution sounds fucking awful.

Re: Ruby: A great language for shell scripts

#87
post #9

I sometimes wonder why we don't see ruby used for shell stuff more often. It inherited most of the good stuff for shell scripting from Perl, and Perl took a lot of it's syntax from sh and sed and awk, so almost anything you can do in shell script you can do in ruby, but with an option of making it gradually less terse and more readable, while having sane variables and data handling from the start. Also ruby is great…

I think golang is used because you can easily create a single static binary, which is incredibly easy to distribute. I often find non-trivial CLI tools written in Python cumbersome because of the dependency wrangling necessary.

> I often find non-trivial CLI tools written in Python cumbersome because of the dependency wrangling necessary.

I'm thinking of trying out Mojo in large part because they say they're aiming for Python compatibility, and they produce single-file executables.

Previous to that I was using PyInstaller but it was always a little fragile (I had to run the build script a couple of times before it would successfully complete).

Currently I'm using pipx and Poetry, which seems pretty good (100% success rate on builds, and when my 5-line build script fails it's because of an actual error on my part).

Which is a round-about way of asking everyone:

Does anyone have any other good way(s) to build single-file executables with Python?

Re: Ruby: A great language for shell scripts

#88
post #77

Earlier quoted context omitted.

Ruby is fantastic for the main project language, too! And is also standard on many Linux distros.

Ruby is unsuitable for large projects for the same reason python is, but it also lacks the huge ecosystem and labor pool that python has. When I'm interviewing and a company tells me ruby is the main language, I end the call.

“X is unsuitable for large projects” when there are many readily discovered existence proofs to the contrary (including but not limited to $1B+ businesses, massive communities, deep thoughtful and disciplined engineering spokespeople, etc.) strikes me as a common trope here on HN.

(Which is not to say X is flawless even at scale or a clear best fit along all axes. That is true for no X that I know of.)

Re: Ruby: A great language for shell scripts

#89

Earlier quoted context omitted.

> Migrating to 1.9 was a huge hassle for many firms. This seems contrary to my experience. We took a large project from 1.8 to 1.9 to 2.0 to 3.0, and it was much easier than we expected. It was a lot easier than our Python 2 to 3 conversations were.

> It was a lot easier than our Python 2 to 3 conversations were. Python's is (present tense very much intended) notoriously one of the worst-managed transitions in programming language history, so that's not exactly a ringing endorsement.

It is completely relevant, because it’s arguing against the claim that Ruby was unstable once back in 2005.
Post reply on HN