Hacker News new | ask | show | jobs
by chucknelson 3091 days ago
Would you consider non-trivial install scripts as an exception to this general rule? I mean, you wouldn't write some install script in ruby or python, right?
5 comments

I don't know why not?

At the least, rather than Bash, you might consider Perl as a default, lowest common denominator for scripts that need to run anywhere.

- It's nearly as ubiquitous as bash.

- It has approximately the same kinds of file/path operations built in.

- It has reasonably good support for strings/regexes/etc. all built-in, so you don't have to call out to tools like sed/awk/grep all the time and hope that they are available and compatible across your target platforms.

- It provides reasonably good arrays and hashes, which are horribly horrible in bash.[1]

- You can use syscalls very easily if you really need to, but usually you don't.

[1] Of course, no language can save you from the file system disaster (https://www.dwheeler.com/essays/fixing-unix-linux-filenames....), but being able to know that "foo bar" is a string instead of two array elements is a good start.

Mostly this all applies to Ruby or Python too, modulo perhaps the degree of ubiquity.

Great point about ubiquity.

Perl regexes are the best of breed that everyone else replicates — far better than “reasonably good.”

The Perl erasure in this HN thread is startling.

> "The Perl erasure in this HN thread is startling."

"Erasure" to me implies some active effort to remove Perl from discourse. I don't see anything like that here: indeed, there are a number of positive mentions, and no negative ones I see. Granted, Python and Ruby are both mentioned more often, but none of those is at Perl's expense. Am I misunderstanding what you mean by 'erasure'?

This is what Perl is designed to be. Perl unlike the others is almost certain to be on any Unix or Linux installation. Several commenters leaving out Perl in discussions of the next step up from bash scripts is truly strange.

I suppose being ignored beats the typical herp-derp anti-Perl bigotry, but I’d prefer all-around civility.

> "Several commenters leaving out Perl in discussions of the next step up from bash scripts is truly odd."

I'm having a hard time following you here. Do you think that they're doing so for any other reason that Perl is no longer their go-to tool? There are communities where Perl is still used: PostgreSQL for example uses Perl for some of its scripting, as well as its build farm tool, in particular because of its portability on older systems.

That said, from what I've seen over the past 10 years or so, Perl hasn't had much of a presence in areas where a lot of computer work in tech is being done. For example, in cloud computing, or scientific computing, or machine learning, or web frameworks. Please don't read this to mean that Perl couldn't be or isn't being used in these cases or wouldn't be a better fit. (As an aside, I think Perl missed out a lot while a large portion of the community was focused on Perl 6: there's only so much energy in a community, and that absorbed on Perl 6 wasn't focusing on evangelism. But that's not something I'm interested in litigating here.) Or that there isn't something a bit frustrating in seeing the wheel reinvented time and time again. And so many examples on the web use bash as a common denominator. This puts Perl further out of mind if it's not already part of your everyday workflow. And how many developers today have come of age without seeing Perl in their everyday environments?

Consider the current forum. What's the percentage of front-page posts that are about Perl or tools where Perl is a part of the tool chain? It would be understandable for the people who frequent HN to not view Perl as their go-to. I don't consider it uncivil for people to neglect to mention some other language when it's not something they'd actually think of reaching for. It seems the solution would be to share examples of where Perl provides advantages, both in the comments here and in submissions to HN.

Well said, perl might be the theoretically best match in specifically this problem domain but the thing is there are only so many programming languages one can learn.

If i had to choose only one of ruby/python or perl i would choose the former and it would be able to cover my base both as glue-code and for more programs. Perl would maybe make the glue code a bit easier but instead i would be much less employable and have a much harder time finding other people who can read the glue. I'm not qualified to have an opinion on perls capabilities for other programs but i'm sure there are valid reasons most people prefer other alternatives.

Perl erasure?

After using the linux command line (or its many «relatives» like cygwin, mac os, unixes) for more than 10 years now, I’ve talked to exactly one person that used perl to accomplish anything at all. He used it to edit text files, so he could have done the same in awk/sed/vim in my opinion.

I know more people who write fortran 77 than perl.

People just don’t seem to use (or like) Perl very much.

Bash has too many surprising edge cases. A lot of my install scripts have at least snippets of Perl in them. The installation/upgrade/maintenance scripts for my employer's main product is Ruby-based.

We support a lot of different OSes, and there's usually less variance between the Perl deployed on them than there is in the shell.

I would not consider those an exception, and would typically prefer to see the use of some other language. Bash is excellent at dealing with semi-structured text, and as part of a command pipeline, and if you have no alternative than to write POSIX sh, well, it exists. Bash does not have niceties like typed variables or named function arguments, and arrays are best avoided. Even parsing command line arguments is more fun in other languages.

The problem is that Bash has about the lowest barrier to entry which can be found: just dump the things you were going to type anyway into a text file and mark it executable. It's simple, and then you bloody your nose on one of Bash's many idiosyncrasies, and people will say, "Oh yes, ']' is just a required last argument to '['. You gotta watch for that." And the true Bash master knows that my rule is silly and that anything may be written in Bash.

Just...please don't.

I say please don't write any goddamned software at all.
Yes, you would write non-trivial install scripts in ruby.

https://en.m.wikipedia.org/wiki/Chef_(software)

If any of my bash scripts get long enough to where I want a reusable class, I rewrite in Ruby.
Isn't that what chef and Capistrano are at some level?