Use UNIX tools

Use UNIX tools — 2 minute read

It has been a while since my last post… So I thought I might combat the inertia with a fun project:

Presenting: video2flipbook

What it does: Downloads a video, splits it up into frames, and assembles those frames back into printable pages - which you can then print, cut, and finally glue - and voila a flip book of your favourite video!

Best of all, it does all of that using just one simple shell script.

Not my idea permalink

I cannot lay claim to the ingenuity behind this idea: This one comes right out of the hive mind of Reddit.

I quickly found that the author of that post had his code on github, which I promptly checked out, and I discovered that he had the binary executable of ImageMagick included within his project.

Reinventing the wheel? permalink

Reinventing the wheel

Why rewrite something that already exists? If there are tools out there that already get the job done reasonably well, then just use them. If one strings a bunch of them different tools together, one can create novel ideas with very little effort.

In fact, this is articulated in the UNIX philosophy

(i) Make each program do one thing well. To do a new job, build afresh rather than complicate old programs by adding new “features.”

(ii) Expect the output of every program to become the input to another, as yet unknown, program. Don’t clutter output with extraneous information. Avoid stringently columnar or binary input formats. Don’t insist on interactive input.

(iii) Design and build software, even operating systems, to be tried early, ideally within weeks. Don’t hesitate to throw away the clumsy parts and rebuild them.

(iv) Use tools in preference to unskilled help to lighten a programming task, even if you have to detour to build the tools and expect to throw some of them out after you’ve finished using them.

(Douglas McIlroy, Bell Labs, 1978)

Prescription permalink

Write small independent programs, designed such that each of them can receive input from the others’ output.

If there already is a small independent program which does this already, then better yet, the task at hand becomes much simpler: Take the outputs of each of these programs and feed them as inputs into the next one.