2 ms·
I didn't code it, but at a prior position part of my job was to maintain a 15,000 line sh script. (Why? Because it was part of a large enterprise product that h
by JohnFen 2y ago
I didn't code it, but at a prior position part of my job was to maintain a 15,000 line sh script. (Why? Because it was part of a large enterprise product that had to run on a wide variety of platforms. That made a compiled binary problematic for installation and configuration.)
Honestly? It was fine. It was well-written and easy to follow and maintain.
I don't think the size of the script (or source code for a proper programming language) is nearly as important as how well-written it is.
- shrimp_emoji 2y agoClarity is more important but so is scope, I think. If the script is trying to do programming language stuff (data structures, complex computation -- as opposed to just calling commands on files) in a command language (like Bash), that's bad. Use a programming language, like Python. If it's a complex program, switch from a scripting language to a compiled language (since compilers give you static type checking, which is useful in large programs).
- JohnFen 2y ago> Clarity is more important but so is scope, I think. Scope is important, yes. My point was really just that very large shell scripts can be done in a way that isn't a nightmare. I agree that if you're doing more complex stuff such as data structures and the like, using a programming language should be the default position. In this particular case, it was not possible to use Python as that doesn't exist on most the platforms that we needed to support. Using a compiled language was possible, but not desirable, as it would have greatly complicated everything. A shell script really was the least-bad option. Once the shell script was done doing its thing, the actual application was compiled (by the script), though. The script wasn't doing the main business logic, only installation and configuration.