by yuvipanda · 10y ago · 0 comments
As someone who has had to cleanup the messes of people who started with this and built many hundred line dense bash scripts... please do not do this.
> I made most of a SOAP server using static files and Apache's mod_rewrite. I could have done the whole thing Taco Bell style if I had only manned up and broken out sed, but I pussied out and wrote some Python.
I feel sad for whoever inherited this person's systems.
"Write code as if whoever inherits it is a psychopath with an axe who knows where you live" is something I heard pretty early on in life and it's been pretty useful.
Of course. But that's with any language that's many hundred lines of dense code.
His point is if something can be done simply with built-in proven tools, use them until you need something more.
Most experienced programmers know a little bash and enough UNIX commands to get by. This is enough to write a script that handles the happy path, but not enough to handle all error conditions correctly. There are all sorts of tricks you need to know that are commonly skipped. (Forgetting to use -print0 for example, and that's an easy one.) The resulting script is probably okay if you run it interactively and check the output but will blow up or silently do the wrong thing for unexpected input in production. To properly review a bash script for errors you need to be an expert.
By contrast, Go programmers with a few months of experience typically know all of Go.
The older tool is not necessarily better if it has lots of obscure sharp edges that most people don't learn.
Just like Excel "programs", shell scripts can be easily mined for requirements for a real program though.
No builtins were used in the example, just core utilities deployed the way they were designed.
Rewriting the wheel is completely bogus, doubly so when you ultimately make calls to those utilities, as is common when 'admins-cum-programmers' start getting their hands dirty with Python.
Not really. Just to give an example of things that new Go programmers don't know: what the limits of json serialization are, how introspection works, the funcitonality and limits of the "virtual inheritance", how the GC handles stuff like Go routines... There might be a selection bias though
$ echo 'test $(foo bar) test' | xargs echo
test $(foo bar) test
$ echo 'test $(foo bar) test' | xargs python -c 'print(len(__import__("sys").argv))'
5
the $ and ( are nothing special to xargs, nor to echo (or wget).Not to say yay xargs is always great, just that this specific counter example doesn't hold up.