Live data from Hacker News

Ruby: A great language for shell scripts

lucasoshiro.github.io

31–40 of 368 posts

Re: Ruby: A great language for shell scripts

#31
post #2

These are great points, if you already have Ruby in your stack. For me, when Bash ain't enough I upgrade to the Project language (PHP, Python, JS, etc). For compiled project I reach for LSB language (Perl, Python) before introducing a new dependency.

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

Ruby's fine for small to medium-sized projects. It's pretty great for small DSLs.

In my professional experience on medium to large-sized projects, its lack of explicit typing, the habit of Rubyists to use its fairly-substantial metaprogramming capabilities at the drop of a hat, and (for projects that include pieces or all of Rails) the system's implicit library loading make such projects a nightmare to reason about and maintain.

I'm sure these aspects are manageable with a small group, or a very, very disciplined group, but when you have large-sized projects that have been continually worked on for ten, fifteen, more years, you're just not going to be able to guarantee that everyone involved will have the combination of knowledge and discipline require to ensure the thing remains easy to understand, extend, and maintain.

Re: Ruby: A great language for shell scripts

#32
post #18

Earlier quoted context omitted.

Many distros come with Ruby standard, it's not very big and I think it has a lot to recommend it over Python or Perl when it comes to lightweight scripting for sysadmins and day to day automation. I wouldn't necessarily pull it into an open source project where they weren't already present, but I would definitely choose it for personal use well before Python or Perl

Ubuntu, Debian, Arch, CentOS - none of these, as far as I know, ship with a Ruby interpreter by default. I’d like to be wrong, but I don’t think many do.

It's been a while since I reinstalled Ubuntu, but the latest version (24.04 LTS) definitely includes Ruby (3.2) according to their docs [0].

[0] https://canonical.com/blog/canonical-releases-ubuntu-24-04-n....

Re: Ruby: A great language for shell scripts

#33
Ruby is slow and encourages an esoteric convention over configuration style of OO code.

If you enjoy it, more power to you. However, Python is everyone's second favorite or least favorite language, and it runs laps around Ruby any day. Then there's Go if you need some extra oomph!

Re: Ruby: A great language for shell scripts

#34
post #33

Ruby is slow and encourages an esoteric convention over configuration style of OO code. If you enjoy it, more power to you. However, Python is everyone's second favorite or least favorite language, and it runs laps around Ruby any day. Then there's Go if you need some extra oomph!

Go is a good language for when I want binaries an order of magnitude larger than necessary.

Re: Ruby: A great language for shell scripts

#35
post #33

Ruby is slow and encourages an esoteric convention over configuration style of OO code. If you enjoy it, more power to you. However, Python is everyone's second favorite or least favorite language, and it runs laps around Ruby any day. Then there's Go if you need some extra oomph!

Perl is basically available everywhere git is installed, too. Way lower startup time than ruby.

Re: Ruby: A great language for shell scripts

#37
post #3
post #2

These are great points, if you already have Ruby in your stack. For me, when Bash ain't enough I upgrade to the Project language (PHP, Python, JS, etc). For compiled project I reach for LSB language (Perl, Python) before introducing a new dependency.

What does LSB stand for?

[deleted]

Re: Ruby: A great language for shell scripts

#38
post #24

Earlier quoted context omitted.

Most shell-ish scripts probably use no dependencies and will not be picky about exact version

Mmm. I’d argue that all shell scripts use a ton of dependencies that are different across Unix/Linux. I. E. ‘sed -i’ is only in GNU sed. Same with ‘grep -P’.

This has bitten me many times

Re: Ruby: A great language for shell scripts

#39
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.

Golang's not so secret weapon

Re: Ruby: A great language for shell scripts

#40
post #18

Earlier quoted context omitted.

Ubuntu, Debian, Arch, CentOS - none of these, as far as I know, ship with a Ruby interpreter by default. I’d like to be wrong, but I don’t think many do.

It's been a while since I reinstalled Ubuntu, but the latest version (24.04 LTS) definitely includes Ruby (3.2) according to their docs [0]. [0] https://canonical.com/blog/canonical-releases-ubuntu-24-04-n... .

It's in the repos, but not installed by default.

Not on my Fedora box either.

Post reply on HN