top | item 44080668

(no title)

syene | 9 months ago

If you prefer the command-line and Unix shell, that’s one thing, but it’s no more “flexible or scriptable” than Emacs and Lisp.

Dired can filter files with regexp; you can even fall back on GNU ‘find’ (‘find-dired’). And you can execute shell commands on filtered files in Dired (‘&’), it’s like xargs without the confusing syntax—but, of course, you can just run ‘xargs’ from it, if that’s what you prefer.

A graphical file-manager is, I find, a much nicer interface for file-management than the command-line. I see all filtered files, and I can view and edit them anytime, as I please. With the command-line, it’s like I’m working with blindfolds on.

Dired can be a nice refuge even if you’re a command-line junkie, because in-spite of its own commands (abstracting the shell), you can always drop back to the shell, as you please. Funnily enough, my usage of Dired vis-à-vis the shell is kind of the inverse of what you described, I use the shell for either quick or really complicated operations and Dired for everything else—which ends up being over 95% of my use.

discuss

order

imiric|9 months ago

> If you prefer the command-line and Unix shell, that’s one thing, but it’s no more “flexible or scriptable” than Emacs and Lisp.

Preference is definitely a factor, I agree with you there. But while a programming language is obviously more flexible technically, most people don't want to write a program to perform a task on their computer.

My point is that the shell is easier to script than writing Lisp (for most people; I'm sure Lisp nerds would disagree), and is more flexible than whatever facilities dired provides out of the box. To be fair, I haven't used dired more than a few times even though Emacs is my primary editor, but even if it emulates xargs or allows you to drop down to shell commands directly, it will never be as flexible for file operations as just using the shell.

The shell is not just a file manager. That's one of its primary features, sure, but it allows you to operate on files in an infinite number of ways. This is because it exposes fairly simple primitives that allow you to combine programs in ways that even their authors hadn't anticipated. This is why the do-one-thing-well philosophy is so powerful.

The famous Knuth-McIlroy story illustrates this well. Knuth created a sophisticated program to count words, which McIlroy replicated in a one-line shell script using a few UNIX tools. Knuth's was probably more correct, better documented, and handled edge cases better, but McIlroy's obviously required far less effort and would be easier to understand and expand. I don't think any tech geek or programmer would prefer writing a program for such relatively simple tasks.

syene|9 months ago

> the shell is easier to script than writing Lisp

My points were, first, Dired is easier than the shell for 99% of file management, as it’s a graphical file manager with many advanced functions. It’s literally a graphical ‘ls -l’ that that you can freely move around, browse and act on; the same way vi was a graphical ed. And, second,

> it will never be as flexible for file operations as just using the shell

for the remaining 1% where the shell would be easier than a Dired built-in, I’d rather do them from Dired, because, being a graphical program, I have a dynamic directory listing that I can peruse as I please. And the shell is the shell, whether you open a command-line in your terminal emulator or run shell commands from Dired.

Maybe the shell’s primitives are too abstract and I prefer them abstracted behind Dired. Emacs Lisp has primitive functions, too, it’s just the higher-level functions are useful most of the time.

> Knuth created a sophisticated program to count words, which McIlroy replicated in a one-line shell script using a few UNIX tools.

Yes, now let’s see McIlroy publish the C source of the Unix built-ins he used to be fair to Knuth in that comparison, who provided the whole source of his implementation.

Composibility was an afterthought when making C, and that’s what Unix inherits; redirecting text with pipes between different programs will never be as simple and elegant as an interface that was made for composibility and extension, from the programming language up—Lisp Machines. I have scarcely found shell one-liners to be elegant in the sense they make sense at first glance—granted I’m a user, not a programmer. Lisp functions—functional programming—on the other hand, when used together, have an intuitive flow, especially in how they modify input, that’s easy to wrap my head around.

But the word runs on Unix shell, much, much more so than a functional-programming-language REPLs—“worse is better” like you said earlier.

> I don't think any tech geek or programmer would prefer writing a program for such relatively simple tasks.

Writing little Emacs Lisp functions—combining more abstract built-in Emacs Lisp functions—feels a lot like chaining shell command together, but better.