- Joined
- Jan 28, 2018
I never really thought lines of code were a particular useful metric. At first glance it feels logical to count the lines and then make conclusions but if you really think about it, it really kinda doesn't and isn't really telling you that much about what you have in front of you. There are more useful metrics. I could write you an incredibly simple but useful 300 line sh script, or a five-liner that does something very complex but meaningless that makes a 16-core machine scream. What did the amount of lines really tell you?
I can kinda see it how it pertains to shell scripts because sh although Turing complete and therefore theoretically usable to write *anything* just doesn't really lend itself to complex programs. (Turing completeness funnily not being a very useful metric here either, for obvious reasons)
I think understandably, maintainability and usability are a better metric and there it often makes sense to switch away from posix sh. I think it's place is best for juggling strings between different software tools and parts of linux devices and filesystem and making basic boolean logic decisions, maybe very light arithmetic and string manipulation where it makes sense. The glue I talked about, gluing programs together. sh syntax is very suited for that task, although I was also partial to tcl and rexx which probably nobody knows anymore. In my experience things get chaotic when you don't draw that clear line between glue- and complex program logic and do both in the same script. That is never necessary and if you find yourself doing it it might make sense to check if you can't approach the problem from a different angle and compartmentalize it into several smaller problems.
For everything else I'd rather use a different language. Nowadays i like to use lua if I just quickly want to write a small program. It's lightweight, malleable and very fast, both in writing and in execution, especially with luajit. I also like Golang. I never really cared much for python and believe that whitespace indentation is the mark of the beast.
I can kinda see it how it pertains to shell scripts because sh although Turing complete and therefore theoretically usable to write *anything* just doesn't really lend itself to complex programs. (Turing completeness funnily not being a very useful metric here either, for obvious reasons)
I think understandably, maintainability and usability are a better metric and there it often makes sense to switch away from posix sh. I think it's place is best for juggling strings between different software tools and parts of linux devices and filesystem and making basic boolean logic decisions, maybe very light arithmetic and string manipulation where it makes sense. The glue I talked about, gluing programs together. sh syntax is very suited for that task, although I was also partial to tcl and rexx which probably nobody knows anymore. In my experience things get chaotic when you don't draw that clear line between glue- and complex program logic and do both in the same script. That is never necessary and if you find yourself doing it it might make sense to check if you can't approach the problem from a different angle and compartmentalize it into several smaller problems.
For everything else I'd rather use a different language. Nowadays i like to use lua if I just quickly want to write a small program. It's lightweight, malleable and very fast, both in writing and in execution, especially with luajit. I also like Golang. I never really cared much for python and believe that whitespace indentation is the mark of the beast.