Hacker News new | past | comments | ask | show | jobs | submit login

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.




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.


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.


In fact, that's true for Python if you use a zipapp and no c extension: https://docs.python.org/3/library/zipapp.html

You can happily copy the zip of your scripts and all deps in the server.

You still do have to mind your versions, as always with python.


> The same applies to Ruby.

With a big difference -- Perl and Python will always be installed on these machines, whereas Ruby might need two deployment steps: (1) copy file, (2) install Ruby!


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.


Does it still require global library / module installations for your script's dependencies? If so, hard pass.


It does not, and has not for at least a decade!


So any guides on how to make a self-contained Perl script that needs dependencies?


See https://metacpan.org/pod/pp for one tool to do that.


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


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).


Interesting! I still find Python too verbose to stand in for shell scripts when Perl is available, with what I think is a decent chunk of experience.


Ha - I actually haven't changed my opinion about verbosity, Python is still more verbose and I will choose Perl for throwaway scripts even today; I just have a greater appreciation of readability of Python code compared to the free-for-all style-fest of Perl code (admittedly written by a bunch of devs with little code style enforcement). Perl is great for smaller scripts but I'm talking about many thousands lines of code and the lack of native object orientation, messy error handling, lack of a decent repl etc start to take their toll.


Thousands of lines := time to use a real (compiled) language


Very true; unfortunately quite often one is not in the decision maker's seat.


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.


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


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


Sure, especially every bash script that goes over 200-250 lines is super readable. /s

Or when you have to start using all the combinations of characters to achieve f.ex. proper iteration through an array without word splitting. Etc. to infinity.

I've danced this dance hundreds of times and got sick of it. Gradually moving away from scripts and to Golang programs and so far it has been an improvement in almost every way, I'd say easily in 90% of the cases.


still more readable than disassembler output :)

sure if it's your "script" and you know exactly the code corresponding to it it might be ok, but that's a lot of overhead for a disposable script.


Are you arguing against my point or for it? :D


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


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


Why do you choose to write in a snarky way? Why does that make you glad? Why does this make you energetic?


It's tongue in cheek, and he's right. I am a old man Sunos/VMS/Linux admin. Having root used to be my god given right.

However I haven't worked at a company in years that gives anyone access to root anywhere except your own local machine or maybe in rare cases a dev box that is destroyed and rebuilt at will.


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.


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: