
Ask HN: What's your favorite scripting language? - jasonhansel
For programs that are too complex for bash, but still need to use shell commands and process command line input. Props if it&#x27;s included by default in major Linux distros.
======
thesuperbigfrog
Perl 5 is old, but reliable. Many people deride it as a write-only language or
executable line noise, but you can write ugly code in any language.

Perl 5 can be terse or verbose depending on your needs. It is not "one size
fits all" like Python, it fits many different sizes depending on your needs
(TIMTOWTDI).

You also have tons of modules available via CPAN, so you can get a script done
quickly.

Don't get me wrong: I use Python too, but some systems only have Python 2 and
Python's significant white space can be problematic at times. Perl is an old,
reliable camel that you can trust to get you through your problem desert
quickly, frequently before the Python caravan has started out.

~~~
jasonhansel
I also like Perl, and it's common on Linux. My issue is that perl 5 is
obsolete, and perl 6 isn't included in most distros.

~~~
thesuperbigfrog
How exactly is Perl 5 obsolete?

Perl 5.30 just came out in May. So it is still actively being maintained and
improved.

Perl 5 is included by default in most Linux distros and there are Perl
distributions available for all major operating systems and platforms. (See
[http://www.cpan.org/ports/index.html](http://www.cpan.org/ports/index.html)
for the comprehensive list.)

Obsolete != Trendy / popular

~~~
jasonhansel
I just mean that it's not the latest version of perl (now that perl 6 exists).

~~~
Grinnz
That's factually incorrect. Perl 6 also known as Raku is an unrelated
language. The latest version of Perl is 5.30.0 as shown on
[http://www.perl.org/](http://www.perl.org/).

------
joshstrange
This won't be popular but... NodeJS. It's easy to grab input from the CLI,
"shelling out" isn't really all that bad and often I want to do some "business
logic" type stuff in code really quick and I know the toolset very well. It's
much faster for me to do stuff in JS even if it might be slightly slower to
execute. Execution time is rarely what I'm optimizing for in one-off scripts
or even things I might run on a regular basis. My ability to understand the
code and make changes is valued much higher for me.

~~~
bradknowles
So, a language where the average program has something like 1900 dependencies
and sub-dependencies?

Seriously?

~~~
dang
Please don't do programming flamewars here.

[https://news.ycombinator.com/newsguidelines.html](https://news.ycombinator.com/newsguidelines.html)

------
roryrjb
My favourite scripting language is POSIX shell. It is also my most used
language in terms of different "projects" I write with it; most of these
projects are very small and focused. I feel that shell programming is very
misunderstood, this is conjectural of course, but people dismiss it out of
hand and _move on up_ to something like Python usually. I have some rules of
thumb: if you need to use a hash data type _then_ move on to something else;
if your LOC starts getting big then probably move on; always use ShellCheck.

Just like every language ever, it has some warts, and it has some features
that make it less readable and maintainable, but POSIX shell above all others
(to me) having less features actually makes it easy to avoid the pitfalls.

Of course in general I don't write massively complicated programs in POSIX
shell but that's not the point, but it can take you very far, you just have to
wrap your mind around how to implement certain things compared to other
languages. I think the time taken to do that, in the long run will pay off. Of
course if figuring it out takes too long, then move on to something else.

As for the something else Perl is a very good candidate and is influenced in
certain ways by shell programming. It just makes things easier. To me Perl is
as readable as Python. I say this as someone who uses Python and Node.js in
the day job, so in terms of LOC they are my main used languages, it's just
that POSIX shell and Perl are better suited to the tasks as stated by the
question. Also they are more portable, as in, both seem to be already present
on a lot of Unices (I have no idea about macOS which I never have to touch or
really care about).

------
cjbprime
Python's the only serious candidate that fits those requirements. Node is
popular recently but I don't think e.g. Ubuntu installs it by default, or even
has a modern version in its apt repos.

~~~
jasonhansel
IMHO Python makes it too hard to run shell commands & perform other Unix
magic. Personally, I like perl5, perl6, and tcl in these respects, but those
languages aren't especially popular now.

EDIT: also virtualenvs make my head explode. I think node/npm is currently the
best in terms of dependency management.

~~~
tomthehero
It's not hard, just too much noise.

from subprocess import run run("ls -la".split())

This is what I do to reduce noise

~~~
mindcrime
Try Groovy:

    
    
        $groovy -e ' println "ls -l /".execute().text'
    

Without the "run the example on the command line" baggage, it reduces to:

    
    
        println "ls -l".execute().text
    

assuming you just want to spit out the results. What's nice about this is that
it's ultimately just syntactic sugar over the standard Java ProcessBuilder /
Process mechanism, and it's relatively easy to support more advanced cases
like defining your own input, output, and error streams for the underlying
process, etc.

------
nextos
I loved Ruby. For me it had most of the niceties Perl had, plus a much cleaner
design.

Sadly Rails outshined plain Ruby, except in Japan.

------
uponcoffee
Lua. I never really got behind importing a package for everything, so the lack
luster package management/community doesn't bother me. The syntax is fairly
clean (its a nice break from braces and semi colons everywhere), it's easy to
extend, and it's perf under LuaJIT is hard to argue with.

------
bradknowles
My favorite scripting language is still bash.

~~~
geocrasher
Most things I need to get done can be done in bash. I know it, I am
comfortable using it, and everything I log into has it. So it's what I use.
Python is great too of course, but I don't really know it- I haven't had a
need.

I tried learning Perl once but reverted back to Bash the first thing I needed
to do something in a hurry. And, my IDE is also my interpreter. It's pretty
hard to argue with. I can just take a one-liner and throw it in a file and now
I can distribute it. It's that simple.

I suppose if I could write Python one-liners (maybe you can, I don't know...)
and it was as universally installed and configured, I'd use it- if I needed
to.

What it comes down to is this: My needs are simple, and if I can't do it in
bash, then I'm probably going about it wrong.

------
mindcrime
Groovy and/or Python depending on what I'm doing. If I want to do something
where I know using some Java library that I'm already familiar with will help,
I will definitely use Groovy.

~~~
mindcrime
I especially like the .execute() method in Groovy. Just create a String that
represents a valid command, call .execute() on it, and use the .text property
to get the output. For example:

    
    
        $groovy -e ' println "ls /".execute().text'

------
vorg
The title should be "What's your favorite Linux scripting language?"
Presumably you don't want to talk about Powershell (Windows), Javascript
(Web), or Apache Groovy (JVM).

~~~
wglb
Or, for good grief, REXX.

~~~
mindcrime
> Or, for good grief, REXX.

FWIW, Rexx is readily available on Linux.

    
    
        [prhodes@whiskey pdfs]$ dnf search rexx
        Last metadata expiration check: 0:29:48 ago on Sat 06 Jul 2019 10:50:28 PM EDT.
        ========================================================== Name & Summary Matched: rexx ==========================================================
        oorexx.x86_64 : Open Object Rexx
        oorexx.x86_64 : Open Object Rexx
        oorexx-libs.x86_64 : Libraries for ooRexx
        oorexx-libs.i686 : Libraries for ooRexx
        oorexx-libs.x86_64 : Libraries for ooRexx
        brexx.x86_64 : Classic Rexx Implementation
        oorexx-docs.x86_64 : Documentation for ooRexx
        oorexx-docs.x86_64 : Documentation for ooRexx
        rexx-imc.x86_64 : IMC's interpreter for the Rexx
        oorexx-devel.x86_64 : Header files and libraries for ooRexx
        oorexx-devel.i686 : Header files and libraries for ooRexx
        oorexx-devel.x86_64 : Header files and libraries for ooRexx

~~~
mindcrime
Addendum:

NetRexx is also open source and readily available, which is one more option
for any Rexx junkies out there.

[http://netrexx.org](http://netrexx.org)

------
childintime
This question belongs to Randall Schwarz, author of Learning Perl and
presenter of Floss Weekly. His default answer to this question, Perl, has
changed a bit recently, and might surprise.

~~~
thesuperbigfrog
Would you please provide a link to Randall's response?

I know he has taken a liking to Dart / Flutter, but I have not seen / heard
what he said.

------
zmmmmm
People definitely shouldn't overlook Groovy for this kind of scripting.
Especially if you are doing anything with the JVM it has the huge advantage of
allowing you to easily integrate your actual application code into your
scripts and call it directly, all while using a scripting language that is
more powerful, versatile and cross-platform than other obvious options such as
Python.

------
getdreambits
Python. You can do pretty much anything with it, yet it's easy to grok and
become quickly productive in.

------
semperdark
I really enjoy Wren ([https://github.com/wren-
lang/wren](https://github.com/wren-lang/wren)) and have used it for a few of
my personal programs.

------
jolmg
Haskell is pretty nice for scripting, too. It's very concise, and the strong
static type system gives assurance that the code will probably work before
even running it.

------
_448
Pike Language ([https://pike.lysator.liu.se](https://pike.lysator.liu.se))

------
chmielewski
Redlang

~~~
gulabjamyn
I've used it a bit. Care to elaborate.

I mostly use ruby, but perl5 and python will do, too.

~~~
chmielewski
It’s so much fun! Red view is my favorite scripting language

------
PaulHoule
Python. I use it on Windows and on Linux and sometimes a Mac.

------
p1p
Python as it's default on Linux.

------
im_down_w_otp
To read: AppleScript

To write: escript (part of Erlang)

------
nanomonkey
Joker (Clojure syntax written in Go).

