From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hongyi Zhao Newsgroups: gmane.emacs.help Subject: Re: For text processing, which is more powerful, emacs or perl? Date: Sat, 9 Oct 2021 09:42:28 +0800 Message-ID: References: <87tuhr5uhl.fsf@mbork.pl> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2584"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs To: Marcin Borkowski Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 09 03:43:28 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mZ1Oa-0000S8-Sf for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 09 Oct 2021 03:43:28 +0200 Original-Received: from localhost ([::1]:37202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mZ1OY-0005z0-Mr for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 08 Oct 2021 21:43:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:32936) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mZ1Nr-0005yb-Rf for help-gnu-emacs@gnu.org; Fri, 08 Oct 2021 21:42:43 -0400 Original-Received: from mail-ua1-x92b.google.com ([2607:f8b0:4864:20::92b]:37877) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mZ1No-0007C8-TQ for help-gnu-emacs@gnu.org; Fri, 08 Oct 2021 21:42:43 -0400 Original-Received: by mail-ua1-x92b.google.com with SMTP id f4so2183563uad.4 for ; Fri, 08 Oct 2021 18:42:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CigsG737AAOvgN+Nva6xgoVrzXGt30vWvqUgnZUNJmI=; b=oqbsL81ObOPoVCvJhjxsBhguUjiwIyPZ18xh8hBEhEp2HV1O4C7rUQRivhrsrrbWXT aMN0Jxe/q5T664yYle6R44h+VRyCi1la8fGBnKUvfseszDeemB80+9wxZBgDix5i/CMz RHonIAVq9Awxf6FoB/FdyI3Zdq8WyjpglV4Ii4YaiZjx9q9lOroGKHYcvkVNxHNpRJWv zkassLhsSaFcKb2WLL+ln3Uqd/Q72bn1Rq3XTlkFFaZZMNCIxjjCfLTmA+rAf891Bfoj H0YR0Lgw6OxkJGJR39xhQmnN2Frr5FfJJATZdnKdN1/hYHBPrXTtkBElupiOVPM5VcKu +Bnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CigsG737AAOvgN+Nva6xgoVrzXGt30vWvqUgnZUNJmI=; b=UseyjGjl77TOTKxZcta1N365GQLqyat/BOO9N52lzytKDC9prB2vYJ7uQoSeHFdsWS pGtIuQjsFqYHkhmUF3ixRDuICfwdJgDzoWy0A/dA1ksspXQ4LlzMENiKpSdXhnwmTdWT tNlw9ufWvA7/cOCUqEmZZEcRX8XMfrhta3kohkv3kLJ5hggoIVvDCMIj9oQoeyI+vnCi oyaPfSUW0LxWjywcqovK9W2QTvylxJFMPsrC2il3ZnIS3y6hnnjL6hH35p8FBMsVfY6I civNL8WUuBoKHyWOfSZzbeH80FggOt5KSoK1YXGaR+YMFSLq9/99c9St+9fIE54KyLp8 ZwLw== X-Gm-Message-State: AOAM533g02xa6aJpqtIHPrdV8I9ODujZsAWDrLPjJAKHBr4q47tHOof8 2QIAe4uryhDb0srScrkrqnUpXS80SVPGKkblF2yCmeJJU8dmqmMk X-Google-Smtp-Source: ABdhPJyCV7OEbyCzJwo0RCdY89HcMDfUOKAH7/PDWIj83Hd32AU71JSneukBE+oDJtfbmMum5Xz4Gyejw7oB7gzLehg= X-Received: by 2002:a05:6130:328:: with SMTP id ay40mr7612874uab.60.1633743759580; Fri, 08 Oct 2021 18:42:39 -0700 (PDT) In-Reply-To: <87tuhr5uhl.fsf@mbork.pl> Received-SPF: pass client-ip=2607:f8b0:4864:20::92b; envelope-from=hongyi.zhao@gmail.com; helo=mail-ua1-x92b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:133658 Archived-At: On Sat, Oct 9, 2021 at 12:53 AM Marcin Borkowski wrote: > > > On 2020-12-19, at 08:43, Hongyi Zhao wrote: > > > It's well known that perl's regexp is very powerful for its capability > > of text processing. So, which is more powerful, emacs or perl, in this > > scenario? > > While others offered free jokes and musings about performance (which is > usually irrelevant unless you process multi-gigabyte files, craft > malicious regexen or do something extremely complicated), let me mention > something that wasn't mentioned in this thread (or so I think). > > Perl (or Python, or whatever "mainstream" language you take) usually > processes texts in a traditional way, using strings and regexen. Emacs, > OTOH, is a text editor, with all its concepts, so you may process texts > using buffers, which differ from strings in one important respect: the > notion of /point/. (There are other differences, too, e.g., buffers are > usually more performant.) This means that you can write code that > processes text like a human editor would do, in terms of "moving the > point a word forward, transposing two sentences, deleting from point to > the end of line" etc. > > It's much like the difference between classical graphical operations > (draw a point, a line segment between two points, a circle with given > center and radius etc.) and turtle graphics known from LOGO. > > I'm not saying that the Emacs way is definitely better - that probably > depends on the context and the nature of your text processing - but you > might find it quite intuitive and easier, both in implementing and in > studying existing code But lisp - any lisp dialects - is much more obscure than python to some extent. Of course, perl regexp and syntax is also known for being difficult to understand. > (when you e.g. need to improve something you > wrote 6 months earlier and you remember nothing about the > implementation). What is the point of having unreadable code running in > 2 milliseconds instead of clear and easy to understand code running in > even 200 milliseconds when you don't want to run it a million times, but > you need to modify it from time to time? > > Hth, > > -- > Marcin Borkowski > http://mbork.pl