-
Notifications
You must be signed in to change notification settings - Fork 4
A little something to answer
Why on earth would I run AS3 shell scripts?
Bash is cool, I like it I used it for many years, it's there by default on almost all systems, it's ubiquitous and terse and basically do a hell of a good job.
But as any tools Bash can have limitations and that lead many sysadmin and other devop to use something else, something "stronger": Perl, Python, PHP, etc.
And that "something else" can be even more:
- Command Line Utilities with Node.js
- Use Haskell for shell scripting
-
Beyond Bash -- Shell scripting in a typed, OO language "Scala"
Beyond Bash slides
Ok, so we can use any other language, just because we can ?
Yes it's a bit of that, but mainly it is because of Bash shortcoming as a programming language when you want to write more than a few lines script.
And when I say "few lines" it could be anything, from a dozen lines to few hundred, the exact number does not matter, but at one moment or another you hit that limit.
Many dev hit the Bash Pitfalls and in the worst case it lead to catastrophic results like this one.
Bash is hard to test, is untyped, the syntax is a bit obscure, everything is global, everything is a string, and some basic things are just hard to get right.
For me writing bash scripts is a long and tedious process, I just wanted something easier and faster and for that I thought ActionScript 3 will be a good candidate, but not "as is".
The real trick is using AS3 with the redtamarin runtime (redshell) which include by default a POSIX layer.
Here what we get
- the AS3 language builtins
(Number, String, Date, etc.) - the POSIX layer
(stdin, stdout, fopen, rmdir, etc.) - a single component to install:
as3shebang (the redshell repackaged) - all scripts, no compilation
You don't need to write full blown programs with packages and classes and fall into the trap of being super extra verbose (like Java), you can write simple logic and functions and still feel confident maintaining scripts that are few hundred lines long (without losing your head or hair).
The goal is still the same: write scripts to automate the system, at the very worst the script can grow so big it become a program and there you have the option to compile the AS3 source code into an executable.