I’ve been a professional programmer since the start of this century. And I’ve been a guy who’s spent the whole century (thus far) arguing that the best tools we have for doing this job are ones from early in the last century: A unix shell (bash is our flavor of choice here), and vi (well, vim, of course these days). Give me those tools on a black screen with a white fixed-width font, and I’ll work magic (or, gobbledy-gook as my wife and kids call it).
There’s no arguing with the powerful things a smart guy with some good experience can do with that toolset. In bash, using the unix philosophy (chaining together small tools that do small things well, pipes and command-substitution), you can write a one-liner to swap the first two words on all lines that end with some pattern, for all the files under the current directory, minus ones with a certain extension, oh, and only ones that also contain some other pattern. You know, like a quick little:
sed -i "/some pattern/s/^\(\s\+\)\(\w\+\)\(\s\+\)\(\w\+\)/\1\4\3\2/" \ $(grep -l "some other pattern" $(find . -type f | grep -v .html))
You get the idea. In a GUI, where do you even start that process?
The power of bash… with its globs, its loops, command substitution – then the unix tools, the grep, sed, awk, find, sort, uniq, cut, wc, the list just goes on and on. Yeah, it takes you 5 years to think you’ve become an expert, then another 5 to realize you didn’t know anything after those first 5 years, but some day, you end up a very powerful “Jedi”, indeed.
And don’t get me started on vi (yeah, I know I mean vim, but 300 times a day i type “vi”, and i never type “vim”, so get off my back). It’s almost the same story as bash. The first month I used vi, if i ever accidentally typed a newline in a file where I didn’t want one, I’d have to quit and go back in, because I didn’t know how to delete a newline (because you have to use the Join command). And actually, even learning how to quit vi was a major accomplishment – the first several times I’d used it, I would just have to close my console window to get out!
So there’s a learning curve, for sure, but the payoff is a world of power once you get up that hill! Modal editing, regular expressions, using operators on the whole range of motion commands, macros, registers, tags, and top it off with a reasonably usable scripting language. My favorite part is probably using “hjkl” to move left-down-up-right, meaning I never have to take my hands off the home row to navigate. I like this one so much so that I delight in mocking users who still use the arrow keys by doing an exaggerated pantomime of picking my right hand up a foot off the keyboard, moving it a foot to the right, then slowly lowering it down to hit an arrow key, then repeating the process to get back to the home row, about a 6 second animation that really makes those arrow-users laugh (out of jealousy).
And maybe my favorite thing about both of these tools, bash and vi, is the customizability. My bin directory is chock full of utility scripts (along the lines of extended cd) that help scratch any itch that isn’t already there. Most of them pre-chained set of tools I chain together so much that it’s worth putting them in a script. Examples being vifind.sh – a glorified vi $(find ./ -type f $1), or newest.sh – a simple ls -1rt $@ | tail -1.
And vi – we’ve got about 5000 lines of vim script, to give us custom commands for code formatting, code generation, comment formatting, and the list goes on and on. For example, to produce our “beautiful” block comments like this, it’s a single keypress – F6:
""""""""""""""""""""""""""""" "" block comment quick key "" """"""""""""""""""""""""""""" :map :call CommentOutBlock()
(of course that command is file-type sensitive, so it inserted ” as the comment-char in a .vimrc file, versus / for java, versus # for shell, etc.)
So here I am. The year 2012, and I think I’m a master of the toolset from the previous generation. And I’m pretty happy, right? I mean, things couldn’t be better than they are, right?
I mean, I got tired of writing my java imports by hand, so I spent two days writing a vim function to read the file, check for imports that were needed, read an index (maintained by some cron-called shell scripts) and add any needed imports. And I didn’t really love the output from javac, so I can just put together a filter to reformat it with color coding… And I even added a auto-command every time I write a java file that calls a shell script that runs a syntax checker, to highlight any lines with syntax errors, to avoid having to go to the compiler window and wait for it to scan and output those errors…
As the years have gone by, I’ve spent quite a bit of time building out that toolset. Has it been worth it? If I add up the hours I’ve spent improving my tools, is the net time saved actually positive? Yes, there’s no denying how good the bash/vi toolset is for many tasks. But is it really the ultimate power? Is it the best I can be?
2013 is a year of change.