help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Too fine design granularity leads to numerous macro/function/command


From: Hongyi Zhao
Subject: Re: Too fine design granularity leads to numerous macro/function/command existed in Emacs.
Date: Sat, 14 Aug 2021 08:24:32 +0800

On Sat, Aug 14, 2021 at 7:43 AM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
> [...]
> Forget about the shell script, it is just a wrapper, an
> interface for convenience. No, what it amounts to is the use
> and combination of 3 tools. (BTW I didn't get the other guy's
> suggestion to work, that which only used awk and nothing else
> - well, that might be better (I agree) but as for how
> difficult it is it is probably *more* difficult than mine
> because his requires some understanding of awk beyond the
> most basic "pile together a bunch of common tool with their
> common/very simple and familiar options".)

It's not difficult for me or maybe some others, just too lazy to think
for a while. After all, we have so many convenient uinx tools and the
excellent (but with performance penalty) pipe method at hand. Anyway,
I've presented a comparison between pure AWK and UNIX toolchains as
follows:

$ time awk 'length > max_length { max_length = length; longest_line =
$0 } END { print longest_line }' american-english-exhaustive
correspond with someone about someone or something correspond with
someone about someone or something

real    0m0.255s
user    0m0.255s
sys    0m0.003s

$ time awk '{ print length($0) " " $0; }' american-english-exhaustive
| sort -n | tail -1| cut -d ' ' -f2-
correspond with someone about someone or something correspond with
someone about someone or something

real    0m1.794s
user    0m1.853s
sys    0m0.053s

Obviously, the former is about 6 times faster than the latter.

> So again there is no shell programming, just awk (gawk(1)),
> sort(1) and tail(1).
>
>   $ awk '{ print length($0) " " $0; }' $file | sort -n | tail -1
>
> > I hope you realize the difference. And that hypothetical
> > *everyone* can also learn how to write elisp if they choose
> > so. By the way you know what is also like lego blocks?
> > Lisp functions :).
>
> True but that Lego is too difficult for a lot of people while
> everyone can pipe together three shell tools.

Hongyi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]