97 Things Every Programmer Should Know

(Chris Devlin) #1

(^176) 97 Things Every Programmer Should Know


The Unix Tools


Are Your Friends


Diomidis Spinellis


iF, ON MY WAY TO ExiLE ON A DESERT iSLAND, I had to choose between an
IDE and the Unix toolchest, I’d pick the Unix tools without a second thought.
Here are the reasons why you should become proficient with Unix tools.


First, IDEs target specific languages, while Unix tools can work with anything
that appears in textual form. In today’s development environment, where new
languages and notations spring up every year, learning to work in the Unix
way is an investment that will pay off time and again.


Furthermore, while IDEs offer just the commands their developers conceived,
with Unix tools you can perform any task you can imagine. Think of them
as (classic pre-Bionicle) Lego blocks: you create your own commands simply
by combining the small but versatile Unix tools. For instance, the following
sequence is a text-based implementation of Cunningham’s signature analysis—a
sequence of each file’s semicolons, braces, and quotes, which can reveal a lot
about the file’s contents:


for i in *.java; do
echo -n "$i: "
sed 's/[^"{};]//g' $i | tr -d '\n'
echo
done

In addition, each IDE operation you learn is specific to that given task—for
instance, adding a new step in a project’s debug build configuration. By con-
trast, sharpening your Unix tool skills makes you more effective at any task.
As an example, I’ve employed the sed tool used in the preceding command
sequence to morph a project’s build for cross-compiling on multiple processor
architectures.

Free download pdf