Hacker News new | ask | show | jobs
by forrestthewoods 702 days ago
And then the programmer had to debug a hundred line shell script and they realized it should have all been written in Python or Rust instead.

Master Foo is shorthand for Fool.

2 comments

Shell is just one way. There’s nothing that says we can’t do better than shell, but what it’s good at is saving programmer time when the need isn’t there for more, and Rust is definitely not good at that.
My rule of thumb:

    Shell: <= 5 lines
    Python: <= 500 lines
    Rust: > 500 lines
Although to be honest I'd be perfectly happy if Shell was restricted to single line commands only.

I've wasted a lot of time and energy deciphering undebuggable shell scripts that were written to "save programmer time". Not a fan.

My rule (and the code review policy I impose) emphasizes complexity instead - a 50 line shell script is great if it doesn't use if or case. (It's not so much of a strict rule as "once you're nesting conditionals, or using any shell construct that really needs a comment to explain the shell and not your code, you should probably already have switched to python." This is in parallel with "error handling in this case is critical, do you really think your bash is accurate enough?")

I wasn't the strictest reviewer (most feared, sure, but not strictest) at least partly because my personal line for "oh that bit of shell is obvious" is way too high.

Nothing is as obvious as it could be when it’s 3am and you’re debugging a production outage. :)
This rule of thumb is clearly too simplified, even as far as the definition goes.

Sometimes you just want to execute 50 lines with little logic.

Sometimes you just have some simple logic that needs to be repeated.

Sometimes that logic is complicated, sometimes it is not.

Sometimes someone writes 50 lines of simple logic. And then sometimes someone else needs to figure out why it’s not working. That person gets very cranky and wastes a lot of time when those “simple” 50 lines aren’t debuggable.

If shell scripting didn’t exist I would be totally fine with that. There are far more scripts that I wish were written in a real language than the other way around.

Master Foo long predates Python and Rust.
Masters live to be surpassed by their students. Just because something was best in class in the 80s doesn't mean it should still be used.
Very true, but also student hubris is legendary. Which is perfectly fine, as we all know successful students.

But let's not blind ourselves with the survivor bias. Not everything new and very bright will succeed the test of time.

So let's take evrything with a grain of salt, and wait until the time has choosen its champions. Which might not be the best technology as we learned