all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Peter Neidhardt <pe.neidhardt@googlemail.com>
To: Alan Mackenzie <acm@muc.de>
Cc: van@scratch.space, eliz@gnu.org, emacs-devel@gnu.org,
	rms@gnu.org, Noam Postavsky <npostavs@gmail.com>
Subject: Re: rx.el sexp regexp syntax (WAS: Off Topic)
Date: Fri, 25 May 2018 22:35:06 +0200	[thread overview]
Message-ID: <87h8mvh3t1.fsf@gmail.com> (raw)
In-Reply-To: <20180525181710.GC4096@ACM>

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


Alan Mackenzie <acm@muc.de> writes:

> It may be part of the explanation.  But more salient, I think, is that
> hackers prefer powerful means of expression.  A single character in a
> string regexp has the power of a sexp in the corresponding rx regexp.
> Paul Graham (at http://www.paulgraham.com) has had quite a bit to say
> about this in the (distant) past.  Conciseness of expression is where
> it's at.

I think you are referring to this article:

	http://paulgraham.com/ineq.html

> Another easy test is the number of characters in a program, but this
> is not very good either; some languages (Perl, for example) just use
> shorter identifiers than others.
>
> I think a better measure of the size of a program would be the number
> of elements, where an element is anything that would be a distinct
> node if you drew a tree representing the source code. The name of a
> variable or function is an element; an integer or a floating-point
> number is an element; a segment of literal text is an element; an
> element of a pattern, or a format directive, is an element; a new
> block is an element. There are borderline cases (is -5 two elements or
> one?) but I think most of them are the same for every language, so
> they don't affect comparisons much.

With this definition, rx and regexp have the same length (except for
`eval').  "Conciseness in characters" is not what Paul Graham was
referring to.

Others might think differently, for instance those who prefer Perl to
Lisp.

In the end this is all what it boils down to: the "Unix" hacker culture
vs. the Lisp one.  The Unix tradition has long spread the use of
acronyms and and shortcuts.  Lisp on the other hand (espcecially Scheme)
put a lot of emphasis on explicit full names.

My opinion is that acronyms and shortcuts were mostly useful in the
era of teletypes and limited terminals and shells.  Now we have
completion and fuzzy-search, for which explicit full names not only make
sense but are necessary.
(It's much more intuitive to search for "string compare" in Emacs
Lisp than "str cmp" in C.)

In the end, rx vs. regexp reflects the same mindset difference.

>> Have you used rx?
>
> No.  Neither have I used Cobol (much).

Cobol is not very relevant, let's focus on the discussion here.  Try
using rx on some midly complex regular expressions, it could be
insightful for this discussion.

> You seem to want to increase the readability for beginners, for people
> who have laboriously to slog through an expression trying to make sense
> of each bit of it.  I don't think experienced regexp users have
> difficulty with the syntax.  I don't, for one.
>
> There was a time when people thought that
>
>     ADD 1 TO A GIVING B
>
> was more readable than
>
>     b = a + 1;

This is not what rx is about though.  Your example does not show any
change in structure.  rx does.

> Hexadecimal CPU codes aren't and aren't intended to be human-readable.
> String regular expressions are.

Well, "readable" is not black and white.  If we can have "more readable",
then even better.

> rx MUST be written over several lines and indented.  A string regexp, by
> contrast, usually fits onto a single line.

No, it does not have to be written over several lines.  I don't know
where you got that from.

That said, is "fitting onto a single line" necessarily good?

>> - rx does not require escaping any character with backslashes.  This
>>   is always a great source of confusion when switching from BRE to ERE,
>>   between different interpreters and when storing regexp in Lisp strings
>>   where backslashes must be escaped themselves for instance.
>
>> - Symbols with non-trivial meanings in regexp (e.g. \<, :, ^, etc.) have
>>   a trivial _English_ counterpart in rx: (respectively "word-start",
>>   nothing, "line-start" _and_ "not").
>
> The "English" counterpart used in rx is bulky and difficult to learn.
> Somehow, you've got to learn that it's "word-start" and not
> "word-beginning",

Could argue the same about "*" vs. "%".  But words that have a meaning
in a natural language are easier to remember than arbitrary symbols.

> that it's "not" and not "non", and so on.  This is more
> difficult than just learning \< and ^.  If your native language isn't
> English, it might be much more difficult.

All programmers learn some basic English, say, "if then else".  I don't
think that symbolic languages are easier to learn than natural languages
for human beings.

> Well, so far, on this list, two or three people have said they "like"
> rx.el.  Nobody has said "I'm going to be using rx.el in my programs from
> now on".

Which is precisely why we are talking about it.  To let people know,
pique their curiosity, let them try and report feedback.

"Not famous" does not equal bad quality.  That's why we need to
communicate to give good products a better chance.

--
Peter Neidhardt

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

  reply	other threads:[~2018-05-25 20:35 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-24 10:47 rx.el sexp regexp syntax (WAS: Off Topic) Noam Postavsky
2018-05-24 10:58 ` Van L
2018-05-25  2:57 ` Richard Stallman
2018-05-25  8:52   ` Pierre Neidhardt
2018-05-25 15:51     ` Alan Mackenzie
2018-05-25 16:47       ` Pierre Neidhardt
2018-05-25 18:01         ` rx.el sexp regexp syntax Eric Abrahamsen
2018-05-25 18:12           ` Pierre Neidhardt
2018-05-25 18:56             ` Eric Abrahamsen
2018-05-25 21:42               ` Clément Pit-Claudel
2018-05-25 21:51                 ` Eric Abrahamsen
2018-05-25 22:27                   ` Michael Heerdegen
2018-05-25 22:44                     ` Eric Abrahamsen
2018-05-27 20:27           ` Stefan Monnier
2018-05-28 16:37             ` Pierre Neidhardt
2018-05-28 17:15               ` Stefan Monnier
2018-05-29  3:10                 ` Richard Stallman
2018-05-29  7:28                   ` Robert Pluim
2018-05-29  8:27                 ` Philipp Stephani
2018-05-30  3:24                   ` Richard Stallman
2018-05-30  7:25                     ` Robert Pluim
2018-05-31  3:53                       ` Richard Stallman
2018-05-31  8:57                         ` Robert Pluim
2018-05-31  4:13                       ` Clément Pit-Claudel
2018-05-31 14:19                       ` Stefan Monnier
2018-05-31 15:43                         ` Drew Adams
2018-05-31 16:12                           ` João Távora
2018-05-31 16:18                             ` Robert Pluim
2018-05-31 16:48                               ` Basil L. Contovounesios
2018-05-31 17:02                                 ` Basil L. Contovounesios
2018-05-31 18:40                                   ` João Távora
2018-06-02 19:33             ` Eric Abrahamsen
2018-06-03  3:49               ` Stefan Monnier
2018-06-03  4:59                 ` Eric Abrahamsen
2018-06-03 14:51                 ` Helmut Eller
2018-06-03 15:15                   ` Eric Abrahamsen
2018-06-03 15:53                     ` Helmut Eller
2018-06-03 16:40                       ` Eric Abrahamsen
2018-06-03 19:57                       ` Drew Adams
2018-06-03 21:15                         ` Eric Abrahamsen
2018-06-03 23:23                           ` Drew Adams
2018-06-04 13:56                         ` Stefan Monnier
2018-06-04 15:24                           ` Drew Adams
2018-06-04 15:44                             ` Pierre Neidhardt
2018-05-25 18:17         ` rx.el sexp regexp syntax (WAS: Off Topic) Alan Mackenzie
2018-05-25 20:35           ` Peter Neidhardt [this message]
2018-05-25 21:01           ` rx.el sexp regexp syntax Michael Heerdegen
2018-05-25 23:32             ` Peter Neidhardt
2018-05-27 16:56       ` Tom Tromey
2018-05-27 20:16         ` Alan Mackenzie
2018-05-27 20:23       ` Stefan Monnier
2018-05-27 20:16     ` Stefan Monnier
2018-05-28 16:36       ` Pierre Neidhardt
2018-05-28 17:04         ` Stefan Monnier

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=87h8mvh3t1.fsf@gmail.com \
    --to=pe.neidhardt@googlemail.com \
    --cc=acm@muc.de \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=npostavs@gmail.com \
    --cc=rms@gnu.org \
    --cc=van@scratch.space \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.