172 points · by Jarred · 10y ago · 109 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.
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.
I had an intern a couple years ago. Nice guy, but he didn't listen when we said "Keep this simple". We had all the data from an A/B test he ran, and we needed to do the analysis. He broke out MapReduce on EMR and all sorts of other complexity. It was a few MB of data!
After his analysis went pretty poorly, I wrote up a shell script in a few hours (sed, awk, xargs, woo) and got us the data we needed. I'd never ask someone to maintain that madness, but I was able to break it down into simple functions, piped into each other, in a single file.
I remember being younger, doing things the way I found "interesting" rather than the way I found practical. Eventually for a project or two you end up with basically nothing for all that complexity because you're focusing on the wrong things, and I learned to start putting functionality first.
http://widgetsandshit.com/teddziuba/2010/10/taco-bell-progra...
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 know this article was written over 5 years ago, but I still feel the need to say: expressions like manned up and pussied out are a huge turn-off for me. Regardless of the ideas surrounding them or the author's programming skills, the author loses a good chunk of credibility in my eyes simply by using them. Sure, it's a stylistic choice, but it's one that I feel is actively harmful to our industry, especially for those who are new to software development or interesting in learning.
So if you're reading this and you're one of those new or interested people: please don't let this turn you off from discovering and learning tools like sed or Python. One is not inferior to the other—they are simply different tools that can be used for a wide range of different things. Don't be afraid of using the "wrong" tool for the job (because even experienced developers do this sometimes), just keep on learning new tools and adding them to your own tool belt. Share your work with others, and then when someone tells you you're using the "wrong" tool, ask them to explain why and to propose alternatives. Lather, rinse, repeat.
Your comment has exactly the same effect on me that its content warns people about. I'm not interested in an industry where people engage in policing other people's tone and word choices in such a harsh way.
For every imaginary person you claim who might be turned off from the industry when reading such terms, there's some other imaginary person who feels more connected and enjoys the atmosphere better maybe because it seems more honest and less "professional".
Feeling offended, are we?
His words no more harmed you than the original article harmed the person you're replying to, and they certainly don't have the force of police backing them up.
We all have the right to express our opinions, and we all should have the expectation to be called on it when we say stupid shit (like "pussied out" or "manned up", which are sexist in a time where at least some of us would like for our industry to be more diverse and welcoming to new people, especially people who aren't especially common in our industry, like women). The article said some stupid shit, surrounded by lots of good advice. It's OK to call out the stupid shit.
Take your own advice: Don't be so sensitive.
There, it’s no longer theoretical.
What credibility is the author losing? Credibility as a programmer? Credibility as someone who can speak to you personally?
How are phrases like "manned up" or "pussied out" harmful to "our industry"? I guess I'm living under a rock, because I had no idea that we were destroying the future of programming by using words that aren't on your approved list.
Your post has absolutely nothing to do with the content, the author, or the author's intentions. It has everything to do with your own insecurities. I sincerely hope that your post was actually sarcastic and I've simply jumped to conclusions here.
I truly hate this zero-tolerance generation (my own generation), and I have never met a man I respected that didn't curse.
EDIT:
To even further help remove that big rock. Using those phrases shows a lack of tolerance for diversity, because they're willing to use phrases that other people, ala diversity (not you), find offensive.
Not at all. You can be tolerant and socialized with a particular vocabulary. Same old arguments from the same old SJWs.
I want to increase the diversity in the field of "computers". I do not dislike either phrase.
There's a huge difference between wanting more variety and political pandering. They're only tangentially related, in fact. I actually don't want to work with the kind of people who get really upset at vernacular.
http://www.theguardian.com/education/2015/dec/21/the-gay-wor...
I think they meant "manning up" signifies to act like a man, while "pussied out" is use in a derogatory fashion to signify acting like a woman (especially since the term "pussy" is often used to describe a vagina). I could be wrong, though.
However, even though I am a proponent of equality (and know quite a few developers who are women), I don't find those expressions offensive (neither do they). Also, I don't even find LGBT (I'm gay) derogatory terms offensive. Being offended is, in my opinion, always a choice.
With all this said, I do believe that such language doesn't belong here, because this type of behaviour likely has deterred some people from being more active in this industry (it's irrelevant if they're "overly sensitive" or if the author lacks decency/respect/politeness/tact/diplomacy/whatever).
>if I had only manned up and broken out sed, but I pussied out and wrote some Python
Sounds to me like the author was speaking about being tough vs being weak. It doesn't sound like he was referring to women at all. I wonder if we asked the author if he would say he was talking about how weak women are? Cause I seriously doubt that.
http://www.leancrew.com/all-this/2011/12/more-shell-less-egg...
The point of both of these posts is more that Unix style tools are extremely powerful and expressive, to the point that writing more involved code for most simple tasks (especially one-off tasks) frequently isn't worth the effort.
Complexity doesn't improve things, especially when it doesn't add value.
http://www.leancrew.com/all-this/2011/12/more-shell-less-egg/
TLDR: Donald Knuth and Doug McIlroy both wrote a program that would read a textfile, determine the n most frequently used words, and print out a sorted list of those words along with their frequencies.Knuth's was 10 pages of (very tightly/well written/literately documented) Pascal.
McIlroy's was tweetable:
tr -cs A-Za-z '\n' |
tr A-Z a-z |
sort |
uniq -c |
sort -rn |
sed ${1}q
Now... a programmer doesn't always have the luxury of working with a full suite of convenient tools well-suited to their problem domain (as UNIX shell tools were in this case), and the merits of Knuth's careful and literate approach can serve well across many domains.Still, there's something about this I think should strike any developer. It seems we talk about reuse & composability a lot more than we see it done this well, and when it is done this well it's not just elegant but kindof shocking.
(And I bet the astute FP programmers see some familiar lessons at work here...)
Some examples:
> I have far more faith in xargs than I do in Hadoop.
Me too, but those things are very far from comparable. You can only compare xargs to Hadoop only if you have a Hadoop cluster with one node and I'm really not sure why would anybody use Hadoop like that.
> I trust syslog to handle asynchronous message recording far more than I trust a message queue service.
You mean you trust the protocol that sends messages over UDP and can silently truncate or lose messages?
Standard Unix tools are nice and I always try to use them first, but for some tasks, they are just not the right tools.
Not only are Unix tools nice, they also change over time like all tools that are in heavy use...
The programmer enters the UNIX command sort -n numbers
Or... those hooves could be a couple horses. Use the standard low effort solution of stepping out of their way. Redirect the energy that would have been wasted into something actually useful.
I was once asked to create a pie chart of the number of lines of code my team wrote every week. I still haven't figured it out.
Pray you never do. This is the sort of pointless "metric" that is used by clueless management to withold a raise for the "underperforming" programmer who spends his time tracking down critical bugs with minimal code changes rather than producing volumes of new code.
Most (all) programmers I socialize with seem to get paid for results, not lines of code.
For some reason though, a few of them build things that are way more complex than they need to be for no better reason (as far as I can tell) that they like doing so.
If you're going to download millions of webpages, you'll instantly saturate your network io. yes you can split and rsync, but you'll lose proper error reporting, and ability to systematically retry, dynamic scaling, machine failure recovery, along many others that a properly designed system would provide you.
It often depends on what you require and expect from your solution.
It still complexity in the end, but you just have to factor it all in - I bet you that 90% of those "big data" problems can fit in a small server's RAM. Most of the time is just people making shit up, so they'll have a job.
Another problem you'll hit is how to make sure that the machines are saturated. How many jobs should be running at the current time depends on what's being downloaded and how much room you have to run additional downloads.
Again, it all depends on what you need from the system and how much leeway you have.
https://www.gnu.org/software/wget/manual/wget.html#Time_002d...
Generally, yes, there is some point at which wget would fall short of a purpose built tool. I think that point, though, is farther out than you're suggesting.