Avoiding batch/shell scripting: a case of over-engineering?

Was not expecting to blog today but had a epiphany while in the bathroom.

I was wondering why I have a tendency to write complete application and programs rather than quick and easy scripts using Windows PowerShell, batch files and shell scripts. I questioned myself whether it is a typical case of “if all you have is a hammer, everything looks like a nail.”

Then it dawned upon me that I was trying to buy myself insurance by making them as cross-platform as possible by being as least dependent on a specific CPU architecture or operating system as possible, unless there is a good reason for that. For example, needing to access hardware through the OS or some low level Windows API or Linux system calls to get things done.

So at the very least write even the simplest thing as a Python or Perl script, instead of Bash shell script or a Windows PowerShell. We never know if one day we would be forced to change a CPU architecture or operating system that our old trusty scripts/apps/programs run on.

If I am afraid of having to move away from Windows one day, and are thus avoiding coding PowerShell or Windows Active Scripts (WSH), why not just write plain Bash shell scripts? Well, for one, old versions of Windows do not run Bash shell scripts, and it is probably a crazy idea to install Cygwin to emulate a Unix/Linux environment for the sake of running a tiny 1KB script.

Ah, then what about writing them in Java or .NET?

Well, for small scripts. I have my love-hate relationship with modern Java in recent years, with its growing Java Virtual Machine (JVM) bloat. Each time I package my app, it is a 100KB app, with 20MB of dependencies that requires a huge Java Runtime Environment despite its best attempt at slimming down with Java 9 Platform Module System (JPMS) and Native Image.

And .NET? it is pretty much a Microsoft-controlled platform. Great if one is writing for Windows. Sure, it touts the recent “cross-platform” .NET Core and .NET Standard, but let’s face it, I would hesitate to force a user to install a 200MB .NET or Mono Framework to run my tiny 100KB tool.

The tradeoff is Python and Perl are about 20MB in size, that’s about the max tradeoff I can stomach. For all other things, a compact native binary executable is probably the best option.

Sure some people would think if and when that day truly ever arrives, then we should worry and actually prepare for it. In most probable cases, such situation never happens, which is true.

Just a personal preference. But does anyone care? Great that nobody cares anyway.

Perhaps I may be forced to change my mind again soon.