top | item 40764288

(no title)

NullInvictus | 1 year ago

I think the quality of a language for shell scripting is often secondary. What’s of greater significance is where it is at. I.e., does it have it already installed? The answer with Linux and Bash is almost always “yes”. Not so with ruby.

The moment you start asking the user to install things, you’ve opened up the possibility for writing a program rather than a shell script. The lifecycle of a piece of software is almost always one of growing responsibility. This cycle is devastating when it happens to shell scripts. What was once a simple script slowly becomes creaking mass of untestable, poorly understood code playing in the traffic of swimming environments (which grep you got, buddy?).

I guess I’m saying that once you open up the possibility of writing a program, you generally take that option and are usually happier for it. In the “write a program” world, ruby is still good, but it becomes a far harder question to answer whether ruby is still the right choice. There are a lot of languages with a lot of features engineers like.

discuss

order

kqr|1 year ago

This is indeed why I use Perl over Ruby. As long as it's not for a Window machine, a Perl script is deployed by copying it over and that's it.

pmontra|1 year ago

That's true of Python and Perl as long as you keep using only the features built in in the core language (standard lib or whatever they call it.) The same applies to Ruby.

My scripting language is bash in at least 99% of cases. I used to program in Perl when I need some complex logic. I stopped using it some 10 or 15 years ago when I switched to Ruby for two reasons: I became more familiar with it than with Perl and it's easier to manage data structures whenever I need something complex or classes. That doesn't happen often in scripts but as I wrote, I use bash for all the normal stuff.

I use Python for the scripts that start an HTTP server because it has the http.server module in the standard lib and it's very simple to write handlers for GET, POST and all the other HTTP verbs. The last example was a script to test callbacks from an API. I just implemented two POST and PUT methods that print the request data and return 200 and a {} JSON. I think that to do the same in Ruby I would need to install the webrick gem.

brightball|1 year ago

Perl is deeply underappreciated and needs a lot more love. One of the keynotes at the polyglot conference that I run is going to be Perl talk and I'm really looking forward to it.

MaxBarraclough|1 year ago

Even on Windows there's a good chance. The Git for Windows project bundles Perl, but not Ruby.

noisy_boy|1 year ago

That was the reason Perl was what I switched too from bash when I was working on Solaris boxes; it was miles ahead of what was possible with bash AND it was already present. If I remember an older version of Python was also installed but by then Perl had already got me reeled in and I felt Python to be too "verbose" compared to Perl (I eventually changed my opinion when I got a bit more experience under my belt).

petre|1 year ago

One usually needs modules to easily do something more advanced, but yes, Perl is almost always installed. Although I find Ruby much more ergonomic, I still reach for Perl as well because I know it better and don’t have to open the documentation so often.

pdimitar|1 year ago

> I.e., does it have it already installed? The answer with Linux and Bash is almost always “yes”. Not so with ruby.

True, not true for Ruby, but with Golang and Rust you have an almost-no-dependencies final binary so the argument there does not apply.

> which grep you got, buddy?

For dev machines it's not such a tall order to require `rg` be installed these days.

cozzyd|1 year ago

One advantage of a scripting language for scripts is that you can read it and see what it does one month later...

oopsallmagic|1 year ago

Not once have I worked anywhere where the people writing shell scripts didn't also control all of the boxen those scripts ran on.

vault|1 year ago

I'm glad you never worked at a bank or an insurance company!

shlant|1 year ago

yea as soon as I read through the post, I ssh'd into one of my many Ubuntu servers, ran `ruby -v` and then noped out. From past experience I want nothing to do with trying to wrangle RVM or rbenv and then making sure the paths work properly.

speleding|1 year ago

Nowadays `apt install ruby` on an ubuntu box will give you a reasonably up to date ruby that's more than adequate to run scripts. This is not like the old days where a script written on Ruby 1.87 would break on 1.9.