zsh-users
 help / color / mirror / code / Atom feed
From: "Mark J. Reed" <markjreed@gmail.com>
To: Ray Andrews <rayandrews@eastlink.ca>
Cc: zsh-users@zsh.org
Subject: Re: the splits
Date: Wed, 22 May 2024 22:31:12 -0400	[thread overview]
Message-ID: <CAA=-s3z_prOwms5hXyAL1HZaRKJR2DVAZr6urHd_9XSiGM1vzA@mail.gmail.com> (raw)
In-Reply-To: <e3e033a9-e4bc-4d00-ad26-e3ecdcdfe28d@eastlink.ca>

[-- Attachment #1: Type: text/plain, Size: 2348 bytes --]

The shell is fundamentally an interpreter; stuff written in shell can't
possibly be as fast as the code that is interpreting it. In general, native
tools are going to be more efficient.

I mean, if you had to write code in your awk program to do the parsing and
splitting that it does automatically, that would be slow, too. But you
don't, because it's it's already written for you inside the awk binary, and
in compiled C rather than interpreted awk.

In college I wrote a complete email-based helpdesk/workflow system for my
team of sysadmins, and I prided myself on doing so entirely in pure ksh,
like the Rand MH reimplementation in the back of Korn's book. I definitely
went too far in the direction of avoiding external tools, and have since
corrected.

As I see it, the shell is best utilized as commander and coordinator rather
than actually doing the hands-on nitty-gritty work; that's better delegated
to more efficient (and usually more specialized) tools. The shell can
absolutely do it, but it won't be the best application of the available
resources.

_
Mark J. Reed <markjreed@gmail.com>


On Wed, May 22, 2024 at 20:30 Ray Andrews <rayandrews@eastlink.ca> wrote:

>
>
> On 2024-05-22 17:04, Lawrence Velázquez wrote:
>
> Yes, it's quite common -- borderline universal -- to start with sed
> and pick up awk later.
>
> Good to know.  Sometimes I think I get everything wrong.
>
> You take this way too far, in my opinion.  Compared to appropriate
> external tools, zsh-heavy solutions often perform poorly and are
> more difficult to understand and maintain.  (Compare your original
> code to the awk solutions Mark and Roman offered.)  Most of your
> code would improve if you (judiciously) used more external utilities
> and less zsh.
>
> It seems 'obvious' that internal code would be faster, but I know from
> Roman's various tests over the years that it ain't necessarily so.
> Besides, at the concept level, shells are intended as glue between system
> commands and all their internal abilities are addons.  I suppose when,  as
> you say, one replaces a multi line internal construction with a single line
> construction that calls an external prog. the mere fact of many lines to
> interpret has a penalty right there that you'd not notice in a compiled
> program.
>
>
>

[-- Attachment #2: Type: text/html, Size: 3460 bytes --]

  reply	other threads:[~2024-05-23  2:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-21 17:42 Ray Andrews
2024-05-22  1:48 ` Mark J. Reed
2024-05-22  2:21   ` Ray Andrews
2024-05-22  5:56     ` Roman Perepelitsa
2024-05-22 19:25       ` Ray Andrews
2024-05-22 20:41         ` Lawrence Velázquez
2024-05-22 21:36           ` Ray Andrews
2024-05-23  0:04             ` Lawrence Velázquez
2024-05-23  0:30               ` Ray Andrews
2024-05-23  2:31                 ` Mark J. Reed [this message]
2024-05-23 12:58                   ` Ray Andrews
2024-05-22  5:57     ` Jim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAA=-s3z_prOwms5hXyAL1HZaRKJR2DVAZr6urHd_9XSiGM1vzA@mail.gmail.com' \
    --to=markjreed@gmail.com \
    --cc=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).