From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 11CAA244F0 for ; Thu, 23 May 2024 04:32:04 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1716431524; b=Ux0rN+8yUSHEYr5jhJoplQjaGn/XIvivasQiR5d59CcJNudsm0UTiOKmNsClwwz7rARN/R297l rgFIyn2ZJA2HSVD3VBv1aGdCEI4KcxtvUngV14ghmZnbQWf81qorYjIk653fcQptnO/iXCWpgt w52YepwUP31MWtQkyuGm3ZolCvlSSoMvXXUobycccHiCo1UYNdWUlFJNdxmc056MOocgW9VYZJ iwWmN6ZKB5bkou1oMbIDzQxQPfQCEw8zUUccs1A1hwEykrB4MinOLMrtaZeEMUO2EKST8/JxYu YCXNYy9ylCYahvH+4x7kY9CCjZ6/ZjBGcA3ZfvTqwijz+g==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f175.google.com) smtp.remote-ip=209.85.208.175; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1716431524; bh=kdzGdnJZRheyoNgHSFj1ASHEb6sSEdqY1thN8VBbTN8=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=kw7iA/DxG/14kNrqymQq/1PU1mpldV1jgfWzpRHOMRkr5jpz0hFEI1Y2e0KNLgpRuYoVymEQkh UOoi5sbS/VvnKqVT6Vf9eD0uf/7IRenGExF7W1Rw7c4VZx2VrtDxaj9oACXOBrtwpSionxyO4T /wzEz5T1X7KWvrFE8vUaBTTbCbVjOHiHGrM65In/kj/1w6BiEs+8mDG70KcSCQUo6nWKCd7H4i jxs+0Dh+LJufCarsmojHVxvPcb/zmDk7tIKIyOUNq3ZHZH/YohO85taPO5dTct+thPfsSeuVw5 EwmdkOmcEF7w3o4ipS1L9Ly5qOl5MpqnEC05S+gvlh7LVw==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=u52xq3ZalgJPV1Re+YOqucVEc2amf+QV3KvOTRzqwZc=; b=P7juG98l1oLRAiGtx5Y+UmqF+h QI+w+VKSuCbcEqoogx8ESQNHyM2e89e/WYvPHEC0F+3l7zt/pQNv4mrid9RU3YXJMdpZxgHjEzvFd ZiVjU2wPAUTlU6lJoPemD4sEHy/He4KbhYsQieimkcWmY6kCe2WAf6PzKkLtNnLywBG/NiVATcyJi trA1XXlgw17S2eAKN1k+z3ruKU1gXnvx19ikKhEn+GK8Ip6lVQMx5nswxeuqQxKJ/y/Wt48lGfqyL YNM2cx06Eh1jKPyqAEoikwcGnc5C7jAc20EmXqvoa5I1vnpfeOehKY24dSzhOSWpu5IKAPvbDciQS T6u4dDSw==; Received: by zero.zsh.org with local id 1s9yFQ-0008Be-Cw; Thu, 23 May 2024 02:32:04 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f175.google.com) smtp.remote-ip=209.85.208.175; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lj1-f175.google.com ([209.85.208.175]:54401) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1s9yEo-0007Uw-Ib; Thu, 23 May 2024 02:31:28 +0000 Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2e1fa824504so69118371fa.0 for ; Wed, 22 May 2024 19:31:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716431485; x=1717036285; darn=zsh.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=u52xq3ZalgJPV1Re+YOqucVEc2amf+QV3KvOTRzqwZc=; b=Y/1fH/Kgz1UAcvkIudyT0404jan8y2B/wnpw1/dJRX4yI9Z+QtDgOK2LoQfGUu8jre v63Xfgykj3sfG0KLsYxjV0EqsTiCnTTLu4vMsGar3lKNeJ0L2lJ95pytOmPXuhH5zrhg s4jdd8YS3Xi5TeRVEJjVJFXIlOwd4h9WBMn6+3NpzlzsRuzQxLwsmiWtQ/BgUti6slRU Dixff4YA1aBwZA3Rl4nB79pIfStd+pr3ZMXkn4bSuElMLpLpeMDBzhefYncmzTwB8N7m C+E0xZ8gvl1gBV+uMS385FPTAPm8jHQC55bODkZD7+qOnGx0bJEhvU+JA5DSj66fWjG2 Jjgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716431485; x=1717036285; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=u52xq3ZalgJPV1Re+YOqucVEc2amf+QV3KvOTRzqwZc=; b=MfXYopBZuYTZk0eAQvcjfKMDDztu5iIA7ljq8qngrOYRcz3MYky2N0nTkLEq23AWf0 nteUgTKUfE1Tyjz9l+6bew8yK8K2z7uG81qu5CqhrS2Qmy1bEkPj6dtKYXoDlBAXw9xd YlYAMCsP2XGZOIXRL3A/z2nV+D0VLNtTwIoBW3gQw08AN7EUfRGgaZHYj+BLMgK+hRMb eCPg1aLrcqC15jsH1E0eUiZCEoidlchUo/YnVoiJf9Sru8xaedJn5JKfTrDVsuKEWSZI LTzpetKqZz+5wilUk5wpyd908+UtT7blbO7MdjmqBfw5B7YWVIKGfc34gzWQla14ojsI ORBQ== X-Gm-Message-State: AOJu0Yyx1PuFkUnSTAVniInGMrEZoMhBL/uYdZ8/kUcZfsdwN6q1nZTC 9DE9HZyhrGuiN5b50Mg1yTKsyUJATyNI7NzSt5yRUCWfFe0l8pNnBnq4BfjOSXjBMQgA07khaE9 p8R7wQChLbVnCUJJ94gDdlVFeDik= X-Google-Smtp-Source: AGHT+IE4hel179yqeLN0+TIgjKNPqHyO/1FkiIKGrtfte4/hxOHMkVvTYWftiwzmaKIuvi2ufXojJsfv4egWzxcf+Jg= X-Received: by 2002:a05:651c:93:b0:2dc:d2c5:ed0 with SMTP id 38308e7fff4ca-2e94946b3dbmr19705971fa.12.1716431484454; Wed, 22 May 2024 19:31:24 -0700 (PDT) MIME-Version: 1.0 References: <75784205-3d78-4dd8-8474-e2eb48598307@eastlink.ca> <0b6a048b-4fbf-4162-a31a-d5f6f963d72a@eastlink.ca> <91c546cf-ec25-49ff-bd14-b6f3105e0d12@app.fastmail.com> <8b434c8d-4618-49bd-998b-72644a2727fd@eastlink.ca> <527f680d-6c71-4eb0-9586-bb4cd253b76e@app.fastmail.com> In-Reply-To: From: "Mark J. Reed" Date: Wed, 22 May 2024 22:31:12 -0400 Message-ID: Subject: Re: the splits To: Ray Andrews Cc: zsh-users@zsh.org Content-Type: multipart/alternative; boundary="000000000000e98f3e061915d8a0" X-Seq: 29972 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: --000000000000e98f3e061915d8a0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 On Wed, May 22, 2024 at 20:30 Ray Andrews wrote: > > > On 2024-05-22 17:04, Lawrence Vel=C3=A1zquez 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, a= s > you say, one replaces a multi line internal construction with a single li= ne > 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. > > > --000000000000e98f3e061915d8a0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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.=C2=A0

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

I= n college I wrote a complete email-based helpdesk/workflow system for my te= am 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 co= rrected.=C2=A0

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

_
Mark J. Re= ed <markjreed@g= mail.com>


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


On 2024-05-22 17:04, Lawrence Vel=C3=A1zquez wrote:
Yes, it's quite common -- bo=
rderline universal -- to start with sed
and pick up awk later.
Good to know.=C2=A0 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 kn= ow from Roman's various tests over the years that it ain't necessa= rily so.=C2=A0=C2=A0=C2=A0 Besides, at the concept level, shells are intende= d as glue between system commands and all their internal abilities are addons.=C2=A0 I suppose when,=C2=A0 as you say, one replaces a multi li= ne 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.=C2= =A0


--000000000000e98f3e061915d8a0--