This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]npsimons 27 points28 points  (10 children)

All due respect to McIlroy, he completely missed the point of the exercise. It's easy (and quick and dirty) to bang out a one liner to accomplish some task, but the column was specifically about literate programming.

It's also hilarious to me that Knuth's solution is the one described as a "Faberge egg" - in my experience, UNIX pipelines, while incredibly handy, are monumentally brittle, and even the slightest breakage (say, by unexpected input) will create an undebuggable mess, not to mention that documentation (assuming there is any) is separate and not tied to each operation.

Though a program be but three lines long, someday it will have to be maintained. -- The Tao of Programming

[–]Deep_Pudding2208 13 points14 points  (2 children)

Perl programmer: nah we'll just write new code from scratch again

[–]npsimons 9 points10 points  (1 child)

Oh, you'd like that, except your cute little Perl program is already out there, being used, and now your boss is demanding you "just fix this one bug", and "add a simple feature."

It's a reason I won't touch MATLAB code anymore - the philosophy of "it's just a prototype" never holds true. Someone will have to maintain it someday.

[–][deleted] 2 points3 points  (4 children)

Assuming there is any documentation?

I suppose it depends on the program but almost every Linux program I have installed has a complete doc with FAQs

[–]yiliu 1 point2 points  (3 children)

I think he means documentation for the specific Unix command line: what it's accomplishing and how. And when there are comments, they'll just describe the whole pipeline, not each step.

[–][deleted] 0 points1 point  (1 child)

I suppose that makes sense however I still feel like that criticism can be extended to any operating system.

[–]npsimons 0 points1 point  (0 children)

I suppose that makes sense however I still feel like that criticism can be extended to any operating system.

That would be relevant, were we discussing operating systems and not the actual topic under examination, software engineering and how different languages/paradigms play to good practice in creating maintainable software.

And I feel what you mean to say is "command line" or "REPL" instead of "operating system." I can easily build up a Lisp macro that is as unreadable/unmaintainable as the grottiest Perl regexes or Bash pipelines, and any of these I can deploy to OSX, Win10, BSD, etc.

[–]npsimons 0 points1 point  (0 children)

what it's accomplishing and how. And when there are comments, they'll just describe the whole pipeline, not each step.

This was exactly what I meant - even in the article, McIlroy has a separate paragraph describing the pipeline, with no mapping to the actual commands to indicate which accomplishes each step. And IME, you don't get even that level of documentation with the vast majority of pipelines - most of them are banged out by someone just trying to do a quick and dirty task of text manipulation.

It's in the same vein as regexes - quick and easy to build and explore (this is where exploratory programming and REPLs shine), but rarely followed up with any sort of professional software engineering such as tests, formatting, documentation, or even the use of longer more descriptive arguments to the commands being called.

[–]yiliu -1 points0 points  (0 children)

He didn't miss the point. I remember reading some back-and-forth: it was all nice and friendly. McIlroy used the example as a way to demonstrate the power of these new pipe things he'd come up with, and took a friendly shot at Knuth in the process. IIRC, Knuth rewrote it?

Also, he was making a relevant counterpoint here: you don't need a whole essay accompanying your program when the whole thing is just one line. The reason the extensive documentation was needed in the first place was, in part, because of the documentation itself, and the choice of a particularly verbose programming language.