• Command Languages Versus Programming Languages

    From Lawrence D'Oliveiro@21:1/5 to All on Fri Mar 29 01:14:18 2024
    XPost: comp.unix.shell, comp.unix.programmer

    At one time, we distinguished between “scripting” languages and “programming” languages. To begin with, the “scripting” languages were somehow more limited in functionality than full-fledged “programming” languages. Or they were slower, because they were interpreted.

    Then languages like Perl and Java came along: both were compiled to a
    bytecode, a sort of pseudo-machine-language, which was interpreted by
    software, not CPU hardware. Were they “scripting” or “programming” languages? Some might have classed Perl as a “scripting” language to
    begin with, but given it is must as powerful as Java, then why
    shouldn’t Java also be considered a “scripting” rather than “programming” language? And before these two, there was UCSD Pascal,
    which was probably the pioneer of this compile-to-bytecode idea.

    So that terminology for distinguishing between classes of programming
    languages became largely obsolete.

    But there is one distinction that I think is still relevant, and that
    is the one between shell/command languages and programming languages.

    In a shell language, everything you type is assumed to be a literal
    string, unless you use special substitution sequences. E.g. in a POSIX
    shell:

    ls -l thingy

    “give me information about the file/directory named ‘thingy’”, vs.

    ls -l $thingy

    “give me information about the files/directories whose names are in
    the value of the variable ‘thingy’”.

    Whereas in a programming language, everything is assumed to be a
    language construct, and every unadorned name is assumed to reference
    some value/object, so you need quote marks to demarcate literal
    strings, e.g. in Python:

    os.listdir(thingy)

    “return a list of the contents of the directory whose name is in the
    variable ‘thingy’”, vs.

    os.listdir("thingy")

    “return a list of the contents of the directory named ‘thingy’”.

    This difference in design has to do with their typical usage: most of
    the use of a shell/command language is in typing a single command at a
    time, for immediate execution. Whereas a programming language is
    typically used to construct sequences consisting of multiple lines of
    code before they are executed.

    This difference is also why attempts to use programming languages as
    though they were shell/command languages, entering and executing a
    single line of code at a time, tend to end up being more trouble than
    they are worth.

    Conversely, using shell/command languages as programming languages, by collecting multiple lines of code into shell scripts, does work, but
    only up to a point. The concept of variable substitution via string substitution tends to lead to trouble when trying to do more advanced
    data manipulations.

    So, in short, while there is some overlap in their applicable usage
    areas, they are still very much oriented to different application
    scenarios.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From candycanearter07@21:1/5 to Lawrence D'Oliveiro on Fri Mar 29 03:10:12 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Lawrence D'Oliveiro <ldo@nz.invalid> wrote at 01:14 this Friday (GMT):
    At one time, we distinguished between “scripting” languages and “programming” languages. To begin with, the “scripting” languages were
    somehow more limited in functionality than full-fledged “programming” languages. Or they were slower, because they were interpreted.

    Then languages like Perl and Java came along: both were compiled to a bytecode, a sort of pseudo-machine-language, which was interpreted by software, not CPU hardware. Were they “scripting” or “programming” languages? Some might have classed Perl as a “scripting” language to begin with, but given it is must as powerful as Java, then why
    shouldn’t Java also be considered a “scripting” rather than “programming” language? And before these two, there was UCSD Pascal, which was probably the pioneer of this compile-to-bytecode idea.

    So that terminology for distinguishing between classes of programming languages became largely obsolete.

    But there is one distinction that I think is still relevant, and that
    is the one between shell/command languages and programming languages.

    In a shell language, everything you type is assumed to be a literal
    string, unless you use special substitution sequences. E.g. in a POSIX
    shell:

    ls -l thingy

    “give me information about the file/directory named ‘thingy’”, vs.

    ls -l $thingy

    “give me information about the files/directories whose names are in
    the value of the variable ‘thingy’”.

    Whereas in a programming language, everything is assumed to be a
    language construct, and every unadorned name is assumed to reference
    some value/object, so you need quote marks to demarcate literal
    strings, e.g. in Python:

    os.listdir(thingy)

    “return a list of the contents of the directory whose name is in the variable ‘thingy’”, vs.

    os.listdir("thingy")

    “return a list of the contents of the directory named ‘thingy’”.

    This difference in design has to do with their typical usage: most of
    the use of a shell/command language is in typing a single command at a
    time, for immediate execution. Whereas a programming language is
    typically used to construct sequences consisting of multiple lines of
    code before they are executed.

    This difference is also why attempts to use programming languages as
    though they were shell/command languages, entering and executing a
    single line of code at a time, tend to end up being more trouble than
    they are worth.

    Conversely, using shell/command languages as programming languages, by collecting multiple lines of code into shell scripts, does work, but
    only up to a point. The concept of variable substitution via string substitution tends to lead to trouble when trying to do more advanced
    data manipulations.

    So, in short, while there is some overlap in their applicable usage
    areas, they are still very much oriented to different application
    scenarios.


    Interesting, I never thought of it like that.
    --
    user <candycane> is generated from /dev/urandom

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to Lawrence D'Oliveiro on Fri Mar 29 09:55:33 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 29 Mar 2024 01:14:18 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    At one time, we distinguished between “scripting” languages and >“programming” languages. To begin with, the “scripting” languages were >somehow more limited in functionality than full-fledged “programming” >languages. Or they were slower, because they were interpreted.

    Then languages like Perl and Java came along: both were compiled to a >bytecode, a sort of pseudo-machine-language, which was interpreted by >software, not CPU hardware. Were they “scripting” or “programming” >languages? Some might have classed Perl as a “scripting” language to

    My rule of thimb is that a scripting language is one whereby the source code can be run immediately by the interpreter, eg perl, python, regardless of
    what happens internally. A full fledged programming language is one that requires a compile/debug/link step first with the compiler and runtime (if required) being seperate. eg Java, C

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Josef_M=C3=B6llers?=@21:1/5 to Muttley@dastardlyhq.com on Fri Mar 29 12:10:20 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 29.03.24 10:55, Muttley@dastardlyhq.com wrote:
    On Fri, 29 Mar 2024 01:14:18 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    At one time, we distinguished between “scripting” languages and
    “programming” languages. To begin with, the “scripting” languages were
    somehow more limited in functionality than full-fledged “programming”
    languages. Or they were slower, because they were interpreted.

    Then languages like Perl and Java came along: both were compiled to a
    bytecode, a sort of pseudo-machine-language, which was interpreted by
    software, not CPU hardware. Were they “scripting” or “programming” >> languages? Some might have classed Perl as a “scripting” language to

    My rule of thimb is that a scripting language is one whereby the source code can be run immediately by the interpreter, eg perl, python, regardless of what happens internally. A full fledged programming language is one that requires a compile/debug/link step first with the compiler and runtime (if required) being seperate. eg Java, C

    I second that.

    My 2€cts,
    Josef

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Johanne Fairchild@21:1/5 to Lawrence D'Oliveiro on Fri Mar 29 08:09:46 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    At one time, we distinguished between “scripting” languages and “programming” languages. [...] But there is one distinction that I
    think is still relevant, and that is the one between shell/command
    languages and programming languages.

    [...]

    Consider looking at a shell language like a domain-specific programming language. A shell is a programming language made specifically for
    running programs. When you write a shell line, you're specifying the
    arguments of execve(2). In other words, a shell is a programming
    language made to prepare the memory to be consumed by the system in a
    specific way---execve(2). (Of course, the idea evolves and you want to
    glue programs, do variable substitution et cetera.)

    A scripting language is a programming language made for a hypothetical
    machine, not too different from a programming language made for a real
    machine, one made of hardware.

    You seem to find trouble with using a programming language in a REPL.
    It seems to contradict be the overall feeling of so many people who
    understand a lot about programming---who made all of these things
    actually work (and fun).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to Richard Kettlewell on Fri Mar 29 12:02:34 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 29 Mar 2024 11:40:03 +0000
    Richard Kettlewell <invalid@invalid.invalid> wrote:
    Muttley@dastardlyhq.com writes:
    My rule of thimb is that a scripting language is one whereby the source code >> can be run immediately by the interpreter, eg perl, python, regardless of
    what happens internally. A full fledged programming language is one that
    requires a compile/debug/link step first with the compiler and runtime (if >> required) being seperate. eg Java, C

    C can be a scripting language by that rule:

    No definition is perfect in this case, its all shades of grey.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Kettlewell@21:1/5 to Muttley@dastardlyhq.com on Fri Mar 29 11:40:03 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@dastardlyhq.com writes:
    My rule of thimb is that a scripting language is one whereby the source code can be run immediately by the interpreter, eg perl, python, regardless of what happens internally. A full fledged programming language is one that requires a compile/debug/link step first with the compiler and runtime (if required) being seperate. eg Java, C

    C can be a scripting language by that rule:

    $ cat t.c
    #!/usr/bin/tcc -run
    #include <stdio.h>

    int main(void) {
    return printf("Hello, world\n");
    }
    $ ./t.c
    Hello, world

    --
    https://www.greenend.org.uk/rjk/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Brown@21:1/5 to Lawrence D'Oliveiro on Fri Mar 29 13:47:07 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 29/03/2024 02:14, Lawrence D'Oliveiro wrote:
    At one time, we distinguished between “scripting” languages and “programming” languages. To begin with, the “scripting” languages were
    somehow more limited in functionality than full-fledged “programming” languages. Or they were slower, because they were interpreted.

    I don't think there has ever been a clear distinction.

    A "script" is usually small and often written for a particular task on a particular system, while a "program" might be bigger and more generic,
    runnable on multiple systems by multiple people. But there is no
    dividing point in the type of code, and plenty of overlap - even though
    the difference is often clear ("This is a script for making backups of
    my servers - it uses the rsync program to do the bulk of the work").

    Similarly, there are not "scripting languages" and "programming
    languages". There are languages that are more suitable for script work,
    and languages that are more suitable for programming work, and languages
    that are suitable for both.

    Then there are "interpreted" languages and "compiled" languages. As you
    say, this is not a binary distinction - there are shades between this, especially with byte compiling. Some languages, such as Python, are
    used like interpreted language (you "run" the source code) but are byte-compiled on the fly. Some, like Java, are used like compiled
    languages but generate byte code that is interpreted. Others use some byte-compiled code along with JIT machine code to blur the lines even more.

    It is fair to say that "scripts" are usually written in interpreted
    languages (or languages designed to look like they interpreted, by
    compiling or byte-compiling on the fly). "Programs" can be written in interpreted or compiled languages - there is no consensus.


    Then languages like Perl and Java came along: both were compiled to a bytecode, a sort of pseudo-machine-language, which was interpreted by software, not CPU hardware. Were they “scripting” or “programming” languages? Some might have classed Perl as a “scripting” language to begin with, but given it is must as powerful as Java, then why
    shouldn’t Java also be considered a “scripting” rather than “programming” language? And before these two, there was UCSD Pascal, which was probably the pioneer of this compile-to-bytecode idea.


    Such classification is just wrong, IMHO. You can write scripts in Perl,
    and you can write programs in Perl. "APL" is invariably (AFAIK)
    interpreted, and it is for programming rather than scripting - the
    acronym stands for "A Programming Language".

    And of course there are many computer languages whose prime purpose is
    other tasks, even though they can be used for programming - TeX and
    Postscript are examples.

    So that terminology for distinguishing between classes of programming languages became largely obsolete.

    I am not at all convinced it was ever relevant to distinguish between "scripting languages" and "programming languages". It was useful to distinguish between "interpreted" and "compiled" languages, and the
    overlap and blurring has increased there.


    But there is one distinction that I think is still relevant, and that
    is the one between shell/command languages and programming languages.

    In a shell language, everything you type is assumed to be a literal
    string, unless you use special substitution sequences. E.g. in a POSIX
    shell:

    ls -l thingy

    “give me information about the file/directory named ‘thingy’”, vs.

    ls -l $thingy

    “give me information about the files/directories whose names are in
    the value of the variable ‘thingy’”.

    Whereas in a programming language, everything is assumed to be a
    language construct, and every unadorned name is assumed to reference
    some value/object, so you need quote marks to demarcate literal
    strings, e.g. in Python:

    os.listdir(thingy)

    “return a list of the contents of the directory whose name is in the variable ‘thingy’”, vs.

    os.listdir("thingy")

    “return a list of the contents of the directory named ‘thingy’”.

    This difference in design has to do with their typical usage: most of
    the use of a shell/command language is in typing a single command at a
    time, for immediate execution. Whereas a programming language is
    typically used to construct sequences consisting of multiple lines of
    code before they are executed.

    That is arguably a useful distinction in the style of programming
    languages, and this difference makes the language more or less suited to particular tasks (such as typical short scripts).

    Again, however, there are exceptions that mean a clear binary
    distinction is not possible. Knuth did a lot of work on "literary programming", where documentation and source is combined along with
    executable code, and used such languages and tools for programs like TeX
    and Metafont. ("Linux from Scratch" is another example.)

    TCL is a language that might be considered half-way between your
    categories here.


    This difference is also why attempts to use programming languages as
    though they were shell/command languages, entering and executing a
    single line of code at a time, tend to end up being more trouble than
    they are worth.

    Conversely, using shell/command languages as programming languages, by collecting multiple lines of code into shell scripts, does work, but
    only up to a point. The concept of variable substitution via string substitution tends to lead to trouble when trying to do more advanced
    data manipulations.

    So, in short, while there is some overlap in their applicable usage
    areas, they are still very much oriented to different application
    scenarios.


    <https://en.wikipedia.org/wiki/List_of_programming_languages_by_type>
    gives something like 40 categories of programming languages, of which "scripting languages" is one type. I think any attempt at dividing up programming languages will either be so full of grey areas as to be
    almost useless, or have so many categories that it is almost useless.
    The best you can do is pick some characteristics of languages, or some
    typical use-cases of languages, and ask if any given language fits there.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to John Ames on Fri Mar 29 16:02:13 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 29 Mar 2024 08:44:54 -0700
    John Ames <commodorejohn@gmail.com> wrote:
    On Fri, 29 Mar 2024 09:55:33 -0000 (UTC)
    Muttley@dastardlyhq.com wrote:

    My rule of thimb is that a scripting language is one whereby the
    source code can be run immediately by the interpreter, eg perl,
    python, regardless of what happens internally. A full fledged
    programming language is one that requires a compile/debug/link step
    first with the compiler and runtime (if required) being seperate. eg
    Java, C

    By *that* logic, even Lisp and Forth don't count as "full-fledged
    programming languages" o_O Johanne's definition of a "scripting

    As a counter point, good luck writing a device driver in lisp. Forth maybe,
    no idea.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to John Ames on Fri Mar 29 17:12:40 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-03-29, John Ames <commodorejohn@gmail.com> wrote:
    On Fri, 29 Mar 2024 09:55:33 -0000 (UTC)
    Muttley@dastardlyhq.com wrote:

    My rule of thimb is that a scripting language is one whereby the
    source code can be run immediately by the interpreter, eg perl,
    python, regardless of what happens internally. A full fledged
    programming language is one that requires a compile/debug/link step
    first with the compiler and runtime (if required) being seperate. eg
    Java, C

    By *that* logic, even Lisp and Forth don't count as "full-fledged
    programming languages" o_O Johanne's definition of a "scripting
    language" as a DSL designed for directing the actions of the operating
    system makes much more sense, IMHO.

    Common Lisp requires the implementation to be able to read
    and execute printed expressions, without having them placed into
    a file that must be translated to a compiled file.

    The most prominent CL implementations compile every form before
    executing it, even at the interactive prompt. It's invisible to the
    user.

    Scripting doesn't mean that the commands cannot be transparently
    translated into antoher language before being executed.

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Muttley@dastardlyhq.com on Fri Mar 29 17:09:56 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-03-29, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    On Fri, 29 Mar 2024 11:40:03 +0000
    Richard Kettlewell <invalid@invalid.invalid> wrote:
    Muttley@dastardlyhq.com writes:
    My rule of thimb is that a scripting language is one whereby the source code
    can be run immediately by the interpreter, eg perl, python, regardless of >>> what happens internally. A full fledged programming language is one that >>> requires a compile/debug/link step first with the compiler and runtime (if >>> required) being seperate. eg Java, C

    C can be a scripting language by that rule:

    No definition is perfect in this case, its all shades of grey.

    Yes, a definition can be close to perfet here:

    Scripting is an activity, a use case, not a language.

    Scripting refers to executing commands which are so high level that they
    are entire applications or functional blocks within an application.
    Scripting automates applications or groups of applications.

    A language can /support/ scripting (and other paradigms).

    If a language only supports scripting well, and nothing else, then it's
    a scripting language. That's exactly the same as that a language can be functional, or multi-paradigm with support for functional programming.

    Scripting tend to have the attribute that they would never be used (and possibly could not be used) to write the functional building blocks
    which their commands execute. It's possible for an application to be
    written in a language in which it is scripted, but then that's almost
    certainly not a scripting language.

    Yes, an aspect of scripting is that scripts are taken as-is, in the representation in which they are written. Or at least, can be. If there
    is a compiling step, it is either optional, or hidden by the
    implementation. The requirement for some ahead-of-time compilation
    ritual to prepare the script for execution by translating it to a
    different file in a different format is anti-scripting, in a sense.

    The ordinary meaning of the word "script" refers to a dialog followed by
    an actor, in the same form in which it was written. The programming
    word was almost certainly coined in reference to that.

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Muttley@dastardlyhq.com on Fri Mar 29 17:13:47 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-03-29, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    On Fri, 29 Mar 2024 08:44:54 -0700
    John Ames <commodorejohn@gmail.com> wrote:
    On Fri, 29 Mar 2024 09:55:33 -0000 (UTC)
    Muttley@dastardlyhq.com wrote:

    My rule of thimb is that a scripting language is one whereby the
    source code can be run immediately by the interpreter, eg perl,
    python, regardless of what happens internally. A full fledged
    programming language is one that requires a compile/debug/link step
    first with the compiler and runtime (if required) being seperate. eg
    Java, C

    By *that* logic, even Lisp and Forth don't count as "full-fledged >>programming languages" o_O Johanne's definition of a "scripting

    As a counter point, good luck writing a device driver in lisp.

    The Lisp machines had operating systems and device drivers written in
    Lisp, interrupt-driven and all. Where do you perceive the difficulty?

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to Kaz Kylheku on Fri Mar 29 17:20:49 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 29 Mar 2024 17:13:47 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:
    On 2024-03-29, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    On Fri, 29 Mar 2024 08:44:54 -0700
    John Ames <commodorejohn@gmail.com> wrote:
    On Fri, 29 Mar 2024 09:55:33 -0000 (UTC)
    Muttley@dastardlyhq.com wrote:

    My rule of thimb is that a scripting language is one whereby the
    source code can be run immediately by the interpreter, eg perl,
    python, regardless of what happens internally. A full fledged
    programming language is one that requires a compile/debug/link step
    first with the compiler and runtime (if required) being seperate. eg
    Java, C

    By *that* logic, even Lisp and Forth don't count as "full-fledged >>>programming languages" o_O Johanne's definition of a "scripting

    As a counter point, good luck writing a device driver in lisp.

    The Lisp machines had operating systems and device drivers written in
    Lisp, interrupt-driven and all. Where do you perceive the difficulty?

    Were the mucky bits actually written in Lisp or was Lisp simply calling some routines written in assembler? In the same sense that Python doesn't actually "do" AI, its way too slow, the AI but is done in libraries written in C++ that Python simply calls.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to Kaz Kylheku on Fri Mar 29 17:18:23 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 29 Mar 2024 17:09:56 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:
    On 2024-03-29, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    On Fri, 29 Mar 2024 11:40:03 +0000
    Richard Kettlewell <invalid@invalid.invalid> wrote: >>>Muttley@dastardlyhq.com writes:
    My rule of thimb is that a scripting language is one whereby the source >code
    can be run immediately by the interpreter, eg perl, python, regardless of >>>> what happens internally. A full fledged programming language is one that >>>> requires a compile/debug/link step first with the compiler and runtime (if

    required) being seperate. eg Java, C

    C can be a scripting language by that rule:

    No definition is perfect in this case, its all shades of grey.

    Yes, a definition can be close to perfet here:

    Define perfect. Yours isn't.

    Scripting is an activity, a use case, not a language.

    So if I write a program to for example process some files in a directory by your argument its a script whether I write it in shell, python, C++ or assembler.

    Umm, no, try again.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Muttley@dastardlyhq.com on Fri Mar 29 17:25:18 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-03-29, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    On Fri, 29 Mar 2024 17:09:56 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:
    On 2024-03-29, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    On Fri, 29 Mar 2024 11:40:03 +0000
    Richard Kettlewell <invalid@invalid.invalid> wrote: >>>>Muttley@dastardlyhq.com writes:
    My rule of thimb is that a scripting language is one whereby the source >>code
    can be run immediately by the interpreter, eg perl, python, regardless of >>>>> what happens internally. A full fledged programming language is one that >>>>> requires a compile/debug/link step first with the compiler and runtime (if

    required) being seperate. eg Java, C

    C can be a scripting language by that rule:

    No definition is perfect in this case, its all shades of grey.

    Yes, a definition can be close to perfet here:

    Define perfect. Yours isn't.

    Scripting is an activity, a use case, not a language.

    So if I write a program to for example process some files in a directory by your argument its a script whether I write it in shell, python, C++ or assembler.

    I also wrote: "Scripting refers to executing commands which are so high
    level that they are entire applications or functional blocks within an application."

    If you write the program in assembler, are the instructions
    "commands which are so high level that they are entire applications
    or functional blocks within an application?"

    In the assembly language program, mulitiple instructions, irrelevant
    to the file processing task, are required just to correctly set up a
    function call with parameters and return from it.

    You're just being deliberately obtuse, not to mention snippy with the
    scissors.

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Muttley@dastardlyhq.com on Fri Mar 29 17:58:41 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-03-29, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    On Fri, 29 Mar 2024 17:13:47 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:
    On 2024-03-29, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    On Fri, 29 Mar 2024 08:44:54 -0700
    John Ames <commodorejohn@gmail.com> wrote:
    On Fri, 29 Mar 2024 09:55:33 -0000 (UTC)
    Muttley@dastardlyhq.com wrote:

    My rule of thimb is that a scripting language is one whereby the
    source code can be run immediately by the interpreter, eg perl,
    python, regardless of what happens internally. A full fledged
    programming language is one that requires a compile/debug/link step
    first with the compiler and runtime (if required) being seperate. eg >>>>> Java, C

    By *that* logic, even Lisp and Forth don't count as "full-fledged >>>>programming languages" o_O Johanne's definition of a "scripting

    As a counter point, good luck writing a device driver in lisp.

    The Lisp machines had operating systems and device drivers written in
    Lisp, interrupt-driven and all. Where do you perceive the difficulty?

    Were the mucky bits actually written in Lisp or was Lisp simply calling some routines written in assembler?

    Sorry, could you demarcate where exactly the goalposts are? Which mucky
    bits?

    In kernels written in C, there are mucky bits in assembler, like
    entry and exit into an trap/interrupt handler. You usually can't save
    the machine state in an interrupt handler without some instruction that
    is of no use in general code generation, not to mention detailed access
    to all the working registers that are not normally manipulated from the
    HLL.

    Yes, the mucky bits of communicating with the device, like passing
    frames to and from an ethernet card, would be written in Lisp.

    Assembly routines in Lisps, though not Lisp, can at least be written
    in Lisp notation and assembled within Lisp.

    In machine-compiled Lisps, there is the possibility of inline code,
    like in C or other languages.

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David W. Hodgins@21:1/5 to All on Fri Mar 29 14:51:07 2024
    XPost: comp.unix.shell, comp.unix.programmer

    The distinctions between script and programming languages made sense when
    they were first introduced. Later, the ability to compile scripts followed
    by the things like java bytecode, and then the use of microcode in to make "machine language" act like a script have made the distinction murky to
    the point of effectively being useless at the technical level.

    From the user's point of view, text files the are executed by passing them
    to an interpreter are best called scripts, and anything that goes through
    some sort of compilation to a binary file that then gets executed are best called programs.

    The terminology will continue to be used, but the distinction does not matter, except from a speed of processing difference.

    Regards, Dave Hodgins

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Christian Weisgerber@21:1/5 to Muttley@dastardlyhq.com on Fri Mar 29 18:12:35 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-03-29, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:

    As a counter point, good luck writing a device driver in lisp.

    Mmh--anybody know whether that was done for Lisp machines?

    --
    Christian "naddy" Weisgerber naddy@mips.inka.de

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Ram@21:1/5 to Johanne Fairchild on Fri Mar 29 20:07:29 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Johanne Fairchild <jfairchild@tudado.org> wrote or quoted:
    A scripting language is a programming language made for a hypothetical >machine, not too different from a programming language made for a real >machine, one made of hardware.

    C is clearly a programming language, yet its specification
    says, "The semantic descriptions in this document describe
    the behavior of an abstract machine". And you cannot buy
    this abstract C machine as a piece of hardware anywhere!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Johanne Fairchild@21:1/5 to David W. Hodgins on Fri Mar 29 16:38:48 2024
    XPost: comp.unix.shell, comp.unix.programmer

    "David W. Hodgins" <dwhodgins@nomail.afraid.org> writes:

    [...]

    The terminology will continue to be used, but the distinction does not matter, except from a speed of processing difference.

    Just to share that I, personally, don't use the distinction. For
    instance, I say that

    "the answer is %.2f\n"

    is a program that builds a string given its usual context. I say that

    awk '1; { print "" }'

    is a program to double-space a file. I haven't said ``script'' in
    years.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Janis Papanagnou on Fri Mar 29 20:59:02 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 29 Mar 2024 10:37:22 +0100, Janis Papanagnou wrote:

    Program text is initially text.[*] During parsing (either in
    an interpreted or in a compiled language) you split the text
    in tokens.

    And then, how do you interpret the tokens? In a shell language, you have
    the assumption that “everything is literal text until indicated
    otherwise”; in a programming language, you have the assumption that “everything is a program construct until indicated otherwise”.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Johanne Fairchild on Fri Mar 29 21:06:58 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 29 Mar 2024 08:09:46 -0300, Johanne Fairchild wrote:

    Consider looking at a shell language like a domain-specific programming language. A shell is a programming language made specifically for
    running programs. ... (Of course, the idea evolves and you want to
    glue programs, do variable substitution et cetera.)

    That’s the thing. The design for a “language made specifically for running programs” always seems to start with the assumption that what the user
    types is to be passed as literal text, unless special markers are present
    to indicate that they want to “glue programs, do variable substitution et cetera”. Notice your use of the term “variable substitution”, which is characteristic of a shell language: in a programming language, you don’t
    call it “substitution”, you call it “evaluation”.

    A scripting language is a programming language made for a hypothetical machine, not too different from a programming language made for a real machine, one made of hardware.

    In our CS classes we learned to think about “abstract machines”, and
    forget the distinction between “software” and “hardware”. Instead, we build layers of abstract machines, one on top of the other, getting more
    and more specialized towards the particular class of problems we want to
    solve at any particular time.

    Command languages are just another such “abstract machine”, and the
    scripts we write in them are another layer on top.

    The layering only stops when you get to a GUI; they can’t be used to build any further “machines” on top.

    You seem to find trouble with using a programming language in a REPL.

    I find REPLs annoying and inconvenient. If I want to do “scratchpad” programming, I do it in a Jupyter notebook.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to David Brown on Fri Mar 29 20:36:52 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 29 Mar 2024 13:47:07 +0100, David Brown wrote:

    TCL is a language that might be considered half-way between your
    categories here.

    TCL is definitely an interesting in-between case. In my limited use, I
    recall it was awkward with data structures, just like shell languages. So
    maybe that puts it more on the shell side than the programming side.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to David W. Hodgins on Sat Mar 30 00:14:48 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 29.03.2024 19:51, David W. Hodgins wrote:
    The distinctions between script and programming languages made sense when they were first introduced. [...]

    I abandoned the term "shell script" as soon as I got aware that
    writing a reliable piece of software with "scripts" follows the
    same engineering techniques and requires the same quality means
    as non-"scripts". (Occasionally I still use the term informally
    though I don't see any formal, technical, or practical necessity
    for any such distinction between Command and Programming Language
    as far as _programming_ is concerned.)

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Lawrence D'Oliveiro on Sat Mar 30 00:14:42 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 29.03.2024 21:59, Lawrence D'Oliveiro wrote:
    On Fri, 29 Mar 2024 10:37:22 +0100, Janis Papanagnou wrote:

    Program text is initially text.[*] During parsing (either in
    an interpreted or in a compiled language) you split the text
    in tokens.

    And then, how do you interpret the tokens?

    In an interpreter the tokens are interpreted, in a compiler
    they are subject to the parsing. (But you know that I'm sure.)

    What I was saying is that there's initially literal program text
    that is transformed to tokens in the lexical analysis, and then
    further processed.

    It was a reply on your original statement which was:
    In a shell language, everything you type is assumed to be a
    literal string, unless you use special substitution sequences.

    In a shell language, you have
    the assumption that “everything is literal text until indicated otherwise”;

    Who is that "you"? (Not me, for sure.) And where did you get that
    from?

    in a programming language, you have the assumption that
    “everything is a program construct until indicated otherwise”.

    So what is 'for i in a ; do ... ; done' then in your world?

    This is one of many basic shell constructs that I use in shell
    programming (not "shell scripting") regularly.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Janis Papanagnou on Fri Mar 29 23:51:02 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sat, 30 Mar 2024 00:14:42 +0100, Janis Papanagnou wrote:

    What I was saying is that there's initially literal program text
    that is transformed to tokens in the lexical analysis, and then
    further processed.

    In a shell language, that is “further processed” as literal text, except for any instances of substitution markers.

    in a programming language, you have the assumption that
    “everything is a program construct until indicated otherwise”.

    So what is 'for i in a ; do ... ; done' then in your world?

    “for” is just the name of a command, like any other. In POSIX, this one happens to be built into the shell; it might not in other shells.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Janis Papanagnou on Sat Mar 30 00:45:21 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 30.03.2024 00:14, Janis Papanagnou wrote:
    On 29.03.2024 21:59, Lawrence D'Oliveiro wrote:
    On Fri, 29 Mar 2024 10:37:22 +0100, Janis Papanagnou wrote:

    Program text is initially text.[*] During parsing (either in
    an interpreted or in a compiled language) you split the text
    in tokens.

    And then, how do you interpret the tokens?

    In an interpreter the tokens are interpreted, in a compiler
    they are subject to the parsing. [...]

    Just noticed that this may be misleading. Of course the shell
    does also a syntax analysis step and report syntax errors. So
    don't get me wrong here.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Keith Thompson on Sat Mar 30 01:06:35 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 30.03.2024 01:03, Keith Thompson wrote:

    Just noticed that this may be misleading. Of course the shell
    does also a syntax analysis step and report syntax errors. So
    don't get me wrong here.

    I did indeed get you wrong here (see my other followup).

    Sorry for the inconvenience!

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Johanne Fairchild@21:1/5 to Lawrence D'Oliveiro on Fri Mar 29 21:24:01 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Fri, 29 Mar 2024 08:09:46 -0300, Johanne Fairchild wrote:

    Consider looking at a shell language like a domain-specific programming
    language. A shell is a programming language made specifically for
    running programs. ... (Of course, the idea evolves and you want to
    glue programs, do variable substitution et cetera.)

    That’s the thing. The design for a “language made specifically for running
    programs” always seems to start with the assumption that what the user types is to be passed as literal text, unless special markers are present
    to indicate that they want to “glue programs, do variable substitution et cetera”. Notice your use of the term “variable substitution”, which is characteristic of a shell language: in a programming language, you don’t call it “substitution”, you call it “evaluation”.

    That's right. Substitution is evaluation; a specific form of.

    You seem to find trouble with using a programming language in a REPL.

    I find REPLs annoying and inconvenient. If I want to do “scratchpad” programming, I do it in a Jupyter notebook.

    That's something to think about. Your perception is wildly different
    from a lot of people who have thought and think very deeply about the
    whole craft.

    Consider your Lisp writing, which violates the culture of Lisp writing.
    Of course you should keep your independence, but maybe there are good
    reasons why the culture is as it is---not all culture is fashion.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Johanne Fairchild@21:1/5 to Stefan Ram on Fri Mar 29 21:17:48 2024
    XPost: comp.unix.shell, comp.unix.programmer

    ram@zedat.fu-berlin.de (Stefan Ram) writes:

    Johanne Fairchild <jfairchild@tudado.org> wrote or quoted:
    A scripting language is a programming language made for a hypothetical >>machine, not too different from a programming language made for a real >>machine, one made of hardware.

    C is clearly a programming language, yet its specification
    says, "The semantic descriptions in this document describe
    the behavior of an abstract machine". And you cannot buy
    this abstract C machine as a piece of hardware anywhere!

    Of course. :) But we both know what that means. It's abstract because
    there are so many real machines for which this abstract one is an
    abstraction of. And the real ones are the target of the language.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Lawrence D'Oliveiro on Sat Mar 30 01:30:53 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 30.03.2024 00:51, Lawrence D'Oliveiro wrote:
    On Sat, 30 Mar 2024 00:14:42 +0100, Janis Papanagnou wrote:

    So what is 'for i in a ; do ... ; done' then in your world?

    “for” is just the name of a command, like any other. In POSIX, this one happens to be built into the shell; it might not in other shells.

    'for' is a "reserved word" and part of a "compound command". It's
    part of the _shell syntax_! - You get syntax errors like

    $ for ; do : ; done
    ksh: syntax error: `;' unexpected

    And, specifically, "i in a" are *not* arguments of a 'for' command
    but also part of the control construct syntax.

    But, okay, I see where you're coming from.

    Besides the naming, keep in mind that there's a semantical differences
    between a "command", a "built-in command", and "shell construct". An
    example where you can observe operational differences is:
    '/bin/test' and '/bin/['
    'test' and '['
    '[['
    where (for example) the latter does not need quoting.

    $ x="Hello world" ; [[ $x == "Hello world" ]] ; echo $?
    0
    $ x="Hello world" ; [ $x == "Hello world" ] ; echo $?
    ksh: [: world: unknown operator
    2
    $ x="Hello world" ; [ "$x" == "Hello world" ] ; echo $?
    0

    The distinction is important since there's operational differences
    associated with these forms. The same holds for other control constructs ("built-in compound commands"), like 'case', or even simple assignments.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Keith Thompson on Sat Mar 30 01:49:20 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 30.03.2024 01:01, Keith Thompson wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    So what is 'for i in a ; do ... ; done' then in your world?

    This is one of many basic shell constructs that I use in shell
    programming (not "shell scripting") regularly.

    I use it both in shell scripting/programming and interactively.

    So do I. (To me there's no significant difference. Only that larger
    projects I do not start to develop in interactive mode, of course.)

    And the entire construct needs to be processed before the shell can
    begin to execute it. Misspelling "done" prevents the whole thing from running.

    Indeed.

    From the other posters statements I got the impression that he may
    think that control constructs is what makes the difference (between
    scripting and programming, or, command interpreters and programming
    languages; still not sure what he thinks). In a later post I read
    it as if the naming of e.g. 'for' as a "command" leads to his view.
    Anyway.

    I can see a point where people use for interactive use other shells
    than for programming; like tcsh (interactively) and bash (programming),
    because of the powerful features tcsh supports. Since the increase of interactive features supported by the shells that are typically used
    for programming I prefer to have the same shell with same syntax and
    features for both, and to be able to pass code from one application
    context to the other.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Johanne Fairchild on Sat Mar 30 01:11:31 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 29 Mar 2024 21:24:01 -0300, Johanne Fairchild wrote:

    Consider your Lisp writing, which violates the culture of Lisp writing.
    Of course you should keep your independence, but maybe there are good
    reasons why the culture is as it is---not all culture is fashion.

    Let me know what they are. The only reasons I have seen offered so far are basically just “that’s the way it’s always been done”.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Keith Thompson on Sat Mar 30 01:12:05 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 29 Mar 2024 17:08:35 -0700, Keith Thompson wrote:

    "for" is not just a command. It's a keyword, part of the shell language syntax.

    Remember, that’s only true of POSIX shells.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Lawrence D'Oliveiro on Sat Mar 30 01:21:09 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:
    On Fri, 29 Mar 2024 17:08:35 -0700, Keith Thompson wrote:

    "for" is not just a command. It's a keyword, part of the shell language
    syntax.

    Remember, that’s only true of POSIX shells

    Not necessarily. Bash is not a POSIX shell. It can be,
    but without special configuration it is not POSIX.

    ksh is as close as one might get to a true POSIX shell,
    but even ksh has extensions.

    But nitpicking aside, the context of the discussion that
    you responded to was about clearly POSIX-like shells.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Janis Papanagnou on Sat Mar 30 01:15:29 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sat, 30 Mar 2024 01:30:53 +0100, Janis Papanagnou wrote:

    Besides the naming, keep in mind that there's a semantical differences between a "command", a "built-in command", and "shell construct". An
    example where you can observe operational differences is:
    '/bin/test' and '/bin/['
    'test' and '['
    '[['
    where (for example) the latter does not need quoting.

    I know that there are places in POSIX shells where the usual rules for interpretation of special-substitution markers are altered or suspended.
    But those situations are always delimited in some special way (distinctive syntactic constructs or reserved words). Throughout the entire rest of the language, the principles I have described still apply.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David W. Hodgins@21:1/5 to Johanne Fairchild on Fri Mar 29 18:32:30 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 29 Mar 2024 15:38:48 -0400, Johanne Fairchild <jfairchild@tudado.org> wrote:
    "David W. Hodgins" <dwhodgins@nomail.afraid.org> writes:

    [...]

    The terminology will continue to be used, but the distinction does not
    matter, except from a speed of processing difference.

    Just to share that I, personally, don't use the distinction. For
    instance, I say that

    "the answer is %.2f\n"

    is a program that builds a string given its usual context. I say that

    awk '1; { print "" }'

    is a program to double-space a file. I haven't said ``script'' in
    years.

    I still refer to text files, intended to be run through an interpreter such
    as bash, as scripts, while things like c text files that must be compiled to
    an object file and then linked to be executable as programs.

    Regards, Dave Hodgins

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Ram@21:1/5 to Johanne Fairchild on Sat Mar 30 07:47:14 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Johanne Fairchild <jfairchild@tudado.org> wrote or quoted: >ram@zedat.fu-berlin.de (Stefan Ram) writes:
    Johanne Fairchild <jfairchild@tudado.org> wrote or quoted:
    A scripting language is a programming language made for a hypothetical >>>machine, not too different from a programming language made for a real >>>machine, one made of hardware.
    C is clearly a programming language, yet its specification
    says, "The semantic descriptions in this document describe
    the behavior of an abstract machine". And you cannot buy
    this abstract C machine as a piece of hardware anywhere!
    Of course. :) But we both know what that means. It's abstract because
    there are so many real machines for which this abstract one is an
    abstraction of. And the real ones are the target of the language.

    If you want to see it this way ...

    But look at Pascal, Java, or Python. They are usually compiled
    into an intermediate code (called "p-code" in the case of
    Pascal) which is then interpreted (the interpreter is called
    "JVM" in the case of Java). Yet, we think of Pascal and Java
    as programming languages and of Python as a scripting language.

    But this is actually an implementation detail: Java also can
    be compiled into machine code.

    In any case, we can write a small batch file "execute" which
    can be called for source code in any programming language and
    will execute it:

    execute Main.pas
    execute Main.java
    execute Main.py
    execute main.c
    execute main.cpp
    execute main.bas
    execute main.bat
    ...

    They all will print "Hello World". Whether the execution happens
    via translation to machine code or via interpretation by another
    program or by a mixture of both is just an implementation
    detail of "execute", that usually will not matter much for the
    programmer. And often for the same language, one is free to
    either compile it to machine language or interpret it via another
    program.

    Some language, like LISP or Python, have "eval": These languages
    still can be compiled, but they require an interpreter at run-
    time. Java often is executed by interpretation first, but when
    the "Hotspot" interpreter sees that some code is executed often,
    it will then decide /at run-time/ to compile it into actual
    machine code! (And there are Python implementations that run
    on the JVM.)

    How can such implementation details matter for the question whether
    a language is called a programming language or a scripting language,
    when the programmer often does not even need to know about them?

    Yes, there also are C interpreters IIRC, but they are rare.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to Kaz Kylheku on Sat Mar 30 10:19:46 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 29 Mar 2024 17:58:41 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:
    On 2024-03-29, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    Were the mucky bits actually written in Lisp or was Lisp simply calling some >> routines written in assembler?

    Sorry, could you demarcate where exactly the goalposts are? Which mucky
    bits?

    Oh I dunno, the parts that walk a kernel memory structure for example.

    In kernels written in C, there are mucky bits in assembler, like
    entry and exit into an trap/interrupt handler. You usually can't save

    Sure, but far less that there would be in a higher level language.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Muttley@dastardlyhq.com on Sat Mar 30 11:35:55 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 30.03.2024 11:16, Muttley@dastardlyhq.com wrote:

    I'm not being obtuse. There is no hard dividing line between scripts and programs - as I said, its shades of grey.

    The terms "script" and "scripting languages" are very fuzzy and
    just trying to be descriptive, but are effectively meaningless,
    the terms don't serve any practical purpose (in my book).

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to Kaz Kylheku on Sat Mar 30 10:16:33 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 29 Mar 2024 17:25:18 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:
    On 2024-03-29, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote: >>>Scripting is an activity, a use case, not a language.

    So if I write a program to for example process some files in a directory by >> your argument its a script whether I write it in shell, python, C++ or
    assembler.

    I also wrote: "Scripting refers to executing commands which are so high
    level that they are entire applications or functional blocks within an >application."

    So if I write:

    int main()
    {
    system("ls | wc -l");
    return 0;
    }

    Thats a script? No? What if I use popen() or execve() then? Where do you
    draw the line?

    You're just being deliberately obtuse, not to mention snippy with the >scissors.

    I'm not being obtuse. There is no hard dividing line between scripts and programs - as I said, its shades of grey.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Stefan Ram on Sat Mar 30 11:28:34 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 30.03.2024 08:47, Stefan Ram wrote:

    But look at Pascal, Java, or Python. They are usually compiled
    into an intermediate code (called "p-code" in the case of
    Pascal) which is then interpreted (the interpreter is called
    "JVM" in the case of Java). Yet, we think of Pascal and Java
    as programming languages and of Python as a scripting language.

    I never used an interpreted Pascal, nor one that produced p-code.
    (As far as memory serves it was the UCSD Pascal dialect that
    decided to use intermediate code to be interpreted.) My Pascal
    programs have always been compiled.

    And there were BASIC compilers on mainframes before the BASIC
    interpreters on PCs became popular and widespread.

    It's _the same_ language (modulo dialects), and languages are
    usually defined by their grammar and semantics and not whether
    it is interpreted/compiled or how it is run (VM or else).

    I think it's obvious that interpretation vs. compilation or any
    intermediate interpreted p-code is not an appropriate criterion
    to declare something as a "scripting" language. You can't tell
    whether a language, Pascal, BASIC, or any other language, is a
    "scripting" language by that criterion. It's also generally a
    fuzzy term; literature speaks vaguely about "typical" criteria
    but cannot pin them down. - And that term isn't even helpful in
    any way! - So why use it at all or religiously dispute about it.

    Janis


    But this is actually an implementation detail: Java also can
    be compiled into machine code.

    [...]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dmitry A. Kazakov@21:1/5 to Lawrence D'Oliveiro on Sat Mar 30 12:44:37 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-03-29 02:14, Lawrence D'Oliveiro wrote:
    At one time, we distinguished between “scripting” languages and “programming” languages. To begin with, the “scripting” languages were
    somehow more limited in functionality than full-fledged “programming” languages. Or they were slower, because they were interpreted.
    [...]

    The key difference is that a program in a scripting language need not to
    be complete or known in order to be executed.

    The limitations and ugliness of scripting languages is determined by
    this requirement, but also easiness of use.

    --
    Regards,
    Dmitry A. Kazakov
    http://www.dmitry-kazakov.de

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Christian Weisgerber@21:1/5 to Stefan Ram on Sat Mar 30 13:37:24 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-03-30, Stefan Ram <ram@zedat.fu-berlin.de> wrote:

    But look at Pascal, Java, or Python. They are usually compiled
    into an intermediate code (called "p-code" in the case of
    Pascal) which is then interpreted

    Pascal is usually compiled to machine code. UCSD Pascal with its
    intermediate p-code was an atypical case.

    --
    Christian "naddy" Weisgerber naddy@mips.inka.de

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Muttley@dastardlyhq.com on Sat Mar 30 18:10:36 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-03-30, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    On Fri, 29 Mar 2024 17:25:18 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:
    On 2024-03-29, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote: >>>>Scripting is an activity, a use case, not a language.

    So if I write a program to for example process some files in a directory by >>> your argument its a script whether I write it in shell, python, C++ or
    assembler.

    I also wrote: "Scripting refers to executing commands which are so high >>level that they are entire applications or functional blocks within an >>application."

    So if I write:

    int main()
    {
    system("ls | wc -l");
    return 0;
    }

    Thats a script?

    The "ls | wc -l" part is a script, passed off for execution to a
    language that mainly supports scripting.

    Note the non-scripting features here like "int main",
    which doesn't /do/ anything, and typically the need to compile
    and link this in order to run it.

    system() itself also isn't quite "command which is so high level that
    it's an inter application or functional block within an application";
    it's a shim whose argument might be such a command.

    No? What if I use popen() or execve() then? Where do you
    draw the line?

    If you use popen and execve, you're using more systems programming
    functional blocks that are not scripting commands.

    You're just being deliberately obtuse, not to mention snippy with the >>scissors.

    I'm not being obtuse. There is no hard dividing line between scripts and

    Right now you're doubling down on obtusity, by my estimate.

    programs - as I said, its shades of grey.

    Would you say, fifty shades?

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Muttley@dastardlyhq.com on Sat Mar 30 18:46:50 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-03-30, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    On Fri, 29 Mar 2024 17:58:41 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:
    On 2024-03-29, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    Were the mucky bits actually written in Lisp or was Lisp simply calling some
    routines written in assembler?

    Sorry, could you demarcate where exactly the goalposts are? Which mucky >>bits?

    Oh I dunno, the parts that walk a kernel memory structure for example.

    Well, since the kernel is written in Lisp, of course Lisp walks its own
    data structures.

    In a kernel, there often occur externally imposed memory structures,
    like for instance lists of entries in a DMA buffer ring above an
    ethernet device. Or banks of registers.

    The kernel-writing Lisp dialect would have provisions for dealing
    with binary structures like that.

    The following example is not from a Lisp operating system, or a Lisp
    that is known for operating system work. It's from my own application.

    It shows how in CCL (Clozure Common Lisp) (note: note the Z, not Clojure
    with a J) we can obtain a linked list C data structure and walk it,
    using some CCL-specific concepts; CCL provides #> notations for C
    types, and offsets into C structures and such.

    The GetAdaptersInfo Win32 API is called, filling the list into a stack-allocated buffer, with the help of CCL's %stack-block operator.
    We get a list of adapters, each of which is a list consisting of
    a list of the mac bytes, IP address list, name and description.

    (The information is then encrypted, hashed and tied to a software license, along with other bits of system info.)

    (defun get-network-interface-list ()
    (open-shared-library "iphlpapi.dll")
    (let ((blk-size 65536) ;; crude!
    (get-adapters-info (foreign-symbol-address "GetAdaptersInfo")))
    (if get-adapters-info
    (%stack-block ((blk blk-size))
    (rlet ((len-inout #>ULONG blk-size))
    (if (zerop (ff-call get-adapters-info :address blk
    :address len-inout
    #>DWORD))
    (loop for ptr = blk then (pref ptr #>IP_ADAPTER_INFO.Next)
    until (%null-ptr-p ptr)
    collecting
    (let ((alen (pref ptr #>IP_ADAPTER_INFO.AddressLength))
    (addr (pref ptr #>IP_ADAPTER_INFO.Address))
    (aname (pref ptr #>IP_ADAPTER_INFO.AdapterName))
    (descr (pref ptr #>IP_ADAPTER_INFO.Description))
    (iplist (pref ptr #>IP_ADAPTER_INFO.IpAddressList))
    (type (pref ptr #>IP_ADAPTER_INFO.Type)))
    (list type
    (loop for i below alen
    collecting (%get-unsigned-byte addr i)
    into mac-bytes
    finally
    (return (mac-bytes-to-string mac-bytes)))
    (get-ip-address-list iplist)
    (%get-cstring aname)
    (%get-cstring descr))))))))))

    CCL is compiled; this just turns into a machine language function
    poking at stack memory.

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Brown@21:1/5 to Muttley@dastardlyhq.com on Sat Mar 30 19:32:05 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 29/03/2024 17:02, Muttley@dastardlyhq.com wrote:
    On Fri, 29 Mar 2024 08:44:54 -0700
    John Ames <commodorejohn@gmail.com> wrote:
    On Fri, 29 Mar 2024 09:55:33 -0000 (UTC)
    Muttley@dastardlyhq.com wrote:

    My rule of thimb is that a scripting language is one whereby the
    source code can be run immediately by the interpreter, eg perl,
    python, regardless of what happens internally. A full fledged
    programming language is one that requires a compile/debug/link step
    first with the compiler and runtime (if required) being seperate. eg
    Java, C

    By *that* logic, even Lisp and Forth don't count as "full-fledged
    programming languages" o_O Johanne's definition of a "scripting

    As a counter point, good luck writing a device driver in lisp. Forth maybe, no idea.


    "Open Firmware" is an attempt to have device drivers for PCI cards (and
    other hardware) included in flash on the cards, in a processor and
    platform independent way. It uses Forth - so the device drivers are
    provided as Forth source code or byte-compiled Forth, and can then be
    executed with a simple Forth VM on the target system. They can also be
    JIT compiled for the target.

    <https://en.wikipedia.org/wiki/Open_Firmware>

    It didn't really take off very well, but certainly people have written
    device drivers in Forth.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Muttley@dastardlyhq.com on Sat Mar 30 19:27:05 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@dastardlyhq.com writes:
    On Fri, 29 Mar 2024 17:25:18 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:
    On 2024-03-29, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote: >>>>Scripting is an activity, a use case, not a language.

    So if I write a program to for example process some files in a directory by >>> your argument its a script whether I write it in shell, python, C++ or
    assembler.

    I also wrote: "Scripting refers to executing commands which are so high >>level that they are entire applications or functional blocks within an >>application."

    So if I write:

    int main()
    {
    system("ls | wc -l");
    return 0;
    }

    Thats a script? No? What if I use popen() or execve() then? Where do you
    draw the line?

    Technically, only the 'ls | wc -l' is a script. One that is passed
    to the default SHELL.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Stefan Ram on Sat Mar 30 19:25:58 2024
    XPost: comp.unix.shell, comp.unix.programmer

    ram@zedat.fu-berlin.de (Stefan Ram) writes:
    Johanne Fairchild <jfairchild@tudado.org> wrote or quoted: >>ram@zedat.fu-berlin.de (Stefan Ram) writes:
    Johanne Fairchild <jfairchild@tudado.org> wrote or quoted:
    A scripting language is a programming language made for a hypothetical >>>>machine, not too different from a programming language made for a real >>>>machine, one made of hardware.
    C is clearly a programming language, yet its specification
    says, "The semantic descriptions in this document describe
    the behavior of an abstract machine". And you cannot buy
    this abstract C machine as a piece of hardware anywhere!
    Of course. :) But we both know what that means. It's abstract because >>there are so many real machines for which this abstract one is an >>abstraction of. And the real ones are the target of the language.

    If you want to see it this way ...

    But look at Pascal, Java, or Python. They are usually compiled
    into an intermediate code (called "p-code" in the case of
    Pascal) which is then interpreted (the interpreter is called
    "JVM" in the case of Java). Yet, we think of Pascal and Java
    as programming languages and of Python as a scripting language.

    VAX Pascal (1980) was compiled directly to VAX machine code, as was
    the Pascal compiler I wrote in the graduate compiler class.

    UCSD Pascal used p-code, and IIRC Borland picked up
    on that.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to David Brown on Sat Mar 30 20:19:25 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-03-30, David Brown <david.brown@hesbynett.no> wrote: ><https://en.wikipedia.org/wiki/Open_Firmware>

    It didn't really take off very well, but certainly people have written
    device drivers in Forth.

    Unfortunately, the device tree crap from Open Firmware took off.

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Christian Weisgerber@21:1/5 to Scott Lurndal on Sat Mar 30 21:48:11 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-03-30, Scott Lurndal <scott@slp53.sl.home> wrote:

    VAX Pascal (1980) was compiled directly to VAX machine code, as was
    the Pascal compiler I wrote in the graduate compiler class.

    UCSD Pascal used p-code, and IIRC Borland picked up
    on that.

    Borland's Turbo Pascal compiled to machine code.

    --
    Christian "naddy" Weisgerber naddy@mips.inka.de

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dmitry A. Kazakov@21:1/5 to Keith Thompson on Sun Mar 31 22:06:50 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-03-30 22:28, Keith Thompson wrote:
    "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
    On 2024-03-29 02:14, Lawrence D'Oliveiro wrote:
    At one time, we distinguished between “scripting” languages and
    “programming” languages. To begin with, the “scripting” languages were
    somehow more limited in functionality than full-fledged “programming” >>> languages. Or they were slower, because they were interpreted.
    [...]

    The key difference is that a program in a scripting language need not
    to be complete or known in order to be executed.

    The limitations and ugliness of scripting languages is determined by
    this requirement, but also easiness of use.

    Perl, Python, and Lua are all considered scripting languages, and for
    all of them a syntax error at the end of a script will prevent any of it
    from being executed. The distinction is that they're not optimized for interactive use, as shell languages are (though they all can be used interactively).

    I was not talking about [syntactically] incorrect incomplete programs.
    In a scripting language an incomplete program can be correct and
    executable. E.g. I type in bash:

    ls

    This is only a part of my program. Because then I inspect the output and
    type:

    rm foo.bar

    After that I turn off the computer. My program is complete now.

    --
    Regards,
    Dmitry A. Kazakov
    http://www.dmitry-kazakov.de

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Janis Papanagnou on Sun Mar 31 20:47:29 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sat, 30 Mar 2024 00:14:42 +0100, Janis Papanagnou wrote:

    So what is 'for i in a ; do ... ; done' then in your world?

    ldo@theon:~> for i in a b c; do echo i; done
    i
    i
    i

    Like I said, in a shell language, you have the assumption that “everything
    is literal text until indicated otherwise”.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to Kaz Kylheku on Mon Apr 1 08:31:17 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sat, 30 Mar 2024 18:10:36 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:
    On 2024-03-30, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    I also wrote: "Scripting refers to executing commands which are so high >>>level that they are entire applications or functional blocks within an >>>application."

    So if I write:

    int main()
    {
    system("ls | wc -l");
    return 0;
    }

    Thats a script?

    The "ls | wc -l" part is a script, passed off for execution to a
    language that mainly supports scripting.

    So its not a script.

    Note the non-scripting features here like "int main",
    which doesn't /do/ anything, and typically the need to compile
    and link this in order to run it.

    There may be plenty of surrounding code that does do something.

    No? What if I use popen() or execve() then? Where do you
    draw the line?

    If you use popen and execve, you're using more systems programming
    functional blocks that are not scripting commands.

    They both call high level commands so is it scripting or programming?

    I'm not being obtuse. There is no hard dividing line between scripts and

    Right now you're doubling down on obtusity, by my estimate.

    Perhaps you don't understand what being obtuse actually means.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to Kaz Kylheku on Mon Apr 1 08:32:48 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sat, 30 Mar 2024 18:46:50 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:
    (defun get-network-interface-list ()
    (open-shared-library "iphlpapi.dll")
    (let ((blk-size 65536) ;; crude!
    (get-adapters-info (foreign-symbol-address "GetAdaptersInfo")))
    (if get-adapters-info
    (%stack-block ((blk blk-size))
    (rlet ((len-inout #>ULONG blk-size))
    (if (zerop (ff-call get-adapters-info :address blk
    :address len-inout
    #>DWORD))
    (loop for ptr = blk then (pref ptr #>IP_ADAPTER_INFO.Next)
    until (%null-ptr-p ptr)
    collecting
    (let ((alen (pref ptr #>IP_ADAPTER_INFO.AddressLength))
    (addr (pref ptr #>IP_ADAPTER_INFO.Address))
    (aname (pref ptr #>IP_ADAPTER_INFO.AdapterName))
    (descr (pref ptr #>IP_ADAPTER_INFO.Description))
    (iplist (pref ptr #>IP_ADAPTER_INFO.IpAddressList))

    (type (pref ptr #>IP_ADAPTER_INFO.Type)))
    (list type
    (loop for i below alen
    collecting (%get-unsigned-byte addr i)
    into mac-bytes
    finally
    (return (mac-bytes-to-string mac-bytes)))

    (get-ip-address-list iplist)
    (%get-cstring aname)
    (%get-cstring descr))))))))))

    Ugh. No wonder the language fell out of fashion. Looks like some kind of
    hacked up Basic.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Johanne Fairchild@21:1/5 to Muttley@dastardlyhq.com on Mon Apr 1 06:49:48 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@dastardlyhq.com writes:

    On Sat, 30 Mar 2024 18:46:50 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:
    (defun get-network-interface-list ()
    (open-shared-library "iphlpapi.dll")
    (let ((blk-size 65536) ;; crude!
    (get-adapters-info (foreign-symbol-address "GetAdaptersInfo")))
    (if get-adapters-info
    (%stack-block ((blk blk-size))
    (rlet ((len-inout #>ULONG blk-size))
    (if (zerop (ff-call get-adapters-info :address blk
    :address len-inout
    #>DWORD))
    (loop for ptr = blk then (pref ptr #>IP_ADAPTER_INFO.Next)
    until (%null-ptr-p ptr)
    collecting
    (let ((alen (pref ptr #>IP_ADAPTER_INFO.AddressLength)) >> (addr (pref ptr #>IP_ADAPTER_INFO.Address))
    (aname (pref ptr #>IP_ADAPTER_INFO.AdapterName)) >> (descr (pref ptr #>IP_ADAPTER_INFO.Description)) >> (iplist (pref ptr #>IP_ADAPTER_INFO.IpAddressList))

    (type (pref ptr #>IP_ADAPTER_INFO.Type)))
    (list type
    (loop for i below alen
    collecting (%get-unsigned-byte addr i)
    into mac-bytes
    finally
    (return (mac-bytes-to-string mac-bytes)))

    (get-ip-address-list iplist)
    (%get-cstring aname)
    (%get-cstring descr))))))))))

    Ugh. No wonder the language fell out of fashion. Looks like some kind of hacked up Basic.

    Fashion and intelligence have never been very good friends.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Ram@21:1/5 to Johanne Fairchild on Mon Apr 1 14:16:33 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Johanne Fairchild <jfairchild@tudado.org> wrote or quoted:
    A scripting language is a programming language made for a hypothetical >machine, not too different from a programming language made for a real >machine, one made of hardware.

    I think of the type system:

    In a non-scripting programming language, the types often are
    based on hardware, like "16 bit integer", and typing is often
    handled in a static and rather strict way. Higher types, like
    strings whose size can change at run time, are often missing.

    Scripting languages are often less strictly typed, some rely entirely
    on strings which are interpreted as integers if necessary. Often
    one has no control over the internal represention of data, so one
    cannot access a library using the ABI or write a device driver in a
    scripting language. Explicit type conversions are rarely required.

    Also, resource handling:

    Scripting languages handle the memory for you. In a scripting
    language, you cannot call "malloc" to obtain the obligation to
    free this piece of memory exactly once in the future. They are
    garbage collected.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to Johanne Fairchild on Mon Apr 1 14:47:15 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Mon, 01 Apr 2024 06:49:48 -0300
    Johanne Fairchild <jfairchild@tudado.org> wrote:
    Muttley@dastardlyhq.com writes:

    On Sat, 30 Mar 2024 18:46:50 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:
    (defun get-network-interface-list ()
    (open-shared-library "iphlpapi.dll")
    (let ((blk-size 65536) ;; crude!
    (get-adapters-info (foreign-symbol-address "GetAdaptersInfo")))
    (if get-adapters-info
    (%stack-block ((blk blk-size))
    (rlet ((len-inout #>ULONG blk-size))
    (if (zerop (ff-call get-adapters-info :address blk
    :address len-inout
    #>DWORD))
    (loop for ptr = blk then (pref ptr #>IP_ADAPTER_INFO.Next)
    until (%null-ptr-p ptr)
    collecting
    (let ((alen (pref ptr #>IP_ADAPTER_INFO.AddressLength))

    (addr (pref ptr #>IP_ADAPTER_INFO.Address))
    (aname (pref ptr #>IP_ADAPTER_INFO.AdapterName)) >>> (descr (pref ptr #>IP_ADAPTER_INFO.Description)) >>> (iplist (pref ptr >#>IP_ADAPTER_INFO.IpAddressList))

    (type (pref ptr #>IP_ADAPTER_INFO.Type)))
    (list type
    (loop for i below alen
    collecting (%get-unsigned-byte addr i) >>> into mac-bytes
    finally
    (return (mac-bytes-to-string >mac-bytes)))

    (get-ip-address-list iplist)
    (%get-cstring aname)
    (%get-cstring descr))))))))))

    Ugh. No wonder the language fell out of fashion. Looks like some kind of
    hacked up Basic.

    Fashion and intelligence have never been very good friends.

    Readability of the flow of control matters. God knows whats going on with
    all those nested statements.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andreas Eder@21:1/5 to Muttley@dastardlyhq.com on Mon Apr 1 17:11:31 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fr 29 Mär 2024 at 17:20, Muttley@dastardlyhq.com wrote:

    On Fri, 29 Mar 2024 17:13:47 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:
    On 2024-03-29, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    On Fri, 29 Mar 2024 08:44:54 -0700
    John Ames <commodorejohn@gmail.com> wrote:
    On Fri, 29 Mar 2024 09:55:33 -0000 (UTC)
    Muttley@dastardlyhq.com wrote:

    My rule of thimb is that a scripting language is one whereby the
    source code can be run immediately by the interpreter, eg perl,
    python, regardless of what happens internally. A full fledged
    programming language is one that requires a compile/debug/link step
    first with the compiler and runtime (if required) being seperate. eg >>>>> Java, C

    By *that* logic, even Lisp and Forth don't count as "full-fledged >>>>programming languages" o_O Johanne's definition of a "scripting

    As a counter point, good luck writing a device driver in lisp.

    The Lisp machines had operating systems and device drivers written in
    Lisp, interrupt-driven and all. Where do you perceive the difficulty?

    Were the mucky bits actually written in Lisp or was Lisp simply calling some routines written in assembler? In the same sense that Python doesn't actually "do" AI, its way too slow, the AI but is done in libraries written in C++ that
    Python simply calls.

    It was Lisp all the way down. Even the machine langauge was quite lispy
    simply because the processor was a lisp chip.
    Go read about it - there is lots of info about it on the net and if you
    want, you can even run the lisp machines (several implementations) on an emulator.

    'Andreas
    --
    ceterum censeo redmondinem esse delendam

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Muttley@dastardlyhq.com on Mon Apr 1 18:25:54 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-04-01, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    On Mon, 01 Apr 2024 06:49:48 -0300
    Johanne Fairchild <jfairchild@tudado.org> wrote:
    Muttley@dastardlyhq.com writes:

    On Sat, 30 Mar 2024 18:46:50 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:
    (defun get-network-interface-list ()
    (open-shared-library "iphlpapi.dll")
    (let ((blk-size 65536) ;; crude!
    (get-adapters-info (foreign-symbol-address "GetAdaptersInfo"))) >>>> (if get-adapters-info
    (%stack-block ((blk blk-size))
    (rlet ((len-inout #>ULONG blk-size))
    (if (zerop (ff-call get-adapters-info :address blk
    :address len-inout
    #>DWORD))
    (loop for ptr = blk then (pref ptr #>IP_ADAPTER_INFO.Next) >>>> until (%null-ptr-p ptr)
    collecting
    (let ((alen (pref ptr #>IP_ADAPTER_INFO.AddressLength))

    (addr (pref ptr #>IP_ADAPTER_INFO.Address)) >>>> (aname (pref ptr #>IP_ADAPTER_INFO.AdapterName))
    (descr (pref ptr #>IP_ADAPTER_INFO.Description))
    (iplist (pref ptr >>#>IP_ADAPTER_INFO.IpAddressList))

    (type (pref ptr #>IP_ADAPTER_INFO.Type)))
    (list type
    (loop for i below alen
    collecting (%get-unsigned-byte addr i) >>>> into mac-bytes
    finally
    (return (mac-bytes-to-string >>mac-bytes)))

    (get-ip-address-list iplist)
    (%get-cstring aname)
    (%get-cstring descr))))))))))

    Ugh. No wonder the language fell out of fashion. Looks like some kind of >>> hacked up Basic.

    Fashion and intelligence have never been very good friends.

    Readability of the flow of control matters. God knows whats going on with
    all those nested statements.

    I didn't spend a lot of time on that code in the first place, and have
    not looked it in over ten years; yet it's trivially easily readable to me.

    Anyway, it's in a high level language, yet following a linked list of
    structs obtained from a Win32 function, which the code fetches into
    a buffer allocated efficiently on the native stack.

    The whole thing is compiled into native code.

    CCL's primitives for accessing the C stuff aren't pretty, but they are
    helpful. It's nice that it has the parsed information about the struct
    offsets, like #>IP_ADAPTER_INFO.AdapterName. I didn't have to define
    that anywhere. I remember it was pretty easy to figure the primtiies
    out from CCL's reference documentation. Easy to write, easy to read
    a decade later.

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to John Ames on Mon Apr 1 19:42:05 2024
    XPost: comp.unix.shell, comp.unix.programmer

    John Ames <commodorejohn@gmail.com> writes:
    On 1 Apr 2024 14:16:33 GMT
    ram@zedat.fu-berlin.de (Stefan Ram) wrote:


    Scripting languages handle the memory for you. In a scripting
    language, you cannot call "malloc" to obtain the obligation to
    free this piece of memory exactly once in the future. They are
    garbage collected.

    And while this is pretty true of scripting languages, it doesn't make
    for a good point-of-contrast with "non-scripting" languages; *piles* of
    them include support for automatic memory management, and some (outside
    of the C family) don't even include facilities for doing it "by hand."

    Indeed, and if you use the set (resources) rather than a member
    of the set (memory), even scripting languages allocate resources and
    must free them. E.g. temporary files, with some garbage collection
    (/tmp cleaners).

    Why is it important that there be a distinction between "scripting"
    and "non-scripting" languages at all?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Ram@21:1/5 to John Ames on Mon Apr 1 21:13:42 2024
    XPost: comp.unix.shell, comp.unix.programmer

    John Ames <commodorejohn@gmail.com> wrote or quoted:
    And, in fact, C actually does one specific bit of automatic memory
    management itself - the stack, which may or may not even *be* a true
    hardware stack (depending on the architecture,) and which is handled in
    an entirely transparent fashion* by compiler-generated entry/exit code >generated by the compiler for each function.

    This stack "management" is "limited" in C:

    |Unfortunately, the notion of stack overflow is not mentioned
    |by the standard or the standard’s rationale at all. This is
    |very troublesome, as for most actual implementations stack
    |overflow is a real problem.
    ...
    |in a real C implementation, a call like f(10000000) will not
    |return 10000000, but instead will crash with a message like
    |"segmentation fault". Furthermore, stack overflow does not
    |necessarily have to result in a crash with a nice error
    |message, but might also overwrite non-stack parts of the
    |memory (possibly putting the address of virus code there).
    |Stack overflow even can occur without function calls. For
    |example, the program int main(void) { int a[10000000]; }
    ...
    "Subtleties of the ANSI/ISO C standard" (2012); Robbert
    Krebbers, Freek Wiedijk; Radboud University Nijmegen.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Muttley on Mon Apr 1 21:41:56 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Mon, 1 Apr 2024 08:32:48 -0000 (UTC), Muttley wrote:

    Ugh. No wonder the language fell out of fashion. Looks like some kind of hacked up Basic.

    The BASIC comparison is just ignorant, but a lot of the ugliness comes
    from the traditional “parenthesis pileup” layout. I prefer to write my
    LISP code in a different way.

    One of the key things about LISP is homoiconicity. That is, the language explicitly includes an AST representation made out of objects defined in
    the language itself. This allows for a robust token-based macro facility,
    for example. Contrast this with the fiddliness and fragility of #define in
    C and C++, for example.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Stefan Ram on Mon Apr 1 21:43:23 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 1 Apr 2024 14:16:33 GMT, Stefan Ram wrote:

    Scripting languages handle the memory for you.

    If I were to link compiled C code against a runtime that includes a
    garbage collector, would that turn it into a “scripting” language?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to John Ames on Mon Apr 1 22:40:31 2024
    XPost: comp.unix.shell, comp.unix.programmer

    John Ames <commodorejohn@gmail.com> writes:
    On 1 Apr 2024 21:13:42 GMT
    ram@zedat.fu-berlin.de (Stefan Ram) wrote:

    This stack "management" is "limited" in C:

    True enough, although as noted that's an implementation issue as much
    as it is a limitation of the language spec. (I'm not sure how you could >handle that in a way that's both robust and reasonably C-ish...)

    Modern (64-bit) linux systems leave large buffer zones (unmapped addresses)
    on either side of the stack; a stack overflow or underflow will
    immediately fault if the RLIMIT_STACK value is exceeded.


    |Stack overflow even can occur without function calls. For
    |example, the program int main(void) { int a[10000000]; }

    POSIX and linux systems support limiting the amount of address
    space an individual users stack can consume. 8MB is the default
    on many linux distributions.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to John Ames on Tue Apr 2 00:19:44 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Mon, 1 Apr 2024 13:44:57 -0700, John Ames wrote:

    ... the stack, which may or may not even *be* a true
    hardware stack (depending on the architecture,) ...

    This reinforces the point I made elsewhere about abstract machines being layered on top of other abstract machines, such that the line between “hardware” and “software” really becomes arbitrary.

    What constitutes a “true” hardware stack? Does it have to be a reserved area, like page 1 on the 6502 family? Does the use of a particular
    register as a stack pointer have to be defined by the instruction set, or
    just by the ABI, as in many RISC architectures?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Johanne Fairchild on Tue Apr 2 00:57:23 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Mon, 01 Apr 2024 21:26:19 -0300, Johanne Fairchild wrote:

    reading that indentation.

    If indentation is good, more indentation should be better.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Johanne Fairchild@21:1/5 to Muttley@dastardlyhq.com on Mon Apr 1 21:26:19 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@dastardlyhq.com writes:

    [...]

    Readability of the flow of control matters. God knows whats going on with
    all those nested statements.

    You don't seem to much of a Lisp writer. Lisp writers have no problem
    reading that indentation.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Scott Lurndal on Tue Apr 2 00:20:31 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Mon, 01 Apr 2024 19:42:05 GMT, Scott Lurndal wrote:

    Why is it important that there be a distinction between "scripting" and "non-scripting" languages at all?

    Particularly since the point of this thread is that there isn’t an
    important one.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Keith Thompson on Tue Apr 2 03:01:42 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Mon, 01 Apr 2024 18:18:32 -0700, Keith Thompson wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Mon, 01 Apr 2024 21:26:19 -0300, Johanne Fairchild wrote:

    reading that indentation.

    If indentation is good, more indentation should be better.

    No.

    Don’t quote so deeply, then.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Ram@21:1/5 to Johanne Fairchild on Tue Apr 2 07:56:48 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Johanne Fairchild <jfairchild@tudado.org> wrote or quoted:
    You don't seem to much of a Lisp writer. Lisp writers have no problem >reading that indentation.

    Well, there is the expression "write-only code", which shows
    that a good Lisp writer may not necessarily be a good reader.

    This is an example of LISP code:

    ( SETQ DIFF
    ( LAMBDA( X )
    ( COND
    ( ( ATOMP X )
    ( COND
    ( ( = X 'X )
    1 )
    ( T
    0 )))
    ( T
    ( COND
    ( ( =( CAR X )'SUM )
    ( LIST 'SUM( DIFF( CADR X ))( DIFF( CADDR X )))))))))

    . For someone who has not learned LISP, this is difficult to read,
    /not/ because of the indentation, but because the words used have no
    meaning for him. Without the indentation it would be harder to read.

    It defines ("SETQ") the name "DIFF" to be a function ("LAMBDA")
    of one argument ("X"). When called, the functions tests
    ("COND") whether X is an atom ("ATOMP X"). In this case,
    if X is the letter "X" the result is one, otherwise it's zero.
    If X is not a atom, but a sum, we will return the sum of the
    DIFFs of the augend and the added. This calls the same function
    as the one defined. Yes! In LISP a function may call itself!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Ram@21:1/5 to Stefan Ram on Tue Apr 2 08:26:14 2024
    XPost: comp.unix.shell, comp.unix.programmer

    ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:
    def diff( x ):
    return 1 if x == 'x' else 0 if type( x )is str
    else[ 'sum', diff( x[ 1 ]), diff( x[ 2 ])]
    if x[ 0 ]== 'sum' else None

    Oops! That was one long line starting with "return";
    it was wrapped by the newsreader, but is not correct
    Python anymore when wrapped this way.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From James Kuyper@21:1/5 to Scott Lurndal on Tue Apr 2 05:13:13 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 4/1/24 15:42, Scott Lurndal wrote:
    ...
    Why is it important that there be a distinction between "scripting"
    and "non-scripting" languages at all?

    I don't know, which is why this discussion bores me. But when people
    aren't in agreement about the definition of a term, it's often useful to consider what you might want to say using the term - not what you want
    to say about the definition, but what you want to say that can be
    non-trivially derived from the definition. Then you should carefully
    choose a definition for the term so that makes what you want to say
    about it both true, and even more important, useful.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Ram@21:1/5 to Stefan Ram on Tue Apr 2 08:18:48 2024
    XPost: comp.unix.shell, comp.unix.programmer

    ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:
    ( SETQ DIFF
    ( LAMBDA( X )
    ( COND
    ( ( ATOMP X )
    ( COND
    ( ( = X 'X )
    1 )
    ( T
    0 )))
    ( T
    ( COND
    ( ( =( CAR X )'SUM )
    ( LIST 'SUM( DIFF( CADR X ))( DIFF( CADDR X )))))))))

    In Python:

    def diff( x ):
    return 1 if x == 'x' else 0 if type( x )is str
    else[ 'sum', diff( x[ 1 ]), diff( x[ 2 ])]
    if x[ 0 ]== 'sum' else None

    . An attempt at indentation:

    def diff( x ):
    return \
    1 if x == 'x' else 0 \
    if type( x )is str else \
    [ 'sum', diff( x[ 1 ]), diff( x[ 2 ])] \
    if x[ 0 ]== 'sum' else None

    . In a multiple-returns style:

    def diff( x ):
    if type( x )is str:
    if x == 'x':
    return 1
    else:
    return 0
    else:
    if x[ 0 ]== 'sum':
    return [ 'sum', diff( x[ 1 ]), diff( x[ 2 ])]

    .

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From James Kuyper@21:1/5 to Lawrence D'Oliveiro on Tue Apr 2 05:28:15 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 4/1/24 20:57, Lawrence D'Oliveiro wrote:
    On Mon, 01 Apr 2024 21:26:19 -0300, Johanne Fairchild wrote:

    reading that indentation.

    If indentation is good, more indentation should be better.

    By that same logic, if water is good, more water should be better. Tell
    that to someone who is drowning.
    For that matter, tell it to my mother who had a dangerous drug
    interaction involving a diuretic, while (unknown to her doctor) she was following a recommendation that she drink 8 glasses of water a day "for
    her health". Look up hyponatremia.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From candycanearter07@21:1/5 to Scott Lurndal on Tue Apr 2 15:30:09 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Scott Lurndal <scott@slp53.sl.home> wrote at 22:40 this Monday (GMT):
    John Ames <commodorejohn@gmail.com> writes:
    On 1 Apr 2024 21:13:42 GMT
    ram@zedat.fu-berlin.de (Stefan Ram) wrote:

    This stack "management" is "limited" in C:

    True enough, although as noted that's an implementation issue as much
    as it is a limitation of the language spec. (I'm not sure how you could >>handle that in a way that's both robust and reasonably C-ish...)

    Modern (64-bit) linux systems leave large buffer zones (unmapped addresses) on either side of the stack; a stack overflow or underflow will
    immediately fault if the RLIMIT_STACK value is exceeded.

    It still protects writing to memory outside that buffer, right?
    [snip]
    --
    user <candycane> is generated from /dev/urandom

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to John Ames on Tue Apr 2 16:09:38 2024
    XPost: comp.unix.shell, comp.unix.programmer

    John Ames <commodorejohn@gmail.com> writes:
    On Tue, 2 Apr 2024 15:30:09 -0000 (UTC)
    candycanearter07 <candycanearter07@candycanearter07.nomail.afraid>
    wrote:

    It still protects writing to memory outside that buffer, right?
    [snip]

    "Protecting memory" doesn't mean "no page fault," though, just that it
    won't scribble all over some other process's memory.

    The regions each side of the stack are marked not-present. This supports automatic stack expansion, within the resource limit for the stack on
    one side, and will produce a SIGSEGV or SIGBUS on the other end.


    But I am curious
    how universally various freenix distributions these days just let the >application segfault vs. using that as a cue to allocate additional
    stack space; a quick test with WSL (Debian somethingorother) runs that
    test without complaint, but I don't have a genuine *nix box to hand to
    try it with.

    All linux will allocate space, up to the stack resource limit.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Stefan Ram on Tue Apr 2 16:33:11 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-04-02, Stefan Ram <ram@zedat.fu-berlin.de> wrote:
    ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:
    ( SETQ DIFF
    ( LAMBDA( X )
    ( COND
    ( ( ATOMP X )
    ( COND
    ( ( = X 'X )
    1 )
    ( T
    0 )))
    ( T
    ( COND
    ( ( =( CAR X )'SUM )
    ( LIST 'SUM( DIFF( CADR X ))( DIFF( CADDR X )))))))))

    In Python:

    def diff( x ):
    return 1 if x == 'x' else 0 if type( x )is str
    else[ 'sum', diff( x[ 1 ]), diff( x[ 2 ])]
    if x[ 0 ]== 'sum' else None

    n TXR Lisp:

    (defun-match dif
    ((sum @left @right) ^(sum ,(dif left) ,(dif right)))
    ((@op . @args) (error "~s: unrecognized operator: ~s" 'dif op))
    (x 1)
    (@else 0))

    diff is a built in, which we don't want to be redefining without
    an exceptionally good reason, so I changed to dif.

    If we compile 'dif we get unused variable warnings:

    2> (compile 'dif)
    ** expr-1:1: warning: let*: variable args unused
    ** expr-1:1: warning: let*: variable else unused
    #<vm fun: 0 param + 3 optional + variadic>

    To suppress that, we use @nil instead of @args or @else; @nil is a
    placeholder pattern that matches any object without binding a variable.

    Otherwise we need more verbiage:

    ((@op . @args) (ignore args) (error ....))
    ...
    (@else (ignore else) 0)


    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Stefan Ram on Tue Apr 2 16:18:24 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-04-02, Stefan Ram <ram@zedat.fu-berlin.de> wrote:
    Johanne Fairchild <jfairchild@tudado.org> wrote or quoted:
    You don't seem to much of a Lisp writer. Lisp writers have no problem >>reading that indentation.

    Well, there is the expression "write-only code", which shows
    that a good Lisp writer may not necessarily be a good reader.

    This is an example of LISP code:

    ( SETQ DIFF
    ( LAMBDA( X )
    ( COND
    ( ( ATOMP X )
    ( COND
    ( ( = X 'X )
    1 )
    ( T
    0 )))
    ( T
    ( COND
    ( ( =( CAR X )'SUM )
    ( LIST 'SUM( DIFF( CADR X ))( DIFF( CADDR X )))))))))

    . For someone who has not learned LISP, this is difficult to read,
    /not/ because of the indentation, but because the words used have no
    meaning for him. Without the indentation it would be harder to read.

    I know all the words. It's still hard to read because of the weird
    spaces.

    This is the way of writing the code that the vast majority of the Lisp
    word since gravitated toward:

    (SETQ DIFF
    (LAMBDA (X)
    (COND
    ((ATOMP X)
    (COND
    ((= X 'X) 1) ;; unnecessary line breaks shored up here
    (T 0)))
    (T
    (COND
    ((= (CAR X) 'SUM)
    (LIST 'SUM (DIFF (CADR X)) (DIFF (CADDR X)))))))))

    The code is from just before MacCarthy invented the ternary IF, as a
    shorthand for a one clause cond:

    (SETQ DIFF
    (LAMBDA (X)
    (IF (ATOM X)
    (IF (= X 'X) 1 0)
    (IF (= (CAR X) 'SUM)
    (LIST 'SUM (DIFF (CADR X)) (DIFF (CADDR X)))))))

    Also, modern cond clauses are not strictly pairs,
    which allows the T to be omitted:

    (cond (this that) (else)) ;; rather than (t else)

    when a cond clause consists of a single expression, then if that
    expression is true, cond stops and yields that expression's value.

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Johanne Fairchild@21:1/5 to Lawrence D'Oliveiro on Tue Apr 2 15:20:06 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Mon, 01 Apr 2024 21:26:19 -0300, Johanne Fairchild wrote:

    reading that indentation.

    If indentation is good, more indentation should be better.

    Too much of a good thing is a bad thing.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenny McCormack@21:1/5 to jfairchild@tudado.org on Tue Apr 2 18:58:01 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <87plv762zt.fsf@tudado.org>,
    Johanne Fairchild <jfairchild@tudado.org> wrote:
    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Mon, 01 Apr 2024 21:26:19 -0300, Johanne Fairchild wrote:

    reading that indentation.

    If indentation is good, more indentation should be better.

    Too much of a good thing is a bad thing.

    By definition. Because the definition of "too much" implies having crossed into the zone of being a bad thing.

    I would like to argue that there are things that there is no such thing as
    too much of, but I can't think of any examples off hand.

    --

    First of all, I do not appreciate your playing stupid here at all.

    - Thomas 'PointedEars' Lahn -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Kenny McCormack on Tue Apr 2 18:59:00 2024
    XPost: comp.unix.shell, comp.unix.programmer

    gazelle@shell.xmission.com (Kenny McCormack) writes:
    In article <87plv762zt.fsf@tudado.org>,
    Johanne Fairchild <jfairchild@tudado.org> wrote:
    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Mon, 01 Apr 2024 21:26:19 -0300, Johanne Fairchild wrote:

    reading that indentation.

    If indentation is good, more indentation should be better.

    Too much of a good thing is a bad thing.

    By definition. Because the definition of "too much" implies having crossed >into the zone of being a bad thing.

    I would like to argue that there are things that there is no such thing as >too much of, but I can't think of any examples off hand.

    Money?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From candycanearter07@21:1/5 to Scott Lurndal on Tue Apr 2 18:50:11 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Scott Lurndal <scott@slp53.sl.home> wrote at 16:09 this Tuesday (GMT):
    John Ames <commodorejohn@gmail.com> writes:
    On Tue, 2 Apr 2024 15:30:09 -0000 (UTC)
    candycanearter07 <candycanearter07@candycanearter07.nomail.afraid>
    wrote:

    It still protects writing to memory outside that buffer, right?
    [snip]

    "Protecting memory" doesn't mean "no page fault," though, just that it >>won't scribble all over some other process's memory.

    The regions each side of the stack are marked not-present. This supports automatic stack expansion, within the resource limit for the stack on
    one side, and will produce a SIGSEGV or SIGBUS on the other end.


    But I am curious
    how universally various freenix distributions these days just let the >>application segfault vs. using that as a cue to allocate additional
    stack space; a quick test with WSL (Debian somethingorother) runs that
    test without complaint, but I don't have a genuine *nix box to hand to
    try it with.

    All linux will allocate space, up to the stack resource limit.


    Interesting.
    --
    user <candycane> is generated from /dev/urandom

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dmitry A. Kazakov@21:1/5 to Scott Lurndal on Tue Apr 2 22:05:18 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-04-02 20:59, Scott Lurndal wrote:
    gazelle@shell.xmission.com (Kenny McCormack) writes:
    In article <87plv762zt.fsf@tudado.org>,
    Johanne Fairchild <jfairchild@tudado.org> wrote:
    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Mon, 01 Apr 2024 21:26:19 -0300, Johanne Fairchild wrote:

    reading that indentation.

    If indentation is good, more indentation should be better.

    Too much of a good thing is a bad thing.

    By definition. Because the definition of "too much" implies having crossed >> into the zone of being a bad thing.

    I would like to argue that there are things that there is no such thing as >> too much of, but I can't think of any examples off hand.

    Money?

    Inflation.

    --
    Regards,
    Dmitry A. Kazakov
    http://www.dmitry-kazakov.de

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From James Kuyper@21:1/5 to Scott Lurndal on Tue Apr 2 19:15:13 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 4/2/24 14:59, Scott Lurndal wrote:
    gazelle@shell.xmission.com (Kenny McCormack) writes:
    ...
    I would like to argue that there are things that there is no such thing as >> too much of, but I can't think of any examples off hand.

    Money?

    If you have lots of moeny, and insufficient protection, you can be in
    danger. Also, a sufficiently large amount of money can crush you.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Johanne Fairchild on Wed Apr 3 00:23:38 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Tue, 02 Apr 2024 15:20:06 -0300, Johanne Fairchild wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Mon, 01 Apr 2024 21:26:19 -0300, Johanne Fairchild wrote:

    reading that indentation.

    If indentation is good, more indentation should be better.

    Too much of a good thing is a bad thing.

    Should that principle be carried to excess, though?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to James Kuyper on Wed Apr 3 00:25:37 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Tue, 2 Apr 2024 05:28:15 -0400, James Kuyper wrote:

    By that same logic, if water is good, more water should be better. Tell
    that to someone who is drowning.

    Now there would be an example of too much logic, if you really want to
    discuss such a thing with someone who is drowning, would it not?

    ... she was following a recommendation that she drink 8 glasses of water
    a day "for her health".

    Also look up “water intoxication”. Can kill anybody.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Stefan Ram on Wed Apr 3 00:23:12 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2 Apr 2024 08:26:14 GMT, Stefan Ram wrote:

    ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:

    def diff( x ):
    return 1 if x == 'x' else 0 if type( x )is str else[ 'sum', diff( x[
    1 ]), diff( x[ 2 ])]
    if x[ 0 ]== 'sum' else None

    Oops! That was one long line starting with "return";
    it was wrapped by the newsreader, but is not correct Python anymore
    when wrapped this way.

    It’s bloody horrible Python even when wrapped correctly. I think Python’s version of the conditional expression is a complete abortion.

    How about this, to at least get things the same way round as in the more
    usual C-style conditional expression:

    def diff(x) :
    return \
    [
    lambda :
    [
    lambda :
    [
    lambda : None,
    lambda : ['sum', diff(x[1]), diff(x[2])],
    ][x[0] == 'sum'](),
    lambda : 0,
    ][isinstance(x, str)](),
    lambda : 1,
    ][x == 'x']()
    #end diff

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Brown@21:1/5 to Lawrence D'Oliveiro on Wed Apr 3 09:50:28 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 03/04/2024 02:23, Lawrence D'Oliveiro wrote:
    On 2 Apr 2024 08:26:14 GMT, Stefan Ram wrote:

    ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:

    def diff( x ):
    return 1 if x == 'x' else 0 if type( x )is str else[ 'sum', diff( x[ >>> 1 ]), diff( x[ 2 ])]
    if x[ 0 ]== 'sum' else None

    Oops! That was one long line starting with "return";
    it was wrapped by the newsreader, but is not correct Python anymore
    when wrapped this way.

    It’s bloody horrible Python even when wrapped correctly. I think Python’s version of the conditional expression is a complete abortion.


    That's probably the reason almost no one uses it. That post is the
    first time I have ever seen conditional expressions outside of a brief
    mention in a tutorial on Python conditionals showing how to write normal conditionals in the language. I think Python stole this one from Perl.


    How about this, to at least get things the same way round as in the more usual C-style conditional expression:

    def diff(x) :
    return \
    [
    lambda :
    [
    lambda :
    [
    lambda : None,
    lambda : ['sum', diff(x[1]), diff(x[2])],
    ][x[0] == 'sum'](),
    lambda : 0,
    ][isinstance(x, str)](),
    lambda : 1,
    ][x == 'x']()
    #end diff

    How about just writing Python code the way pretty much everyone else
    writes Python code? In a simple and obvious manner :

    def diff(x) :
    if x == 'x' :
    return 1
    if isinstance(x, str) :
    return 0
    if x[0] == 'sum' :
    return ['sum', diff(x[1]), diff(x[2])]
    return None

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to David Brown on Wed Apr 3 07:53:28 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Wed, 3 Apr 2024 09:50:28 +0200, David Brown wrote:

    How about just writing Python code the way pretty much everyone else
    writes Python code?

    That can be generalized to switch-expressions as well. See my notebook on “Simple Code-Shortening Idioms” at <https://gitlab.com/ldo/python_topics_notebooks/>.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Johanne Fairchild@21:1/5 to Lawrence D'Oliveiro on Wed Apr 3 07:18:07 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Tue, 02 Apr 2024 15:20:06 -0300, Johanne Fairchild wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Mon, 01 Apr 2024 21:26:19 -0300, Johanne Fairchild wrote:

    reading that indentation.

    If indentation is good, more indentation should be better.

    Too much of a good thing is a bad thing.

    Should that principle be carried to excess, though?

    Surely not if it's a good thing. :-)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Kettlewell@21:1/5 to Scott Lurndal on Wed Apr 3 15:45:54 2024
    XPost: comp.unix.shell, comp.unix.programmer

    scott@slp53.sl.home (Scott Lurndal) writes:
    John Ames <commodorejohn@gmail.com> writes:
    On 1 Apr 2024 21:13:42 GMT
    ram@zedat.fu-berlin.de (Stefan Ram) wrote:

    This stack "management" is "limited" in C:

    True enough, although as noted that's an implementation issue as much
    as it is a limitation of the language spec. (I'm not sure how you could >>handle that in a way that's both robust and reasonably C-ish...)

    Modern (64-bit) linux systems leave large buffer zones (unmapped addresses) on either side of the stack; a stack overflow or underflow will
    immediately fault if the RLIMIT_STACK value is exceeded.

    ...unless it’s exceeded by enough to reach some other mapped address.

    https://blog.qualys.com/vulnerabilities-threat-research/2017/06/19/the-stack-clash

    --
    https://www.greenend.org.uk/rjk/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Kettlewell@21:1/5 to Keith Thompson on Wed Apr 3 17:16:31 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
    David Brown <david.brown@hesbynett.no> writes:
    On 03/04/2024 02:23, Lawrence D'Oliveiro wrote:
    It’s bloody horrible Python even when wrapped correctly. I think
    Python’s version of the conditional expression is a complete
    abortion.

    That's probably the reason almost no one uses it. That post is the
    first time I have ever seen conditional expressions outside of a brief
    mention in a tutorial on Python conditionals showing how to write
    normal conditionals in the language. I think Python stole this one
    from Perl.

    No, Perl's conditional expressions use the same syntax as C's.

    As for whether Python's conditional expression syntax, it's not clear
    that (cond ? expr1 : expr2) is better or worse than (expr1 if cond else expr2) (unless you happen to be familiar with one of them).

    I’ve been familiar with both for years and I think the Python version is awful; in particular the ordering is a bizarre choice. The PEP where
    they worked out the design acknowledges this but then they went ahead
    and did it anyway...

    --
    https://www.greenend.org.uk/rjk/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Brown@21:1/5 to Keith Thompson on Wed Apr 3 18:30:08 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 03/04/2024 18:00, Keith Thompson wrote:
    David Brown <david.brown@hesbynett.no> writes:
    On 03/04/2024 02:23, Lawrence D'Oliveiro wrote:
    On 2 Apr 2024 08:26:14 GMT, Stefan Ram wrote:

    ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:

    def diff( x ):
    return 1 if x == 'x' else 0 if type( x )is str else[ 'sum', diff( x[ >>>>> 1 ]), diff( x[ 2 ])]
    if x[ 0 ]== 'sum' else None

    Oops! That was one long line starting with "return";
    it was wrapped by the newsreader, but is not correct Python anymore >>>> when wrapped this way.
    It’s bloody horrible Python even when wrapped correctly. I think
    Python’s version of the conditional expression is a complete
    abortion.

    That's probably the reason almost no one uses it. That post is the
    first time I have ever seen conditional expressions outside of a brief
    mention in a tutorial on Python conditionals showing how to write
    normal conditionals in the language. I think Python stole this one
    from Perl.

    No, Perl's conditional expressions use the same syntax as C's.

    I am not very familiar with Perl, and don't know what are expressions or statements. Perhaps I have been imagining things. I had the idea that
    in Perl you could write "<do_this> if <condition>" as an alternative to
    the more common imperative language ordering "if <condition> then
    <do_this>".


    As for whether Python's conditional expression syntax, it's not clear
    that (cond ? expr1 : expr2) is better or worse than (expr1 if cond else expr2) (unless you happen to be familiar with one of them).


    I think expr1 and expr2 belong naturally together, as you are selecting
    one or the other. If you are using a short-circuit evaluation, you
    would express it in words as "evaluate cond, and based on that, evaluate
    either expr1 and expr2". Having "expr1" first is a bit like a recipe
    that says "add the sugar to the egg whites, having first beaten the egg whites". It is an ordering that does not suit well in an imperative
    language (I know Python is multi-paradigm, but it is basically imperative).

    But I agree that familiarity could be a big factor in my subjective
    opinion here.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Richard Kettlewell on Wed Apr 3 16:56:25 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Richard Kettlewell <invalid@invalid.invalid> writes:
    scott@slp53.sl.home (Scott Lurndal) writes:
    John Ames <commodorejohn@gmail.com> writes:
    On 1 Apr 2024 21:13:42 GMT
    ram@zedat.fu-berlin.de (Stefan Ram) wrote:

    This stack "management" is "limited" in C:

    True enough, although as noted that's an implementation issue as much
    as it is a limitation of the language spec. (I'm not sure how you could >>>handle that in a way that's both robust and reasonably C-ish...)

    Modern (64-bit) linux systems leave large buffer zones (unmapped addresses) >> on either side of the stack; a stack overflow or underflow will
    immediately fault if the RLIMIT_STACK value is exceeded.

    ...unless it’s exceeded by enough to reach some other mapped address.

    https://blog.qualys.com/vulnerabilities-threat-research/2017/06/19/the-stack-clash

    Yes, clearly the buffer zones must be limited in size to allow space
    for the rest of the application (and note that most extant processors
    limit the virtual address space to 44 or 48 bits (up to 52 on ARM64)).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Brown@21:1/5 to Keith Thompson on Wed Apr 3 21:33:58 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 03/04/2024 19:19, Keith Thompson wrote:
    David Brown <david.brown@hesbynett.no> writes:
    On 03/04/2024 18:00, Keith Thompson wrote:
    David Brown <david.brown@hesbynett.no> writes:
    [...]
    That's probably the reason almost no one uses it. That post is the
    first time I have ever seen conditional expressions outside of a brief >>>> mention in a tutorial on Python conditionals showing how to write
    normal conditionals in the language. I think Python stole this one
    from Perl.
    No, Perl's conditional expressions use the same syntax as C's.

    I am not very familiar with Perl, and don't know what are expressions
    or statements. Perhaps I have been imagining things. I had the idea
    that in Perl you could write "<do_this> if <condition>" as an
    alternative to the more common imperative language ordering "if
    <condition> then <do_this>".

    Yes, but it's not the same thing. Perl has postfix conditionals, so you
    can write:

    statement if condition;

    but that's a statement, not an expression, and there's no form
    equivalent to if/else. It's a specific case of "statement modifiers",
    where the keyword can be any of if, unless, while, until, for, foreach,
    or when. (The latter is for an experimental "switch" feature, disabled
    by default in recent releases.)

    OK. That's a lot more than I knew.

    However, I don't see a relevant distinction between a statement and an expression as particularly significant here, at least in terms of code
    clarity.


    https://perldoc.perl.org/perlsyn#Statement-Modifiers

    As for whether Python's conditional expression syntax, it's not
    clear
    that (cond ? expr1 : expr2) is better or worse than (expr1 if cond else
    expr2) (unless you happen to be familiar with one of them).

    I think expr1 and expr2 belong naturally together, as you are
    selecting one or the other. If you are using a short-circuit
    evaluation, you would express it in words as "evaluate cond, and based
    on that, evaluate either expr1 and expr2". Having "expr1" first is a
    bit like a recipe that says "add the sugar to the egg whites, having
    first beaten the egg whites". It is an ordering that does not suit
    well in an imperative language (I know Python is multi-paradigm, but
    it is basically imperative).

    But I agree that familiarity could be a big factor in my subjective
    opinion here.

    I don't have a strong opinion one way or the other, beyond a willingness
    to accept the syntax and other rules of whatever language I'm using.

    Of course we use the languages we use, warts and all. It's rare that
    anyone uses a language for a significant amount of work and doesn't
    dislike at least some aspects of the language.

    But I suggest that Python's "expr1 if condition else expr2" is intended
    to emphasize expr1 over expr2, treating the condition being true as the "normal" case. That's not necessarily a bad thing.


    Perhaps.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to Richard Kettlewell on Thu Apr 4 08:13:22 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Wed, 03 Apr 2024 17:16:31 +0100
    Richard Kettlewell <invalid@invalid.invalid> wrote:
    Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
    David Brown <david.brown@hesbynett.no> writes:
    On 03/04/2024 02:23, Lawrence D'Oliveiro wrote:
    It’s bloody horrible Python even when wrapped correctly. I think
    Python’s version of the conditional expression is a complete
    abortion.

    That's probably the reason almost no one uses it. That post is the
    first time I have ever seen conditional expressions outside of a brief
    mention in a tutorial on Python conditionals showing how to write
    normal conditionals in the language. I think Python stole this one
    from Perl.

    No, Perl's conditional expressions use the same syntax as C's.

    As for whether Python's conditional expression syntax, it's not clear
    that (cond ? expr1 : expr2) is better or worse than (expr1 if cond else
    expr2) (unless you happen to be familiar with one of them).

    I’ve been familiar with both for years and I think the Python version is >awful; in particular the ordering is a bizarre choice. The PEP where
    they worked out the design acknowledges this but then they went ahead
    and did it anyway...

    I believe its known as being different for the sake of being different which
    is closely related to change for changes sake. Its the reason screwed up the WIndows GUI - a new generation of devs had to prove their could be different
    to the previous one regardless of how badly their new version sucked. Or in more general cases - we've all seen new managers come in and change processes just to prove they were doing something.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Ram@21:1/5 to Richard Kettlewell on Thu Apr 4 11:20:48 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Richard Kettlewell <invalid@invalid.invalid> wrote or quoted:
    I’ve been familiar with both for years and I think the Python version is >awful; in particular the ordering is a bizarre choice.

    The way this syntax is set up is apparently credited to
    this guy named Guido, according to this PEP 308 thing.

    Now, in English, we usually throw a comma in there when an
    "if" clause comes first, 'cause it kinda throws off the normal
    flow, you know? So that shows the default position for "if"
    is actually after the main part. - Maybe Guido was making that
    same kind of comparison to English, and that's why he decided
    the post-"if" format works better.

    In my example here, there were a whole bunch of these operators
    all nested inside each other without any parentheses. And let
    me tell you, when you start getting into that kind of nested
    stuff with not parentheses in view, even the "?:" notation
    can start looking pretty darn mysterious to some folks.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Stefan Ram on Thu Apr 4 23:29:21 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 4 Apr 2024 11:20:48 GMT, Stefan Ram wrote:

    And let me tell you, when you start getting into that kind of nested
    stuff with not parentheses in view, even the "?:" notation can start
    looking pretty darn mysterious to some folks.

    This is where indentation helps. E.g.

    a =
    b ?
    c ? d : e
    : f ?
    g ? h : i
    : j;

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to Lawrence D'Oliveiro on Fri Apr 5 09:17:37 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Thu, 4 Apr 2024 23:29:21 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On 4 Apr 2024 11:20:48 GMT, Stefan Ram wrote:

    And let me tell you, when you start getting into that kind of nested
    stuff with not parentheses in view, even the "?:" notation can start
    looking pretty darn mysterious to some folks.

    This is where indentation helps. E.g.

    a =
    b ?
    c ? d : e
    : f ?
    g ? h : i
    : j;

    Just use brackets. Saves a lot of pain.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From candycanearter07@21:1/5 to Muttley@dastardlyhq.com on Fri Apr 5 12:40:02 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote at 09:17 this Friday (GMT):
    On Thu, 4 Apr 2024 23:29:21 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On 4 Apr 2024 11:20:48 GMT, Stefan Ram wrote:

    And let me tell you, when you start getting into that kind of nested
    stuff with not parentheses in view, even the "?:" notation can start
    looking pretty darn mysterious to some folks.

    This is where indentation helps. E.g.

    a =
    b ?
    c ? d : e
    : f ?
    g ? h : i
    : j;

    Just use brackets. Saves a lot of pain.


    Or just use if blocks if it's too complex.
    --
    user <candycane> is generated from /dev/urandom

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to candycanearter07@candycanearter07.n on Fri Apr 5 15:09:47 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 5 Apr 2024 12:40:02 -0000 (UTC)
    candycanearter07 <candycanearter07@candycanearter07.nomail.afraid> wrote: >Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote at 09:17 this Friday >(GMT):
    On Thu, 4 Apr 2024 23:29:21 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On 4 Apr 2024 11:20:48 GMT, Stefan Ram wrote:

    And let me tell you, when you start getting into that kind of nested
    stuff with not parentheses in view, even the "?:" notation can start
    looking pretty darn mysterious to some folks.

    This is where indentation helps. E.g.

    a =
    b ?
    c ? d : e
    : f ?
    g ? h : i
    : j;

    Just use brackets. Saves a lot of pain.


    Or just use if blocks if it's too complex.

    Indeed. It might not look as "l33t", but with modern compilers it'll end
    up as the same assembler anyway.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Lawrence D'Oliveiro on Fri Apr 5 18:30:12 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 05.04.2024 01:29, Lawrence D'Oliveiro wrote:
    On 4 Apr 2024 11:20:48 GMT, Stefan Ram wrote:

    And let me tell you, when you start getting into that kind of nested
    stuff with not parentheses in view, even the "?:" notation can start
    looking pretty darn mysterious to some folks.

    This is where indentation helps. E.g.

    a =
    b ?
    c ? d : e
    : f ?
    g ? h : i
    : j;


    Indentation generally helps. In above code (in my book) it's not
    that clear [from the indentation], e.g. where the last ':' 'else'
    belongs to. So I'd have lined the colons up with the respective
    '?'. (YMMV.)

    Not all languages differentiate (per syntax) a conditional command
    from a conditional expression. Here are the two forms supported by
    Algol for both, statements and expressions (here the examples are
    both depicted for expressions only)

    a :=
    ( b | ( c | d | e )
    | ( f | ( g | h | i )
    | j ) );

    The parenthesis are not used for grouping, but are the alternative
    form for IF/THEN/ELSE/FI

    a := IF b
    THEN
    IF c THEN d ELSE e FI
    ELSE
    IF f THEN
    IF g THEN h ELSE i FI
    ELSE j FI
    FI

    Pick your choice depending on the case (or taste).

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Ram@21:1/5 to Janis Papanagnou on Fri Apr 5 17:37:52 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote or quoted:
    On 05.04.2024 01:29, Lawrence D'Oliveiro wrote:
    This is where indentation helps. E.g.
    a =
    b ?
    c ? d : e
    : f ?
    g ? h : i
    : j;

    Indentation generally helps.

    Let me give it a try to find how I would indent that!

    b?
    c? d: e:
    f?
    g? h: i:
    j;

    The parenthesis are not used for grouping, but are the alternative
    form for IF/THEN/ELSE/FI

    It's funny how the discussion oscillates between
    "too many parentheses" (LISP code) and "not enough parentheses"
    ("let me add some parens to improve readability").

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Janis Papanagnou on Fri Apr 5 20:47:40 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-04-05, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
    On 05.04.2024 01:29, Lawrence D'Oliveiro wrote:
    On 4 Apr 2024 11:20:48 GMT, Stefan Ram wrote:

    And let me tell you, when you start getting into that kind of nested
    stuff with not parentheses in view, even the "?:" notation can start
    looking pretty darn mysterious to some folks.

    This is where indentation helps. E.g.

    a =
    b ?
    c ? d : e
    : f ?
    g ? h : i
    : j;


    Indentation generally helps. In above code (in my book) it's not
    that clear [from the indentation], e.g. where the last ':' 'else'
    belongs to. So I'd have lined the colons up with the respective
    '?'. (YMMV.)

    Not all languages differentiate (per syntax) a conditional command
    from a conditional expression. Here are the two forms supported by
    Algol for both, statements and expressions (here the examples are
    both depicted for expressions only)

    a :=
    ( b | ( c | d | e )
    | ( f | ( g | h | i )
    | j ) );

    The parenthesis are not used for grouping, but are the alternative
    form for IF/THEN/ELSE/FI

    a := IF b
    THEN
    IF c THEN d ELSE e FI
    ELSE
    IF f THEN
    IF g THEN h ELSE i FI
    ELSE j FI
    FI

    Pick your choice depending on the case (or taste).


    #define XCAT(A, B) A ## B
    #define CAT(A, B) XCAT(A, B)

    #define IF(A, B, C) ((A) ? (B) : (C))

    #define COND_2(cond, then, ...) IF(cond, then, 0)
    #define COND_4(cond, then, ...) IF(cond, then, COND_2(__VA_ARGS__))
    #define COND_6(cond, then, ...) IF(cond, then, COND_4(__VA_ARGS__))
    #define COND_8(cond, then, ...) IF(cond, then, COND_6(__VA_ARGS__))

    #define COND_1(...) {syntax error}
    #define COND_3(...) {syntax error}
    #define COND_5(...) {syntax error}
    #define COND_7(...) {syntax error}

    #define COUNT_ARGS(...) COUNT_ARGS_IMPL(__VA_ARGS__, 8, 7, 6, 5, 4, 3, 2, 1) #define COUNT_ARGS_IMPL(_1, _2, _3, _4, _5, _6, _7, _8, N, ...) N

    #define COND(...) CAT(COND_, COUNT_ARGS(__VA_ARGS__))(__VA_ARGS__)


    Now we can do:

    COND(b, ...,
    f, ...
    1, j)

    filling in the ...:

    COND(b, IF(c, d, e),
    f, IF(g, h, i),
    1, j)

    The GNU preprocessor gives me this:

    ((b) ? (((c) ? (d) : (e))) : (((f) ? (((g) ? (h) : (i))) : (((1) ? (j) : (0))))))

    which looks correct.

    The code is readable now, and importantly, my editor can format it. If I
    start adding line breaks, it's indented right. If I turn it into this:

    COND(b, IF(c, d, e),
    f, IF(g, h, i),
    1, j)

    then highlight it in Vim and hit =, it gets put back the way it was.

    If I add line breaks into the IFs, they get automatically indented
    right, just using Vim's support for basic C formatting of macro/function
    calls:

    cond(b, IF(c,
    d,
    e),
    f, IF(g,
    h,
    i),
    1, j)

    Compared to wrestling with five ways of formatting the the ill-conceived
    ?: syntax, it's a complete no brainer.

    Here is a version where the cond pairs have to be parenthesized.
    We can lose the even/odd argument count handling, and might as well
    extend to up to 8 clauses:

    #define IF(A, B, C) ((A) ? (B) : (C))

    #define XCAT(A, B) A ## B
    #define CAT(A, B) XCAT(A, B)

    #define COND_PAIR(pair, rest) IF(COND_COND pair, COND_THEN pair, rest)
    #define COND_COND(cond, then) cond
    #define COND_THEN(cond, then) then
    #define COND_1(pair, ...) COND_PAIR(pair, 0)
    #define COND_2(pair, ...) COND_PAIR(pair, COND_1(__VA_ARGS__))
    #define COND_3(pair, ...) COND_PAIR(pair, COND_2(__VA_ARGS__))
    #define COND_4(pair, ...) COND_PAIR(pair, COND_3(__VA_ARGS__))
    #define COND_5(pair, ...) COND_PAIR(pair, COND_4(__VA_ARGS__))
    #define COND_6(pair, ...) COND_PAIR(pair, COND_5(__VA_ARGS__))
    #define COND_7(pair, ...) COND_PAIR(pair, COND_6(__VA_ARGS__))
    #define COND_8(pair, ...) COND_PAIR(pair, COND_7(__VA_ARGS__))

    #define COUNT_ARGS(...) COUNT_ARGS_IMPL(__VA_ARGS__, 8, 7, 6, 5, 4, 3, 2, 1) #define COUNT_ARGS_IMPL(_1, _2, _3, _4, _5, _6, _7, _8, N, ...) N

    #define COND(...) CAT(COND_, COUNT_ARGS(__VA_ARGS__))(__VA_ARGS__)

    COND((b, IF(c,
    d,
    d)),
    (f, IF(g,
    h,
    i)),
    (1, j))

    The expansion is still

    ((b) ? (((c) ? (d) : (d))) : (((f) ? (((g) ? (h) : (i))) : (((1) ? (j) : (0))))))

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Janis Papanagnou on Fri Apr 5 23:08:52 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 5 Apr 2024 18:30:12 +0200, Janis Papanagnou wrote:

    Here are the two forms supported by Algol ...

    Just a note, that’s Algol 68. In my time, “Algol” used unqualified was understood to refer to Algol 60.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Muttley on Fri Apr 5 23:11:54 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 5 Apr 2024 09:17:37 -0000 (UTC), Muttley wrote:

    On Thu, 4 Apr 2024 23:29:21 -0000 (UTC) Lawrence D'Oliveiro
    <ldo@nz.invalid> wrote:

    This is where indentation helps. E.g.

    a =
    b ?
    c ? d : e
    : f ?
    g ? h : i
    : j;

    Just use brackets. Saves a lot of pain.

    a=(b?(c?d:e):(f?(g?h:i):j));

    The improvement speaks for itself.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Alan Bawden@21:1/5 to Muttley on Fri Apr 5 19:35:37 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Fri, 5 Apr 2024 09:17:37 -0000 (UTC), Muttley wrote:
    ...
    >> a =
    >> b ?
    >> c ? d : e
    >> : f ?
    >> g ? h : i
    >> : j;
    >
    > Just use brackets. Saves a lot of pain.

    a=(b?(c?d:e):(f?(g?h:i):j));

    A normal programmer would write something like:

    a = b ? (c ? d : e) :
    f ? (g ? h : i) :
    j;

    I.e., she would allow herself to use spaces and newlines, and just
    enough parentheses to make the structure clear.

    - Alan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Alan Bawden on Sat Apr 6 01:01:48 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-04-05, Alan Bawden <alan@csail.mit.edu> wrote:
    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Fri, 5 Apr 2024 09:17:37 -0000 (UTC), Muttley wrote:
    ...
    >> a =
    >> b ?
    >> c ? d : e
    >> : f ?
    >> g ? h : i
    >> : j;
    >
    > Just use brackets. Saves a lot of pain.

    a=(b?(c?d:e):(f?(g?h:i):j));

    A normal programmer would write something like:

    a = b ? (c ? d : e) :
    f ? (g ? h : i) :
    j;

    I.e., she would allow herself to use spaces and newlines, and just
    enough parentheses to make the structure clear.

    It looks good, undeniably.

    However, I cannot tell at a glance whether or not the nice appearance
    isn't telling me some kind of lie. That's an inherent problem with
    the ternary operator.

    I have to remember that = has lower precedence than ?:. But, ==
    has higher precedence. So this careless edit makes it wrong,
    even though it still looks just as nice:

    a == b ? (c ? d : e) :
    f ? (g ? h : i) :
    j;

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Alan Bawden on Sat Apr 6 00:25:45 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 05 Apr 2024 19:35:37 -0400, Alan Bawden wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Fri, 5 Apr 2024 09:17:37 -0000 (UTC), Muttley wrote:
    ...
    >> a =
    >> b ?
    >> c ? d : e
    >> : f ?
    >> g ? h : i
    >> : j;
    >
    > Just use brackets. Saves a lot of pain.

    a=(b?(c?d:e):(f?(g?h:i):j));

    A normal programmer would write something like:

    a = b ? (c ? d : e) :
    f ? (g ? h : i) :
    j;

    I.e., she would allow herself to use spaces and newlines, and just
    enough parentheses to make the structure clear.

    It’s like, I don’t know ... you’re trying to save space. Why?

    It’s like programming inside an apartment block, instead of having a
    bungalow with a yard of your own.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From candycanearter07@21:1/5 to Muttley@dastardlyhq.com on Sat Apr 6 01:10:05 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote at 15:09 this Friday (GMT):
    On Fri, 5 Apr 2024 12:40:02 -0000 (UTC)
    candycanearter07 <candycanearter07@candycanearter07.nomail.afraid> wrote:
    Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote at 09:17 this Friday >>(GMT):
    On Thu, 4 Apr 2024 23:29:21 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On 4 Apr 2024 11:20:48 GMT, Stefan Ram wrote:

    And let me tell you, when you start getting into that kind of nested >>>>> stuff with not parentheses in view, even the "?:" notation can start >>>>> looking pretty darn mysterious to some folks.

    This is where indentation helps. E.g.

    a =
    b ?
    c ? d : e
    : f ?
    g ? h : i
    : j;

    Just use brackets. Saves a lot of pain.


    Or just use if blocks if it's too complex.

    Indeed. It might not look as "l33t", but with modern compilers it'll end
    up as the same assembler anyway.


    Yeah. Not everything needs to be a hyper optimized single line
    statement.
    --
    user <candycane> is generated from /dev/urandom

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From candycanearter07@21:1/5 to Alan Bawden on Sat Apr 6 01:10:06 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Alan Bawden <alan@csail.mit.edu> wrote at 23:35 this Friday (GMT):
    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Fri, 5 Apr 2024 09:17:37 -0000 (UTC), Muttley wrote:
    ...
    >> a =
    >> b ?
    >> c ? d : e
    >> : f ?
    >> g ? h : i
    >> : j;
    >
    > Just use brackets. Saves a lot of pain.

    a=(b?(c?d:e):(f?(g?h:i):j));

    A normal programmer would write something like:

    a = b ? (c ? d : e) :
    f ? (g ? h : i) :
    j;

    v (she?)
    I.e., she would allow herself to use spaces and newlines, and just
    enough parentheses to make the structure clear.

    - Alan


    Yeah, a bit of space for the code to breathe goes a long way.
    --
    user <candycane> is generated from /dev/urandom

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to Stefan Ram on Sat Apr 6 08:58:45 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 5 Apr 2024 17:37:52 GMT
    ram@zedat.fu-berlin.de (Stefan Ram) wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote or quoted:
    On 05.04.2024 01:29, Lawrence D'Oliveiro wrote:
    This is where indentation helps. E.g.
    a =
    b ?
    c ? d : e
    : f ?
    g ? h : i
    : j;

    Indentation generally helps.

    Let me give it a try to find how I would indent that!

    b?
    c? d: e:
    f?
    g? h: i:
    j;

    The parenthesis are not used for grouping, but are the alternative
    form for IF/THEN/ELSE/FI

    It's funny how the discussion oscillates between
    "too many parentheses" (LISP code) and "not enough parentheses"
    ("let me add some parens to improve readability").

    Lisp overloads them as block markers which simply makes the code more confusing, not less.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to Alan Bawden on Sat Apr 6 09:00:12 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 05 Apr 2024 19:35:37 -0400
    Alan Bawden <alan@csail.mit.edu> wrote:
    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Fri, 5 Apr 2024 09:17:37 -0000 (UTC), Muttley wrote:
    ...
    >> a =
    >> b ?
    >> c ? d : e
    >> : f ?
    >> g ? h : i
    >> : j;
    >
    > Just use brackets. Saves a lot of pain.

    a=(b?(c?d:e):(f?(g?h:i):j));

    A normal programmer would write something like:

    a = b ? (c ? d : e) :
    f ? (g ? h : i) :
    j;

    I.e., she would allow herself to use spaces and newlines, and just

    ITYM "he" would allow HIMself.

    Lets give the woke BS a miss, 95% of developers are men. It doesn't give you any brownie points, just makes you look a try-hard ass.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to David Brown on Sat Apr 6 15:03:57 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sat, 6 Apr 2024 15:44:13 +0200
    David Brown <david.brown@hesbynett.no> wrote:
    A lot of people think the layout of code should make the programmer's >intentions clear, and make it easy to see what the code does. That's

    Unfortunately IME another lot (usually young) seem to think that the more complicated their make their code the more it will impress their peers and/or boss. This seems to be a particular problem with C++ as its current overspecced and overcomplicated syntax allows you to write code that would make a Perl dev envious.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Brown@21:1/5 to Kaz Kylheku on Sat Apr 6 15:44:13 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 06/04/2024 03:01, Kaz Kylheku wrote:
    On 2024-04-05, Alan Bawden <alan@csail.mit.edu> wrote:
    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Fri, 5 Apr 2024 09:17:37 -0000 (UTC), Muttley wrote:
    ...
    >> a =
    >> b ?
    >> c ? d : e
    >> : f ?
    >> g ? h : i
    >> : j;
    >
    > Just use brackets. Saves a lot of pain.

    a=(b?(c?d:e):(f?(g?h:i):j));

    A normal programmer would write something like:

    a = b ? (c ? d : e) :
    f ? (g ? h : i) :
    j;

    I.e., she would allow herself to use spaces and newlines, and just
    enough parentheses to make the structure clear.

    It looks good, undeniably.

    However, I cannot tell at a glance whether or not the nice appearance
    isn't telling me some kind of lie. That's an inherent problem with
    the ternary operator.

    That's a key point - and it is not just with the ternary operator, but a general issue. Good spacing, indentation, newlines and layout make code
    easier to read. But it is vital that there is never any doubt that the
    layout matches the meaning of the code. If not, then you might be sure
    what the programmer meant dues to the layout, but you are not sure that
    the compiler sees it the same way. After all, this looks neat and clear
    too :

    a =
    b & c +
    d & e +
    f & g

    But the language viewpoint (assuming it is in C, or a language with
    similar precedences) and the code appearance are very different.

    Parentheses help, until there are too many to be easily tracked by the
    reader. Splitting the expression into parts, adding new local
    variables, using separate statements, making new helper functions -
    these are all ways to improve the code, and have no efficiency cost with
    modern tools.

    A lot of people think the layout of code should make the programmer's intentions clear, and make it easy to see what the code does. That's
    true, but it is not enough. Code layout should also make it easy to see
    that the code does what the programmer intended. It should be easy for
    a maintainer to modify it without introducing errors. It should also be
    hard for a reader to misinterpret it (which is not the same as saying it
    should be easy to interpret correctly). It should be hard for a
    maintainer to make mistakes. It should be easy to spot any mistakes
    that get made.



    I have to remember that = has lower precedence than ?:. But, ==
    has higher precedence. So this careless edit makes it wrong,
    even though it still looks just as nice:

    a == b ? (c ? d : e) :
    f ? (g ? h : i) :
    j;


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Lawrence D'Oliveiro on Sat Apr 6 18:57:47 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 06.04.2024 01:08, Lawrence D'Oliveiro wrote:
    On Fri, 5 Apr 2024 18:30:12 +0200, Janis Papanagnou wrote:

    Here are the two forms supported by Algol ...

    Just a note, that’s Algol 68. In my time, “Algol” used unqualified was understood to refer to Algol 60.

    This seems to have been the case before Algol 68 appeared.
    (I'm not sure this matches with what you call "in my time".)

    I named it always explicitly as "Algol 60" and "Algol 68".
    But at some instance of time I read somewhere that "Algol"
    would "now" refer to Algol 68, so I changed my habit.

    But since your post shows that this may not (not yet?) be
    common usage I'll be more specific in future. - Thanks for
    the hint!

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Stefan Ram on Sat Apr 6 18:49:38 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 05.04.2024 19:37, Stefan Ram wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote or quoted:

    [ Algol syntax variants, keywords vs. parenthesis ("meek form" ?) ]

    The parenthesis are not used for grouping, but are the alternative
    form for IF/THEN/ELSE/FI

    It's funny how the discussion oscillates between
    "too many parentheses" (LISP code) and "not enough parentheses"
    ("let me add some parens to improve readability").

    We should distinguish the various aspects posted over time.
    Parenthesis used...
    - to group sub-expressions (to make precedence clear or
    fix some precedence inconsistency in the language)
    => that's IMO a Good Thing for non-trivial cases
    - as necessary syntax of the language (like inherently
    in Lisp, or in C's control structures)
    => I don't like them, but you have no choice here
    (but changing the language, where/if possible)
    - as an alternative syntactic form of conditionals
    (as in Algol, where you can choose the syntax)
    => Personally I like the verbose keywords, but in
    case of conditional expressions the concise form
    with parenthesis might be better readable (though
    this can be different in complex cases as posted)
    Note that in Algol not only the 'IF's can be written
    in that parenthesis syntax form, you can also use
    the '(' and ')' instead of the 'BEGIN'/'END' keywords.

    It boils down to: to each his own, and, use what's most
    appropriate depending on context.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andy Walker@21:1/5 to Janis Papanagnou on Sat Apr 6 19:32:14 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 06/04/2024 17:57, Janis Papanagnou wrote:
    I named it always explicitly as "Algol 60" and "Algol 68".
    But at some instance of time I read somewhere that "Algol"
    would "now" refer to Algol 68, so I changed my habit.

    Quite right. Algol 60 died, for all practical purposes,
    half a century ago. Algol 68 may be a niche interest, but it is
    still a nice language, and its [dwindling] band of adherents and
    practitioners still use it and prefer it to C and other more
    recent languages.

    But since [LD'O's] post shows that this may not (not yet?) be
    common usage I'll be more specific in future. - Thanks for
    the hint!

    For how long? Does anyone still think that an unadorned
    "Unix" must refer to 6th Edition [or earlier], "C" to K&R, "Fortran"
    to Fortran IV, and so on? Clearly, there /are/ occasions when it is
    necessary to specify which version of a language/OS/computer/... is
    being referred to, and there is often a change-over period of a few
    years when an older version is still sufficiently current. But fifty
    years is surely long enough to get used to the newer version!

    --
    Andy Walker, Nottingham.
    Andy's music pages: www.cuboid.me.uk/andy/Music
    Composer of the day: www.cuboid.me.uk/andy/Music/Composers/Godfrey

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Andy Walker on Sat Apr 6 23:54:50 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 06.04.2024 20:32, Andy Walker wrote:
    On 06/04/2024 17:57, Janis Papanagnou wrote:
    I named it always explicitly as "Algol 60" and "Algol 68".
    But at some instance of time I read somewhere that "Algol"
    would "now" refer to Algol 68, so I changed my habit.

    Quite right. Algol 60 died, for all practical purposes,
    half a century ago. Algol 68 may be a niche interest, but it is
    still a nice language, and its [dwindling] band of adherents and practitioners still use it and prefer it to C and other more
    recent languages.

    I think it's a not only formally outstanding language; despite I've
    never used it professionally since my first contact with it in the
    early 1980's. (Though I still have a compiler on my private box to
    play with it.)


    But since [LD'O's] post shows that this may not (not yet?) be
    common usage I'll be more specific in future. - Thanks for
    the hint!

    For how long? Does anyone still think that an unadorned
    "Unix" must refer to 6th Edition [or earlier], "C" to K&R, "Fortran"
    to Fortran IV, and so on? Clearly, there /are/ occasions when it is necessary to specify which version of a language/OS/computer/... is
    being referred to, and there is often a change-over period of a few
    years when an older version is still sufficiently current. But fifty
    years is surely long enough to get used to the newer version!

    Yes. - What I didn't know was whether that generic "Algol" naming
    convention was already made around 1968 or maybe only much later.

    But, WRT Algol 60 vs. Algol 68, these are quite different languages;
    I wouldn't call the latter a new version. While some basic abstract
    concepts from Algol 60 have certainly been considered in Algol 68
    the whole design and specification process was done anew in Algol 68.
    (The van Wijngaarden grammar also was some fundamental new approach.)
    These languages can hardly be seen as "versions" of the same language.

    Algol 60, OTOH, also had an own history and continued use after 1968;
    to my knowledge it had been used in numerical mathematics and it was
    (while per se quite terse a language) the base of Simula 67, an
    extremely powerful language ahead of time (still).

    But Algol 60, Simula, and also Algol 68 are all meaningless today, I
    (sadly) dare to say. Maybe more than of "niche interest"? Can't tell.
    Back these days they certainly were not hyped (as languages nowadays
    are as part of the inventor's "marketing" activities). There's papers
    existing that try to explain the/possible reasons for their fail to
    become established.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Janis Papanagnou on Sat Apr 6 22:57:13 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sat, 6 Apr 2024 18:57:47 +0200, Janis Papanagnou wrote:

    I named it always explicitly as "Algol 60" and "Algol 68". But at some instance of time I read somewhere that "Algol" would "now" refer to
    Algol 68, so I changed my habit.

    Sure, Algol 60 is way beyond a museum piece by now. But remember, that was
    the one that spawned a great number of offshoots, namely the “Algol-like” language family--or really, superfamily. That included Pascal and its own offshoots.

    Algol 68 was a bit less influential in terms of language features (I think
    C “int”, “char”, “struct” and “union”, and the “long” and “short”
    qualifiers came from there, and csh “if ... fi” as well), but it did seem to introduce a bunch of new terminology, some of which caught on, others
    did not. See how many you can spot:

    * “Elaboration” for the process of executing a program (including possibly
    transforming from source form to an executable form)
    * “Transput” instead of “input/output”
    * “Heap” for an area in which memory may be dynamically allocated and
    freed in no particular order
    * “Overloading” for multiple context-dependent definitions of an operator
    * “Name” instead of “pointer” or “address”
    * “Mode” instead of “data type”
    * “Coercion” for a type conversion
    * “Cast” for an explicit type conversion
    * “Void” for a construct yielding no value
    * “Dereferencing” for following a pointer
    * “Slice” for a subarray of an array
    * “Pragmat” for compiler directive (I think “pragma” is more common
    nowadays.)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Lawrence D'Oliveiro on Sun Apr 7 01:47:13 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 07.04.2024 00:57, Lawrence D'Oliveiro wrote:

    Algol 68 was a bit less influential in terms of language features [...]
    See how many you can spot:

    * “Elaboration” for the process of executing a program (including possibly
    transforming from source form to an executable form)
    * “Transput” instead of “input/output”

    After all these decades it sounds still strange in my ears.

    * “Heap” for an area in which memory may be dynamically allocated and
    freed in no particular order
    * “Overloading” for multiple context-dependent definitions of an operator * “Name” instead of “pointer” or “address”

    Well, we had function parameters called "by name" before.

    And we have 'REF' for references. (Also seen in Simula 67.)

    * “Mode” instead of “data type”
    * “Coercion” for a type conversion
    * “Cast” for an explicit type conversion
    * “Void” for a construct yielding no value

    This is an interesting thing in Algol 68 if you study the
    details!

    As the "type" of statements it makes function definitions
    or the mentioned conditionals (statements and expressions)
    a coherent concept.

    * “Dereferencing” for following a pointer
    * “Slice” for a subarray of an array
    * “Pragmat” for compiler directive (I think “pragma” is more common
    nowadays.)

    And maybe printf() and the op:= set of operators, and more.

    I also find its collateral abilities very interesting. But I
    seem to recall that not every compiler supports that.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Muttley on Sat Apr 6 23:49:30 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sat, 6 Apr 2024 08:58:45 -0000 (UTC), Muttley wrote:

    Lisp overloads them as block markers which simply makes the code more confusing, not less.

    That’s because there is no fundamental difference between “blocks” and whatever else it is you think those Lisp parentheses are used for.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Janis Papanagnou on Sat Apr 6 23:57:39 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sun, 7 Apr 2024 01:47:13 +0200, Janis Papanagnou wrote:

    On 07.04.2024 00:57, Lawrence D'Oliveiro wrote:

    * “Name” instead of “pointer” or “address”

    Well, we had function parameters called "by name" before.

    Those were actually “thunks”. An early draft Algol 68 spec kept them on in the form of “proceduring” coercions, but these were dropped in the revised report.

    See also <https://en.wikipedia.org/wiki/Jensen%27s_device>.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Lawrence D'Oliveiro on Sun Apr 7 01:31:59 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 07.04.2024 00:57, Lawrence D'Oliveiro wrote:

    Sure, Algol 60 is way beyond a museum piece by now. But remember, that was the one that spawned a great number of offshoots, namely the “Algol-like” language family--or really, superfamily. That included Pascal and its own offshoots.

    Indeed, it became the base of a huge tree of important programming
    languages.


    Algol 68 was a bit less influential in terms of language features

    I like it more for its formal coherence than for specific features.

    But of course it also has a lot of features; besides some mentioned
    in your post, e.g., the generalized 'for' loop (that can even be
    abbreviated for control structure subsets), but that we also find
    (even in a more generalized version) already in Simula 67, BTW.

    (I think
    C “int”, “char”, “struct” and “union”, and the “long” and “short”
    qualifiers came from there, and csh “if ... fi” as well), [...]

    It was more a base for the Bourne shell family (and its successors,
    including POSIX shell through ksh88). But yes, it influenced quite
    some languages. And, yes, it was less influential than Algol 60.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Javier@21:1/5 to Johanne Fairchild on Sun Apr 7 00:01:43 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In comp.unix.shell Johanne Fairchild <jfairchild@tudado.org> wrote:
    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    At one time, we distinguished between “scripting” languages and
    “programming” languages. [...] But there is one distinction that I
    think is still relevant, and that is the one between shell/command
    languages and programming languages.

    [...]

    Consider looking at a shell language like a domain-specific programming language. A shell is a programming language made specifically for
    running programs. When you write a shell line, you're specifying the arguments of execve(2). In other words, a shell is a programming
    language made to prepare the memory to be consumed by the system in a specific way---execve(2).

    It certainly encourages the writing of small modular tools. The
    downside is the loss of performance because of disk access for trivial
    things like 'nfiles=$(ls | wc -l)'. I suspect disk access times where
    one of the reasons for the development of perl in the early 90s.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Javier on Sun Apr 7 02:02:15 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sun, 07 Apr 2024 00:01:43 +0000, Javier wrote:

    The downside is the loss of performance because of disk access for
    trivial things like 'nfiles=$(ls | wc -l)'.

    Well, you could save one process creation by writing
    “nfiles=$(echo * | wc -l)” instead. But that would still not be strictly correct.

    I suspect disk access times where
    one of the reasons for the development of perl in the early 90s.

    Shells were somewhat less powerful in those days. I would describe the
    genesis of Perl as “awk on steroids”. Its big party trick was regular expressions. And I guess combining that with more sophisticated data- structuring capabilities.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Alan Bawden@21:1/5 to Alan Bawden on Sun Apr 7 06:04:16 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@dastardlyhq.com writes:

    On Fri, 05 Apr 2024 19:35:37 -0400
    Alan Bawden <alan@csail.mit.edu> wrote:
    ...
    >I.e., she would allow herself to use spaces and newlines, and just

    ITYM "he" would allow HIMself.

    My practice when I am writing and I need a generic pronoun is to flip a
    coin to decide whether I am going to use "she" or "he". On this
    occasion the coin determined that I was going to write "she".

    I started doing this many years ago after some author, in his book's introduction, offered as a defense of using exclusively male pronouns in
    the rest of his book the fact that he had just used female pronouns in
    the previous paragraph, and "the reader will have found this jarring".
    Well I hadn't actually noticed that he had done that, and I had to go
    back and check to be sure he had.

    The book in question was a couple decades old at that time, so I took my failure to notice what the author thought I would find jarring as
    evidence that the language had evolved to the point where a occasional
    generic "she" would not offend a reasonable reader. So for years I've
    used "she" about 50% of the time, and nobody has _ever_ objected.

    Until today...

    Lets give the woke BS a miss, 95% of developers are men. It doesn't
    give you any brownie points, just makes you look a try-hard ass.

    It doesn't matter to me what percentage of developers are male. As long
    as there are _some_ female developers, it is possible that the developer
    in a hypothetical situation might be female, so it seems fair to
    occasionally use "she".

    If acknowledging the existence of female developers makes you
    uncomfortable, you're just going to have to learn to deal with that
    yourself. I'm not going to adjust my language to cater to your
    insecurities.

    - Alan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andy Walker@21:1/5 to Janis Papanagnou on Sun Apr 7 14:43:04 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 06/04/2024 22:54, Janis Papanagnou wrote:
    But, WRT Algol 60 vs. Algol 68, these are quite different languages;
    I wouldn't call the latter a new version.

    I agree; OTOH, WG2.1 accepted A68 as the "new" Algol. The
    instant question here was what an unadorned "Algol" means, and while
    I can see an argument for saying that it shouldn't happen, I can see
    no argument for saying that it, by default, refers to A60.

    [...]
    Algol 60, OTOH, also had an own history and continued use after 1968;
    to my knowledge it had been used in numerical mathematics [...].

    It was intended for use in the /description/ of NA, for which
    it was decently suitable. But it was unsuitable as a practical language
    for use in NA: no proper error control, no double-length numbers, no
    array slices, and doubtless other things I've forgotten. So you could
    say "Here is my new whizzo algorithm for [whatever]", get it published,
    and "everyone" would understand what your code meant. But in practice
    you would transcribe it into Fortran or some Autocode, typically twice
    as fast and with much better practical facilities.

    But Algol 60, Simula, and also Algol 68 are all meaningless today, I
    (sadly) dare to say.

    You're probably right. But A68G is still a nice language. It
    creaks in places, and it's not suitable for everything [what is?]. But
    it serves all my programming needs. It has the advantage, in practice,
    over C that all the common programming blunders -- use of uninitialised variables, array accesses out of bounds, numerical overflow, dereferencing
    null pointers, memory leaks and consequences thereof, the things that
    cause most of the security holes -- are picked up either by the compiler
    or at run-time before they can do any damage. I expect there are modern languages that also do that, but at my age it's not worth learning a new language when the old one works perfectly well.

    --
    Andy Walker, Nottingham.
    Andy's music pages: www.cuboid.me.uk/andy/Music
    Composer of the day: www.cuboid.me.uk/andy/Music/Composers/Haydn

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Janis Papanagnou on Sun Apr 7 15:47:18 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 06.04.2024 20:32, Andy Walker wrote:


    But Algol 60, Simula, and also Algol 68 are all meaningless today, I
    (sadly) dare to say. Maybe more than of "niche interest"? Can't tell.

    There is still some small amount of new Algol code being developed
    and likely quite a bit in production in Unisys Clearpath shops.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Andy Walker on Sun Apr 7 21:05:54 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sun, 7 Apr 2024 14:43:04 +0100, Andy Walker wrote:

    I can see no argument for saying that [“Algol”], by default, refers to A60.

    “Wirth-Hoare Algol”, a.k.a. “Algol-W” (the precursor of Pascal) was a derivative of Algol-60, not Algol-68 (which didn’t exist yet).

    “Burroughs Algol” was an implementation of Algol-60, not Algol-68.

    Even in the 21st century, articles like <https://seattlewebsitedevelopers.medium.com/algol-the-language-that-influenced-the-future-cfec9a3e2a4c>
    can say

    Generally called ALGOL 60, ALGOL had three major updates ...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to Alan Bawden on Mon Apr 8 07:47:05 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sun, 07 Apr 2024 06:04:16 -0400
    Alan Bawden <alan@csail.mit.edu> wrote:
    If acknowledging the existence of female developers makes you
    uncomfortable, you're just going to have to learn to deal with that
    yourself. I'm not going to adjust my language to cater to your
    insecurities.

    If my insecurities you mean acknowledging reality then fine. The thing about people like you is (and I don't believe the 50% thing, sorry) is that you
    would never use a male pronoun if talking about nurses or pre school teachers who are heavily biased towards women.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to Lawrence D'Oliveiro on Mon Apr 8 07:44:27 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sat, 6 Apr 2024 23:49:30 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Sat, 6 Apr 2024 08:58:45 -0000 (UTC), Muttley wrote:

    Lisp overloads them as block markers which simply makes the code more
    confusing, not less.

    That’s because there is no fundamental difference between “blocks” and >whatever else it is you think those Lisp parentheses are used for.

    Hmm, wonder why hardly anyone outside academia used the language even back in the day, never mind now....

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Andy Walker on Mon Apr 8 14:11:44 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 07.04.2024 15:43, Andy Walker wrote:

    I agree; OTOH, WG2.1 accepted A68 as the "new" Algol. The
    instant question here was what an unadorned "Algol" means, and while
    I can see an argument for saying that it shouldn't happen, I can see
    no argument for saying that it, by default, refers to A60.

    Well, after that other post I decided to explicitly differentiate them
    per year suffix to not confuse anyone. That's okay for me. (OTOH I just
    notice that I missed to identify "Simula" as "Simula 67"; there's also
    "Simula I". But in case of Simula it's anyway more of a version.[*])


    But Algol 60, Simula, and also Algol 68 are all meaningless today, I
    (sadly) dare to say.

    You're probably right. But A68G is still a nice language. It
    creaks in places, and it's not suitable for everything [what is?]. But
    it serves all my programming needs. It has the advantage, in practice,
    over C that all the common programming blunders -- use of uninitialised variables, array accesses out of bounds, numerical overflow, dereferencing null pointers, memory leaks and consequences thereof, the things that
    cause most of the security holes -- are picked up either by the compiler
    or at run-time before they can do any damage. I expect there are modern languages that also do that, but at my age it's not worth learning a new language when the old one works perfectly well.

    Yes, indeed.

    Janis

    [*] Nice fact, BTW, that you can compile (almost all) Algol 60
    programs with Simula 67 - Algol 60 is [mostly] a subset - but not
    with Algol 68, which is a different language.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Brown@21:1/5 to Muttley@dastardlyhq.com on Mon Apr 8 14:35:48 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 08/04/2024 09:47, Muttley@dastardlyhq.com wrote:
    On Sun, 07 Apr 2024 06:04:16 -0400
    Alan Bawden <alan@csail.mit.edu> wrote:
    If acknowledging the existence of female developers makes you
    uncomfortable, you're just going to have to learn to deal with that
    yourself. I'm not going to adjust my language to cater to your
    insecurities.

    If my insecurities you mean acknowledging reality then fine. The thing about people like you is (and I don't believe the 50% thing, sorry) is that you would never use a male pronoun if talking about nurses or pre school teachers who are heavily biased towards women.


    What makes you so sure about that? Are you assuming that because /you/
    are sexist, everyone else is?

    It is a fact that some professions have a heavy gender bias. Yes, most programmers are male, and most nurses are female. It is even reasonable
    to say that for some tasks there are statistically relevant biological differences that justify a bias (in the same way that you can say men
    are, on average, taller than women, even though some women are taller
    than some men).

    But is it a good thing that there is such gender bias? Usually not - it
    is usually best to have a mix in all practical ways (genders, race, nationality, age, etc.).

    Being inclusive in the language used is not likely to make a big dent in attracting people from poorly represented groups in a particular field -
    but using non-inclusive language does make a difference in chasing away
    those that venture in. Worst of all is people like you who actively say
    that women programmers are so abnormal we should ignore the possibility
    of their existence!

    Some people write "he/she". Some people alternate gender pronouns, or
    pick randomly. Some people use "they", or try to avoid using pronouns
    at all in their wording. These are all fine. It is also entirely understandable that some people just write "he" because they don't think
    about it at all. But I can't understand the mentality of someone who
    actively tries to work against inclusive language. We are not talking
    about some kind of quota system that you might feel is unfair, or even requiring you to change /your/ language - we are talking about someone
    who used "she" in reference to "a normal programmer", and that has got
    you throwing a fit.

    And for the record, I would use he/she/they for nurses or pre-school
    teachers if I did not know the gender of the individual.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Lawrence D'Oliveiro on Mon Apr 8 14:53:09 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 07.04.2024 23:05, Lawrence D'Oliveiro wrote:

    Even in the 21st century, articles like <https://seattlewebsitedevelopers.medium.com/algol-the-language-that-influenced-the-future-cfec9a3e2a4c>
    can say

    Generally called ALGOL 60, ALGOL had three major updates ...

    An extremely badly written article in *all* aspects (form, content,
    facts, quality, etc.). Not worth reading (I've just read it).
    And thus even less useful as sort of "reference" to any argument.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to David Brown on Mon Apr 8 14:33:25 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Mon, 8 Apr 2024 14:35:48 +0200
    David Brown <david.brown@hesbynett.no> wrote:
    On 08/04/2024 09:47, Muttley@dastardlyhq.com wrote:
    On Sun, 07 Apr 2024 06:04:16 -0400
    Alan Bawden <alan@csail.mit.edu> wrote:
    If acknowledging the existence of female developers makes you
    uncomfortable, you're just going to have to learn to deal with that
    yourself. I'm not going to adjust my language to cater to your
    insecurities.

    If my insecurities you mean acknowledging reality then fine. The thing about >> people like you is (and I don't believe the 50% thing, sorry) is that you
    would never use a male pronoun if talking about nurses or pre school teachers

    who are heavily biased towards women.


    What makes you so sure about that? Are you assuming that because /you/
    are sexist, everyone else is?

    An immediate fallacious ad hominem no doubt in order to prop up whatever
    straw men follow.

    tl;dr, bugger off.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Javier@21:1/5 to John Ames on Mon Apr 8 17:54:42 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In comp.unix.shell John Ames <commodorejohn@gmail.com> wrote:
    On Sun, 07 Apr 2024 00:01:43 +0000
    Javier <invalid@invalid.invalid> wrote:

    the loss of performance because of disk access for trivial
    things like 'nfiles=$(ls | wc -l)'. I suspect disk access times where
    one of the reasons for the development of perl in the early 90s.

    You really want either built-ins for a lot of basic commands, or a good scheme for caching commonly-used executables. AmigaDOS (a TriPOS
    derivative) made it pretty trivial to set up a RAM disk and add that to
    the search path, which made a big difference in performance since
    almost nothing was built-in. Wouldn't be hard to do in *nix-land,
    either, but it's an open question whether you'd gain anything over
    modern generalized disk caching.

    I don't worry about that anymore. My bash scripts run blazing fast
    in my laptop with an SSD. I guess it was an issue at the time Perl
    appeared (1987), although TBH I didn't experience it myself, since at
    that time I wasn't a Unix user.

    Also, I suspect HD caching and the increase in HD speed was one of the
    reasons for the fall in popularity of Perl for writing small system
    automation tasks that could be done with just shell. But there were
    another reasons, like the disapearance of diversity in the Unix OS ecosystem. Perl made easy to write portable scripts that could run on propietary Unixen that came with slight incompatibilities in the command line tools (IRIX/Solaris/HP-UX/AIX, etc.)

    Perhaps somebody here who uses (or used to use) Perl for system
    automation tasks can tell us more about their personal reasons
    for prefering (or used to prefer) Perl over shell.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Muttley@dastardlyhq.com on Mon Apr 8 19:32:21 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-04-08, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    On Mon, 8 Apr 2024 14:35:48 +0200
    David Brown <david.brown@hesbynett.no> wrote:
    On 08/04/2024 09:47, Muttley@dastardlyhq.com wrote:
    On Sun, 07 Apr 2024 06:04:16 -0400
    Alan Bawden <alan@csail.mit.edu> wrote:
    If acknowledging the existence of female developers makes you
    uncomfortable, you're just going to have to learn to deal with that
    yourself. I'm not going to adjust my language to cater to your
    insecurities.

    If my insecurities you mean acknowledging reality then fine. The thing about
    people like you is (and I don't believe the 50% thing, sorry) is that you >>> would never use a male pronoun if talking about nurses or pre school teachers

    who are heavily biased towards women.


    What makes you so sure about that? Are you assuming that because /you/
    are sexist, everyone else is?

    An immediate fallacious ad hominem no doubt in order to prop up whatever straw men follow.

    You wrote, "people like you ... would never use a male pronoun if
    talking about nurses", written by you, is already ad hominem;
    it's a direct accusation of hypocrisy, rather than focusing on the
    argument content.

    If you can't handle the ad-hominem ball returned to your court,
    don't serve it!

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to John Ames on Mon Apr 8 22:14:16 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Mon, 8 Apr 2024 08:20:37 -0700, John Ames wrote:

    ... compulsively indenting and
    splitting across lines can get out of hand, too. It seems to me that a
    lot of people in this age of "cinematic" aspect ratios and super-sized displays in personal computing forget that eye-travel isn't free, and spreading information across maximal space can make it *harder* to keep
    track of context.

    There it is again: “maximal space”. The “space” is there to be used. Code may be one-dimensional, but you have a two-dimensional screen to
    display it, why not make use of that, if it makes a complex structure
    clearer?

    Another example:

    def fill_in_depreciations(tax_year) :
    "(re)inserts depreciation entries for the specified tax year," \
    " based on currently-entered assets."
    sql.cursor.execute \
    (
    "delete from payments where kind = %s and tax_year = %s",
    ["D", tax_year]
    )
    for \
    entry \
    in \
    get_each_record \
    (
    table_name = "assets, asset_depreciations",
    fields =
    [
    "assets.description as description",
    "assets.initial_value as initial_value",
    "assets.when_purchased as when_purchased",
    "assets.depreciation_rate as rate",
    "assets.depreciation_method as method",
    "asset_depreciations.depreciation_amount as amount",
    ],
    condition =
    "assets.asset_id = asset_depreciations.asset_id and"
    " asset_depreciations.tax_year = %s",
    values = [tax_year]
    ) \
    :
    sql.cursor.execute \
    (
    "insert into payments set when_made = %(when_made)s,"
    " description = %(description)s, other_party_name = \"\","
    " amount = %(amount)d, kind = \"D\", tax_year = %(tax_year)d"
    %
    {
    "when_made" : end_for_tax_year(tax_year) - 1,
    "description" :
    sql_string
    (
    "%s: %s $%s at %d%% from %s"
    %
    (
    entry["description"],
    entry["method"],
    format_amount(entry["initial_value"]),
    entry["rate"],
    format_date(entry["when_purchased"]),
    )
    ),
    "amount" : - entry["amount"],
    "tax_year" : tax_year,
    }
    )
    #end for
    #end fill_in_depreciations

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Muttley on Mon Apr 8 22:16:08 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Mon, 8 Apr 2024 07:44:27 -0000 (UTC), Muttley wrote:

    Hmm, wonder why hardly anyone outside academia used the language even back in the day, never mind now....

    *cough* AutoCAD *cough*

    (Even if they did end up doing it wrong.)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Javier on Mon Apr 8 22:21:29 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Mon, 08 Apr 2024 17:54:42 +0000, Javier wrote:

    Also, I suspect HD caching and the increase in HD speed was one of the reasons for the fall in popularity of Perl for writing small system automation tasks that could be done with just shell. But there were
    another reasons, like the disapearance of diversity in the Unix OS
    ecosystem.

    Systems that can legally be called “Unix®” may be essentially extinct, but Linux on its own offers more diversity than they could manage, anyway.

    And yes, Perl may not be the Hot New Thing™, but it still lives on.

    On my Debian system:

    ldo@theon:~> apt-cache rdepends perl | sort | uniq | wc -l
    1115

    Perl made easy to write portable scripts that could run on propietary
    Unixen that came with slight incompatibilities in the command line tools (IRIX/Solaris/HP-UX/AIX, etc.)

    I thought the usual way any self-respecting Unix sysadmin fixed that
    problem was by installing the GNU tools.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Lawrence D'Oliveiro on Mon Apr 8 23:02:52 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-04-08, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    There it is again: “maximal space”. The “space” is there to be used. Code may be one-dimensional, but you have a two-dimensional screen to
    display it, why not make use of that, if it makes a complex structure clearer?

    A canvas is two dimensional. That doesn't mean that a chimpanzee with
    a brush is Rembrandt.


    Another example:

    def fill_in_depreciations(tax_year) :
    "(re)inserts depreciation entries for the specified tax year," \
    " based on currently-entered assets."
    sql.cursor.execute \
    (
    "delete from payments where kind = %s and tax_year = %s",
    ["D", tax_year]
    )
    for \
    entry \
    in \
    get_each_record \

    This ain't Rembrandt.

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to Kaz Kylheku on Tue Apr 9 07:45:51 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Mon, 8 Apr 2024 19:32:21 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:
    On 2024-04-08, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    On Mon, 8 Apr 2024 14:35:48 +0200
    David Brown <david.brown@hesbynett.no> wrote:
    On 08/04/2024 09:47, Muttley@dastardlyhq.com wrote:
    What makes you so sure about that? Are you assuming that because /you/ >>>are sexist, everyone else is?

    An immediate fallacious ad hominem no doubt in order to prop up whatever
    straw men follow.

    You wrote, "people like you ... would never use a male pronoun if
    talking about nurses", written by you, is already ad hominem;
    it's a direct accusation of hypocrisy, rather than focusing on the
    argument content.

    Mine was correct in general, yours shows you don't understand the difference between sexism and realism. But then the woke mindset is simply a secular religion so logic doesn't apply.

    If you can't handle the ad-hominem ball returned to your court,
    don't serve it!

    In tennis spectators don't generally jump onto the court and return the ball.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Muttley@dastardlyhq.com on Tue Apr 9 07:57:24 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-04-09, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    On Mon, 8 Apr 2024 19:32:21 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:
    On 2024-04-08, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    On Mon, 8 Apr 2024 14:35:48 +0200
    David Brown <david.brown@hesbynett.no> wrote:
    On 08/04/2024 09:47, Muttley@dastardlyhq.com wrote:
    What makes you so sure about that? Are you assuming that because /you/ >>>>are sexist, everyone else is?

    An immediate fallacious ad hominem no doubt in order to prop up whatever >>> straw men follow.

    You wrote, "people like you ... would never use a male pronoun if
    talking about nurses", written by you, is already ad hominem;
    it's a direct accusation of hypocrisy, rather than focusing on the
    argument content.

    Mine was correct in general, yours shows you don't understand the difference between sexism and realism.

    I've not addressed myself to that topic whatsoever, let alone revealed
    a position.


    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Kettlewell@21:1/5 to John Ames on Tue Apr 9 08:47:03 2024
    XPost: comp.unix.shell, comp.unix.programmer

    John Ames <commodorejohn@gmail.com> writes:
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    There it is again: “maximal space”. The “space” is there to be used. >> Code may be one-dimensional, but you have a two-dimensional screen to
    display it, why not make use of that, if it makes a complex structure
    clearer?

    Like I said: eye-travel. If the same amount of information is spread
    out over a larger space, there comes a point where it's actually *more*
    work to read, and it eventually becomes harder for the brain to keep
    track of the relevant context as a result; the "flow" is broken.

    Also, the more it’s spread out, the less of it you can get on one
    screen, and the resulting need for paging makes the medium-scale
    structure a lot less clear.

    --
    https://www.greenend.org.uk/rjk/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Muttley@dastardlyhq.com on Tue Apr 9 10:02:25 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 09.04.2024 09:45, Muttley@dastardlyhq.com wrote:
    On Mon, 8 Apr 2024 19:32:21 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:

    If you can't handle the ad-hominem ball returned to your court,
    don't serve it!

    In tennis spectators don't generally jump onto the court and return the ball.

    If players missed the goal and hit the net there's ball kids that
    jump onto the court to fetch the misguided balls.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Richard Kettlewell on Tue Apr 9 10:07:13 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 09.04.2024 09:47, Richard Kettlewell wrote:
    John Ames <commodorejohn@gmail.com> writes:
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    There it is again: “maximal space”. The “space” is there to be used.
    Code may be one-dimensional, but you have a two-dimensional screen to
    display it, why not make use of that, if it makes a complex structure
    clearer?

    Like I said: eye-travel. If the same amount of information is spread
    out over a larger space, there comes a point where it's actually *more*
    work to read, and it eventually becomes harder for the brain to keep
    track of the relevant context as a result; the "flow" is broken.

    Also, the more it’s spread out, the less of it you can get on one
    screen, and the resulting need for paging makes the medium-scale
    structure a lot less clear.

    Add structuring code (e.g. using functions) to manage complexity
    and make it possible to keep entities in appropriate sizes.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Brown@21:1/5 to Richard Kettlewell on Tue Apr 9 10:11:09 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 09/04/2024 09:47, Richard Kettlewell wrote:
    John Ames <commodorejohn@gmail.com> writes:
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    There it is again: “maximal space”. The “space” is there to be used.
    Code may be one-dimensional, but you have a two-dimensional screen to
    display it, why not make use of that, if it makes a complex structure
    clearer?

    Like I said: eye-travel. If the same amount of information is spread
    out over a larger space, there comes a point where it's actually *more*
    work to read, and it eventually becomes harder for the brain to keep
    track of the relevant context as a result; the "flow" is broken.

    Also, the more it’s spread out, the less of it you can get on one
    screen, and the resulting need for paging makes the medium-scale
    structure a lot less clear.


    And if you need line continuation characters - ending the line in "\" in
    this case - it's a sure sign that you are doing something questionable.
    In some cases it is unavoidable, such as for complex macros in C or for
    long lists in bash, but it is extremely rare that it is necessary in
    Python code.

    Comments to say when your loop or functions end is another big red flag
    that the layout is bad.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to David Brown on Tue Apr 9 08:38:02 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Tue, 9 Apr 2024 10:11:09 +0200, David Brown wrote:

    Comments to say when your loop or functions end is another big red flag
    that the layout is bad.

    Without #end comments: how easy is it to tell which lines belong to
    the inner function, and which to the outer?

    def set_message(self, message) :

    w_self = weak_ref(self)

    def wrap_message(c_conn, c_message, c_user_data) :
    self = _wderef(w_self, "vtable")
    conn = Connection(dbus.dbus_connection_ref(c_conn))
    msg = Message(dbus.dbus_message_ref(c_message))
    user_data = conn._user_data.get(c_user_data)
    result = message(conn, msg, user_data)
    if asyncio.iscoroutine(result) :
    self.create_task(result)
    result = DBUS.HANDLER_RESULT_HANDLED
    return \
    result

    if message != None :
    self._wrap_message_func = DBUS.ObjectPathMessageFunction(wrap_message)
    else :
    self._wrap_message_func = None
    self._dbobj.message_function = self._wrap_message_func
    return \
    self

    Now, with #end comments (and a #begin as well, for good measure):

    def set_message(self, message) :

    w_self = weak_ref(self)

    def wrap_message(c_conn, c_message, c_user_data) :
    self = _wderef(w_self, "vtable")
    conn = Connection(dbus.dbus_connection_ref(c_conn))
    msg = Message(dbus.dbus_message_ref(c_message))
    user_data = conn._user_data.get(c_user_data)
    result = message(conn, msg, user_data)
    if asyncio.iscoroutine(result) :
    self.create_task(result)
    result = DBUS.HANDLER_RESULT_HANDLED
    #end if
    return \
    result
    #end wrap_message

    #begin set_message
    if message != None :
    self._wrap_message_func = DBUS.ObjectPathMessageFunction(wrap_message)
    else :
    self._wrap_message_func = None
    #end if
    self._dbobj.message_function = self._wrap_message_func
    return \
    self
    #end set_message

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Brown@21:1/5 to Lawrence D'Oliveiro on Tue Apr 9 15:22:25 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 09/04/2024 10:38, Lawrence D'Oliveiro wrote:
    On Tue, 9 Apr 2024 10:11:09 +0200, David Brown wrote:

    Comments to say when your loop or functions end is another big red flag
    that the layout is bad.

    Without #end comments: how easy is it to tell which lines belong to
    the inner function, and which to the outer?


    You could try doing what almost every other Python programmer does - use smaller functions and drop the silly line continuations.

    When you see that you have a style that is very different from all the
    others you see around you, you have to consider what is more likely -
    are you a lone genius that sees what no one else does, or are you doing something weird and unhelpful?

    Now, I know there are plenty of people who think Python's method of
    determining blocks is not ideal. But look up some statistics comparing
    Pascal and Python usage, and it should be quite clear that begin/end is
    not something many people find necessary.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to Scott Lurndal on Tue Apr 9 15:09:01 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Tue, 09 Apr 2024 15:01:46 GMT
    scott@slp53.sl.home (Scott Lurndal) wrote:
    Muttley@dastardlyhq.com writes:
    On Mon, 8 Apr 2024 19:32:21 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:
    On 2024-04-08, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    On Mon, 8 Apr 2024 14:35:48 +0200
    David Brown <david.brown@hesbynett.no> wrote:
    On 08/04/2024 09:47, Muttley@dastardlyhq.com wrote:
    What makes you so sure about that? Are you assuming that because /you/ >>>>>are sexist, everyone else is?

    An immediate fallacious ad hominem no doubt in order to prop up whatever >>>> straw men follow.

    You wrote, "people like you ... would never use a male pronoun if
    talking about nurses", written by you, is already ad hominem;
    it's a direct accusation of hypocrisy, rather than focusing on the >>>argument content.

    Mine was correct in general

    Only in your worldview.

    FWIW, at the local A&E, the split is about 50-50.

    What local A&E? Here in the UK the vast majority of nurses are female whereas with doctors its a more even mix.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Muttley@dastardlyhq.com on Tue Apr 9 15:01:46 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@dastardlyhq.com writes:
    On Mon, 8 Apr 2024 19:32:21 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:
    On 2024-04-08, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    On Mon, 8 Apr 2024 14:35:48 +0200
    David Brown <david.brown@hesbynett.no> wrote:
    On 08/04/2024 09:47, Muttley@dastardlyhq.com wrote:
    What makes you so sure about that? Are you assuming that because /you/ >>>>are sexist, everyone else is?

    An immediate fallacious ad hominem no doubt in order to prop up whatever >>> straw men follow.

    You wrote, "people like you ... would never use a male pronoun if
    talking about nurses", written by you, is already ad hominem;
    it's a direct accusation of hypocrisy, rather than focusing on the
    argument content.

    Mine was correct in general

    Only in your worldview.

    FWIW, at the local A&E, the split is about 50-50.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Muttley@dastardlyhq.com on Tue Apr 9 15:30:15 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@dastardlyhq.com writes:
    On Tue, 09 Apr 2024 15:01:46 GMT
    scott@slp53.sl.home (Scott Lurndal) wrote:
    Muttley@dastardlyhq.com writes:
    On Mon, 8 Apr 2024 19:32:21 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:
    On 2024-04-08, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote: >>>>> On Mon, 8 Apr 2024 14:35:48 +0200
    David Brown <david.brown@hesbynett.no> wrote:
    On 08/04/2024 09:47, Muttley@dastardlyhq.com wrote:
    What makes you so sure about that? Are you assuming that because /you/ >>>>>>are sexist, everyone else is?

    An immediate fallacious ad hominem no doubt in order to prop up whatever >>>>> straw men follow.

    You wrote, "people like you ... would never use a male pronoun if >>>>talking about nurses", written by you, is already ad hominem;
    it's a direct accusation of hypocrisy, rather than focusing on the >>>>argument content.

    Mine was correct in general

    Only in your worldview.

    FWIW, at the local A&E, the split is about 50-50.

    What local A&E? Here in the UK the vast majority of nurses are female whereas >with doctors its a more even mix.

    Across the pond.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to John Ames on Tue Apr 9 16:01:11 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Tue, 9 Apr 2024 08:40:09 -0700
    John Ames <commodorejohn@gmail.com> wrote:
    On Tue, 9 Apr 2024 15:09:01 -0000 (UTC)
    Muttley@dastardlyhq.com wrote:

    Mine was correct in general

    Only in your worldview.

    FWIW, at the local A&E, the split is about 50-50.

    What local A&E? Here in the UK the vast majority of nurses are female
    whereas with doctors its a more even mix.

    "I was actually correct in a broadly objective sense, if you discount >attestations to the contrary because I don't feel they match my
    specific experience" is a *special* breed of argument :|

    You could say the same thing about the OP.

    I've never been in a hospital where the nurses were anything other than about 95% women and frankly I don't believe the 50-50 split he's citing unless "nurse"
    has a different definition in the USA. Sounds like something he plucked out his arse to try to win a point.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Kettlewell@21:1/5 to Janis Papanagnou on Tue Apr 9 18:57:40 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 09.04.2024 09:47, Richard Kettlewell wrote:
    John Ames <commodorejohn@gmail.com> writes:
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    There it is again: “maximal space”. The “space” is there to be used.
    Code may be one-dimensional, but you have a two-dimensional screen to
    display it, why not make use of that, if it makes a complex structure
    clearer?

    Like I said: eye-travel. If the same amount of information is spread
    out over a larger space, there comes a point where it's actually *more*
    work to read, and it eventually becomes harder for the brain to keep
    track of the relevant context as a result; the "flow" is broken.

    Also, the more it’s spread out, the less of it you can get on one
    screen, and the resulting need for paging makes the medium-scale
    structure a lot less clear.

    Add structuring code (e.g. using functions) to manage complexity
    and make it possible to keep entities in appropriate sizes.

    Yes, but that should be driven by the natural structure of the problem,
    rather than by the relationship between layout and screen size.

    --
    https://www.greenend.org.uk/rjk/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to David Brown on Wed Apr 10 00:32:47 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Tue, 9 Apr 2024 15:22:25 +0200, David Brown wrote:

    You could try doing what almost every other Python programmer does - use smaller functions and drop the silly line continuations.

    Fine. Try that with the example I gave.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Lawrence D'Oliveiro on Wed Apr 10 01:35:10 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-04-10, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Tue, 9 Apr 2024 15:22:25 +0200, David Brown wrote:

    You could try doing what almost every other Python programmer does - use
    smaller functions and drop the silly line continuations.

    Fine. Try that with the example I gave.

    Maybe you have a Python-coding niece or nephew in the fifth grade who can reformat it for you?

    Meanwhile:

    Pass 1:

    def fill_in_depreciations(tax_year) :
    """
    (re)inserts depreciation entries for the specified tax year,
    based on currently-entered assets.
    """

    sql.cursor.execute("delete from payments where kind = %s and tax_year = %s",
    ["D", tax_year])
    for entry in get_each_record(table_name = "assets, asset_depreciations",
    fields = [
    "assets.description as description",
    "assets.initial_value as initial_value",
    "assets.when_purchased as when_purchased",
    "assets.depreciation_rate as rate",
    "assets.depreciation_method as method",
    "asset_depreciations.depreciation_amount as amount",
    ],
    condition = "assets.asset_id = asset_depreciations.asset_id and"
    " asset_depreciations.tax_year = %s",
    values = [tax_year]):
    sql.cursor.execute("insert into payments set when_made = %(when_made)s,"
    " description = %(description)s, other_party_name = \"\","
    " amount = %(amount)d, kind = \"D\", tax_year = %(tax_year)d"
    % { "when_made" : end_for_tax_year(tax_year) - 1,
    "description" : sql_string("%s: %s $%s at %d%% from %s" %
    (entry["description"],
    entry["method"],
    format_amount(entry["initial_value"]),
    entry["rate"],
    format_date(entry["when_purchased"]))),
    "amount" : - entry["amount"],
    "tax_year" : tax_year })



    Pass 2: fits into 80 cols and everything:

    def fill_in_depreciations(tax_year) :
    """
    (re)inserts depreciation entries for the specified tax year,
    based on currently-entered assets."
    """

    table = "assets, asset_depreciations"

    fields = ["assets.description as description",
    "assets.initial_value as initial_value",
    "assets.when_purchased as when_purchased",
    "assets.depreciation_rate as rate",
    "assets.depreciation_method as method",
    "asset_depreciations.depreciation_amount as amount"]

    condition = ("assets.asset_id = asset_depreciations.asset_id and"
    " asset_depreciations.tax_year = %s")

    insert = ("insert into payments set when_made = %(when_made)s,"
    " description = %(description)s, other_party_name = \"\","
    " amount = %(amount)d, kind = \"D\", tax_year = %(tax_year)d")

    sql.cursor.execute("delete from payments where kind = %s and tax_year = %s",
    ["D", tax_year])

    for entry in get_each_record(table_name = table_name, fields = fields,
    condition = condition, values = [tax_year]):
    desc = sql_string("%s: %s $%s at %d%% from %s" %
    (entry["description"],
    entry["method"],
    format_amount(entry["initial_value"]),
    entry["rate"],
    format_date(entry["when_purchased"])))
    sql.cursor.execute(insert %
    {"when_made" : end_for_tax_year(tax_year) - 1,
    "description" : desc,
    "amount" : - entry["amount"],
    "tax_year" : tax_year})

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andy Walker@21:1/5 to Janis Papanagnou on Wed Apr 10 10:10:00 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 08/04/2024 13:53, Janis Papanagnou wrote:
    On 07.04.2024 23:05, Lawrence D'Oliveiro wrote:
    Even in the 21st century, articles like
    <https:// [... snipped, to avoid giving it more publicity -- ANW]
    An extremely badly written article in *all* aspects (form, content,
    facts, quality, etc.).

    Agreed. I think it is a prime candidate for the worst serious supposedly-scientific web page I've ever seen. If it was written by a
    12yo with access to ChatGPT, that would not surprise me. It has two
    indirect redeeming features:

    -- It pointed me at "https://opensource.com/article/20/6/algol68",
    which /is/ worth reading.

    -- Its list of the A60 committee members prompted me to check, and I
    found, somewhat to my surprise, that one of them, Mike Woodger,
    who I worked with briefly nearly 50 years ago, is still alive, aged
    101. Having recently seen a couple of new scientific papers by F. G.
    Smith, the former Astronomer Royal, aged 100, perhaps we are entering
    a new era of golden oldies? Richard Guy made it to 103, and was still
    working past his century. I know of a fair number of nonagenarians,
    not least Tom Lehrer [96 yesterday], but [mostly] not whether they are
    still active.

    --
    Andy Walker, Nottingham.
    Andy's music pages: www.cuboid.me.uk/andy/Music
    Composer of the day: www.cuboid.me.uk/andy/Music/Composers/Necke

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenny McCormack@21:1/5 to Keith.S.Thompson+u@gmail.com on Wed Apr 10 12:05:10 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <87jzl5fz4c.fsf@nosuchdomain.example.com>,
    Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
    Muttley@dastardlyhq.com writes:
    [...]
    ITYM "he" would allow HIMself.

    I am looking forward with great eagerness to this subthread dying out,
    and I encourage everyone to help make that happen.

    Leader Keith has spoken. All must obey.

    --
    It's possible that leasing office space to a Starbucks is a greater liability in today's GOP than is hitting your mother on the head with a hammer.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Andy Walker on Wed Apr 10 14:43:54 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 10.04.2024 11:10, Andy Walker wrote:
    On 08/04/2024 13:53, Janis Papanagnou wrote:
    On 07.04.2024 23:05, Lawrence D'Oliveiro wrote:
    Even in the 21st century, articles like
    <https:// [... snipped, to avoid giving it more publicity -- ANW]
    An extremely badly written article in *all* aspects (form, content,
    facts, quality, etc.).

    Agreed. I think it is a prime candidate for the worst serious supposedly-scientific web page I've ever seen.

    Oh, I haven't perceived its intention as being scientific; yet worse
    if that's the case of that web site in general. (I've just read that
    one article.)

    If it was written by a
    12yo with access to ChatGPT, that would not surprise me.

    :-) Wouldn't surprise these days, indeed.

    It has two
    indirect redeeming features:

    -- It pointed me at "https://opensource.com/article/20/6/algol68",
    which /is/ worth reading.

    Indeed interesting. (I've meanwhile, after your hint, read it.)


    -- Its list of the A60 committee members prompted me to check, and I
    found, somewhat to my surprise, that one of them, Mike Woodger,
    who I worked with briefly nearly 50 years ago, is still alive, aged
    101. Having recently seen a couple of new scientific papers by F. G.
    Smith, the former Astronomer Royal, aged 100, perhaps we are entering
    a new era of golden oldies? Richard Guy made it to 103, and was still
    working past his century. I know of a fair number of nonagenarians,
    not least Tom Lehrer [96 yesterday], but [mostly] not whether they are
    still active.

    Interestingly, WRT committee members, that was one detail that annoyed
    me; Friedrich L. Bauer was mentioned twice, once as "Friedrich Baue"
    and once as "Friedric L. Bauer", both wrongly spelled (and not even consistently wrong). - He died 9 years ago at age of 91. Two weeks ago
    would have been his centenary! He established the CS chair here at the university and (as is said) held the very first "official" CS lectures
    in Germany. - I had the opportunity to hear his lectures during the
    1980's.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Janis Papanagnou on Wed Apr 10 19:03:41 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 10.04.2024 14:43, Janis Papanagnou wrote:

    [ Friedrich L. Bauer ] - He died 9 years ago at age of 91.
    Two weeks ago would have been his centenary!

    Correction: Two weeks ago was his 9th death day anniversary.
    His centenary will be in two months. - Just noticed my error,
    sorry.

    Janis


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Javier on Fri Apr 12 15:48:37 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 08.04.2024 19:54, Javier wrote:

    I don't worry about that anymore. My bash scripts run blazing fast
    in my laptop with an SSD.

    If speed would be an issue you could also switch to faster POSIX
    shells than Bash, like Ksh.

    But speed very much depend on the tasks you actually do with them.
    Sometimes Shells are "misused".

    I guess it was an issue at the time Perl
    appeared (1987), although TBH I didn't experience it myself, since at
    that time I wasn't a Unix user.

    Also, I suspect HD caching and the increase in HD speed was one of the reasons for the fall in popularity of Perl for writing small system automation tasks that could be done with just shell. But there were
    another reasons, like the disapearance of diversity in the Unix OS ecosystem. Perl made easy to write portable scripts that could run on propietary Unixen that came with slight incompatibilities in the command line tools (IRIX/Solaris/HP-UX/AIX, etc.)

    Some notes...
    You have the portability only if you use the same version on all
    target systems.
    To write scripts portably you use standards; like POSIX (including
    the POSIX shells).
    I suppose there's no Perl standard yet?
    You may not have Perl in professional environments available (for
    security considerations, maintenance decisions, policies).


    Perhaps somebody here who uses (or used to use) Perl for system
    automation tasks can tell us more about their personal reasons
    for prefering (or used to prefer) Perl over shell.

    I've programmed in Perl but I'm no Perl-programmer notwithstanding.
    Some more or less obvious reasons I see...
    Abstraction of diverse Unix utilities' interfaces.
    Supporting data structures (beyond primitive arrays).
    Expressiveness.
    Extensive libraries and supporting solutions available.
    One tool instead of a tool chest. (A simplified view, granted.)
    Less quirks than Shell. (I'm saying that as a decades long and
    experienced Shell programmer.)
    I'm reluctant to speak about Shell's crude syntax as one reason,
    since I also dislike Perl's.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Keith Thompson on Fri Apr 12 15:55:30 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 07.04.2024 05:46, Keith Thompson wrote:
    Lawrence D'Oliveiro <ldo@nz.invalid> writes:
    On Sun, 07 Apr 2024 00:01:43 +0000, Javier wrote:

    The downside is the loss of performance because of disk access for
    trivial things like 'nfiles=$(ls | wc -l)'.

    Well, you could save one process creation by writing
    “nfiles=$(echo * | wc -l)” instead. But that would still not be strictly >> correct.

    If that saves a process, it's because echo is builtin.

    You can use only built-ins, e.g. along the line of

    set * ; nfiles=$#

    (It's not only faster but also has less issues.)

    Janis

    But it will set
    $nfiles to 1 (unless you happen to have files with newlines in their
    names). Both skip hidden files, which may or may not be what you want.

    [...]


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Stefan Ram on Sat Apr 13 21:54:58 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 13 Apr 2024 08:18:07 GMT, Stefan Ram wrote:

    Python:

    There should be one - and preferably only one - obvious way to do it.
    Although that way may not be obvious at first unless you're Dutch.

    Actually, given the overlap between functions and classes, there are often multiple ways to do things.

    Unlike Perl, most of them will be more-or-less comprehensible.

    Algol 68 was also masterminded by a Netherlander, who was also the pioneer
    of two-level grammars: Aard van Wijngaarden.

    Coincidence? You be the judge.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sebastian@21:1/5 to Stefan Ram on Tue Aug 6 08:04:35 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In comp.unix.programmer Stefan Ram <ram@zedat.fu-berlin.de> wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote or quoted:
    On 05.04.2024 01:29, Lawrence D'Oliveiro wrote:
    This is where indentation helps. E.g.
    a =
    b ?
    c ? d : e
    : f ?
    g ? h : i
    : j;

    Indentation generally helps.

    Let me give it a try to find how I would indent that!

    b?
    c? d: e:
    f?
    g? h: i:
    j;


    Better:

    a = b ? (c ? d : e) :
    f ? (g ? h : i) :
    j;

    Equivalent Lisp, for comparison:

    (setf a (cond (b (if c d e))
    (f (if g h i))
    (t j)))

    And some people claim that ternaries are SO horribly
    unreadable that they should never be used.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Sebastian on Tue Aug 6 23:34:22 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Tue, 6 Aug 2024 08:04:35 -0000 (UTC), Sebastian wrote:

    Better:

    a = b ? (c ? d : e) :
    f ? (g ? h : i) :
    j;

    Better still (fewer confusing parentheses):

    a =
    b ?
    c ? d : e
    : f ?
    g ? h : i
    : j;

    Equivalent Lisp, for comparison:

    (setf a (cond (b (if c d e))
    (f (if g h i))
    (t j)))

    You can’t avoid the parentheses, but this, too, can be improved:

    (setf a
    (cond
    (b
    (if c d e)
    )
    (f
    (if g h i)
    )
    (t
    j
    )
    ) ; cond
    )

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Lawrence D'Oliveiro on Wed Aug 7 13:43:10 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-08-06, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    Equivalent Lisp, for comparison:

    (setf a (cond (b (if c d e))
    (f (if g h i))
    (t j)))

    You can’t avoid the parentheses, but this, too, can be improved:

    (setf a
    (cond
    (b
    (if c d e)
    )
    (f
    (if g h i)
    )
    (t
    j
    )
    ) ; cond
    )

    Nobody is ever going to follow your idio(syncra)tic coding preferences
    for Lisp, that wouldn't pass code review in any Lisp shop, and result in patches being rejected in a FOSS setting.

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to All on Thu Aug 8 07:33:34 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Wed, 7 Aug 2024 13:43:10 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> boringly babbled:
    On 2024-08-06, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    Equivalent Lisp, for comparison:

    (setf a (cond (b (if c d e))
    (f (if g h i))
    (t j)))

    You can’t avoid the parentheses, but this, too, can be improved:

    (setf a
    (cond
    (b
    (if c d e)
    )
    (f
    (if g h i)
    )
    (t
    j
    )
    ) ; cond
    )

    Nobody is ever going to follow your idio(syncra)tic coding preferences
    for Lisp, that wouldn't pass code review in any Lisp shop, and result in >patches being rejected in a FOSS setting.

    I'm not a Lisp dev, but the original looks far more readable to me.
    His definition of improvement seems to be obfuscation.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andreas Eder@21:1/5 to Lawrence D'Oliveiro on Thu Aug 8 17:25:54 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Di 06 Aug 2024 at 23:34, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    On Tue, 6 Aug 2024 08:04:35 -0000 (UTC), Sebastian wrote:

    Better:

    a = b ? (c ? d : e) :
    f ? (g ? h : i) :
    j;

    Better still (fewer confusing parentheses):

    a =
    b ?
    c ? d : e
    : f ?
    g ? h : i
    : j;

    Equivalent Lisp, for comparison:

    (setf a (cond (b (if c d e))
    (f (if g h i))
    (t j)))

    You can’t avoid the parentheses, but this, too, can be improved:

    (setf a
    (cond
    (b
    (if c d e)
    )
    (f
    (if g h i)
    )
    (t
    j
    )
    ) ; cond
    )

    Sorry, but that is not an improvement but rather an abomination.

    'Andreas
    --
    ceterum censeo redmondinem esse delendam

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Lawrence D'Oliveiro on Fri Aug 9 00:07:25 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-08-08, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Thu, 08 Aug 2024 17:25:54 +0200, Andreas Eder wrote:

    Sorry, but that is not an improvement but rather an abomination.

    Aw, diddums.

    Yep! That's a magic word that will supposedly get your
    idio(syncra)tically formatted commit on the approval fast track.

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Andreas Eder on Thu Aug 8 23:41:55 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Thu, 08 Aug 2024 17:25:54 +0200, Andreas Eder wrote:

    Sorry, but that is not an improvement but rather an abomination.

    Aw, diddums.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Sebastian on Sun Aug 25 07:48:17 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sun, 25 Aug 2024 07:32:26 -0000 (UTC), Sebastian wrote:

    In comp.unix.programmer Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    a =
    b ?
    c ? d : e
    : f ?
    g ? h : i
    : j;

    I find this more confusing than the parentheses.

    Not accustomed to looking at source code in 2D? You have to feel your way
    from symbol to symbol like brackets, rather than being able to see overall shapes?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sebastian@21:1/5 to Lawrence D'Oliveiro on Sun Aug 25 07:32:26 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In comp.unix.programmer Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Tue, 6 Aug 2024 08:04:35 -0000 (UTC), Sebastian wrote:

    Better:

    a = b ? (c ? d : e) :
    f ? (g ? h : i) :
    j;

    Better still (fewer confusing parentheses):

    a =
    b ?
    c ? d : e
    : f ?
    g ? h : i
    : j;

    I find this more confusing than the parentheses.

    Equivalent Lisp, for comparison:

    (setf a (cond (b (if c d e))
    (f (if g h i))
    (t j)))

    You can?t avoid the parentheses, but this, too, can be improved:

    (setf a
    (cond
    (b
    (if c d e)
    )
    (f
    (if g h i)
    )
    (t
    j
    )
    ) ; cond
    )

    If you insist on writing Lisp like that, you might as well do
    this:

    (ql:quickload :with-c-syntax)
    (named-readtables:in-readtable with-c-syntax:with-c-syntax-readtable)

    #{
    a = b ? (c ? d : e) :
    f ? (g ? h : i) :
    j;
    #}

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sebastian@21:1/5 to Lawrence D'Oliveiro on Mon Aug 26 16:13:33 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In comp.unix.programmer Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Sun, 25 Aug 2024 07:32:26 -0000 (UTC), Sebastian wrote:

    In comp.unix.programmer Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    a =
    b ?
    c ? d : e
    : f ?
    g ? h : i
    : j;

    I find this more confusing than the parentheses.

    Not accustomed to looking at source code in 2D? You have to feel your way from symbol to symbol like brackets, rather than being able to see overall shapes?

    Says the guy who finds a few brackets so confusing that he Black-formatted
    a snippet of Lisp code.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Sebastian on Mon Aug 26 21:31:20 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Mon, 26 Aug 2024 16:13:33 -0000 (UTC), Sebastian wrote:

    In comp.unix.programmer Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    On Sun, 25 Aug 2024 07:32:26 -0000 (UTC), Sebastian wrote:

    In comp.unix.programmer Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    a =
    b ?
    c ? d : e
    : f ?
    g ? h : i
    : j;

    I find this more confusing than the parentheses.

    Not accustomed to looking at source code in 2D? You have to feel your
    way from symbol to symbol like brackets, rather than being able to see
    overall shapes?

    Says the guy who finds a few brackets so confusing that he
    Black-formatted a snippet of Lisp code.

    I use the same principles in all my code.

    (And I have no idea about this “Black” thing. I just do my thing.)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sebastian@21:1/5 to Lawrence D'Oliveiro on Tue Aug 27 03:15:16 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In comp.unix.programmer Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Mon, 26 Aug 2024 16:13:33 -0000 (UTC), Sebastian wrote:

    In comp.unix.programmer Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    On Sun, 25 Aug 2024 07:32:26 -0000 (UTC), Sebastian wrote:

    In comp.unix.programmer Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    Says the guy who finds a few brackets so confusing that he
    Black-formatted a snippet of Lisp code.

    I use the same principles in all my code. (And I have no idea about
    this ?Black? thing. I just do my thing.)

    Black is a Python program that formats Python code
    almost exactly the way you formatted that snippet of Lisp
    code. It's just as ugly in Python as it is in Lisp. Black
    spreads by convincing organizations to mandate its use. It's
    utterly non-configurable on purpose, in order to guarantee
    that eventually, all Python code is made to be as ugly
    and unreadable as possible.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Sebastian on Tue Aug 27 04:44:52 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Tue, 27 Aug 2024 03:15:16 -0000 (UTC), Sebastian wrote:

    In comp.unix.programmer Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    (And I have no idea about this “Black” thing. I just do my thing.)

    Black is a [bla bla bla]

    *Yawn*

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Johanne Fairchild@21:1/5 to Lawrence D'Oliveiro on Tue Aug 27 19:56:50 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Tue, 27 Aug 2024 03:15:16 -0000 (UTC), Sebastian wrote:

    In comp.unix.programmer Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    (And I have no idea about this “Black” thing. I just do my thing.)

    Black is a [bla bla bla]

    *Yawn*

    The guy was kindly and politely sharing information with you.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Johanne Fairchild on Tue Aug 27 23:26:50 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Tue, 27 Aug 2024 19:56:50 -0300, Johanne Fairchild wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Tue, 27 Aug 2024 03:15:16 -0000 (UTC), Sebastian wrote:

    In comp.unix.programmer Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    (And I have no idea about this “Black” thing. I just do my thing.)

    Black is a [bla bla bla]

    *Yawn*

    The guy was kindly and politely sharing information with you.

    Didn’t ask, didn’t know, didn’t care.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Johanne Fairchild on Wed Aug 28 00:09:37 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Tue, 27 Aug 2024 21:08:11 -0300, Johanne Fairchild wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Tue, 27 Aug 2024 19:56:50 -0300, Johanne Fairchild wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Tue, 27 Aug 2024 03:15:16 -0000 (UTC), Sebastian wrote:

    In comp.unix.programmer Lawrence D'Oliveiro <ldo@nz.invalid> wrote: >>>>>>
    (And I have no idea about this “Black” thing. I just do my thing.) >>>>>
    Black is a [bla bla bla]

    *Yawn*

    The guy was kindly and politely sharing information with you.

    Didn’t ask, didn’t know, didn’t care.

    Knock yourself out. You have the freedom to disdain.

    I was “disdaining” something even the poster who mentioned it didn’t seem to think much of.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Johanne Fairchild@21:1/5 to Lawrence D'Oliveiro on Tue Aug 27 21:08:11 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Tue, 27 Aug 2024 19:56:50 -0300, Johanne Fairchild wrote:

    Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    On Tue, 27 Aug 2024 03:15:16 -0000 (UTC), Sebastian wrote:

    In comp.unix.programmer Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    (And I have no idea about this “Black” thing. I just do my thing.) >>>>
    Black is a [bla bla bla]

    *Yawn*

    The guy was kindly and politely sharing information with you.

    Didn’t ask, didn’t know, didn’t care.

    Knock yourself out. You have the freedom to disdain. But this is the USENET---we don't need to ask for anything here. Every post is an
    invitation for conversation (to the interested ones).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Tim Rentsch@21:1/5 to Sebastian on Tue Aug 27 18:05:59 2024
    Sebastian <sebastian@here.com.invalid> writes:

    In comp.unix.programmer Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    On Mon, 26 Aug 2024 16:13:33 -0000 (UTC), Sebastian wrote:

    In comp.unix.programmer Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    On Sun, 25 Aug 2024 07:32:26 -0000 (UTC), Sebastian wrote:

    In comp.unix.programmer Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    Says the guy who finds a few brackets so confusing that he
    Black-formatted a snippet of Lisp code.

    I use the same principles in all my code. (And I have no idea about
    this ?Black? thing. I just do my thing.)

    Black is a Python program that formats Python code
    almost exactly the way you formatted that snippet of Lisp
    code. It's just as ugly in Python as it is in Lisp. Black
    spreads by convincing organizations to mandate its use. It's
    utterly non-configurable on purpose, in order to guarantee
    that eventually, all Python code is made to be as ugly
    and unreadable as possible.

    Thank you for this short description.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bozo User@21:1/5 to Muttley@dastardlyhq.com on Mon Sep 30 20:04:52 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-08-08, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
    On Wed, 7 Aug 2024 13:43:10 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> boringly babbled:
    On 2024-08-06, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    Equivalent Lisp, for comparison:

    (setf a (cond (b (if c d e))
    (f (if g h i))
    (t j)))

    You can’t avoid the parentheses, but this, too, can be improved:

    (setf a
    (cond
    (b
    (if c d e)
    )
    (f
    (if g h i)
    )
    (t
    j
    )
    ) ; cond
    )

    Nobody is ever going to follow your idio(syncra)tic coding preferences
    for Lisp, that wouldn't pass code review in any Lisp shop, and result in >>patches being rejected in a FOSS setting.

    I'm not a Lisp dev, but the original looks far more readable to me.
    His definition of improvement seems to be obfuscation.



    Cond can do if clauses by itself. Your code is overloaded.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bozo User@21:1/5 to Lawrence D'Oliveiro on Mon Sep 30 20:04:54 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-04-07, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Sun, 07 Apr 2024 00:01:43 +0000, Javier wrote:

    The downside is the loss of performance because of disk access for
    trivial things like 'nfiles=$(ls | wc -l)'.

    Well, you could save one process creation by writing
    “nfiles=$(echo * | wc -l)” instead. But that would still not be strictly correct.

    I suspect disk access times where
    one of the reasons for the development of perl in the early 90s.

    Shells were somewhat less powerful in those days. I would describe the genesis of Perl as “awk on steroids”. Its big party trick was regular expressions. And I guess combining that with more sophisticated data- structuring capabilities.

    Perl is more awk+sed+sh in a single language. Basically the killer
    of the Unix philophy in late 90's/early 00's, and for the good.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Bozo User on Mon Sep 30 21:04:24 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Mon, 30 Sep 2024 20:04:54 -0000 (UTC), Bozo User wrote:

    Perl is more awk+sed+sh in a single language. Basically the killer of
    the Unix philophy in late 90's/early 00's, and for the good.

    That’s what Rob Pike said <https://interviews.slashdot.org/story/04/10/18/1153211/rob-pike-responds>:

    Q: “Given the nature of current operating systems and
    applications, do you think the idea of "one tool doing one job
    well" has been abandoned?”
    A: “Those days are dead and gone and the eulogy was delivered by
    Perl.”

    But I’m not sure I agree. Those small, specialized tools always
    required large, monolithic pieces under them to operate: the shell
    itself for shell scripts, the X server for GUI apps, the kernel itself
    for everything. So while the coming of Perl has changed some things,
    it has not made a difference to the modularity of the Unix way.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Bozo User on Mon Sep 30 20:59:16 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Mon, 30 Sep 2024 20:04:53 -0000 (UTC), Bozo User wrote:

    Check Emacs' eshell where you can mix pseudo-sh code with Elisp

    Can you give examples that either support or refute my claim?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From usuario@21:1/5 to All on Tue Oct 1 20:18:28 2024
    XPost: comp.unix.shell, comp.unix.programmer

    El Mon, 30 Sep 2024 21:04:24 -0000 (UTC), Lawrence D'Oliveiro escribió:

    On Mon, 30 Sep 2024 20:04:54 -0000 (UTC), Bozo User wrote:

    Perl is more awk+sed+sh in a single language. Basically the killer of
    the Unix philophy in late 90's/early 00's, and for the good.

    That’s what Rob Pike said <https://interviews.slashdot.org/story/04/10/18/1153211/rob-pike-
    responds>:

    Q: “Given the nature of current operating systems and applications,
    do you think the idea of "one tool doing one job well" has been
    abandoned?”
    A: “Those days are dead and gone and the eulogy was delivered by
    Perl.”

    But I’m not sure I agree. Those small, specialized tools always required large, monolithic pieces under them to operate: the shell itself for
    shell scripts, the X server for GUI apps, the kernel itself for
    everything. So while the coming of Perl has changed some things,
    it has not made a difference to the modularity of the Unix way.

    The shell could be changed as just a command launcher with no
    conditionals, while perl doing all the hard work.

    On X11/X.org, X11 was never very "Unix like" by itself.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From usuario@21:1/5 to All on Tue Oct 1 20:41:11 2024
    XPost: comp.unix.shell, comp.unix.programmer

    El Mon, 30 Sep 2024 20:59:16 -0000 (UTC), Lawrence D'Oliveiro escribió:

    On Mon, 30 Sep 2024 20:04:53 -0000 (UTC), Bozo User wrote:

    Check Emacs' eshell where you can mix pseudo-sh code with Elisp

    Can you give examples that either support or refute my claim?

    With eshell you can do sh like commands and put elisp (literal lisp code) inside a loop:

    https://howardism.org/Technical/Emacs/eshell-why.html

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to usuario on Tue Oct 1 22:22:42 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Tue, 1 Oct 2024 20:41:11 -0000 (UTC), usuario wrote:

    With eshell you can do sh like commands and put elisp (literal lisp
    code) inside a loop:

    https://howardism.org/Technical/Emacs/eshell-why.html

    You have to put quotes around literal strings. That still makes it a “programming language”, not a “command language” (according to my original
    definition).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Wed Oct 2 07:10:32 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Tue, 1 Oct 2024 20:18:28 -0000 (UTC)
    usuario <anthk@disroot.org> boring babbled:
    El Mon, 30 Sep 2024 21:04:24 -0000 (UTC), Lawrence D'Oliveiro escribió:

    On Mon, 30 Sep 2024 20:04:54 -0000 (UTC), Bozo User wrote:

    Perl is more awk+sed+sh in a single language. Basically the killer of
    the Unix philophy in late 90's/early 00's, and for the good.

    That’s what Rob Pike said
    <https://interviews.slashdot.org/story/04/10/18/1153211/rob-pike- >responds>:

    Q: “Given the nature of current operating systems and applications,
    do you think the idea of "one tool doing one job well" has been
    abandoned?”
    A: “Those days are dead and gone and the eulogy was delivered by
    Perl.”

    But I’m not sure I agree. Those small, specialized tools always required >> large, monolithic pieces under them to operate: the shell itself for
    shell scripts, the X server for GUI apps, the kernel itself for
    everything. So while the coming of Perl has changed some things,
    it has not made a difference to the modularity of the Unix way.

    The shell could be changed as just a command launcher with no
    conditionals, while perl doing all the hard work.

    On X11/X.org, X11 was never very "Unix like" by itself.

    An X server is about as minimal as you can have a graphics system
    and still make it usable. I don't see how it could have been
    subdivided any further and still work.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From usuario@21:1/5 to All on Wed Oct 2 12:52:03 2024
    XPost: comp.unix.shell, comp.unix.programmer

    El Wed, 2 Oct 2024 07:10:32 -0000 (UTC), Muttley escribió:

    On Tue, 1 Oct 2024 20:18:28 -0000 (UTC)
    usuario <anthk@disroot.org> boring babbled:
    El Mon, 30 Sep 2024 21:04:24 -0000 (UTC), Lawrence D'Oliveiro escribió:

    On Mon, 30 Sep 2024 20:04:54 -0000 (UTC), Bozo User wrote:

    Perl is more awk+sed+sh in a single language. Basically the killer of
    the Unix philophy in late 90's/early 00's, and for the good.

    That’s what Rob Pike said
    <https://interviews.slashdot.org/story/04/10/18/1153211/rob-pike- >>responds>:

    Q: “Given the nature of current operating systems and
    applications,
    do you think the idea of "one tool doing one job well" has been
    abandoned?”
    A: “Those days are dead and gone and the eulogy was delivered by
    Perl.”

    But I’m not sure I agree. Those small, specialized tools always
    required large, monolithic pieces under them to operate: the shell
    itself for shell scripts, the X server for GUI apps, the kernel itself
    for everything. So while the coming of Perl has changed some things,
    it has not made a difference to the modularity of the Unix way.

    The shell could be changed as just a command launcher with no
    conditionals, while perl doing all the hard work.

    On X11/X.org, X11 was never very "Unix like" by itself.

    An X server is about as minimal as you can have a graphics system and
    still make it usable. I don't see how it could have been subdivided any further and still work.

    Check out Blit under Unix V10 and Rio under plan9/9front for a much better Unix-oriented (9front/plan9 it's basically Unix philosophy 2.0) approach.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Wed Oct 2 16:00:55 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Wed, 2 Oct 2024 12:52:03 -0000 (UTC)
    usuario <anthk@disroot.org> boring babbled:
    El Wed, 2 Oct 2024 07:10:32 -0000 (UTC), Muttley escribió:
    An X server is about as minimal as you can have a graphics system and
    still make it usable. I don't see how it could have been subdivided any
    further and still work.

    Check out Blit under Unix V10 and Rio under plan9/9front for a much better >Unix-oriented (9front/plan9 it's basically Unix philosophy 2.0) approach.

    Don't have the time. Presumably its a raw frame buffer or similar? If so
    I can't see it being popular. The unix philosphy or breaking workflows up
    into small subsections has it place, but I don't think graphics is that place.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Bozo User on Wed Oct 9 22:25:05 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Bozo User <anthk@disroot.org> writes:
    On 2024-04-07, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Sun, 07 Apr 2024 00:01:43 +0000, Javier wrote:

    The downside is the loss of performance because of disk access for
    trivial things like 'nfiles=$(ls | wc -l)'.

    Well, you could save one process creation by writing
    “nfiles=$(echo * | wc -l)” instead. But that would still not be strictly >> correct.

    I suspect disk access times where
    one of the reasons for the development of perl in the early 90s.

    Shells were somewhat less powerful in those days. I would describe the
    genesis of Perl as “awk on steroids”. Its big party trick was regular
    expressions. And I guess combining that with more sophisticated data-
    structuring capabilities.

    Perl is more awk+sed+sh in a single language. Basically the killer
    of the Unix philophy in late 90's/early 00's, and for the good.

    Perl is a high-level programming language with a rich syntax¹, with
    support for deterministic automatic memory management, functions as
    first-class objects and message-based OO. It's also a virtual machine
    for executing threaded code and a(n optimizing) compiler for translating
    Perl code into the corresponding threaded code.

    ¹ Has recently gained try/catch for exception handling which is IMNSHO a
    great improvement over eval + $@.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Thu Oct 10 08:38:26 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Wed, 09 Oct 2024 22:25:05 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled:
    Bozo User <anthk@disroot.org> writes:
    On 2024-04-07, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Sun, 07 Apr 2024 00:01:43 +0000, Javier wrote:

    The downside is the loss of performance because of disk access for
    trivial things like 'nfiles=$(ls | wc -l)'.

    Well, you could save one process creation by writing
    “nfiles=$(echo * | wc -l)” instead. But that would still not be >strictly
    correct.

    I suspect disk access times where
    one of the reasons for the development of perl in the early 90s.

    Shells were somewhat less powerful in those days. I would describe the
    genesis of Perl as “awk on steroids”. Its big party trick was regular >>> expressions. And I guess combining that with more sophisticated data-
    structuring capabilities.

    Perl is more awk+sed+sh in a single language. Basically the killer
    of the Unix philophy in late 90's/early 00's, and for the good.

    Perl is a high-level programming language with a rich syntax¹, with
    support for deterministic automatic memory management, functions as >first-class objects and message-based OO. It's also a virtual machine
    for executing threaded code and a(n optimizing) compiler for translating
    Perl code into the corresponding threaded code.

    Its syntax is also a horrific mess. Larry took the worst parts of C and shell syntax and mashed them together. Its no surprise Perl has been ditched in favour of Python just about everywhere for new scripting projects. And while
    I hate Pythons meangingful whitespace nonsense, I'd use it in preference
    to Perl any day.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Muttley@DastartdlyHQ.org on Thu Oct 10 16:09:49 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@DastartdlyHQ.org writes:
    On Wed, 09 Oct 2024 22:25:05 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled:
    Bozo User <anthk@disroot.org> writes:
    On 2024-04-07, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Sun, 07 Apr 2024 00:01:43 +0000, Javier wrote:

    The downside is the loss of performance because of disk access for
    trivial things like 'nfiles=$(ls | wc -l)'.

    Well, you could save one process creation by writing
    “nfiles=$(echo * | wc -l)†instead. But that would still not be >>strictly
    correct.

    I suspect disk access times where
    one of the reasons for the development of perl in the early 90s.

    Shells were somewhat less powerful in those days. I would describe the >>>> genesis of Perl as “awk on steroidsâ€. Its big party trick was regular
    expressions. And I guess combining that with more sophisticated data-
    structuring capabilities.

    Perl is more awk+sed+sh in a single language. Basically the killer
    of the Unix philophy in late 90's/early 00's, and for the good.

    Perl is a high-level programming language with a rich syntax¹, with >>support for deterministic automatic memory management, functions as >>first-class objects and message-based OO. It's also a virtual machine
    for executing threaded code and a(n optimizing) compiler for translating >>Perl code into the corresponding threaded code.

    Its syntax is also a horrific mess.

    Which means precisely what?

    Its no surprise Perl has been ditched in favour of Python just about everywhere for new scripting projects.

    "I say so and I'm an avid Phython fan?"

    Not much of a reason.

    BTW, I didn't mean to start another entirely pointless language
    war. Just pointing out the referring to a general-purpose programming
    language as "killer of the UNIX philosophy" makes no sense.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Thu Oct 10 15:34:37 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Thu, 10 Oct 2024 16:09:49 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled: >Muttley@DastartdlyHQ.org writes:
    Its syntax is also a horrific mess.

    Which means precisely what?

    Far too much pointless punctuation. An interpreter shouldn't need the vartype signified by $ or @ once its defined, it should already know. And then there are semantically meaningful underscores (seriously?) and random hacky keywords such as <STDIN>. I could go on.

    Its no surprise Perl has been ditched in favour of Python just about
    everywhere for new scripting projects.

    "I say so and I'm an avid Phython fan?"

    Not much of a reason.

    It shows the general consensus of which is an easier language to work with.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to All on Thu Oct 10 17:55:32 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@DastartdlyHQ.org ignorantly rambled:
    On Thu, 10 Oct 2024 16:09:49 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled:
    Muttley@DastartdlyHQ.org writes:
    Its syntax is also a horrific mess.

    Which means precisely what?

    Far too much pointless punctuation. An interpreter shouldn't need the vartype signified by $ or @ once its defined, it should already know.

    For the purpose of variable declaration, how's the interpeter going to
    know the type of a variable without being told about it? Obviously, not
    at all.

    Perl has three builtin types, scalars, arrays and hashes and
    each is denoted by a single-letter prefix which effectively creates
    three different variable namespaces, one for each type. That's often convenient, because the same name can be reused for a variable of a
    different type, eg:

    my ($data, @data, %data);

    $data = rand(128);
    @data = ($data, $data + 1);
    %data = map { $_, 15 } @data;

    it's also convenient to type and easy to read due to being concise.

    Outside of declarations, $ and @ really denote access modes/ contexts,
    with $ standing for "a thing" and @ for "a number of things", eg

    $a[0]

    is the first element of the array @a and

    @a[-3 .. -1]

    is a list composed of the three last elements of @a.

    And then there are semantically meaningful underscores (seriously?)

    Similar to the number writing convention in English: 1,600,700, numbers
    in Perl can be annotated with _-separators to make them easier to
    read. Eg, all of these are identical

    1_600_700
    16_007_00
    1_6_0_0_7_0_0_

    But the underscores have no meaning in here.

    and random hacky keywords such as <STDIN>.

    <STDIN> isn't a keyword. STDIN is the name of a glob (symbol table
    entry) in the symbol table of the package main. It's most prominent use
    is (as they name may suggest) to provide access to "the standard input
    stream".

    <> is an I/O operator. It's operand must be a file handle, ie, either
    the name of glob with a file handle associated with it like STDIN or a
    scalar variable used to hold a file handle. In scalar context, it reads
    and returns the next line read from this file handle. In list context,
    it returns all lines in the file.

    Eg, this a poor man's implementation of cat:

    perl -e 'open($fh, $_) and print <$fh> for @ARGV'

     I could go on.

    Please don't enumerate everything else on this planet you also don't
    really understand as that's probably going to become a huge list. ;-)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Rainer Weikusat on Thu Oct 10 19:14:15 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-10-10, Rainer Weikusat <rweikusat@talktalk.net> wrote:
    Muttley@DastartdlyHQ.org ignorantly rambled:
    On Thu, 10 Oct 2024 16:09:49 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled: >>>Muttley@DastartdlyHQ.org writes:
    Its syntax is also a horrific mess.

    Which means precisely what?

    Far too much pointless punctuation. An interpreter shouldn't need the vartype
    signified by $ or @ once its defined, it should already know.

    For the purpose of variable declaration, how's the interpeter going to

    Interpreter? Perl has some kind of compiler in it, right?

    Interpreters for typed languages are possible. The lexical environment
    bidnings contain type info, so when the interpreter sees x, it resolves
    it through the environment not only to a location/value, but to type
    info.

    know the type of a variable without being told about it? Obviously, not
    at all.

    But it's not exactly type, because $x means "scalar variable of any
    type" whereas @x is an "array of any type".

    That's quite useless for proper type checking and only causes noise,
    due to having to be repeated.

    Actually typed languages don't use sigils. How is that?

    The type of a name is declared (or else inferred); references to that
    name don't need to repeat that info.

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Kaz Kylheku on Thu Oct 10 21:31:39 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Kaz Kylheku <643-408-1753@kylheku.com> writes:
    On 2024-10-10, Rainer Weikusat <rweikusat@talktalk.net> wrote:
    Muttley@DastartdlyHQ.org ignorantly rambled:
    On Thu, 10 Oct 2024 16:09:49 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled: >>>>Muttley@DastartdlyHQ.org writes:
    Its syntax is also a horrific mess.

    Which means precisely what?

    Far too much pointless punctuation. An interpreter shouldn't need the vartype
    signified by $ or @ once its defined, it should already know.

    For the purpose of variable declaration, how's the interpeter going to

    Interpreter? Perl has some kind of compiler in it, right?

    The Perl compiler turns Perl source code into a set of (that's a
    conjecture of mine) so-called "op trees" whose nodes contain pointers to built-in functions and pointers to "op subtrees" supplying arguments for
    these and the interpeter/ virtual machine then evaluates these op trees
    to run the program.

    [...]

    know the type of a variable without being told about it? Obviously, not
    at all.

    But it's not exactly type, because $x means "scalar variable of any
    type" whereas @x is an "array of any type".

    $x means 'scalar variable'. There's no furher differentiation of that at
    the language level despite there are two kinds of scalar variables at
    the implentation level, scalars whose values are "values" of some sort
    (ie, strings or numbers) and scalars whose values are references to
    something.

    @x is an 1-D array of scalars.

    That's quite useless for proper type checking and only causes noise,
    due to having to be repeated.

    Actually typed languages don't use sigils. How is that?

    The type of a name is declared (or else inferred); references to that
    name don't need to repeat that info.

    The Perl type system is based on using different namespaces for
    different types which means the type of a variable is part of its
    name. This has the advantages that declaration syntax is concise and
    that it's possible to have different kinds of variables with the same
    name. It's also not really specific to Perl as C uses a similar model
    for structures declarations and definitions.

    The obvious disadvantage is that every variable name in Perl and every
    use of a variable in an expression has and additional meta-information character associated with it. The actual rules outside of declarations
    are also more complicated because of the underlying idea that $ would be something like a singular article in a spoken language an @ a plural
    article. This means that elements of arrays and hashed are referred to
    using a $ prefix and not @ or %, eg,

    my @a;
    $a[0] = 1;

    or

    my %h;
    $h{goatonion} = 'winged cauliflower';

    I think that's rather a weird than a great idea but it's internally
    consistent and as good (or bad) as any other language ideosyncrasy. It's certainly less confusing than the : as expression separator in
    supposedly punctuation-free Python which tripped me up numerous times
    when initially starting to write (some) Python code.

    Things only start to get slightly awful when references become
    involved. In Perl 4 (reportedly, I've never used that) a reference was a variable holding the name of another variable, eg

    $b = 1;
    $a = 'b';
    print $$a; # prints 1

    Perl 5 added references as typed pointers with reference counting but
    retained the symbolic referenc syntax. For the example above, that would
    be

    $b = 1;
    $a = \$b;
    print $$a; # also prints 1

    Thinks start to become complicated once references to complex objects
    are involved. Eg,

    @{$$a[0]}

    is the array referred to by the first item of the array $a refers to and

    ${$$a[0]}[0]

    which seriously starts to look like a trench fortification with
    barbed-wire obstacles is a way to refer to the first element of this
    array. The {$$a[0]} is a block returning a reference to an array which
    the surrounding $ and [0] then dereference. The { } could contain
    arbitrary code returning a reference. But for the simple case of dereference-chaining, this is not needed as it's implied for adjacent
    subscript (for both hashes and arrays) which means the simpler

    $$a[0][0]

    is equivalent to the other expression.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bart@21:1/5 to Rainer Weikusat on Fri Oct 11 00:09:39 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 10/10/2024 21:31, Rainer Weikusat wrote:
    Kaz Kylheku <643-408-1753@kylheku.com> writes:

    Thinks start to become complicated once references to complex objects
    are involved. Eg,

    @{$$a[0]}

    is the array referred to by the first item of the array $a refers to and

    ${$$a[0]}[0]

    which seriously starts to look like a trench fortification with
    barbed-wire obstacles is a way to refer to the first element of this
    array.

    I thought you were defending the language. Now you seem to be agreeing
    with how bad this syntax is.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bart@21:1/5 to Rainer Weikusat on Fri Oct 11 00:07:02 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 10/10/2024 17:55, Rainer Weikusat wrote:
    Muttley@DastartdlyHQ.org ignorantly rambled:
    On Thu, 10 Oct 2024 16:09:49 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled:
    Muttley@DastartdlyHQ.org writes:
    Its syntax is also a horrific mess.

    Which means precisely what?

    Far too much pointless punctuation. An interpreter shouldn't need the vartype
    signified by $ or @ once its defined, it should already know.

    For the purpose of variable declaration, how's the interpeter going to
    know the type of a variable without being told about it? Obviously, not
    at all.

    Perl has three builtin types, scalars, arrays and hashes and
    each is denoted by a single-letter prefix which effectively creates
    three different variable namespaces, one for each type. That's often convenient, because the same name can be reused for a variable of a
    different type, eg:

    my ($data, @data, %data);

    Why would you want to do this?


    $data = rand(128);
    @data = ($data, $data + 1);
    %data = map { $_, 15 } @data;

    it's also convenient to type and easy to read due to being concise.

    Adding shifted punctuation at the start of every instance of a variable?
    I don't call that convenient!

    So, $ is scalar, @ is an array, and % is a hash?


    Outside of declarations, $ and @ really denote access modes/ contexts,
    with $ standing for "a thing" and @ for "a number of things", eg

    $a[0]

    is the first element of the array @a and

    Now I'm already lost. 'a' is an array, but it's being used with $? What
    would just this:

    a[0]

    mean by itself?

    @a[-3 .. -1]

    is a list composed of the three last elements of @a.

    Sorry, these prefixes look utterly pointless to me. This stuff works
    perfectly well in other languages without them.

    I can write a[i..j] in mine and I know that it yields a slice.

    What would a[-3 .. -1] give you in Perl without the @? What would $a[-3
    .. -1] mean?

    What happens if you have an array of mixed scalars, arrays and hashes;
    what prefix to use in front of a[i]?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Muttley on Fri Oct 11 01:33:21 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Thu, 10 Oct 2024 15:34:37 -0000 (UTC), Muttley wrote:

    An interpreter shouldn't need the vartype signified by $ or @ once its defined, it should already know.

    You realize those symbols represent, not just different types, but
    different namespaces as well?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Fri Oct 11 08:17:22 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Thu, 10 Oct 2024 17:55:32 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled: >Muttley@DastartdlyHQ.org ignorantly rambled:
    On Thu, 10 Oct 2024 16:09:49 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled: >>>Muttley@DastartdlyHQ.org writes:
    Its syntax is also a horrific mess.

    Which means precisely what?

    Far too much pointless punctuation. An interpreter shouldn't need the vartype

    signified by $ or @ once its defined, it should already know.

    For the purpose of variable declaration, how's the interpeter going to

    Which part of "once its defined" did you not understand?

    convenient, because the same name can be reused for a variable of a
    different type, eg:

    my ($data, @data, %data);

    $data = rand(128);
    @data = ($data, $data + 1);
    %data = map { $_, 15 } @data;

    What a mess. And I didn't realise perl allowed variables of different types
    to have the same name! Insanity! Another reason never to use it again.

    it's also convenient to type and easy to read due to being concise.

    If you say so. Others may disagree.

    and returns the next line read from this file handle. In list context,
    it returns all lines in the file.

    Eg, this a poor man's implementation of cat:

    perl -e 'open($fh, $_) and print <$fh> for @ARGV'

    Meanwhile in awk: { print }

    Please don't enumerate everything else on this planet you also don't
    really understand as that's probably going to become a huge list. ;-)

    I understand Perl vies with C++ as the most syntactically messy language
    in common use. Unfortunately I have to use the latter, I don't have to use
    the former.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Bart on Fri Oct 11 16:15:14 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Bart <bc@freeuk.com> writes:
    On 10/10/2024 17:55, Rainer Weikusat wrote:
    Muttley@DastartdlyHQ.org ignorantly rambled:
    On Thu, 10 Oct 2024 16:09:49 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled:
    Muttley@DastartdlyHQ.org writes:
    Its syntax is also a horrific mess.

    Which means precisely what?

    Far too much pointless punctuation. An interpreter shouldn't need the vartype
    signified by $ or @ once its defined, it should already know.
    For the purpose of variable declaration, how's the interpeter going
    to
    know the type of a variable without being told about it? Obviously, not
    at all.
    Perl has three builtin types, scalars, arrays and hashes and
    each is denoted by a single-letter prefix which effectively creates
    three different variable namespaces, one for each type. That's often
    convenient, because the same name can be reused for a variable of a
    different type, eg:
    my ($data, @data, %data);

    Why would you want to do this?

    Because it's convenient. It's possible to have a single variable
    denotning something, say $car, and also a variable use to hold a list of
    cars which could be named @car.

    $data = rand(128);
    @data = ($data, $data + 1);
    %data = map { $_, 15 } @data;
    it's also convenient to type and easy to read due to being concise.

    Adding shifted punctuation at the start of every instance of a
    variable? I don't call that convenient!

    It's convenient for declarations, because it's the shortest possible
    syntax which can be used to declare the type of a variable.

    So, $ is scalar, @ is an array, and % is a hash?

    Yes.

    Outside of declarations, $ and @ really denote access modes/ contexts,
    with $ standing for "a thing" and @ for "a number of things", eg
    $a[0]

    is the first element of the array @a and

    Now I'm already lost. 'a' is an array, but it's being used with $?
    What would just this:

    a[0]

    mean by itself?

    Nothing, ie, it's a syntax error.

    @a[-3 .. -1]
    is a list composed of the three last elements of @a.

    Sorry, these prefixes look utterly pointless to me. This stuff works perfectly well in other languages without them.

    I can write a[i..j] in mine and I know that it yields a slice.

    But presumably only if a is actually an array. In Perl, it's a so-called bareword which was historically just a string. In current Perl, it's
    either a filehandle (which can't be indexed) or calling a function named
    a (which also can't be indexed).

    [...]

    What would $a[-3 .. -1] mean?

    $a[0]

    In list context (denoted by @) the .. operator returns a sequence of
    numbers starting from the value on the left and ending with the value on
    the right. But because of the $, it's in scalar context. Then, it
    returns a boolean value which is false until the left operand becomes
    true, then remains true until the right operand becomes true and then
    again becomes false. That's supposed to be used for matching ranges of something. If an operand is a constant expression, it's supposed to
    refer to a line number of the last file which was accessed. Eg,

    perl -ne 'print if 10 .. 15' </var/log/syslog

    prints lines 10 - 15 from standard input (connected to /var/log/syslog).

    For the given example, the value is always false (arithmetically equal
    to 0) because -3 cannot occur as line number of a file.

    What happens if you have an array of mixed scalars, arrays and hashes;
    what prefix to use in front of a[i]?

    Elements of arrays or hashes are always scalars.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Kaz Kylheku on Fri Oct 11 15:47:06 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Bart <bc@freeuk.com> writes:
    Kaz Kylheku <643-408-1753@kylheku.com> writes:
    On 2024-10-10, Rainer Weikusat <rweikusat@talktalk.net> wrote:
    Muttley@DastartdlyHQ.org ignorantly rambled:
    On Thu, 10 Oct 2024 16:09:49 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled: >>>>Muttley@DastartdlyHQ.org writes:
    Its syntax is also a horrific mess.

    Which means precisely what?

    Far too much pointless punctuation. An interpreter shouldn't need the vartype
    signified by $ or @ once its defined, it should already know.

    For the purpose of variable declaration, how's the interpeter going to

    Interpreter? Perl has some kind of compiler in it, right?

    The Perl compiler turns Perl source code into a set of (that's a
    conjecture of mine) so-called "op trees" whose nodes contain pointers to built-in functions and pointers to "op subtrees" supplying arguments for
    these and the interpeter/ virtual machine then evaluates these op trees
    to run the program.

    [...]

    know the type of a variable without being told about it? Obviously, not
    at all.

    But it's not exactly type, because $x means "scalar variable of any
    type" whereas @x is an "array of any type".

    $x means 'scalar variable'. There's no furher differentiation of that at
    the language level despite there are two kinds of scalar variables at
    the implentation level, scalars whose values are "values" of some sort
    (ie, strings or numbers) and scalars whose values are references to
    something.

    @x is an 1-D array of scalars.

    That's quite useless for proper type checking and only causes noise,
    due to having to be repeated.

    Actually typed languages don't use sigils. How is that?

    The type of a name is declared (or else inferred); references to that
    name don't need to repeat that info.

    The Perl type system is based on using different namespaces for
    different types which means the type of a variable is part of its
    name. This has the advantages that declaration syntax is concise and
    that it's possible to have different kinds of variables with the same
    name. It's also not really specific to Perl as C uses a similar model
    for structures declarations and definitions.

    The obvious disadvantage is that every variable name in Perl and every
    use of a variable in an expression has and additional meta-information character associated with it. The actual rules outside of declarations
    are also more complicated because of the underlying idea that $ would be something like a singular article in a spoken language an @ a plural
    article. This means that elements of arrays and hashed are referred to
    using a $ prefix and not @ or %, eg,

    my @a;
    $a[0] = 1;

    or

    my %h;
    $h{goatonion} = 'winged cauliflower';

    I think that's rather a weird than a great idea but it's internally
    consistent and as good (or bad) as any other language ideosyncrasy. It's certainly less confusing than the : as expression separator in
    supposedly punctuation-free Python which tripped me up numerous times
    when initially starting to write (some) Python code.

    Things only start to get slightly awful when references become
    involved. In Perl 4 (reportedly, I've never used that) a reference was a variable holding the name of another variable, eg

    $b = 1;
    $a = 'b';
    print $$a; # prints 1

    Perl 5 added references as typed pointers with reference counting but
    retained the symbolic referenc syntax. For the example above, that would
    be

    $b = 1;
    $a = \$b;
    print $$a; # also prints 1

    Thinks start to become complicated once references to complex objects
    are involved. Eg,

    @{$$a[0]}

    is the array referred to by the first item of the array $a refers to and

    ${$$a[0]}[0]

    which seriously starts to look like a trench fortification with
    barbed-wire obstacles is a way to refer to the first element of this
    array. The {$$a[0]} is a block returning a reference to an array which
    the surrounding $ and [0] then dereference. The { } could contain
    arbitrary code returning a reference. But for the simple case of dereference-chaining, this is not needed as it's implied for adjacent
    subscript (for both hashes and arrays) which means the simpler

    $$a[0][0]

    is equivalent to the other expression.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to Muttley@DastartdlyHQ.org on Fri Oct 11 15:45:01 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <vebffc$3n6jv$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >On Fri, 11 Oct 2024 15:47:06 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled:
    Bart <bc@freeuk.com> writes:
    Interpreter? Perl has some kind of compiler in it, right?

    The Perl compiler turns Perl source code into a set of (that's a

    Does it produce a standalone binary as output? No, so its an intepreter
    not a compiler. However unlike the python interpreter its non interactive >making it an even less attractive option these days.

    That's a bad distinction. There have been "Load and Go"
    compilers in the past that have compiled and linked a program
    directly into memory and executed it immediately after
    compilation. As I recall, the Waterloo FORTRAN compilers on the
    IBM mainframe did, or could do, more or less this.

    Saving to some sort of object image is not a necessary function
    of a compiler.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Fri Oct 11 15:15:57 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 11 Oct 2024 15:47:06 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled:
    Bart <bc@freeuk.com> writes:
    Interpreter? Perl has some kind of compiler in it, right?

    The Perl compiler turns Perl source code into a set of (that's a

    Does it produce a standalone binary as output? No, so its an intepreter
    not a compiler. However unlike the python interpreter its non interactive making it an even less attractive option these days.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to on the fly. A proper compiler on Fri Oct 11 15:59:15 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 11 Oct 2024 15:45:01 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    In article <vebffc$3n6jv$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >>On Fri, 11 Oct 2024 15:47:06 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled:
    Bart <bc@freeuk.com> writes:
    Interpreter? Perl has some kind of compiler in it, right?

    The Perl compiler turns Perl source code into a set of (that's a

    Does it produce a standalone binary as output? No, so its an intepreter
    not a compiler. However unlike the python interpreter its non interactive >>making it an even less attractive option these days.

    That's a bad distinction. There have been "Load and Go"
    compilers in the past that have compiled and linked a program
    directly into memory and executed it immediately after
    compilation. As I recall, the Waterloo FORTRAN compilers on the
    IBM mainframe did, or could do, more or less this.

    Irrelevant. Lot of interpreters do partial compilation and the JVM does it
    on the fly. A proper compiler writes a standalone binary file to disk.

    Saving to some sort of object image is not a necessary function
    of a compiler.

    Yes it is.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Dan Cross on Fri Oct 11 16:37:02 2024
    XPost: comp.unix.shell, comp.unix.programmer

    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <vebffc$3n6jv$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >>On Fri, 11 Oct 2024 15:47:06 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled:
    Bart <bc@freeuk.com> writes:
    Interpreter? Perl has some kind of compiler in it, right?

    The Perl compiler turns Perl source code into a set of (that's a

    Does it produce a standalone binary as output? No, so its an intepreter
    not a compiler. However unlike the python interpreter its non interactive >>making it an even less attractive option these days.

    That's a bad distinction. There have been "Load and Go"
    compilers in the past that have compiled and linked a program
    directly into memory and executed it immediately after
    compilation. As I recall, the Waterloo FORTRAN compilers on the
    IBM mainframe did, or could do, more or less this.

    Indeed, the Burroughs mainframes also had compile&go capabilities.

    HP-3000 had a concept called "pass files" which held the intermediate
    formats between source and executable:
    $ BASICCOMP HANGMAN.BAS
    $ PREP $OLDPASS, $NEWPASS ($OLDPASS and $NEWPASS were implied if omitted).
    $ RUN $OLDPASS

    It also had

    $ BASICGO (compile, prepare (link) and run)
    $ BASICPREP (compile and prepare)

    Similarly for COBOL, FORTRAN and SPL.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to Muttley@DastartdlyHQ.org on Fri Oct 11 16:28:03 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <vebi0j$3nhvq$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >On Fri, 11 Oct 2024 15:45:01 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    In article <vebffc$3n6jv$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >>>On Fri, 11 Oct 2024 15:47:06 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled:
    Bart <bc@freeuk.com> writes:
    Interpreter? Perl has some kind of compiler in it, right?

    The Perl compiler turns Perl source code into a set of (that's a

    Does it produce a standalone binary as output? No, so its an intepreter >>>not a compiler. However unlike the python interpreter its non interactive >>>making it an even less attractive option these days.

    That's a bad distinction. There have been "Load and Go"
    compilers in the past that have compiled and linked a program
    directly into memory and executed it immediately after
    compilation. As I recall, the Waterloo FORTRAN compilers on the
    IBM mainframe did, or could do, more or less this.

    Irrelevant. Lot of interpreters do partial compilation and the JVM does it
    on the fly. A proper compiler writes a standalone binary file to disk.

    Not generally, no. Most compilers these days generate object
    code and then, as a separate step, a linker is invoked to
    combine object files and library archives into an executable
    binary.

    By the way, when many people talk about a "standalone" binary,
    they are referring to something directly executable on hardware,
    without the benefit of an operating system. The Unix kernel is
    an example of such a "standalone binary."

    Most executable binaries are not standalone.

    Saving to some sort of object image is not a necessary function
    of a compiler.

    Yes it is.

    So you say, but that's not the commonly accepted definition.
    Sorry.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Muttley@DastartdlyHQ.org on Fri Oct 11 19:01:27 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@DastartdlyHQ.org writes:
    On Fri, 11 Oct 2024 15:47:06 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled:
    Bart <bc@freeuk.com> writes:
    Interpreter? Perl has some kind of compiler in it, right?

    The Perl compiler turns Perl source code into a set of (that's a

    Does it produce a standalone binary as output? No, so its an intepreter
    not a compiler. However unlike the python interpreter its non interactive making it an even less attractive option these days.

    The perl debugger offers an interactive environment (with line editing support if
    the necessary packages/ modules are available). It can be invoked with a suitable 'script argument' to use it without actually debugging
    something, eg,

    perl -de 0

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Muttley@DastartdlyHQ.org on Fri Oct 11 19:37:46 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@DastartdlyHQ.org writes:
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled:

    [...]

    Eg, this a poor man's implementation of cat:

    perl -e 'open($fh, $_) and print <$fh> for @ARGV'

    Meanwhile in awk: { print }

    perl -peZ

    It's not only shorter than the awk version but it also works. cat
    doesn't abort when some of its arguments don't name existin files.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Muttley on Fri Oct 11 20:58:26 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 11 Oct 2024 15:15:57 -0000 (UTC), Muttley wrote:

    On Fri, 11 Oct 2024 15:47:06 +0100
    Rainer Weikusat <rweikusat@talktalk.net>:

    The Perl compiler turns Perl source code into a set of (that's a

    Does it produce a standalone binary as output? No, so its an intepreter
    not a compiler.

    There are two parts: the interpreter interprets code generated by the compiler.

    Remember, your CPU is an interpreter, too.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Sat Oct 12 08:39:09 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 11 Oct 2024 16:28:03 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    In article <vebi0j$3nhvq$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >>Irrelevant. Lot of interpreters do partial compilation and the JVM does it >>on the fly. A proper compiler writes a standalone binary file to disk.

    Not generally, no. Most compilers these days generate object
    code and then, as a separate step, a linker is invoked to
    combine object files and library archives into an executable
    binary.

    Ok, the compiler toolchain then. Most people invoke it using a single command, the rest is behind the scenes.

    By the way, when many people talk about a "standalone" binary,
    they are referring to something directly executable on hardware,

    For many read a tiny minority.

    without the benefit of an operating system. The Unix kernel is
    an example of such a "standalone binary."

    If you're going to nitpick then I'm afraid you're wrong. Almost all operating systems require some kind of bootloader and/or BIOS combination to start them up. You can't just point the CPU at the first byte of the binary and off it goes particularly in the case of Linux where the kernel requires decompressing first.

    Most executable binaries are not standalone.

    Standalone as you are well aware in the sense of doesn't require an interpreter or VM to run on the OS and contains CPU machine code.

    Saving to some sort of object image is not a necessary function
    of a compiler.

    Yes it is.

    So you say, but that's not the commonly accepted definition.
    Sorry.

    Where do you get this commonly accepted definition from?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Sat Oct 12 08:40:46 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 11 Oct 2024 19:01:27 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled: >Muttley@DastartdlyHQ.org writes:
    On Fri, 11 Oct 2024 15:47:06 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled:
    Bart <bc@freeuk.com> writes:
    Interpreter? Perl has some kind of compiler in it, right?

    The Perl compiler turns Perl source code into a set of (that's a

    Does it produce a standalone binary as output? No, so its an intepreter
    not a compiler. However unlike the python interpreter its non interactive
    making it an even less attractive option these days.

    The perl debugger offers an interactive environment (with line editing support >if
    the necessary packages/ modules are available). It can be invoked with a >suitable 'script argument' to use it without actually debugging
    something, eg,

    perl -de 0

    I didn't know about that, I stand corrected on that point.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Sat Oct 12 08:42:17 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 11 Oct 2024 20:58:26 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> boring babbled:
    On Fri, 11 Oct 2024 15:15:57 -0000 (UTC), Muttley wrote:

    On Fri, 11 Oct 2024 15:47:06 +0100
    Rainer Weikusat <rweikusat@talktalk.net>:

    The Perl compiler turns Perl source code into a set of (that's a

    Does it produce a standalone binary as output? No, so its an intepreter
    not a compiler.

    There are two parts: the interpreter interprets code generated by the compiler.

    Code generated by a compiler does not require an interpreter.



    Remember, your CPU is an interpreter, too.

    If you want to go down the reductio ad absurdum route then the electrons
    are interpreters too.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to Muttley@DastartdlyHQ.org on Sat Oct 12 13:53:56 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <vedcjc$3mqn$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >On Fri, 11 Oct 2024 16:28:03 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    In article <vebi0j$3nhvq$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >>>Irrelevant. Lot of interpreters do partial compilation and the JVM does it >>>on the fly. A proper compiler writes a standalone binary file to disk.

    Not generally, no. Most compilers these days generate object
    code and then, as a separate step, a linker is invoked to
    combine object files and library archives into an executable
    binary.

    Ok, the compiler toolchain then. Most people invoke it using a single command, >the rest is behind the scenes.

    By the way, when many people talk about a "standalone" binary,
    they are referring to something directly executable on hardware,

    For many read a tiny minority.

    without the benefit of an operating system. The Unix kernel is
    an example of such a "standalone binary."

    If you're going to nitpick then I'm afraid you're wrong. Almost all operating >systems require some kind of bootloader and/or BIOS combination to start them >up. You can't just point the CPU at the first byte of the binary and off it >goes particularly in the case of Linux where the kernel requires decompressing >first.

    Again, not generally, no. Consider an embedded system where the
    program to be executed on, say, a microcontroller is itself
    statically linked at an absolute address and burned into a ROM,
    with the program's entry point at the CPU's reset address. I
    suppose that's not "standalone" if you count a ROM burner as
    part of "loading" it.

    Also, I mentioned Unix, not Linux. The two are different. The
    first version of the Unix kernel started at a fixed location on
    the PDP-7, without a separate loading step (Ken Thompson did
    that manually).

    Of course, this all gets more complex when we start talking
    about modern systems with loading kernel modules and the like.

    Most executable binaries are not standalone.

    Standalone as you are well aware in the sense of doesn't require an interpreter
    or VM to run on the OS and contains CPU machine code.

    So what about a binary that is dynamically linked with a shared
    object? That requires a runtime interpreter nee linker to bind
    its constituent parts together before it's executable. And what
    if it makes a system call? Then it's no longer "standalone", as
    it necessarily relies on the operating system to perform part of
    its function.

    But that's really neither here nor there; I think you are
    conflating object code with text containing instructions meant
    for direct execution on a CPU with something like a P-code;
    the distinction is kind of silly when you consider that we live
    in a world with CPU simulators that let you boot entire systems
    for architecture A in a program running on architecture B,
    usually in userspace. Why do you think that a compiler that
    generates bytecode for some virtual machine is any different
    from a compiler that generates object code for some CPU?

    You don't seem to be able to recognize that the compilation step
    is separate from execution, and that the same techniques for
    compiler development apply to both hardware and virtual targets.

    Saving to some sort of object image is not a necessary function
    of a compiler.

    Yes it is.

    So you say, but that's not the commonly accepted definition.
    Sorry.

    Where do you get this commonly accepted definition from?

    *shrug* Tanenbaum; Silberschatz; Kaashoek; Roscoe; etc. Where
    did you get your definition?

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Muttley@DastartdlyHQ.org on Sat Oct 12 14:37:24 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@DastartdlyHQ.org writes:
    On Fri, 11 Oct 2024 20:58:26 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> boring babbled:
    On Fri, 11 Oct 2024 15:15:57 -0000 (UTC), Muttley wrote:

    On Fri, 11 Oct 2024 15:47:06 +0100
    Rainer Weikusat <rweikusat@talktalk.net>:

    The Perl compiler turns Perl source code into a set of (that's a

    Does it produce a standalone binary as output? No, so its an intepreter
    not a compiler.

    There are two parts: the interpreter interprets code generated by the compiler.

    Code generated by a compiler does not require an interpreter.

    Indeed. As far as I know the term, an interpreter is something which
    reads text from a file, parses it an checks it for syntax errors
    and then executes the code as soon as enough of it has been gathered to
    allow for execution of something, ie, a complete statement. This read,
    check and parse, execute cycle is repeated until the program
    terminates.

    Example for this:

    [rw@doppelsaurus]/tmp#cat a.sh
    ed a.sh <<'TT' >/dev/null 2>&1
    9,$d
    wq
    TT
    echo `expr $i + 0`
    i=`expr $i + 1`
    test $i = 11 && exit
    sed -n '5,8p' a.sh | tee -a a.sh >/dev/null

    This is a script printing the numbers from 0 to 10 by exploiting
    the property that /bin/sh is an interpeter.

    In contrast to this, a compiler reads the source code completely, parses
    and checks it and then transforms it into some sort of "other
    representation" which can be executed without dealing with the source
    code (text) again. Eg, the Java compiler transforms Java source code
    into Java bytecode which is then usually executed by the jvm. OTOH,
    processors capable of executing Java bytecode directly exit or at least
    used to exist. ARM CPUs once had an extension for that (Jazelle).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to All on Sat Oct 12 14:50:09 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sat, 12 Oct 2024 13:53:56 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) gabbled:
    In article <vedcjc$3mqn$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >>up. You can't just point the CPU at the first byte of the binary and off it >>goes particularly in the case of Linux where the kernel requires decompressing

    first.

    Again, not generally, no. Consider an embedded system where the
    program to be executed on, say, a microcontroller is itself
    statically linked at an absolute address and burned into a ROM,

    Unlikely to be running *nix in that case.

    with the program's entry point at the CPU's reset address. I
    suppose that's not "standalone" if you count a ROM burner as
    part of "loading" it.

    Now you're just being silly.

    Also, I mentioned Unix, not Linux. The two are different. The

    Are they? Thats debatable these days. I'd say Linux is a lot closer to
    the philosphy of BSD and SYS-V than MacOS which is a certified unix.

    Standalone as you are well aware in the sense of doesn't require an >interpreter
    or VM to run on the OS and contains CPU machine code.

    So what about a binary that is dynamically linked with a shared
    object? That requires a runtime interpreter nee linker to bind
    its constituent parts together before it's executable. And what
    if it makes a system call? Then it's no longer "standalone", as
    it necessarily relies on the operating system to perform part of
    its function.

    Standalone in the sense that the opcodes in the binary don't need to be transformed into something else before being loaded by the CPU.

    usually in userspace. Why do you think that a compiler that
    generates bytecode for some virtual machine is any different
    from a compiler that generates object code for some CPU?

    I'd say its a grey area because it isn't full compilation is it, the p-code still requires an interpreter before it'll run.

    You don't seem to be able to recognize that the compilation step

    Compiling is not the same as converting. Is a javascript to C converter a compiler? By your definition it is.

    Where do you get this commonly accepted definition from?

    *shrug* Tanenbaum; Silberschatz; Kaashoek; Roscoe; etc. Where
    did you get your definition?

    Only heard of one of them so mostly irrelevant. Mine come from the name of tools that compile code to a runnable binary.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to All on Sat Oct 12 15:51:10 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sat, 12 Oct 2024 15:32:28 GMT
    scott@slp53.sl.home (Scott Lurndal) gabbled:
    Muttley@dastardlyhq.com writes:
    Standalone in the sense that the opcodes in the binary don't need to be >>transformed into something else before being loaded by the CPU.

    That's a rather unique definition of 'standalone'.

    Is it? As opposed to something that requires a seperate program to run any
    of it. That java p-code isn't going to do much without a jvm to translate it into x86 or ARM etc whereas a compiled binary will - after required libraries are loaded with it - just run directly on the CPU.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Muttley@dastardlyhq.com on Sat Oct 12 15:32:28 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@dastardlyhq.com writes:
    On Sat, 12 Oct 2024 13:53:56 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) gabbled:
    In article <vedcjc$3mqn$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >>>up. You can't just point the CPU at the first byte of the binary and off it >>>goes particularly in the case of Linux where the kernel requires decompressing

    first.

    Again, not generally, no. Consider an embedded system where the
    program to be executed on, say, a microcontroller is itself
    statically linked at an absolute address and burned into a ROM,

    Unlikely to be running *nix in that case.

    Some do, some don't. Many run zephyr, others various
    commercial embedded RTOS. In any case, they're binaries
    and if properly created, one simply points the cpu to the
    first byte of the binary (or more likely some standard
    PC value that the processor starts fetching from when
    it leaves reset, e.g. the VTOR on Cortex-m7 cores) and off it goes.



    So what about a binary that is dynamically linked with a shared
    object? That requires a runtime interpreter nee linker to bind
    its constituent parts together before it's executable. And what
    if it makes a system call? Then it's no longer "standalone", as
    it necessarily relies on the operating system to perform part of
    its function.

    Standalone in the sense that the opcodes in the binary don't need to be >transformed into something else before being loaded by the CPU.

    That's a rather unique definition of 'standalone'.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to Muttley@dastardlyhq.com on Sat Oct 12 16:36:26 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <vee2b1$6vup$1@dont-email.me>, <Muttley@dastardlyhq.com> wrote:
    On Sat, 12 Oct 2024 13:53:56 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) gabbled:
    In article <vedcjc$3mqn$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >>>up. You can't just point the CPU at the first byte of the binary and off it >>>goes particularly in the case of Linux where the kernel requires decompressing

    first.

    Again, not generally, no. Consider an embedded system where the
    program to be executed on, say, a microcontroller is itself
    statically linked at an absolute address and burned into a ROM,

    Unlikely to be running *nix in that case.

    We're discussing the concept of a "standalone binary"; you seem
    to think that means a binary image emitted by a linker and meant
    to run under a hosted environment, like an operating system. It
    does not.

    with the program's entry point at the CPU's reset address. I
    suppose that's not "standalone" if you count a ROM burner as
    part of "loading" it.

    Now you're just being silly.

    *shrug* Not my problem if you haven't dealt with many embedded
    systems.

    Also, I mentioned Unix, not Linux. The two are different. The

    Are they? Thats debatable these days. I'd say Linux is a lot closer to
    the philosphy of BSD and SYS-V than MacOS which is a certified unix.

    Yes, they are.

    Standalone as you are well aware in the sense of doesn't require an >>interpreter
    or VM to run on the OS and contains CPU machine code.

    So what about a binary that is dynamically linked with a shared
    object? That requires a runtime interpreter nee linker to bind
    its constituent parts together before it's executable. And what
    if it makes a system call? Then it's no longer "standalone", as
    it necessarily relies on the operating system to perform part of
    its function.

    Standalone in the sense that the opcodes in the binary don't need to be >transformed into something else before being loaded by the CPU.

    Yeah, no, that's not what anybody serious means when they say
    that.

    usually in userspace. Why do you think that a compiler that
    generates bytecode for some virtual machine is any different
    from a compiler that generates object code for some CPU?

    I'd say its a grey area because it isn't full compilation is it, the p-code >still requires an interpreter before it'll run.

    Nope.

    You don't seem to be able to recognize that the compilation step

    Compiling is not the same as converting. Is a javascript to C converter a >compiler? By your definition it is.

    Yes, of course it is. So is the terminfo compiler, and any
    number of other similar things. The first C++ compiler, cfront
    emitted C code, not object code. Was it not a compiler?

    Where do you get this commonly accepted definition from?

    *shrug* Tanenbaum; Silberschatz; Kaashoek; Roscoe; etc. Where
    did you get your definition?

    Only heard of one of them so mostly irrelevant. Mine come from the name of >tools that compile code to a runnable binary.

    It's very odd that you seek to speak from a position of
    authority when you don't even know who most of the major people
    in the field are.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eric Pozharski@21:1/5 to Weikusat on Sat Oct 12 16:39:20 2024
    XPost: comp.unix.shell, comp.unix.programmer

    with <87wmighu4i.fsf@doppelsaurus.mobileactivedefense.com> Rainer
    Weikusat wrote:
    Muttley@DastartdlyHQ.org writes:
    On Wed, 09 Oct 2024 22:25:05 +0100 Rainer Weikusat
    <rweikusat@talktalk.net> boring babbled:
    Bozo User <anthk@disroot.org> writes:
    On 2024-04-07, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Sun, 07 Apr 2024 00:01:43 +0000, Javier wrote:

    *CUT* [ 19 lines 6 levels deep]

    Its syntax is also a horrific mess.
    Which means precisely what?

    You're arguing with Unix Haters Handbook. You've already lost.

    *CUT* [ 8 lines 2 levels deep]

    --
    Torvalds' goal for Linux is very simple: World Domination
    Stallman's goal for GNU is even simpler: Freedom

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Christian Weisgerber@21:1/5 to Rainer Weikusat on Sat Oct 12 17:49:15 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-10-12, Rainer Weikusat <rweikusat@talktalk.net> wrote:

    Indeed. As far as I know the term, an interpreter is something which
    reads text from a file, parses it an checks it for syntax errors
    and then executes the code as soon as enough of it has been gathered to
    allow for execution of something, ie, a complete statement. This read,
    check and parse, execute cycle is repeated until the program
    terminates.

    I don't really want to participate in this discussion, but what
    you're saying there is that all those 1980s home computer BASIC
    interpreters, which read and tokenized a program before execution,
    were actually compilers.

    --
    Christian "naddy" Weisgerber naddy@mips.inka.de

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bart@21:1/5 to Rainer Weikusat on Sat Oct 12 20:50:51 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 12/10/2024 14:37, Rainer Weikusat wrote:
    Muttley@DastartdlyHQ.org writes:
    On Fri, 11 Oct 2024 20:58:26 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> boring babbled:
    On Fri, 11 Oct 2024 15:15:57 -0000 (UTC), Muttley wrote:

    On Fri, 11 Oct 2024 15:47:06 +0100
    Rainer Weikusat <rweikusat@talktalk.net>:

    The Perl compiler turns Perl source code into a set of (that's a

    Does it produce a standalone binary as output? No, so its an intepreter >>>> not a compiler.

    There are two parts: the interpreter interprets code generated by the compiler.

    Code generated by a compiler does not require an interpreter.

    Indeed. As far as I know the term, an interpreter is something which
    reads text from a file, parses it an checks it for syntax errors
    and then executes the code as soon as enough of it has been gathered to
    allow for execution of something, ie, a complete statement. This read,
    check and parse, execute cycle is repeated until the program
    terminates.

    That would be some very old BASIC, or maybe a shell program where the
    input is a stream of lines, and each must be executed when they were
    entered (you'd never reach end-of-file otherwise!).

    Most interpreters taking input from a file will compile the whole thing
    to some intermediate form first (eg. to internal bytecode). Then it will interpret that bytecode.

    Otherwise they would be hoplessly slow.

    In contrast to this, a compiler reads the source code completely, parses
    and checks it and then transforms it into some sort of "other
    representation" which can be executed without dealing with the source
    code (text) again.

    Some compilers (eg. the ones I write) can run programs from source just
    like an interpreted language. The difference here is that it first
    translates the whole program to native code rather than bytecode.

    Then there are more complicated schemes which mix things up: they start
    off interpreting and turn 'hot' paths into native code via JIT techniques.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Muttley on Sat Oct 12 21:25:17 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sat, 12 Oct 2024 08:42:17 -0000 (UTC), Muttley wrote:

    Code generated by a compiler does not require an interpreter.

    Something has to implement the rules of the “machine language”. This is
    why we use the term “abstract machine”, to avoid having to distinguish between “hardware” and “software”.

    Think: modern CPUs typically have “microcode” and “firmware” associated with them. Are those “hardware” or “software”?

    If you want to go down the reductio ad absurdum route then the electrons
    are interpreters too.

    <https://www.americanscientist.org/article/the-computational-universe> <https://en.wikipedia.org/wiki/Digital_physics>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Sun Oct 13 08:19:16 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sat, 12 Oct 2024 16:39:20 +0000
    Eric Pozharski <apple.universe@posteo.net> boring babbled:
    with <87wmighu4i.fsf@doppelsaurus.mobileactivedefense.com> Rainer
    Weikusat wrote:
    Muttley@DastartdlyHQ.org writes:
    On Wed, 09 Oct 2024 22:25:05 +0100 Rainer Weikusat
    <rweikusat@talktalk.net> boring babbled:
    Bozo User <anthk@disroot.org> writes:
    On 2024-04-07, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Sun, 07 Apr 2024 00:01:43 +0000, Javier wrote:

    *CUT* [ 19 lines 6 levels deep]

    Its syntax is also a horrific mess.
    Which means precisely what?

    You're arguing with Unix Haters Handbook. You've already lost.

    ITYF the people who dislike Perl are the ones who actually like the unix
    way of having simple daisychained tools instead of some lump of a language
    that does everything messily.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Sun Oct 13 08:20:19 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sat, 12 Oct 2024 17:49:15 -0000 (UTC)
    Christian Weisgerber <naddy@mips.inka.de> boring babbled:
    On 2024-10-12, Rainer Weikusat <rweikusat@talktalk.net> wrote:

    Indeed. As far as I know the term, an interpreter is something which
    reads text from a file, parses it an checks it for syntax errors
    and then executes the code as soon as enough of it has been gathered to
    allow for execution of something, ie, a complete statement. This read,
    check and parse, execute cycle is repeated until the program
    terminates.

    I don't really want to participate in this discussion, but what
    you're saying there is that all those 1980s home computer BASIC
    interpreters, which read and tokenized a program before execution,
    were actually compilers.

    He's painted himself into a corner. Will be interesting to see how gets
    out of it.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Sun Oct 13 08:22:53 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sat, 12 Oct 2024 21:25:17 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> boring babbled:
    On Sat, 12 Oct 2024 08:42:17 -0000 (UTC), Muttley wrote:

    Code generated by a compiler does not require an interpreter.

    Something has to implement the rules of the “machine language”. This is >why we use the term “abstract machine”, to avoid having to distinguish >between “hardware” and “software”.

    Think: modern CPUs typically have “microcode” and “firmware” >associated
    with them. Are those “hardware” or “software”?

    Who cares what happens inside the CPU hardware? It could be a group of pixies with abacuses for all the relevance it has to this argument. Standalone binaries contain machine code that can be directly executed by the CPU.

    If you want to go down the reductio ad absurdum route then the electrons
    are interpreters too.

    <https://www.americanscientist.org/article/the-computational-universe> ><https://en.wikipedia.org/wiki/Digital_physics>

    Thats heading off into philosphy.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Sun Oct 13 08:18:08 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sat, 12 Oct 2024 16:36:26 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    In article <vee2b1$6vup$1@dont-email.me>, <Muttley@dastardlyhq.com> wrote: >>Unlikely to be running *nix in that case.

    We're discussing the concept of a "standalone binary"; you seem
    to think that means a binary image emitted by a linker and meant
    to run under a hosted environment, like an operating system. It
    does not.

    It can mean either. Essentially its a binary that contains directly runnable CPU machine code. I'm not sure why you're having such a conceptual struggle understanding this simple concept.

    Now you're just being silly.

    *shrug* Not my problem if you haven't dealt with many embedded
    systems.

    I could bore you with the number I've actually "dealt with" including
    military hardware but whats the point. You've probably programmed the occasional PIC or arduino and think you're an expert.

    Are they? Thats debatable these days. I'd say Linux is a lot closer to
    the philosphy of BSD and SYS-V than MacOS which is a certified unix.

    Yes, they are.

    I disagree. Modern linux reminds me a lot of SunOS and HP-UX from back in
    the day. Not something that can be said for MacOS with its role-our-own
    Apple specific way of doing pretty much everything.

    Standalone in the sense that the opcodes in the binary don't need to be >>transformed into something else before being loaded by the CPU.

    Yeah, no, that's not what anybody serious means when they say
    that.

    Anybody serious presumably meaning you.

    I'd say its a grey area because it isn't full compilation is it, the p-code >>still requires an interpreter before it'll run.

    Nope.

    Really? So java bytecode will run direct on x86 or ARM will it? Please give some links to this astounding discovery you've made.

    Compiling is not the same as converting. Is a javascript to C converter a >>compiler? By your definition it is.

    Yes, of course it is. So is the terminfo compiler, and any

    So in your mind google translate is a "compiler" for spoken languages is it?

    number of other similar things. The first C++ compiler, cfront
    emitted C code, not object code. Was it not a compiler?

    No, it was a pre-compiler. Just like Oracles PRO*C/C++.

    Only heard of one of them so mostly irrelevant. Mine come from the name of >>tools that compile code to a runnable binary.

    It's very odd that you seek to speak from a position of
    authority when you don't even know who most of the major people
    in the field are.

    I know the important ones. You've dug out some obscure names from google
    that probably only a few CS courses even mention never mind study the work of.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Muttley@DastartdlyHQ.org on Sun Oct 13 14:55:14 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 13.10.2024 10:19, Muttley@DastartdlyHQ.org wrote:
    On Sat, 12 Oct 2024 16:39:20 +0000
    Eric Pozharski <apple.universe@posteo.net> boring babbled:
    [...]

    You're arguing with Unix Haters Handbook. You've already lost.

    ITYF the people who dislike Perl are the ones who actually like the unix
    way of having simple daisychained tools instead of some lump of a language that does everything messily.

    (I think some topics in this black-or-white mix should be sorted.)

    The pipelining mechanisms - if you meant that with "daisychained
    tools" - has its limitations. For simple filtering it's okay, but
    once you need some information from the front of the processing
    chain at the end of the chain solutions can get very clumsy, may
    create logical problems, race conditions, etc. Being able to
    memorize some information from the pipe-front processes to be used
    later is one inherent advantage of using a [scripting-]language
    like Perl, Awk, or whatever. (Personally I prefer a language like
    Awk because it's simple and has a clear syntax as opposed to Perl,
    but I understand that other folks might prefer Perl or Python.)

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to Muttley@DastartdlyHQ.org on Sun Oct 13 13:43:54 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <vefvo0$k1mm$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >On Sat, 12 Oct 2024 16:36:26 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    In article <vee2b1$6vup$1@dont-email.me>, <Muttley@dastardlyhq.com> wrote: >>>Unlikely to be running *nix in that case.

    We're discussing the concept of a "standalone binary"; you seem
    to think that means a binary image emitted by a linker and meant
    to run under a hosted environment, like an operating system. It
    does not.

    It can mean either. Essentially its a binary that contains directly runnable >CPU machine code. I'm not sure why you're having such a conceptual struggle >understanding this simple concept.

    Oh, I understand what you mean; it's your choice of non-standard
    terminology that I object to. Admittedly, Microsoft uses the
    term "standalone binary" to describe one other people might call
    "statically" linked", but you seem to mean any binary that comes
    out of say, invoking the `gcc` or `clang` driver and getting an
    executable object image. And in context, you seem to mean that
    a "compiler" is a program that _only_ generates such artifacts,
    but that's nonsense, and in fact, many compilers simply don't
    work that way. Even LLVM might generate an intermediate
    language, that is then in turn processed to generate object code
    for some particular target; that target might be an ISA for
    which physical silicon exists, or it might not.

    Consider, for example, the MMIX CPU designed by Knuth; a
    compiler may generate code for that, even though there is no CPU
    implementing the MMIX instruction set that I can pop on down to
    Microcenter and buy. Does that make that compiler less of a
    compiler? Or, keeping with the theme of MMIX, I'll bet someone
    has done an HDL implementation of it suitable for loading into
    and running on an FPGA; so is a compiler targeting it now a
    real compiler?

    Or consider x86; most modern x86 processors are really dataflow
    CPUs, and the x86 instruction encoding is just a bytecode that
    is, in fact, interpreted by the real CPU under the hood. So
    where does that fit on your little shrink-to-fit taxonomy? What
    about a compiler like LLVM that can target multiple backends,
    some of which may not actually be hardware (like, say, eBPF).
    Is any compiler that generates an intermediate laguage not a
    Real compiler, since it's not generating executable object code
    directly? What about a compiler that _only_ outputs an object
    file and defers to an explicitly programmer-driven seperate link
    step? The Plan 9 compiler suite works that way, and indeed,
    actual instruction selection is deferred to the linker. https://9p.io/sys/doc/compiler.html

    Or consider the APEX compiler for APL, which generated output as
    code in the SISAL programming language; the SISAL compiler, in
    turn, output either C or FORTRAN. This was actually quite
    useful; APL is great at very high-level optimizations ("multiply
    these matrices this way..."), SISAL was great a medium-level
    inter-procedural optimizations, and of course the system C and
    FORTRAN compilers excel at low-level register-level
    optimization. The effect was a program that was highly
    optimized when finally distilled down into an executable image.
    To assert that these weren't compilers is inane.

    Now you're just being silly.

    *shrug* Not my problem if you haven't dealt with many embedded
    systems.

    I could bore you with the number I've actually "dealt with" including >military hardware but whats the point.

    Weird appeals to experience, with vague and unsupported claims,
    aren't terribly convincing.

    You've probably programmed the
    occasional PIC or arduino and think you're an expert.

    Ok, Internet Guy.

    Are they? Thats debatable these days. I'd say Linux is a lot closer to >>>the philosphy of BSD and SYS-V than MacOS which is a certified unix.

    Yes, they are.

    I disagree. Modern linux reminds me a lot of SunOS and HP-UX from back in
    the day.

    Then I can only guess that you never used either SunOS or HP-UX.

    Not something that can be said for MacOS with its role-our-own
    Apple specific way of doing pretty much everything.

    Well, since we're talking about "standalone binaries" and my
    example was the Unix kernel, I should confess that I was really
    thinking more like the Unix kernel, or perhaps the standalone
    installation program that came on the V7 tape.

    Standalone in the sense that the opcodes in the binary don't need to be >>>transformed into something else before being loaded by the CPU.

    Yeah, no, that's not what anybody serious means when they say
    that.

    Anybody serious presumably meaning you.

    Sorry, you've shown no evidence why I should believe your
    assertions, and you've ignored directly disconfirming evidence
    showing that those assertions don't hold generally. If you want
    to define the concept of a "compiler" to be what you've narrowly
    defined it to be, you'll just have to accept that you're in very
    short company and people aren't going to take you particularly
    seriously.

    I'd say its a grey area because it isn't full compilation is it, the p-code >>>still requires an interpreter before it'll run.

    Nope.

    Really? So java bytecode will run direct on x86 or ARM will it? Please give >some links to this astounding discovery you've made.

    Um, ok. https://en.wikipedia.org/wiki/Jazelle

    Again, I bring up my earlier example of a CPU simulator.

    Compiling is not the same as converting. Is a javascript to C converter a >>>compiler? By your definition it is.

    Yes, of course it is. So is the terminfo compiler, and any

    So in your mind google translate is a "compiler" for spoken languages is it?

    To quote you above, "now you're just being silly."

    number of other similar things. The first C++ compiler, cfront
    emitted C code, not object code. Was it not a compiler?

    No, it was a pre-compiler. Just like Oracles PRO*C/C++.

    Nope.

    Only heard of one of them so mostly irrelevant. Mine come from the name of >>>tools that compile code to a runnable binary.

    It's very odd that you seek to speak from a position of
    authority when you don't even know who most of the major people
    in the field are.

    I know the important ones. You've dug out some obscure names from google
    that probably only a few CS courses even mention never mind study the work of.

    Ok, so you aren't familiar with the current state of the field
    as far as systems go; fair enough.

    In that case, let's just take a look at an authoritative source
    and see what it says. From Chapter 1, "Introduction to
    Compiling", section 1.1 "Compilers", first sentence of
    "Compilers: Principles, Techniques, and Tools" (1st Edition) by
    Aho, Sethi, and Ullman: "Simply stated, a compiler is a program
    that reads a program written in one language -- the _source_
    language -- and translates it into an equivalent program in
    another language -- the _target_ language."

    In the second paragraph, those authors go on to say, "...a
    target language may be another programming language, or the
    machine language of any computer".

    Note "any computer", could also be a kind of virtual machine.
    And of course, if the target langauge is another programming
    language, that already covers what is under discussion here.

    So it would seem that your definition is not shared by those who
    quite literally wrote the book on compilers.

    Look, I get the desire to want to pin things down into neat
    little categorical buckets, and if in one's own experience a
    "compiler" has only ever meant GCC or perhaps clang (or maybe
    Microsoft's compiler), then I can get where one is coming from.
    But as usual, in its full generality, the world is just messier
    than whatever conceptual boxes you've built up here.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Muttley@DastartdlyHQ.org on Sun Oct 13 15:02:13 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@DastartdlyHQ.org writes:
    On Sat, 12 Oct 2024 16:36:26 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    In article <vee2b1$6vup$1@dont-email.me>, <Muttley@dastardlyhq.com> wrote: >>>Unlikely to be running *nix in that case.


    *shrug* Not my problem if you haven't dealt with many embedded
    systems.

    I could bore you with the number I've actually "dealt with" including >military hardware but whats the point. You've probably programmed the >occasional PIC or arduino and think you're an expert.

    Dan isn't unknown in the field of computer science, particularly
    Unix and Plan 9. You, on the other hand....

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Dan Cross on Sun Oct 13 15:08:32 2024
    XPost: comp.unix.shell, comp.unix.programmer

    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <vefvo0$k1mm$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote:

    Really? So java bytecode will run direct on x86 or ARM will it? Please give >>some links to this astounding discovery you've made.

    Um, ok. https://en.wikipedia.org/wiki/Jazelle

    There was also a company a couple of decades ago that
    built an entire processor designed to execute bytecode
    directly - with a coprocessor to handle I/O.

    IIRC, it was Azul. There were a number of others, including
    Sun.

    None of them panned out - JIT's ended up winning that battle.

    Even ARM no longer includes Jazelle extensions in any of their
    mainstream processors.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Sun Oct 13 14:54:13 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sun, 13 Oct 2024 13:43:54 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    In article <vefvo0$k1mm$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >>On Sat, 12 Oct 2024 16:36:26 -0000 (UTC)
    It can mean either. Essentially its a binary that contains directly runnable >>CPU machine code. I'm not sure why you're having such a conceptual struggle >>understanding this simple concept.

    Oh, I understand what you mean; it's your choice of non-standard
    terminology that I object to. Admittedly, Microsoft uses the

    So what is standard terminology then?

    Or consider x86; most modern x86 processors are really dataflow
    CPUs, and the x86 instruction encoding is just a bytecode that
    is, in fact, interpreted by the real CPU under the hood. So
    where does that fit on your little shrink-to-fit taxonomy? What

    What happens inside the CPU is irrelevant. Its a black box as far as the
    rest of the machine is concerned. As I said in another post, it could be
    pixies with abacuses, doesn't matter.

    [lots of waffle snipped]

    I could bore you with the number I've actually "dealt with" including >>military hardware but whats the point.

    Weird appeals to experience, with vague and unsupported claims,
    aren't terribly convincing.

    So its ok for you to do that but nobody else?

    You've probably programmed the
    occasional PIC or arduino and think you're an expert.

    Ok, Internet Guy.

    I'll take that as a yes. Btw, you're some random guy on the internet too claiming some kind of higher experience.

    I disagree. Modern linux reminds me a lot of SunOS and HP-UX from back in >>the day.

    Then I can only guess that you never used either SunOS or HP-UX.

    "I disagree with you so you must be lying". Whatever.

    Anybody serious presumably meaning you.

    Sorry, you've shown no evidence why I should believe your
    assertions, and you've ignored directly disconfirming evidence

    Likewise.

    Really? So java bytecode will run direct on x86 or ARM will it? Please give >>some links to this astounding discovery you've made.

    Um, ok. https://en.wikipedia.org/wiki/Jazelle

    So its incomplete and has to revert to software for some opcodes. Great.
    FWIW Sun also had a java processor but you still can't run bytecode on
    normal hardware without a JVM.

    So in your mind google translate is a "compiler" for spoken languages is it?

    To quote you above, "now you're just being silly."

    Why, whats the difference? Your definition seems to be any program that can translate from one language to another.

    No, it was a pre-compiler. Just like Oracles PRO*C/C++.

    Nope.

    Yes, they're entirely analoguous.

    https://docs.oracle.com/cd/E11882_01/appdev.112/e10825/pc_02prc.htm

    I know the important ones. You've dug out some obscure names from google >>that probably only a few CS courses even mention never mind study the work of.


    Ok, so you aren't familiar with the current state of the field
    as far as systems go; fair enough.

    Who cares about the current state? Has nothing to do with this discussion.

    Aho, Sethi, and Ullman: "Simply stated, a compiler is a program
    that reads a program written in one language -- the _source_
    language -- and translates it into an equivalent program in
    another language -- the _target_ language."

    Thats an opinion, not a fact.

    So it would seem that your definition is not shared by those who
    quite literally wrote the book on compilers.

    Writing the book is not the same as writing the compilers.

    Look, I get the desire to want to pin things down into neat
    little categorical buckets, and if in one's own experience a
    "compiler" has only ever meant GCC or perhaps clang (or maybe
    Microsoft's compiler), then I can get where one is coming from.

    You can add a couple of TI and MPLAB compilers into that list. And obviously Arduinos , whatever its called. Been a while.

    But as usual, in its full generality, the world is just messier
    than whatever conceptual boxes you've built up here.

    There's a difference between accepting there are shades of grey and asserting that a compiler is pretty much any program which translates from one thing to another.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Muttley@DastartdlyHQ.org on Sun Oct 13 17:17:28 2024
    XPost: comp.unix.programmer

    [ X-post list reduced ]

    On 13.10.2024 16:54, Muttley@DastartdlyHQ.org wrote:

    Aho, Sethi, and Ullman: "Simply stated, a compiler is a program
    that reads a program written in one language -- the _source_
    language -- and translates it into an equivalent program in
    another language -- the _target_ language."

    Thats an opinion, not a fact.

    Well, I recall the compiler construction and formal languages books
    from Aho, Hopcroft, Sethi, Ullman, from the 1980's. Excellent books
    and a reference (also in Europe). - So calling the citation only as
    an "opinion" is quite audacious! - If I'd have to choose an expert
    from the list Muttley, Aho, Hopcroft, Sethi, Ullman, the choice is
    quite obvious. :-)

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to Scott Lurndal on Sun Oct 13 15:52:14 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <QnROO.226037$EEm7.111715@fx16.iad>,
    Scott Lurndal <slp53@pacbell.net> wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <vefvo0$k1mm$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote:

    Really? So java bytecode will run direct on x86 or ARM will it? Please give >>>some links to this astounding discovery you've made.

    Um, ok. https://en.wikipedia.org/wiki/Jazelle

    There was also a company a couple of decades ago that
    built an entire processor designed to execute bytecode
    directly - with a coprocessor to handle I/O.

    IIRC, it was Azul. There were a number of others, including
    Sun.

    None of them panned out - JIT's ended up winning that battle.

    Even ARM no longer includes Jazelle extensions in any of their
    mainstream processors.

    Sure. But the fact that any of these were going concerns is an
    existence proof that one _can_ take bytecodes targetted toward a
    "virtual" machine and execute it on silicon, making the
    distinction a lot more fluid than might be naively assumed, in
    turn exposing the silliness of this argument that centers around
    this weirdly overly-rigid definition of what a "compiler" is.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to Who on Sun Oct 13 16:02:13 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sun, 13 Oct 2024 15:30:03 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    In article <vegmul$ne3v$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >>So what is standard terminology then?

    I've already explained this to you.

    No you haven't. You explanation seems to be "anything that converts from one language to another".

    What happens inside the CPU is irrelevant. Its a black box as far as the >>rest of the machine is concerned. As I said in another post, it could be >>pixies with abacuses, doesn't matter.

    So why do you think it's so important that the definition of a

    Who said its important? Its just what most people think of as compilers.

    CPU"? If, as you admit, what the CPU does is highly variable,
    then why do you cling so hard to this meaningless distinction?

    You're the one making a big fuss about it with pages of waffle to back up
    your claim.

    [lots of waffle snipped]

    In other words, you discard anything that doesn't fit with your >preconceptions. Got it.

    No, I just have better things to do on a sunday than read all that. Keep
    it to the point.

    So its incomplete and has to revert to software for some opcodes. Great. >>FWIW Sun also had a java processor but you still can't run bytecode on >>normal hardware without a JVM.

    Cool. So if I run a program targetting a newer version of an
    ISA is run on an older machine, and that machine lacks a newer
    instruction present in the program, and the CPU generates an
    illegal instruction trap at runtime that the OS catches and
    emulates on the program's behalf, the program was not compiled?

    And again, what about an emulator for a CPU running on a
    different CPU? I can boot 7th Edition Unix on a PDP-11
    emulator on my workstation; does that mean that the 7the
    edition C compiler wasn't a compiler?

    Its all shades of grey. You seem to be getting very worked up about it.
    As I said, most people consider a compiler as something that translates source code to machine code and writes it to a file.

    Why, whats the difference? Your definition seems to be any program that can >>translate from one language to another.

    If you can't see that yourself, then you're either ignorant or
    obstinant. Take your pick.

    So you can't argue the failure of your logic then. Noted.

    Yes, they're entirely analoguous.

    https://docs.oracle.com/cd/E11882_01/appdev.112/e10825/pc_02prc.htm

    Nah, not really.

    Oh nice counter arguement, you really sold your POV there.

    Who cares about the current state? Has nothing to do with this discussion.

    In other words, "I don't have an argument, so I'll just lamely
    try to define things until I'm right."

    Im just defining things the way most people see it, not some ivory tower academics. Anyway, lifes too short for the rest.

    [tl;dr]

    that a compiler is pretty much any program which translates from one thing to >>another.

    No. It translates one computer _language_ to another computer
    _language_. In the usual case, that's from a textual source

    Machine code isn't a language. Fallen at the first hurdle with that
    definition.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to Muttley@DastartdlyHQ.org on Sun Oct 13 15:30:03 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <vegmul$ne3v$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >On Sun, 13 Oct 2024 13:43:54 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    In article <vefvo0$k1mm$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >>>On Sat, 12 Oct 2024 16:36:26 -0000 (UTC)
    It can mean either. Essentially its a binary that contains directly runnable >>>CPU machine code. I'm not sure why you're having such a conceptual struggle >>>understanding this simple concept.

    Oh, I understand what you mean; it's your choice of non-standard >>terminology that I object to. Admittedly, Microsoft uses the

    So what is standard terminology then?

    I've already explained this to you.

    Or consider x86; most modern x86 processors are really dataflow
    CPUs, and the x86 instruction encoding is just a bytecode that
    is, in fact, interpreted by the real CPU under the hood. So
    where does that fit on your little shrink-to-fit taxonomy? What

    What happens inside the CPU is irrelevant. Its a black box as far as the
    rest of the machine is concerned. As I said in another post, it could be >pixies with abacuses, doesn't matter.

    So why do you think it's so important that the definition of a
    compiler means, "generates object code directly runnable on a
    CPU"? If, as you admit, what the CPU does is highly variable,
    then why do you cling so hard to this meaningless distinction?

    [lots of waffle snipped]

    In other words, you discard anything that doesn't fit with your
    preconceptions. Got it.

    Then I can only guess that you never used either SunOS or HP-UX.

    "I disagree with you so you must be lying". Whatever.

    Way to miss the point by fixating on random details. Lawrence,
    is that you?

    Sorry, you've shown no evidence why I should believe your
    assertions, and you've ignored directly disconfirming evidence

    Likewise.

    I've cited evidence written by acknowledged experts in the
    field; have you?

    Really? So java bytecode will run direct on x86 or ARM will it? Please give >>>some links to this astounding discovery you've made.

    Um, ok. https://en.wikipedia.org/wiki/Jazelle

    So its incomplete and has to revert to software for some opcodes. Great.
    FWIW Sun also had a java processor but you still can't run bytecode on
    normal hardware without a JVM.

    Cool. So if I run a program targetting a newer version of an
    ISA is run on an older machine, and that machine lacks a newer
    instruction present in the program, and the CPU generates an
    illegal instruction trap at runtime that the OS catches and
    emulates on the program's behalf, the program was not compiled?

    And again, what about an emulator for a CPU running on a
    different CPU? I can boot 7th Edition Unix on a PDP-11
    emulator on my workstation; does that mean that the 7the
    edition C compiler wasn't a compiler?

    So in your mind google translate is a "compiler" for spoken languages is it? >>
    To quote you above, "now you're just being silly."

    Why, whats the difference? Your definition seems to be any program that can >translate from one language to another.

    If you can't see that yourself, then you're either ignorant or
    obstinant. Take your pick.

    No, it was a pre-compiler. Just like Oracles PRO*C/C++.

    Nope.

    Yes, they're entirely analoguous.

    https://docs.oracle.com/cd/E11882_01/appdev.112/e10825/pc_02prc.htm

    Nah, not really.

    I know the important ones. You've dug out some obscure names from google >>>that probably only a few CS courses even mention never mind study the work of.


    Ok, so you aren't familiar with the current state of the field
    as far as systems go; fair enough.

    Who cares about the current state? Has nothing to do with this discussion.

    In other words, "I don't have an argument, so I'll just lamely
    try to define things until I'm right."

    Aho, Sethi, and Ullman: "Simply stated, a compiler is a program
    that reads a program written in one language -- the _source_
    language -- and translates it into an equivalent program in
    another language -- the _target_ language."

    Thats an opinion, not a fact.

    So it would seem that your definition is not shared by those who
    quite literally wrote the book on compilers.

    Writing the book is not the same as writing the compilers.

    Well, let's look at the words of someone who wrote the compiler,
    then. Stroustrup writes in his HOPL paper on C++ that cfront
    was, "my original C++ compiler". Quoted from, https://stroustrup.com/hopl-almost-final.pdf (page 6).

    Look, I get the desire to want to pin things down into neat
    little categorical buckets, and if in one's own experience a
    "compiler" has only ever meant GCC or perhaps clang (or maybe
    Microsoft's compiler), then I can get where one is coming from.

    You can add a couple of TI and MPLAB compilers into that list. And obviously >Arduinos , whatever its called. Been a while.

    But as usual, in its full generality, the world is just messier
    than whatever conceptual boxes you've built up here.

    There's a difference between accepting there are shades of grey and asserting >that a compiler is pretty much any program which translates from one thing to >another.

    No. It translates one computer _language_ to another computer
    _language_. In the usual case, that's from a textual source
    language to a binary machine language, but that needn't be the
    case.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Muttley@DastartdlyHQ.org on Sun Oct 13 18:28:32 2024
    XPost: comp.unix.programmer

    [ X-post list reduced ]

    On 13.10.2024 18:02, Muttley@DastartdlyHQ.org wrote:
    On Sun, 13 Oct 2024 15:30:03 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    [...]

    No. It translates one computer _language_ to another computer
    _language_. In the usual case, that's from a textual source

    Machine code isn't a language. Fallen at the first hurdle with that definition.

    Careful (myself included); watch out for the glazed frost!

    You know there's formal definitions for what constitutes languages.

    At first glance I don't see why machine code wouldn't quality as a
    language (either as some specific "mnemonic" representation, or as
    a sequence of integral numbers or other "code" representations).

    What's the problem, in your opinion, with considering machine code
    as a language?

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bart@21:1/5 to Dan Cross on Sun Oct 13 17:20:40 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 13/10/2024 16:52, Dan Cross wrote:
    In article <QnROO.226037$EEm7.111715@fx16.iad>,
    Scott Lurndal <slp53@pacbell.net> wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <vefvo0$k1mm$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote:

    Really? So java bytecode will run direct on x86 or ARM will it? Please give
    some links to this astounding discovery you've made.

    Um, ok. https://en.wikipedia.org/wiki/Jazelle

    There was also a company a couple of decades ago that
    built an entire processor designed to execute bytecode
    directly - with a coprocessor to handle I/O.

    IIRC, it was Azul. There were a number of others, including
    Sun.

    None of them panned out - JIT's ended up winning that battle.

    Even ARM no longer includes Jazelle extensions in any of their
    mainstream processors.

    Sure. But the fact that any of these were going concerns is an
    existence proof that one _can_ take bytecodes targetted toward a
    "virtual" machine and execute it on silicon,
    making the
    distinction a lot more fluid than might be naively assumed, in
    turn exposing the silliness of this argument that centers around
    this weirdly overly-rigid definition of what a "compiler" is.

    I've implemented numerous compilers and interpreters over the last few
    decades (and have dabbled in emulators).

    To me the distinctions are clear enough because I have to work at the
    sharp end!

    I'm not sure why people want to try and be clever by blurring the roles
    of compiler and interpreter; that's not helpful at all.

    Sure, people can write emulators for machine code, which are a kind of interpreter, or they can implement bytecode in hardware; so what?

    That doesn't really affect what I do. Writing compiler backends for
    actual CPUs is hard work. Generating bytecode is a lot simpler.
    (Especially in my case as I've devised myself, another distinction.
    Compilers usually target someone else's instruction set.)

    If you want one more distinction, it is this: with my compiler, the
    resultant binary is executed by a separate agency: the CPU. Or maybe the
    OS loader will run it through an emulator.

    With my interpreter, then *I* have to write the dispatch routines and
    write code to implement all the instructions.

    (My compilers generate an intermediate language, a kind of VM, which is
    then processed further into native code.

    But I have also tried interpreting that VM; it just runs 20 times slower
    than native code. That's what interpreting usually means: slow programs.)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Muttley@DastartdlyHQ.org on Sun Oct 13 16:31:58 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-10-11, Muttley@DastartdlyHQ.org <Muttley@DastartdlyHQ.org> wrote:
    Irrelevant. Lot of interpreters do partial compilation and the JVM does it
    on the fly. A proper compiler writes a standalone binary file to disk.

    You might want to check those goalposts again. You can easily make a
    "proper compiler" which just writes a canned interpreter executable to
    disk, appending to it the program source code.

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bart@21:1/5 to Kaz Kylheku on Sun Oct 13 20:06:12 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 13/10/2024 17:31, Kaz Kylheku wrote:
    On 2024-10-11, Muttley@DastartdlyHQ.org <Muttley@DastartdlyHQ.org> wrote:
    Irrelevant. Lot of interpreters do partial compilation and the JVM does it >> on the fly. A proper compiler writes a standalone binary file to disk.

    You might want to check those goalposts again. You can easily make a
    "proper compiler" which just writes a canned interpreter executable to
    disk, appending to it the program source code.


    So, an interpreter. The rest is just details of its deployment. In your example, the program being run is just some embedded data.

    Maybe the real question is what is 'hardware', and what is 'software'.
    But the answer won't make everyone happy because because hardware can be emulated in software.

    (Implementing software in hardware, specifically the bit of software
    that interprets a VM, is less common, and generally harder.)

    I prefer that there is a clear distinction between compiler and
    interpreter, because you immediately know what's what. (Here I'm
    excluding complex JIT products that mix up both.)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to bc@freeuk.com on Sun Oct 13 20:29:46 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <vegs0o$nh5t$1@dont-email.me>, Bart <bc@freeuk.com> wrote:
    On 13/10/2024 16:52, Dan Cross wrote:
    In article <QnROO.226037$EEm7.111715@fx16.iad>,
    Scott Lurndal <slp53@pacbell.net> wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <vefvo0$k1mm$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote:

    Really? So java bytecode will run direct on x86 or ARM will it? Please give
    some links to this astounding discovery you've made.

    Um, ok. https://en.wikipedia.org/wiki/Jazelle

    There was also a company a couple of decades ago that
    built an entire processor designed to execute bytecode
    directly - with a coprocessor to handle I/O.

    IIRC, it was Azul. There were a number of others, including
    Sun.

    None of them panned out - JIT's ended up winning that battle.

    Even ARM no longer includes Jazelle extensions in any of their
    mainstream processors.

    Sure. But the fact that any of these were going concerns is an
    existence proof that one _can_ take bytecodes targetted toward a
    "virtual" machine and execute it on silicon,
    making the
    distinction a lot more fluid than might be naively assumed, in
    turn exposing the silliness of this argument that centers around
    this weirdly overly-rigid definition of what a "compiler" is.

    I've implemented numerous compilers and interpreters over the last few >decades (and have dabbled in emulators).

    To me the distinctions are clear enough because I have to work at the
    sharp end!

    I'm not sure why people want to try and be clever by blurring the roles
    of compiler and interpreter; that's not helpful at all.

    I'm not saying the two are the same; what I'm saying is that
    this arbitrary criteria that a compiler must emit a fully
    executable binary image is not just inadquate, but also wrong,
    as it renders separate compilation impossible. I am further
    saying that there are many different _types_ of compilers,
    including specialized tools that don't emit machine language.

    Sure, people can write emulators for machine code, which are a kind of >interpreter, or they can implement bytecode in hardware; so what?

    That's exactly my point.

    That doesn't really affect what I do. Writing compiler backends for
    actual CPUs is hard work. Generating bytecode is a lot simpler.

    That really depends on the bytecode, doesn't it? The JVM is a
    complex beast; MIPS or the unprivileged integer subset of RISC-V
    are pretty simple in comparison.

    (Especially in my case as I've devised myself, another distinction.
    Compilers usually target someone else's instruction set.)

    If you want one more distinction, it is this: with my compiler, the
    resultant binary is executed by a separate agency: the CPU. Or maybe the
    OS loader will run it through an emulator.

    Python has a mode by which it will emit bytecode _files_, which
    can be separately loaded and interpreted; it even has an
    optimizing mode. Is that substantially different?

    With my interpreter, then *I* have to write the dispatch routines and
    write code to implement all the instructions.

    Again, I don't think that anyone disputes that interpreters
    exist. But insisting that they must take a particular shape is
    just wrong.

    (My compilers generate an intermediate language, a kind of VM, which is
    then processed further into native code.

    Then by the definition of this psuedonyminous guy I've been
    responding to, your compiler is not a "proper compiler", no?

    But I have also tried interpreting that VM; it just runs 20 times slower
    than native code. That's what interpreting usually means: slow programs.)

    Not necessarily. The JVM does pretty good, quite honestly.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Christian Weisgerber on Sun Oct 13 21:25:51 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Christian Weisgerber <naddy@mips.inka.de> writes:
    On 2024-10-12, Rainer Weikusat <rweikusat@talktalk.net> wrote:
    Indeed. As far as I know the term, an interpreter is something which
    reads text from a file, parses it an checks it for syntax errors
    and then executes the code as soon as enough of it has been gathered to
    allow for execution of something, ie, a complete statement. This read,
    check and parse, execute cycle is repeated until the program
    terminates.

    I don't really want to participate in this discussion, but what
    you're saying there is that all those 1980s home computer BASIC
    interpreters, which read and tokenized a program before execution,
    were actually compilers.

    If they contained something which compiled all of the source code prior
    to execution in order to transform it some actually executable
    intermediate representation whose execution didn't require future access
    to the source code and thus, also didn't include checking the source
    code for syntactical correctness, this something can be called a
    compiler and the execution engine some sort of virtual machine which
    could principally execute programs compiled from source code in any
    programming language.

    But judging from Wikipedia, Murkysoft Basic stored programs as linked
    list of preprocessed lines and interpreted these, ie, doing string
    lookups of keywords from the source code at run time in order to
    determine what code to execute. Insofar I vaguely remember this from
    Apple //c BASIC (has been a while) syntax errors would also be found at runtime, ie, once execution reached the line with the error. This would
    make it an interpreter.

    In constrast to this, this somewhat amusing small Perl program:

    while (<>) {
    while (length) {
    s/^(\w+)// and print(scalar reverse($1));
    s/^(\W+)// and print($1);
    }
    }

    [reads lines from stdin and prints them with each word reversed]

    gets translated into an op tree whose textual representation (perl -MO=Concise,-basic) looks like
    this:

    y <@> leave[1 ref] vKP/REFC ->(end)
    1 <0> enter v ->2
    2 <;> nextstate(main 1 a.pl:1) v:{ ->3
    x <2> leaveloop vKP/2 ->y
    3 <{> enterloop(next->r last->x redo->4) v ->s
    - <1> null vK/1 ->x
    w <|> and(other->4) vK/1 ->x
    v <1> defined sK/1 ->w
    - <1> null sK/2 ->v
    - <1> ex-rv2sv sKRM*/1 ->t
    s <#> gvsv[*_] s ->t
    u <1> readline[t2] sKS/1 ->v
    t <#> gv[*ARGV] s ->u
    - <@> lineseq vKP ->-
    4 <;> nextstate(main 3 a.pl:2) v:{ ->5
    q <2> leaveloop vKP/2 ->r
    5 <{> enterloop(next->m last->q redo->6) v ->n
    - <1> null vK/1 ->q
    p <|> and(other->6) vK/1 ->q
    o <1> length[t4] sK/BOOL,1 ->p
    - <1> ex-rv2sv sK/1 ->o
    n <#> gvsv[*_] s ->o
    - <@> lineseq vKP ->-
    6 <;> nextstate(main 5 a.pl:3) v:{ ->7
    - <1> null vK/1 ->f
    9 <|> and(other->a) vK/1 ->f
    8 </> subst(/"^(\\w+)"/) sK/BOOL ->9
    7 <$> const[PV ""] s ->8
    e <@> print vK ->f
    a <0> pushmark s ->b
    - <1> scalar sK/1 ->e
    d <@> reverse[t6] sK/1 ->e
    b <0> pushmark s ->c
    - <1> ex-rv2sv sK/1 ->d
    c <#> gvsv[*1] s ->d
    f <;> nextstate(main 5 a.pl:4) v:{ ->g
    - <1> null vK/1 ->m
    i <|> and(other->j) vK/1 ->m
    h </> subst(/"^(\\W+)"/) sK/BOOL ->i
    g <$> const[PV ""] s ->h
    l <@> print vK ->m
    j <0> pushmark s ->k
    - <1> ex-rv2sv sK/1 ->l
    k <#> gvsv[*1] s ->l
    m <0> unstack v ->n
    r <0> unstack v ->s

    Each line represents a node on this tree and the names refer to builtin
    'ops'. In the actual tree, they're pointers to C functions and execution happens as preorder traversal of this tree and invoking the op functions
    from the leaves to root to produce the arguments necessary for invoking
    op functions residing at a higher level in this tree.

    Modules for writing this internal representation to a file and loading
    it back from there and even for translating it into C exist. They're
    just not part of the core distribution anymore.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to Muttley@DastartdlyHQ.org on Sun Oct 13 20:15:45 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <vegqu5$o3ve$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >On Sun, 13 Oct 2024 15:30:03 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    In article <vegmul$ne3v$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >>>So what is standard terminology then?

    I've already explained this to you.

    No you haven't. You explanation seems to be "anything that converts from one >language to another".

    What happens inside the CPU is irrelevant. Its a black box as far as the >>>rest of the machine is concerned. As I said in another post, it could be >>>pixies with abacuses, doesn't matter.

    So why do you think it's so important that the definition of a

    Who said its important? Its just what most people think of as compilers.

    CPU"? If, as you admit, what the CPU does is highly variable,
    then why do you cling so hard to this meaningless distinction?

    You're the one making a big fuss about it with pages of waffle to back up >your claim.

    [lots of waffle snipped]

    In other words, you discard anything that doesn't fit with your >>preconceptions. Got it.

    No, I just have better things to do on a sunday than read all that. Keep
    it to the point.

    So its incomplete and has to revert to software for some opcodes. Great. >>>FWIW Sun also had a java processor but you still can't run bytecode on >>>normal hardware without a JVM.

    Cool. So if I run a program targetting a newer version of an
    ISA is run on an older machine, and that machine lacks a newer
    instruction present in the program, and the CPU generates an
    illegal instruction trap at runtime that the OS catches and
    emulates on the program's behalf, the program was not compiled?

    And again, what about an emulator for a CPU running on a
    different CPU? I can boot 7th Edition Unix on a PDP-11
    emulator on my workstation; does that mean that the 7the
    edition C compiler wasn't a compiler?

    Its all shades of grey. You seem to be getting very worked up about it.
    As I said, most people consider a compiler as something that translates source >code to machine code and writes it to a file.

    Why, whats the difference? Your definition seems to be any program that can >>>translate from one language to another.

    If you can't see that yourself, then you're either ignorant or
    obstinant. Take your pick.

    So you can't argue the failure of your logic then. Noted.

    Yes, they're entirely analoguous.

    https://docs.oracle.com/cd/E11882_01/appdev.112/e10825/pc_02prc.htm

    Nah, not really.

    Oh nice counter arguement, you really sold your POV there.

    Who cares about the current state? Has nothing to do with this discussion. >>
    In other words, "I don't have an argument, so I'll just lamely
    try to define things until I'm right."

    Im just defining things the way most people see it, not some ivory tower >academics. Anyway, lifes too short for the rest.

    [tl;dr]

    that a compiler is pretty much any program which translates from one thing to
    another.

    No. It translates one computer _language_ to another computer
    _language_. In the usual case, that's from a textual source

    Machine code isn't a language. Fallen at the first hurdle with that >definition.



    Newsgroups: comp.unix.shell,comp.unix.programmer,comp.lang.misc
    Subject: Re: Command Languages Versus Programming Languages
    Summary:
    Expires:
    References: <uu54la$3su5b$6@dont-email.me> <vegmul$ne3v$1@dont-email.me> <vegp1r$oqh$1@reader1.panix.com> <vegqu5$o3ve$1@dont-email.me>
    Sender:
    Followup-To:
    Distribution:
    Organization:
    Keywords:
    Cc:

    In article <vegqu5$o3ve$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >On Sun, 13 Oct 2024 15:30:03 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    In article <vegmul$ne3v$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >>>So what is standard terminology then?

    I've already explained this to you.

    No you haven't. You explanation seems to be "anything that converts from one >language to another".

    The context of this specific quote, which you snipped, was your
    insistence on the meaning of the term, "standalone binary."
    There are a number of common terms for what you are describing,
    which is the general term for the executable output artifact
    from a software build, none of which is "standalone binary".

    Common terms are "executable" or "executable file" (that's what
    the ELF standard calls it, for instance), but also "binary",
    "image", etc.

    What happens inside the CPU is irrelevant. Its a black box as far as the >>>rest of the machine is concerned. As I said in another post, it could be >>>pixies with abacuses, doesn't matter.

    So why do you think it's so important that the definition of a

    Who said its important? Its just what most people think of as compilers.

    Well, you seem to think it's rather important.

    CPU"? If, as you admit, what the CPU does is highly variable,
    then why do you cling so hard to this meaningless distinction?

    You're the one making a big fuss about it with pages of waffle to back up >your claim.

    I just don't like misinformation floating around unchallenged.

    You have cited nothing to back up your claims.

    So its incomplete and has to revert to software for some opcodes. Great. >>>FWIW Sun also had a java processor but you still can't run bytecode on >>>normal hardware without a JVM.

    Cool. So if I run a program targetting a newer version of an
    ISA is run on an older machine, and that machine lacks a newer
    instruction present in the program, and the CPU generates an
    illegal instruction trap at runtime that the OS catches and
    emulates on the program's behalf, the program was not compiled?

    And again, what about an emulator for a CPU running on a
    different CPU? I can boot 7th Edition Unix on a PDP-11
    emulator on my workstation; does that mean that the 7the
    edition C compiler wasn't a compiler?

    Its all shades of grey. You seem to be getting very worked up about it.

    Nah, I don't really care, aside from not wanting misinformation
    to stand unchallenged.

    As I said, most people consider a compiler as something that translates source >code to machine code and writes it to a file.

    Sure, if you're talking informally and you mention "a compiler"
    most people will know more or less what you're talking about.
    But back in <vebffc$3n6jv$1@dont-email.me> you wrote,

    |Does it produce a standalone binary as output? No, so its an
    |intepreter not a compiler.

    I said that was a bad distinction, to which you replied in <vebi0j$3nhvq$1@dont-email.me>:

    |A proper compiler writes a standalone binary file to disk.

    Except that, well, it doesn't. Even the "proper compilers" that
    you claim familiarity with basically don't do that; as I pointed
    out to you, they generate object files and a driver invokes a
    linker.

    For that matter, the compiler itself may not even generate
    object code, but rather, may generate textual assembly and let a
    separate assembler pass turn _that_ into object code.

    So yeah. What you've defined to be a "proper compiler" isn't
    really what you seem to think that it is.

    [snip]
    Who cares about the current state? Has nothing to do with this discussion. >>
    In other words, "I don't have an argument, so I'll just lamely
    try to define things until I'm right."

    Im just defining things the way most people see it, not some ivory tower >academics. Anyway, lifes too short for the rest.

    The people who create the field are the ones who get to make
    the defintiions, not you.

    Machine code isn't a language. Fallen at the first hurdle with that >definition.

    Oh really? Is that why they call it "machine language"? It's
    even in the dictionary with "machine code" as a synonymn: https://www.merriam-webster.com/dictionary/machine%20language

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to 643-408-1753@kylheku.com on Sun Oct 13 20:30:08 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <20241013093004.251@kylheku.com>,
    Kaz Kylheku <643-408-1753@kylheku.com> wrote:
    On 2024-10-11, Muttley@DastartdlyHQ.org <Muttley@DastartdlyHQ.org> wrote:
    Irrelevant. Lot of interpreters do partial compilation and the JVM does it >> on the fly. A proper compiler writes a standalone binary file to disk.

    You might want to check those goalposts again. You can easily make a
    "proper compiler" which just writes a canned interpreter executable to
    disk, appending to it the program source code.

    Indeed; this is what the Moscow ML compiler does.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to All on Sun Oct 13 20:33:10 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sun, 13 Oct 2024 08:22:53 -0000 (UTC), Muttley boring babbled:

    On Sat, 12 Oct 2024 21:25:17 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> wrote:

    On Sat, 12 Oct 2024 08:42:17 -0000 (UTC), Muttley boring babbled:

    Code generated by a compiler does not require an interpreter.

    Something has to implement the rules of the “machine language”. This is >>why we use the term “abstract machine”, to avoid having to distinguish >>between “hardware” and “software”.

    Think: modern CPUs typically have “microcode” and “firmware” associated
    with them. Are those “hardware” or “software”?

    Who cares what happens inside the CPU hardware?

    Because that’s where your “software” runs.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Muttley@DastartdlyHQ.org on Sun Oct 13 21:33:56 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@DastartdlyHQ.org writes:
    On Sat, 12 Oct 2024 16:39:20 +0000
    Eric Pozharski <apple.universe@posteo.net> boring babbled:
    with <87wmighu4i.fsf@doppelsaurus.mobileactivedefense.com> Rainer
    Weikusat wrote:
    Muttley@DastartdlyHQ.org writes:
    On Wed, 09 Oct 2024 22:25:05 +0100 Rainer Weikusat
    <rweikusat@talktalk.net> boring babbled:
    Bozo User <anthk@disroot.org> writes:
    On 2024-04-07, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Sun, 07 Apr 2024 00:01:43 +0000, Javier wrote:

    *CUT* [ 19 lines 6 levels deep]

    Its syntax is also a horrific mess.
    Which means precisely what?

    You're arguing with Unix Haters Handbook. You've already lost.

    ITYF the people who dislike Perl are the ones who actually like the unix
    way of having simple daisychained tools instead of some lump of a language that does everything messily.

    Perl is a general-purpose programming language, just like C or Java (or
    Python or Javascript or Rust or $whatnot). This means it can be used to implement anything (with some practical limitation for anything) and not
    that it "does everything".

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Muttley on Sun Oct 13 20:34:47 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sun, 13 Oct 2024 08:19:16 -0000 (UTC), Muttley wrote:

    ITYF the people who dislike Perl are the ones who actually like the unix
    way of having simple daisychained tools instead of some lump of a
    language that does everything messily.

    Not sure how those small tools can work without the support of much bigger lumps like the shell, the compiler/interpreter for those tools and the
    kernel itself.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Muttley on Sun Oct 13 21:09:13 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sun, 13 Oct 2024 16:02:13 -0000 (UTC), Muttley wrote:

    You explanation seems to be "anything that converts from one
    language to another".

    You would call that a “translator”. That term was used more in the early days, but that’s essentially synonymous with “compiler”.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Janis Papanagnou on Sun Oct 13 21:10:06 2024
    XPost: comp.unix.programmer

    On Sun, 13 Oct 2024 18:28:32 +0200, Janis Papanagnou wrote:

    You know there's formal definitions for what constitutes languages.

    Not really. For example, some have preferred the term “notation” instead
    of “language”.

    Regardless of what you call it, machine code still qualifies.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Muttley on Sun Oct 13 21:08:09 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sun, 13 Oct 2024 14:54:13 -0000 (UTC), Muttley wrote:

    What happens inside the CPU is irrelevant.

    But that’s where your “software” runs.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Lawrence D'Oliveiro on Mon Oct 14 01:16:11 2024
    XPost: comp.unix.programmer

    On 13.10.2024 23:10, Lawrence D'Oliveiro wrote:
    On Sun, 13 Oct 2024 18:28:32 +0200, Janis Papanagnou wrote:

    You know there's formal definitions for what constitutes languages.

    Not really. For example, some have preferred the term “notation” instead of “language”.

    A "notation" is not the same as a [formal (or informal)] "language".

    (Frankly, I don't know where you're coming from; mind to explain your
    point if you think it's relevant. - But since you wrote "_some_ have
    preferred" it might anyway have been only an opinion or a historic
    inaccuracy so it's probably not worth expanding on that?)

    I think we should be clear about terminology.

    I was speaking about [formal] languages as introduced by Chomsky and
    used (and extended) by scientists (specifically computer scientists)
    since then. And these formal characteristics of languages and grammars
    are also the base of the books that have been mentioned and recently
    quoted in this sub-thread.

    Regardless of what you call it, machine code still qualifies.

    Glad you agree.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bart@21:1/5 to Dan Cross on Mon Oct 14 01:20:45 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 13/10/2024 21:29, Dan Cross wrote:
    In article <vegs0o$nh5t$1@dont-email.me>, Bart <bc@freeuk.com> wrote:
    On 13/10/2024 16:52, Dan Cross wrote:
    In article <QnROO.226037$EEm7.111715@fx16.iad>,
    Scott Lurndal <slp53@pacbell.net> wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <vefvo0$k1mm$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote:

    Really? So java bytecode will run direct on x86 or ARM will it? Please give
    some links to this astounding discovery you've made.

    Um, ok. https://en.wikipedia.org/wiki/Jazelle

    There was also a company a couple of decades ago that
    built an entire processor designed to execute bytecode
    directly - with a coprocessor to handle I/O.

    IIRC, it was Azul. There were a number of others, including
    Sun.

    None of them panned out - JIT's ended up winning that battle.

    Even ARM no longer includes Jazelle extensions in any of their
    mainstream processors.

    Sure. But the fact that any of these were going concerns is an
    existence proof that one _can_ take bytecodes targetted toward a
    "virtual" machine and execute it on silicon,
    making the
    distinction a lot more fluid than might be naively assumed, in
    turn exposing the silliness of this argument that centers around
    this weirdly overly-rigid definition of what a "compiler" is.

    I've implemented numerous compilers and interpreters over the last few
    decades (and have dabbled in emulators).

    To me the distinctions are clear enough because I have to work at the
    sharp end!

    I'm not sure why people want to try and be clever by blurring the roles
    of compiler and interpreter; that's not helpful at all.

    I'm not saying the two are the same; what I'm saying is that
    this arbitrary criteria that a compiler must emit a fully
    executable binary image is not just inadquate, but also wrong,
    as it renders separate compilation impossible. I am further
    saying that there are many different _types_ of compilers,
    including specialized tools that don't emit machine language.

    Sure, people can write emulators for machine code, which are a kind of
    interpreter, or they can implement bytecode in hardware; so what?

    That's exactly my point.

    So, then what, we do away with the concepts of 'compiler' and
    'interpreter'? Or allow them to be used interchangeably?

    Somehow I don't think it is useful to think of gcc as a interpreter for
    C, or CPython as an native code compiler for Python.

    That doesn't really affect what I do. Writing compiler backends for
    actual CPUs is hard work. Generating bytecode is a lot simpler.

    That really depends on the bytecode, doesn't it? The JVM is a
    complex beast;

    Is it? It's not to my taste, but it didn't look too scary to me. Whereas
    modern CPU instruction sets are horrendous. (I normally target x64,
    which is described in 6 large volumes. RISC ones don't look much better,
    eg. RISC V with its dozens of extensions and special types)

    Example of JVM:

    aload index Push a reference from local variable #index

    MIPS or the unprivileged integer subset of RISC-V
    are pretty simple in comparison.

    (Especially in my case as I've devised myself, another distinction.
    Compilers usually target someone else's instruction set.)

    If you want one more distinction, it is this: with my compiler, the
    resultant binary is executed by a separate agency: the CPU. Or maybe the
    OS loader will run it through an emulator.

    Python has a mode by which it will emit bytecode _files_, which
    can be separately loaded and interpreted; it even has an
    optimizing mode. Is that substantially different?

    Whether there is a discrete bytecode file is besides the point. (I
    generated such files for many years.)

    You still need software to execute it. Especially for dynamically typed bytecode which doesn't lend itself easily to either hardware
    implementations, or load-time native code translation.


    With my interpreter, then *I* have to write the dispatch routines and
    write code to implement all the instructions.

    Again, I don't think that anyone disputes that interpreters
    exist. But insisting that they must take a particular shape is
    just wrong.

    What shape would that be? Generally they will need some /software/ to
    excute the instructions of the program being interpreted, as I said.
    Some JIT products may choose to do on-demand translation to native code.

    Is there anything else? I'd be interested in anything new!

    (My compilers generate an intermediate language, a kind of VM, which is
    then processed further into native code.

    Then by the definition of this psuedonyminous guy I've been
    responding to, your compiler is not a "proper compiler", no?

    Actually mine is more of a compiler than many, since it directly
    generates native machine code. Others generally stop at ASM code (eg.
    gcc) or OBJ code, and will invoke separate programs to finish the job.

    The intermediate language here is just a step in the process.

    But I have also tried interpreting that VM; it just runs 20 times slower
    than native code. That's what interpreting usually means: slow programs.)

    Not necessarily. The JVM does pretty good, quite honestly.

    But is it actually interpreting? Because if I generated such code for a statically typed language, then I would first translate to native code,
    of any quality, since it's going to be faster than interpreting.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Janis Papanagnou on Mon Oct 14 01:45:49 2024
    XPost: comp.unix.programmer

    On Mon, 14 Oct 2024 01:16:11 +0200, Janis Papanagnou wrote:

    On 13.10.2024 23:10, Lawrence D'Oliveiro wrote:

    On Sun, 13 Oct 2024 18:28:32 +0200, Janis Papanagnou wrote:

    You know there's formal definitions for what constitutes languages.

    Not really. For example, some have preferred the term “notation”
    instead of “language”.

    A "notation" is not the same as a [formal (or informal)] "language".

    (Frankly, I don't know where you're coming from ...

    <https://en.wikipedia.org/wiki/Programming_language>:

    A programming language is a system of notation for writing computer
    programs.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Mon Oct 14 08:25:37 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sun, 13 Oct 2024 20:15:45 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    In article <vegqu5$o3ve$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote:

    [tl;dr]

    The people who create the field are the ones who get to make
    the defintiions, not you.

    ITYF people in the field as a whole make the definitions.

    Machine code isn't a language. Fallen at the first hurdle with that >>definition.

    Oh really? Is that why they call it "machine language"? It's
    even in the dictionary with "machine code" as a synonymn: >https://www.merriam-webster.com/dictionary/machine%20language

    Its not a programming language.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Mon Oct 14 08:23:20 2024
    XPost: comp.unix.programmer

    On Sun, 13 Oct 2024 18:28:32 +0200
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> boring babbled:
    [ X-post list reduced ]

    On 13.10.2024 18:02, Muttley@DastartdlyHQ.org wrote:
    On Sun, 13 Oct 2024 15:30:03 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    [...]

    No. It translates one computer _language_ to another computer
    _language_. In the usual case, that's from a textual source

    Machine code isn't a language. Fallen at the first hurdle with that
    definition.

    Careful (myself included); watch out for the glazed frost!

    You know there's formal definitions for what constitutes languages.

    At first glance I don't see why machine code wouldn't quality as a
    language (either as some specific "mnemonic" representation, or as
    a sequence of integral numbers or other "code" representations).
    What's the problem, in your opinion, with considering machine code
    as a language?

    A programming language is an abstraction of machine instructions that is readable by people.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Mon Oct 14 08:28:57 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Sun, 13 Oct 2024 21:33:56 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled: >Muttley@DastartdlyHQ.org writes:
    ITYF the people who dislike Perl are the ones who actually like the unix
    way of having simple daisychained tools instead of some lump of a language >> that does everything messily.

    Perl is a general-purpose programming language, just like C or Java (or >Python or Javascript or Rust or $whatnot). This means it can be used to >implement anything (with some practical limitation for anything) and not
    that it "does everything".

    I can be , but generally isn't. Its niche tends to be text processing of
    some sort and for that there are better tools IMO. It used to be big in web backend but those days are long gone.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Mon Oct 14 11:05:06 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Mon, 14 Oct 2024 11:38:29 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled:
    The simple but flexible OO system, reliable automatic memory management

    For a certain definition of OO. The requirement to have to use $self-> everywhere to denote object method/var access makes it little better than
    doing OO in C. Then there's the whole 2 stage object creation with the "bless" nonsense. Hacky.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Muttley@DastartdlyHQ.org on Mon Oct 14 11:38:29 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@DastartdlyHQ.org writes:
    On Sun, 13 Oct 2024 21:33:56 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled:
    Muttley@DastartdlyHQ.org writes:
    ITYF the people who dislike Perl are the ones who actually like the unix >>> way of having simple daisychained tools instead of some lump of a language >>> that does everything messily.

    Perl is a general-purpose programming language, just like C or Java (or >>Python or Javascript or Rust or $whatnot). This means it can be used to >>implement anything (with some practical limitation for anything) and not >>that it "does everything".

    I can be , but generally isn't. Its niche tends to be text processing of
    some sort

    It is. That sysadmin-types using it don't use it to create actual
    programs is of no concern for this, because they never do that and this
    use only needs a very small subset of the features of the language. I've
    been using it as system programming language for programs with up to
    21,000 LOC in the main program (and some more thousands in auxiliary
    modules) and it's very well-suited to that.

    The simple but flexible OO system, reliable automatic memory management
    and support for functions/ subroutine as first-class objects make it
    very nice for implementing event-driven, asynchronous "crossbar"
    programs connecting various external entities both running locallly and
    on other computers on the internet to create complex applications from
    them.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Lawrence D'Oliveiro on Mon Oct 14 14:13:11 2024
    XPost: comp.unix.programmer

    On 14.10.2024 03:45, Lawrence D'Oliveiro wrote:
    On Mon, 14 Oct 2024 01:16:11 +0200, Janis Papanagnou wrote:
    On 13.10.2024 23:10, Lawrence D'Oliveiro wrote:
    On Sun, 13 Oct 2024 18:28:32 +0200, Janis Papanagnou wrote:

    You know there's formal definitions for what constitutes languages.

    Not really. For example, some have preferred the term “notation”
    instead of “language”.

    A "notation" is not the same as a [formal (or informal)] "language".

    (Frankly, I don't know where you're coming from ...

    <https://en.wikipedia.org/wiki/Programming_language>:

    A programming language is a system of notation for writing computer
    programs.

    Okay, a "system of notation" (not a "notation") is used here to
    _describe_ it. I'm fine with that formulation. Thanks.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Muttley@DastartdlyHQ.org on Mon Oct 14 14:36:38 2024
    XPost: comp.unix.programmer

    On 14.10.2024 10:23, Muttley@DastartdlyHQ.org wrote:
    On Sun, 13 Oct 2024 18:28:32 +0200
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> boring babbled:
    [ X-post list reduced ]

    On 13.10.2024 18:02, Muttley@DastartdlyHQ.org wrote:
    On Sun, 13 Oct 2024 15:30:03 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    [...]

    No. It translates one computer _language_ to another computer
    _language_. In the usual case, that's from a textual source

    Machine code isn't a language. Fallen at the first hurdle with that
    definition.

    Careful (myself included); watch out for the glazed frost!

    You know there's formal definitions for what constitutes languages.

    At first glance I don't see why machine code wouldn't quality as a
    language (either as some specific "mnemonic" representation, or as
    a sequence of integral numbers or other "code" representations).
    What's the problem, in your opinion, with considering machine code
    as a language?

    A programming language is an abstraction of machine instructions that is readable by people.

    Yes, you can explain "programming language" that way.

    The topic that was cited (Aho, et al.) upthread (and what I spoke
    about) was more generally about [formal] "language", the base also
    of programming languages.

    (In early days of computers they programmed in binary, but that is
    just a side note and unnecessary to support the definition of the
    upthread cited text.)

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to Muttley@DastartdlyHQ.org on Mon Oct 14 13:38:04 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <veiki1$14g6h$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >On Sun, 13 Oct 2024 20:15:45 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    Oh really? Is that why they call it "machine language"? It's
    even in the dictionary with "machine code" as a synonymn: >>https://www.merriam-webster.com/dictionary/machine%20language

    Its not a programming language.

    That's news to those people who have, and sometimes still do,
    write programs in it.

    But that's not important. If we go back and look at what I
    wrote that you were responding to, it was this statement, about
    what a compiler does, and your claim that I was asserting it
    was translating anything to anything, which I was not:

    |No. It translates one computer _language_ to another computer
    |_language_. In the usual case, that's from a textual source

    Note that I said, "computer language", not "programming
    language". Being a human-readable language is not a requirement
    for a computer language.

    Your claim that "machine language" is not a "language" is simply
    not true. Your claim that a "proper" compiler must take the
    shape you are pushing is also not true.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Muttley@DastartdlyHQ.org on Mon Oct 14 14:53:49 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@DastartdlyHQ.org writes:
    On Mon, 14 Oct 2024 13:38:04 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    In article <veiki1$14g6h$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >>>On Sun, 13 Oct 2024 20:15:45 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    Oh really? Is that why they call it "machine language"? It's
    even in the dictionary with "machine code" as a synonymn: >>>>https://www.merriam-webster.com/dictionary/machine%20language

    Its not a programming language.

    That's news to those people who have, and sometimes still do,
    write programs in it.

    Really? So if its a language you'll be able to understand this then:

    0011101011010101010001110101010010110110001110010100101001010100 >0101001010010010100101010111001010100110100111010101010101010101 >0001110100011101010001001010110011100010101001110010100101100010

    I certainly understand this, even four decades later

    94A605440C00010200010400000110

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Mon Oct 14 14:59:22 2024
    XPost: comp.unix.programmer

    On Mon, 14 Oct 2024 14:58:13 GMT
    scott@slp53.sl.home (Scott Lurndal) boring babbled:
    Muttley@DastartdlyHQ.org writes:
    On Sun, 13 Oct 2024 18:28:32 +0200
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> boring babbled:
    [ X-post list reduced ]


    A programming language is an abstraction of machine instructions that is >>readable by people.

    By that definition, PAL-D is a programming language.

    Any assembler is a programming language, by that definition.

    Where did I say it wasn't? Of course assembler is a programming language.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Muttley@DastartdlyHQ.org on Mon Oct 14 14:58:13 2024
    XPost: comp.unix.programmer

    Muttley@DastartdlyHQ.org writes:
    On Sun, 13 Oct 2024 18:28:32 +0200
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> boring babbled:
    [ X-post list reduced ]


    A programming language is an abstraction of machine instructions that is >readable by people.

    By that definition, PAL-D is a programming language.

    Any assembler is a programming language, by that definition.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Mon Oct 14 14:47:58 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Mon, 14 Oct 2024 13:38:04 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    In article <veiki1$14g6h$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >>On Sun, 13 Oct 2024 20:15:45 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    Oh really? Is that why they call it "machine language"? It's
    even in the dictionary with "machine code" as a synonymn: >>>https://www.merriam-webster.com/dictionary/machine%20language

    Its not a programming language.

    That's news to those people who have, and sometimes still do,
    write programs in it.

    Really? So if its a language you'll be able to understand this then:

    0011101011010101010001110101010010110110001110010100101001010100 0101001010010010100101010111001010100110100111010101010101010101 0001110100011101010001001010110011100010101001110010100101100010

    But that's not important. If we go back and look at what I

    Oh right.


    |No. It translates one computer _language_ to another computer
    |_language_. In the usual case, that's from a textual source

    Note that I said, "computer language", not "programming
    language". Being a human-readable language is not a requirement
    for a computer language.

    Oh watch those goalpost moves with pedant set to 11. Presumably you
    think the values of the address lines is a language too.

    Your claim that "machine language" is not a "language" is simply
    not true. Your claim that a "proper" compiler must take the
    shape you are pushing is also not true.

    If you say so.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Muttley@DastartdlyHQ.org on Mon Oct 14 16:04:18 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@DastartdlyHQ.org writes:
    On Mon, 14 Oct 2024 11:38:29 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled:
    The simple but flexible OO system, reliable automatic memory management

    [...]

    Then there's the whole 2 stage object creation with the "bless"
    nonsense. Hacky.

    I was planning to write a longer reply but killed it. You're obviously
    argueing about something you reject for political reasons despite you're
    not really familiar with it and you even 'argue' like a politician. That
    is, you stick peiorative labels on stuff you don't like to emphasize how
    really disagreeable you believe it to be. IMHO, such a method of (pseudo-)discussing anything is completely pointless.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Brown@21:1/5 to Scott Lurndal on Mon Oct 14 17:27:18 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 14/10/2024 16:53, Scott Lurndal wrote:
    Muttley@DastartdlyHQ.org writes:
    On Mon, 14 Oct 2024 13:38:04 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    In article <veiki1$14g6h$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote:
    On Sun, 13 Oct 2024 20:15:45 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    Oh really? Is that why they call it "machine language"? It's
    even in the dictionary with "machine code" as a synonymn:
    https://www.merriam-webster.com/dictionary/machine%20language

    Its not a programming language.

    That's news to those people who have, and sometimes still do,
    write programs in it.

    Really? So if its a language you'll be able to understand this then:

    0011101011010101010001110101010010110110001110010100101001010100
    0101001010010010100101010111001010100110100111010101010101010101
    0001110100011101010001001010110011100010101001110010100101100010

    I certainly understand this, even four decades later

    94A605440C00010200010400000110


    In my early days of assembly programming on my ZX Spectrum, I would hand-assembly to machine code, and I knew at least a few of the codes by
    heart. (01 is "ld bc, #xxxx", 18 is "jr", c9 is "ret", etc.) So while
    I rarely wrote machine code directly, it is certainly still a
    programming language - it's a language you can write programs in.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Ram@21:1/5 to Dan Cross on Mon Oct 14 15:19:03 2024
    cross@spitfire.i.gajendra.net (Dan Cross) wrote or quoted:
    Your claim that "machine language" is not a "language" is simply
    not true.

    Machine language is a language.

    (It might not be a /formal/ language when the specification
    is not definite. For example, when one says, "6502", are the
    "undocumented" opcodes a part of this language or not? So, for
    a formal language, you have to make sure that it's definite.)

    Not related to unix. So, not,

    Newsgroups: comp.unix.shell,comp.unix.programmer,comp.lang.misc

    , but,

    Newsgroups: comp.lang.misc

    .

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Mon Oct 14 15:39:19 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Mon, 14 Oct 2024 16:04:18 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled: >Muttley@DastartdlyHQ.org writes:
    On Mon, 14 Oct 2024 11:38:29 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled:
    The simple but flexible OO system, reliable automatic memory management

    [...]

    Then there's the whole 2 stage object creation with the "bless"
    nonsense. Hacky.

    I was planning to write a longer reply but killed it. You're obviously >argueing about something you reject for political reasons despite you're
    not really familiar with it and you even 'argue' like a politician. That
    is, you stick peiorative labels on stuff you don't like to emphasize how >really disagreeable you believe it to be. IMHO, such a method of >(pseudo-)discussing anything is completely pointless.

    Umm, whatever. I was just saying why I didn't like Perl but if you want to
    read some grand motive into it knock yourself out.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Muttley@DastartdlyHQ.org on Mon Oct 14 17:43:59 2024
    XPost: comp.unix.programmer

    [ X-post list reduced ]

    On 14.10.2024 16:47, Muttley@DastartdlyHQ.org wrote:
    On Mon, 14 Oct 2024 13:38:04 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    In article <veiki1$14g6h$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote:
    On Sun, 13 Oct 2024 20:15:45 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    Oh really? Is that why they call it "machine language"? It's
    even in the dictionary with "machine code" as a synonymn:
    https://www.merriam-webster.com/dictionary/machine%20language

    Its not a programming language.

    That's news to those people who have, and sometimes still do,
    write programs in it.

    Really? So if its a language you'll be able to understand this then:

    0011101011010101010001110101010010110110001110010100101001010100 0101001010010010100101010111001010100110100111010101010101010101 0001110100011101010001001010110011100010101001110010100101100010

    It's substantially (for me) not different from, e.g., Chinese text.

    You need context information to understand it. But understanding a
    language is not a condition for defining and handling a language.
    If there's context information then people can associate semantical
    meaning with it (and understand it).

    To illustrate (just playing)...

    if then else then if or if and else end if

    Are you able to understand that? On what abstraction level do you
    understand it? Does it make [semantical] sense to you?
    (Note: Using the proper translator and interpreter this is quite
    dangerous code. For the puzzler; it's a coded shell fork-bomb.)

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to David Brown on Mon Oct 14 17:55:14 2024
    XPost: comp.unix.programmer

    [ X-post list reduced ]

    On 14.10.2024 17:27, David Brown wrote:
    On 14/10/2024 16:53, Scott Lurndal wrote:
    Muttley@DastartdlyHQ.org writes:

    Really? So if its a language you'll be able to understand this then:

    0011101011010101010001110101010010110110001110010100101001010100
    0101001010010010100101010111001010100110100111010101010101010101
    0001110100011101010001001010110011100010101001110010100101100010

    I certainly understand this, even four decades later

    94A605440C00010200010400000110

    In my early days of assembly programming on my ZX Spectrum, I would hand-assembly to machine code, and I knew at least a few of the codes by heart. (01 is "ld bc, #xxxx", 18 is "jr", c9 is "ret", etc.) So while
    I rarely wrote machine code directly, it is certainly still a
    programming language - it's a language you can write programs in.

    Your post triggered some own memories...

    I have an old pocket calculator (Sharp PC-1401) programmable in
    BASIC. When I found out that it supports undocumented features to
    read machine code numbers from memory and write code numbers into
    memory (and call them as subprograms) I coded programs in decimal
    byte sequences. (A pain, for sure, but in earlier computer eras
    even a normal process.)

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to Muttley@DastartdlyHQ.org on Mon Oct 14 16:51:06 2024
    In article <vejauu$186ln$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote: >On Mon, 14 Oct 2024 13:38:04 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    [snip]
    |No. It translates one computer _language_ to another computer >>|_language_. In the usual case, that's from a textual source

    Note that I said, "computer language", not "programming
    language". Being a human-readable language is not a requirement
    for a computer language.

    Oh watch those goalpost moves with pedant set to 11. Presumably you
    think the values of the address lines is a language too.

    Dunno what to tell you: pretty sure you're the one who
    asserted I meant something something I didn't write.

    Your claim that "machine language" is not a "language" is simply
    not true. Your claim that a "proper" compiler must take the
    shape you are pushing is also not true.

    If you say so.

    Not just me.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bart@21:1/5 to Scott Lurndal on Mon Oct 14 17:23:11 2024
    XPost: comp.unix.programmer

    On 14/10/2024 15:58, Scott Lurndal wrote:
    Muttley@DastartdlyHQ.org writes:
    On Sun, 13 Oct 2024 18:28:32 +0200
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> boring babbled:
    [ X-post list reduced ]


    A programming language is an abstraction of machine instructions that is
    readable by people.

    By that definition, PAL-D is a programming language.

    (I've no idea what PAL-D is in this context.)

    Any assembler is a programming language, by that definition.


    You mean 'assembly'? An assembler (in the sofware world) is usually a
    program that translates textual assembly code.

    'Compiler' isn't a programming language (although no doubt someone here
    will dredge up some obscure language with exactly that name just to
    prove me wrong).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Muttley on Mon Oct 14 21:04:44 2024
    XPost: comp.unix.programmer

    On Mon, 14 Oct 2024 08:23:20 -0000 (UTC), Muttley wrote:

    A programming language is an abstraction of machine instructions that is readable by people.

    Like converting circuit voltages to human-readable “1” and “0” symbols, perhaps?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Brown@21:1/5 to Bart on Tue Oct 15 13:27:09 2024
    XPost: comp.unix.programmer

    On 14/10/2024 18:23, Bart wrote:
    On 14/10/2024 15:58, Scott Lurndal wrote:
    Muttley@DastartdlyHQ.org writes:
    On Sun, 13 Oct 2024 18:28:32 +0200
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> boring babbled:
    [ X-post list reduced ]


    A programming language is an abstraction of machine instructions that is >>> readable by people.

    By that definition, PAL-D is a programming language.

    (I've no idea what PAL-D is in this context.)

    Any assembler is a programming language, by that definition.


    You mean 'assembly'? An assembler (in the sofware world) is usually a
    program that translates textual assembly code.


    I took "an assembler" to mean "an assembler language", which is a common alternative way to write "an assembly language". And IMHO, any assembly language /is/ a programming language.

    'Compiler' isn't a programming language (although no doubt someone here
    will dredge up some obscure language with exactly that name just to
    prove me wrong).


    I tried, just to please you, but I couldn't find such a language :-)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to bc@freeuk.com on Tue Oct 15 15:18:21 2024
    XPost: comp.unix.programmer

    [Followup-To: set to comp.lang.misc, -comp.unix.programmer]

    In article <vejghe$192vs$1@dont-email.me>, Bart <bc@freeuk.com> wrote:
    On 14/10/2024 15:58, Scott Lurndal wrote:
    Muttley@DastartdlyHQ.org writes:
    On Sun, 13 Oct 2024 18:28:32 +0200
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> boring babbled:
    [ X-post list reduced ]


    A programming language is an abstraction of machine instructions that is >>> readable by people.

    By that definition, PAL-D is a programming language.

    (I've no idea what PAL-D is in this context.)

    PAL-D is an assembler for the PDP-8 computer. I don't know why
    one wouldn't consider it's input a programming language. https://bitsavers.org/pdf/dec/pdp8/handbooks/programmingLanguages_May70.pdf

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sebastian@21:1/5 to Muttley@dastartdlyhq.org on Mon Nov 11 07:31:13 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In comp.unix.programmer Muttley@dastartdlyhq.org wrote:
    On Wed, 09 Oct 2024 22:25:05 +0100
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled:
    Bozo User <anthk@disroot.org> writes:
    On 2024-04-07, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Sun, 07 Apr 2024 00:01:43 +0000, Javier wrote:

    The downside is the loss of performance because of disk access for
    trivial things like 'nfiles=$(ls | wc -l)'.

    Well, you could save one process creation by writing
    ???nfiles=$(echo * | wc -l)??? instead. But that would still not be >>strictly
    correct.

    I suspect disk access times where
    one of the reasons for the development of perl in the early 90s.

    Shells were somewhat less powerful in those days. I would describe the >>>> genesis of Perl as ???awk on steroids???. Its big party trick was regular >>>> expressions. And I guess combining that with more sophisticated data-
    structuring capabilities.

    Perl is more awk+sed+sh in a single language. Basically the killer
    of the Unix philophy in late 90's/early 00's, and for the good.

    Perl is a high-level programming language with a rich syntax??, with >>support for deterministic automatic memory management, functions as >>first-class objects and message-based OO. It's also a virtual machine
    for executing threaded code and a(n optimizing) compiler for translating >>Perl code into the corresponding threaded code.

    Its syntax is also a horrific mess. Larry took the worst parts of C and shell syntax and mashed them together. Its no surprise Perl has been ditched in favour of Python just about everywhere for new scripting projects. And while I hate Pythons meangingful whitespace nonsense, I'd use it in preference
    to Perl any day.

    I think you've identified the one language that Python is better than.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Mon Nov 11 10:06:40 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Mon, 11 Nov 2024 07:31:13 -0000 (UTC)
    Sebastian <sebastian@here.com.invalid> boring babbled:
    In comp.unix.programmer Muttley@dastartdlyhq.org wrote:
    syntax and mashed them together. Its no surprise Perl has been ditched in
    favour of Python just about everywhere for new scripting projects. And while >> I hate Pythons meangingful whitespace nonsense, I'd use it in preference
    to Perl any day.

    I think you've identified the one language that Python is better than.

    Yes, Python does have a lot of cons as a language. But its syntax lets
    newbies get up to speed quickly and there are a lot of libraries. However its dog slow and inefficient and I'm amazed its used as a key language for AI development - not traditionally a newbie coder area - when in that application speed really is essential. Yes it generally calls libraries written in C/C++ but then why not just write the higher level code in C++ too?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Wolfgang Agnes@21:1/5 to Muttley@DastartdlyHQ.org on Mon Nov 11 08:28:51 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@DastartdlyHQ.org writes:

    On Mon, 11 Nov 2024 07:31:13 -0000 (UTC)
    Sebastian <sebastian@here.com.invalid> boring babbled:
    In comp.unix.programmer Muttley@dastartdlyhq.org wrote:
    syntax and mashed them together. Its no surprise Perl has been ditched in >>> favour of Python just about everywhere for new scripting projects. And while
    I hate Pythons meangingful whitespace nonsense, I'd use it in preference >>> to Perl any day.

    I think you've identified the one language that Python is better than.

    Yes, Python does have a lot of cons as a language. But its syntax lets newbies get up to speed quickly and there are a lot of libraries. However its dog slow and inefficient and I'm amazed its used as a key language for AI development - not traditionally a newbie coder area - when in that application
    speed really is essential. Yes it generally calls libraries written in C/C++ but then why not just write the higher level code in C++ too?

    You'd have to give up the REPL, for instance.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to All on Mon Nov 11 16:21:26 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Mon, 11 Nov 2024 08:28:51 -0300
    Wolfgang Agnes <wagnes@jemoni.to> gabbled:
    Muttley@DastartdlyHQ.org writes:

    On Mon, 11 Nov 2024 07:31:13 -0000 (UTC)
    Sebastian <sebastian@here.com.invalid> boring babbled:
    In comp.unix.programmer Muttley@dastartdlyhq.org wrote:
    syntax and mashed them together. Its no surprise Perl has been ditched in >>>> favour of Python just about everywhere for new scripting projects. And >while
    I hate Pythons meangingful whitespace nonsense, I'd use it in preference >>>> to Perl any day.

    I think you've identified the one language that Python is better than.

    Yes, Python does have a lot of cons as a language. But its syntax lets
    newbies get up to speed quickly and there are a lot of libraries. However its

    dog slow and inefficient and I'm amazed its used as a key language for AI
    development - not traditionally a newbie coder area - when in that >application
    speed really is essential. Yes it generally calls libraries written in C/C++ >> but then why not just write the higher level code in C++ too?

    You'd have to give up the REPL, for instance.

    Not that big a deal especially if the model takes hours or days to train anyway.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Muttley on Mon Nov 11 20:55:15 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Mon, 11 Nov 2024 10:06:40 -0000 (UTC), Muttley wrote:

    Yes it generally calls libraries written in C/C++
    but then why not just write the higher level code in C++ too?

    Because it’s easier to do higher-level stuff in Python.

    Example: <https://github.com/HamPUG/meetings/tree/master/2018/2018-08-13/ldo-creating-api-bindings-using-ctypes>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Sebastian on Mon Nov 11 21:24:14 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Mon, 11 Nov 2024 07:31:13 -0000 (UTC), Sebastian wrote:

    In comp.unix.programmer Muttley@dastartdlyhq.org wrote:

    [Perl’s] syntax is also a horrific mess. Larry took the worst parts of
    C and shell syntax and mashed them together.

    I think you've identified the one language that Python is better than.

    In terms of the modern era of high-level programming, Perl was the
    breakthrough language. Before Perl, BASIC was considered to be an example
    of a language with “good” string handling. After Perl, BASIC looked old
    and clunky indeed.

    Perl was the language that made regular expressions sexy. Because it made
    them easy to use.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Muttley@DastartdlyHQ.org on Tue Nov 12 10:14:20 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 11.11.2024 11:06, Muttley@DastartdlyHQ.org wrote:

    Yes, Python does have a lot of cons as a language. But its syntax lets newbies get up to speed quickly

    and to abruptly get stopped again due to obscure, misleading, or
    (at best), non-informative error messages

    and there are a lot of libraries. However its
    dog slow and inefficient and I'm amazed its used as a key language for AI

    (and not only there; it's ubiquitous, it seems)

    development - not traditionally a newbie coder area - when in that application
    speed really is essential. Yes it generally calls libraries written in C/C++ but then why not just write the higher level code in C++ too?

    Because of its simpler syntax and less syntactical ballast compared
    to C++?

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Lawrence D'Oliveiro on Tue Nov 12 10:23:38 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 11.11.2024 22:24, Lawrence D'Oliveiro wrote:
    On Mon, 11 Nov 2024 07:31:13 -0000 (UTC), Sebastian wrote:

    In comp.unix.programmer Muttley@dastartdlyhq.org wrote:

    [Perl’s] syntax is also a horrific mess. Larry took the worst parts of >>> C and shell syntax and mashed them together.

    I think you've identified the one language that Python is better than.

    In terms of the modern era of high-level programming, Perl was the breakthrough language. Before Perl, BASIC was considered to be an example
    of a language with “good” string handling. After Perl, BASIC looked old and clunky indeed.

    I'm not, erm.., a fan of Perl or anything, but comparing it to BASIC
    is way off; Perl is not *that* bad. - N.B.: Of course no one can say
    what "BASIC" actually is given the many variants and dialects. - I'm
    sure you must have some modern variant in mind that might have little
    to do with the various former BASIC dialects (that I happened to use
    in the 1970's; e.g., Wang, Olivetti, Commodore, and a mainframe that
    I don't recall).

    It's more interesting what Perl added compared to BRE/ERE, what Unix
    provided since its beginning (and long before Perl).


    Perl was the language that made regular expressions sexy. Because it made them easy to use.

    For those of us who used regexps in Unix from the beginning it's not
    that shiny as you want us to buy it; Unix was supporting Chomsky-3
    Regular Expressions with a syntax that is still used in contemporary
    languages. Perl supports some nice syntactic shortcuts, but also
    patterns that exceed Chomsky-3's; too bad if one doesn't know these
    differences and any complexity degradation that may be bought with it.

    More interesting to me is the fascinating fact that on some non-Unix
    platforms it took decades before regexps got (slooooowly) introduced
    (even in its simplest form).

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Tue Nov 12 09:21:51 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Tue, 12 Nov 2024 10:14:20 +0100
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> boring babbled:
    On 11.11.2024 11:06, Muttley@DastartdlyHQ.org wrote:
    and there are a lot of libraries. However its
    dog slow and inefficient and I'm amazed its used as a key language for AI

    (and not only there; it's ubiquitous, it seems)

    Yes, certainly seems to be the case now.

    development - not traditionally a newbie coder area - when in that >application
    speed really is essential. Yes it generally calls libraries written in C/C++ >> but then why not just write the higher level code in C++ too?

    Because of its simpler syntax and less syntactical ballast compared
    to C++?

    When you're dealing with something as complicated and frankly ineffable as
    an AI model I doubt syntactic quirks of the programming language matter that much in comparison. Surely you'd want the fastest implementation possible and in this case it would be C++.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Muttley@DastartdlyHQ.org on Tue Nov 12 10:31:58 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 12.11.2024 10:21, Muttley@DastartdlyHQ.org wrote:
    On Tue, 12 Nov 2024 10:14:20 +0100
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> boring babbled:
    On 11.11.2024 11:06, Muttley@DastartdlyHQ.org wrote:
    [ Q: why some prefer Python over C++ ]

    Because of its simpler syntax and less syntactical ballast compared
    to C++?

    When you're dealing with something as complicated and frankly ineffable as
    an AI model I doubt syntactic quirks of the programming language matter that much in comparison.

    Oh, I would look at it differently; in whatever application domain I
    program I want a syntactic clear and well defined language.

    Surely you'd want the fastest implementation possible and
    in this case it would be C++.

    Speed is one factor (to me), and expressiveness or "modeling power"
    (OO) is another one. I also appreciate consistently defined languages
    and quality of error catching and usefulness of diagnostic messages.
    (There's some more factors, but...)

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Tue Nov 12 09:53:59 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Tue, 12 Nov 2024 10:31:58 +0100
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> boring babbled:
    On 12.11.2024 10:21, Muttley@DastartdlyHQ.org wrote:
    On Tue, 12 Nov 2024 10:14:20 +0100
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> boring babbled:
    On 11.11.2024 11:06, Muttley@DastartdlyHQ.org wrote:
    [ Q: why some prefer Python over C++ ]

    Because of its simpler syntax and less syntactical ballast compared
    to C++?

    When you're dealing with something as complicated and frankly ineffable as >> an AI model I doubt syntactic quirks of the programming language matter that >> much in comparison.

    Oh, I would look at it differently; in whatever application domain I
    program I want a syntactic clear and well defined language.

    In which case I'd go with a statically typed language like C++ every time
    ahead of a dynamic one like python.

    Surely you'd want the fastest implementation possible and
    in this case it would be C++.

    Speed is one factor (to me), and expressiveness or "modeling power"
    (OO) is another one. I also appreciate consistently defined languages
    and quality of error catching and usefulness of diagnostic messages.
    (There's some more factors, but...)

    C++ is undeniably powerful, but I think the majority would agree now that
    its syntax has become an unwieldy mess.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Muttley@DastartdlyHQ.org on Tue Nov 12 15:05:00 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 12.11.2024 10:53, Muttley@DastartdlyHQ.org wrote:

    In which case I'd go with a statically typed language like C++ every time ahead of a dynamic one like python.

    Definitely!

    I'm using untyped languages (like Awk) for scripting, though, but
    not for code of considerable scale.

    Incidentally, on of my children recently spoke about their setups;
    they use Fortran with old libraries (hydrodynamic earth processes),
    have the higher level tasks implemented in C++, and they do the
    "job control" of the simulation tasks with Python. - A multi-tier
    architecture. - That sounds not unreasonable to me. (But they had
    built their system based on existing software, so it might have
    been a different decision if they'd have built it from scratch.)


    C++ is undeniably powerful, but I think the majority would agree now that
    its syntax has become an unwieldy mess.

    Yes. And recent standards made it yet worse - When I saw it the
    first time I couldn't believe that this would be possible. ;-)

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Tue Nov 12 15:09:23 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Tue, 12 Nov 2024 15:05:00 +0100
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> boring babbled:
    On 12.11.2024 10:53, Muttley@DastartdlyHQ.org wrote:
    C++ is undeniably powerful, but I think the majority would agree now that
    its syntax has become an unwieldy mess.

    Yes. And recent standards made it yet worse - When I saw it the
    first time I couldn't believe that this would be possible. ;-)

    Unfortunately these days the C++ steering committee (or whatever its called) simply seem to be using the language to justify their positions and keep chucking in "features" that no one asked for or care about, with the end
    result of the language becoming a huge mess that no single person could
    ever learn (or at least remember if they tried).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bart@21:1/5 to Janis Papanagnou on Tue Nov 12 14:50:26 2024
    On 12/11/2024 14:05, Janis Papanagnou wrote:
    On 12.11.2024 10:53, Muttley@DastartdlyHQ.org wrote:

    In which case I'd go with a statically typed language like C++ every time
    ahead of a dynamic one like python.

    Definitely!

    I'm using untyped languages (like Awk) for scripting, though, but
    not for code of considerable scale.

    Incidentally, on of my children recently spoke about their setups;
    they use Fortran with old libraries (hydrodynamic earth processes),
    have the higher level tasks implemented in C++, and they do the
    "job control" of the simulation tasks with Python. - A multi-tier architecture. - That sounds not unreasonable to me. (But they had
    built their system based on existing software, so it might have
    been a different decision if they'd have built it from scratch.)


    My last major app (now over 20 years ago), had such a 2-language solution.

    It was a GUI-based low-end 2D/3D CAD app, written in my lower level
    systems language.

    But the app also had an embedded scripting language, which had access to
    the app's environment and users' data.

    That was partly so that users (both OEMs and end-users) could write
    their own scripts. To this end it was moderately successful as OEMs
    could write their own add-on applications (for example, to help design
    lighting rigs).

    But I also used it exclusively for the GUI side of the application:
    menus, dialogs, cursor control, layouts, the simpler file conversions
    (eg. export my data models to 3DS format) while the native code parts
    dealt with the critical parts: the 3D maths, managing the 3D models the
    display drivers, etc.

    The whole thing was perhaps 150-200Kloc (not including OEM or user
    programs), which was about half static/compiled code and half dynamic/interpreted.

    (One of the original motivations, when it had to run on constrained
    systems, was to allow a lot of the code to exist as standalone scripts,
    which resided on floppy disks, and which ere only loaded as needed.)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Wolfgang Agnes@21:1/5 to Janis Papanagnou on Tue Nov 12 13:50:58 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    [...]

    Perl was the language that made regular expressions sexy. Because it made
    them easy to use.

    For those of us who used regexps in Unix from the beginning it's not
    that shiny as you want us to buy it; Unix was supporting Chomsky-3
    Regular Expressions with a syntax that is still used in contemporary languages. Perl supports some nice syntactic shortcuts, but also
    patterns that exceed Chomsky-3's; too bad if one doesn't know these differences and any complexity degradation that may be bought with it.

    By Chomsky-3 you mean a grammar of type 3 in the Chomsky hierarchy? And
    that would be ``regular'' language, recognizable by a finite-state
    automaton? If not, could you elaborate on the terminology?

    More interesting to me is the fascinating fact that on some non-Unix platforms it took decades before regexps got (slooooowly) introduced
    (even in its simplest form).

    Such as which platform?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Wolfgang Agnes@21:1/5 to Muttley@DastartdlyHQ.org on Tue Nov 12 13:47:15 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@DastartdlyHQ.org writes:

    On Tue, 12 Nov 2024 10:14:20 +0100
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> boring babbled:

    [...]

    Because of its simpler syntax and less syntactical ballast compared
    to C++?

    When you're dealing with something as complicated and frankly ineffable as
    an AI model I doubt syntactic quirks of the programming language matter that much in comparison. Surely you'd want the fastest implementation possible and in this case it would be C++.

    I really wouldn't be so sure. :)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Bart on Tue Nov 12 20:35:30 2024
    On Tue, 12 Nov 2024 14:50:26 +0000, Bart wrote:

    But the app also had an embedded scripting language, which had access to
    the app's environment and users' data.

    Did you invent your own scripting language? Nowadays you would use
    something ready-made, like Lua, Guile or even Python.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Janis Papanagnou on Tue Nov 12 20:29:02 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Tue, 12 Nov 2024 10:23:38 +0100, Janis Papanagnou wrote:

    On 11.11.2024 22:24, Lawrence D'Oliveiro wrote:

    Perl was the language that made regular expressions sexy. Because it
    made them easy to use.

    ... Unix was supporting Chomsky-3
    Regular Expressions with a syntax that is still used in contemporary languages.

    Not in anything resembling a general-purpose high-level language. That’s
    what Perl pioneered.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bart@21:1/5 to Lawrence D'Oliveiro on Tue Nov 12 21:48:39 2024
    On 12/11/2024 20:35, Lawrence D'Oliveiro wrote:
    On Tue, 12 Nov 2024 14:50:26 +0000, Bart wrote:

    But the app also had an embedded scripting language, which had access to
    the app's environment and users' data.

    Did you invent your own scripting language? Nowadays you would use
    something ready-made, like Lua, Guile or even Python.

    At that (late 80s) I had to invent pretty much everything.

    I still do, language-wise.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Wolfgang Agnes on Tue Nov 19 06:14:27 2024
    On 12.11.2024 17:50, Wolfgang Agnes wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    [...]

    By Chomsky-3 you mean a grammar of type 3 in the Chomsky hierarchy? And
    that would be ``regular'' language, recognizable by a finite-state
    automaton? If not, could you elaborate on the terminology?

    Yes. I hoped the term was clear enough. If I had used too sloppy
    wording in my ad hoc writing I apologize for the inconvenience.

    My point was about runtime guarantees and complexities (O(N)) of
    Regexp processing, which are also reflected by the FSA model.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Randal L. Schwartz@21:1/5 to All on Tue Nov 19 18:43:48 2024
    XPost: comp.unix.shell, comp.unix.programmer

    "Lawrence" == Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    Lawrence> Perl was the language that made regular expressions
    Lawrence> sexy. Because it made them easy to use.

    I'm often reminded of this as I've been coding very little in Perl these
    days, and a lot more in languages like Dart, where the regex feels like
    a clumsy bolt-on rather than a proper first-class citizen.

    There are times I miss Perl. But not too often any more. :)

    --
    Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/> Perl/Dart/Flutter consulting, Technical writing, Comedy, etc. etc.
    Still trying to think of something clever for the fourth line of this .sig

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Randal L. Schwartz on Wed Nov 20 04:34:31 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Tue, 19 Nov 2024 18:43:48 -0800, Randal L. Schwartz wrote:

    "Lawrence" == Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    Lawrence> Perl was the language that made regular expressions
    Lawrence> sexy. Because it made them easy to use.

    I'm often reminded of this as I've been coding very little in Perl these days, and a lot more in languages like Dart, where the regex feels like
    a clumsy bolt-on rather than a proper first-class citizen.

    Python has regexes as a bolt-on -- a library module, not a core part of
    the language. But I think the way it leverages the core language -- e.g.
    being able to iterate over pattern matches, and collecting information
    about matches in a “Match” object -- keeps it quite useful in a nicely functional way.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Wed Nov 20 08:21:17 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Tue, 19 Nov 2024 18:43:48 -0800
    merlyn@stonehenge.com (Randal L. Schwartz) boring babbled:
    "Lawrence" == Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    Lawrence> Perl was the language that made regular expressions
    Lawrence> sexy. Because it made them easy to use.

    I'm often reminded of this as I've been coding very little in Perl these >days, and a lot more in languages like Dart, where the regex feels like
    a clumsy bolt-on rather than a proper first-class citizen.

    Regex itself is clumsy beyond simple search and replace patterns. A lot of stuff I've seen done in regex would have better done procedurally at the expense of slightly more code but a LOT more readability. Also given its effectively a compact language with its own grammar and syntax IMO it should not be the core part of any language as it can lead to a syntatic mess, which is what often happens with Perl.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Muttley@DastartdlyHQ.org on Wed Nov 20 11:51:11 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 20.11.2024 09:21, Muttley@DastartdlyHQ.org wrote:
    On Tue, 19 Nov 2024 18:43:48 -0800
    merlyn@stonehenge.com (Randal L. Schwartz) boring babbled:

    I'm often reminded of this as I've been coding very little in Perl these
    days, and a lot more in languages like Dart, where the regex feels like
    a clumsy bolt-on rather than a proper first-class citizen.

    Regex itself is clumsy beyond simple search and replace patterns. A lot of stuff I've seen done in regex would have better done procedurally at the expense of slightly more code but a LOT more readability. Also given its effectively a compact language with its own grammar and syntax IMO it should not be the core part of any language as it can lead to a syntatic mess, which is what often happens with Perl.

    I wouldn't look at it that way. I've seen Regexps as part of languages
    usually in well defined syntactical contexts. For example, like strings
    are enclosed in "...", Regexps could be seen within /.../ delimiters.
    GNU Awk (in recent versions) went towards first class "strongly typed"
    Regexps which are then denoted by the @/.../ syntax.

    I'm curious what you mean by Regexps presented in a "procedural" form.
    Can you give some examples?

    Personally I'm fine with the typical lexical meta-symbols in Regexps
    which resembles the FSA and allows a simple transformation forth/back.

    In practice, given that a Regexp conforms to a FSA, any Regexp can be precompiled and used multiple times. The thing I had used in Java - it
    was a library from Apache, IIRC, not the bulky thing that got included
    later - was easily usable; create a Regexp object by a RE expression,
    then operate on that same object. (Since there's still typical Regexp
    syntax involved I suppose that is not what you meant by "procedural"?)

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Wed Nov 20 11:30:44 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Wed, 20 Nov 2024 11:51:11 +0100
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> boring babbled:
    On 20.11.2024 09:21, Muttley@DastartdlyHQ.org wrote:
    On Tue, 19 Nov 2024 18:43:48 -0800
    merlyn@stonehenge.com (Randal L. Schwartz) boring babbled:

    I'm often reminded of this as I've been coding very little in Perl these >>> days, and a lot more in languages like Dart, where the regex feels like
    a clumsy bolt-on rather than a proper first-class citizen.

    Regex itself is clumsy beyond simple search and replace patterns. A lot of >> stuff I've seen done in regex would have better done procedurally at the
    expense of slightly more code but a LOT more readability. Also given its
    effectively a compact language with its own grammar and syntax IMO it should >> not be the core part of any language as it can lead to a syntatic mess, >which
    is what often happens with Perl.

    I wouldn't look at it that way. I've seen Regexps as part of languages >usually in well defined syntactical contexts. For example, like strings
    are enclosed in "...", Regexps could be seen within /.../ delimiters.
    GNU Awk (in recent versions) went towards first class "strongly typed" >Regexps which are then denoted by the @/.../ syntax.

    I'm curious what you mean by Regexps presented in a "procedural" form.
    Can you give some examples?

    Anything that can be done in regex can obviously also be done procedurally.
    At the point regex expression become unwieldy - usually when substitution variables raise their heads - I prefer procedural code as its also often
    easier to debug.

    In practice, given that a Regexp conforms to a FSA, any Regexp can be >precompiled and used multiple times. The thing I had used in Java - it

    Precompiled regex is no more efficient than precompiled anything , its all
    just assembler at the bottom.

    then operate on that same object. (Since there's still typical Regexp
    syntax involved I suppose that is not what you meant by "procedural"?)

    If you don't know the different between declarative syntax like regex and procedural syntax then there's not much point continuing this discussion.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Wed Nov 20 12:27:54 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Wed, 20 Nov 2024 05:46:49 -0600
    Ed Morton <mortonspam@gmail.com> boring babbled:
    On 11/20/2024 2:21 AM, Muttley@DastartdlyHQ.org wrote:
    On Tue, 19 Nov 2024 18:43:48 -0800
    merlyn@stonehenge.com (Randal L. Schwartz) boring babbled:
    "Lawrence" == Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    Lawrence> Perl was the language that made regular expressions
    Lawrence> sexy. Because it made them easy to use.

    I'm often reminded of this as I've been coding very little in Perl these >>> days, and a lot more in languages like Dart, where the regex feels like
    a clumsy bolt-on rather than a proper first-class citizen.

    Regex itself is clumsy beyond simple search and replace patterns. A lot of >> stuff I've seen done in regex would have better done procedurally at the
    expense of slightly more code but a LOT more readability.

    Definitely. The most relevant statement about regexps is this:

    Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.

    Very true!

    Obviously regexps are very useful and commonplace but if you find you
    have to use some online site or other tools to help you write/understand
    one or just generally need more than a couple of minutes to
    write/understand it then it's time to back off and figure out a better
    way to write your code for the sake of whoever has to read it 6 months
    later (and usually for robustness too as it's hard to be sure all rainy
    day cases are handled correctly in a lengthy and/or complicated regexp).

    Edge cases are regex achilles heal, eg an expression that only accounted
    for 1 -> N chars, not 0 -> N, or matches in the middle but not at the ends.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Muttley@DastartdlyHQ.org on Wed Nov 20 12:21:04 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@DastartdlyHQ.org writes:
    merlyn@stonehenge.com (Randal L. Schwartz) boring babbled:
    "Lawrence" == Lawrence D'Oliveiro <ldo@nz.invalid> writes:

    Lawrence> Perl was the language that made regular expressions
    Lawrence> sexy. Because it made them easy to use.

    I'm often reminded of this as I've been coding very little in Perl these >>days, and a lot more in languages like Dart, where the regex feels like
    a clumsy bolt-on rather than a proper first-class citizen.

    Regex itself is clumsy beyond simple search and replace patterns. A lot of stuff I've seen done in regex would have better done procedurally at the expense of slightly more code but a LOT more readability. Also given its effectively a compact language with its own grammar and syntax IMO it should not be the core part of any language as it can lead to a syntatic mess, which is what often happens with Perl.

    A mess is something which often happens when people who can't organize
    their thoughts just trudge on nevertheless. They're perfectly capable of accomplishing that in any programming language.

    A real problem with regexes in Perl is that they're pretty slow for simple
    use cases (like lexical analysis) and thus, not suitable for volume data processing outside of throwaway code¹.

    ¹ I used to use a JSON parser written in OO-Perl which made extensive
    use of regexes for that. I've recently replaced that with a C/XS version
    which - while slightly larger (617 vs 410 lines of text) - is over a
    hundred times faster and conceptually simpler at the same time.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Muttley@DastartdlyHQ.org on Wed Nov 20 16:38:24 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 20.11.2024 12:30, Muttley@DastartdlyHQ.org wrote:
    On Wed, 20 Nov 2024 11:51:11 +0100
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> boring babbled:
    On 20.11.2024 09:21, Muttley@DastartdlyHQ.org wrote:
    On Tue, 19 Nov 2024 18:43:48 -0800
    merlyn@stonehenge.com (Randal L. Schwartz) boring babbled:

    I'm often reminded of this as I've been coding very little in Perl these >>>> days, and a lot more in languages like Dart, where the regex feels like >>>> a clumsy bolt-on rather than a proper first-class citizen.

    Regex itself is clumsy beyond simple search and replace patterns. A lot of >>> stuff I've seen done in regex would have better done procedurally at the >>> expense of slightly more code but a LOT more readability. Also given its >>> effectively a compact language with its own grammar and syntax IMO it should
    not be the core part of any language as it can lead to a syntatic mess,
    which
    is what often happens with Perl.

    I wouldn't look at it that way. I've seen Regexps as part of languages
    usually in well defined syntactical contexts. For example, like strings
    are enclosed in "...", Regexps could be seen within /.../ delimiters.
    GNU Awk (in recent versions) went towards first class "strongly typed"
    Regexps which are then denoted by the @/.../ syntax.

    I'm curious what you mean by Regexps presented in a "procedural" form.
    Can you give some examples?

    Anything that can be done in regex can obviously also be done procedurally. At the point regex expression become unwieldy - usually when substitution variables raise their heads - I prefer procedural code as its also often easier to debug.

    You haven't even tried to honestly answer my (serious) question.
    With your statement above and your hostility below, it rather seems
    you have no clue of what I am talking about.


    In practice, given that a Regexp conforms to a FSA, any Regexp can be
    precompiled and used multiple times. The thing I had used in Java - it

    Precompiled regex is no more efficient than precompiled anything , its all just assembler at the bottom.

    The Regexps are a way to specify the words of a regular language;
    for pattern matching the expression gets interpreted or compiled; you
    specify it, e.g., using strings of characters and meta-characters.
    If you have a programming language where that string gets repeatedly interpreted then it's slower than a precompiled Regexp expression.

    I give you examples...

    (1) DES encryption function

    (1a) ciphertext = des_encode (key, plaintext)

    (1b) cipher = des (key)
    ciphertext = cipher.encode (plaintext)

    In case (1) you can either call the des encription (decription) for
    any (key, plaintext)-pair in a procedural function as in (1a), or
    you can create the key-specific encryption once and encode various
    texts with the same cipher object as in (1b).

    (2) regexp matching

    (2a) location = regexp (pattern, string)

    (2b) fsm = rexexp (pattern)
    location = fsm.match (string)

    In case (2) you can either do the match in a string with a pattern
    in a procedural form as in (2a) or you can create the FSM for the
    given Regexp just once and apply it on various strings as in (2b).

    That's what I was talking about.

    Only if key (in (1)) or pattern (in (2)) are static or "constant"
    that compilation could (but only theoretically) be done in advance
    and optimizing system may (or may not) precompile it (both) to
    [similar] assembler code. How should that work with regexps or DES?
    The optimizing system would need knowledge how to use the library
    code (DES, Regexps, ...) to create binary structures based on the
    algorithms (key-initialization in DES, FSM-generation in Regexps).
    This is [statically] not done.

    Otherwise - i.e. the normal, expected case - there's an efficiency
    difference to observe between the respective cases of (a) and (b).


    then operate on that same object. (Since there's still typical Regexp
    syntax involved I suppose that is not what you meant by "procedural"?)

    If you don't know the different between declarative syntax like regex and procedural syntax then there's not much point continuing this discussion.

    Why do you think so, and why are you saying that? - That wasn't and
    still isn't the point. - You said upthread

    "A lot of stuff I've seen done in regex would have better done
    procedurally at the expense of slightly more code but a LOT more
    readability."

    and I asked

    "I'm curious what you mean by Regexps presented in a "procedural"
    form.
    Can you give some examples?"

    What you wanted to say wasn't clear to me, since you were complaining
    about the _Regexp syntax_. So it couldn't be meant to just write
    regexp (pattern, string) instead of pattern ~ string
    but to somehow(!) transform "pattern", say, like /[0-9]+(ABC)?x*foo/,
    to something syntactically "better".
    I was interested in that "somehow" (that I emphasized), and in an
    example how that would look like in your opinion.
    If you're unable to answer that simple question then just take that
    simple regexp /[0-9]+(ABC)?x*foo/ example and show us your preferred
    procedural variant.

    But my expectation is that you cannot provide any reasonable example
    anyway.

    Personally I think that writing bulky procedural stuff for something
    like [0-9]+ can only be much worse, and that further abbreviations
    like \d+ are the better direction to go if targeting a good interface.
    YMMV.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Ed Morton on Wed Nov 20 16:53:38 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 20.11.2024 12:46, Ed Morton wrote:

    Definitely. The most relevant statement about regexps is this:

    Some people, when confronted with a problem, think "I know, I'll use
    regular expressions." Now they have two problems.

    (Worth a scribbling on a WC wall.)


    Obviously regexps are very useful and commonplace but if you find you
    have to use some online site or other tools to help you write/understand
    one or just generally need more than a couple of minutes to
    write/understand it then it's time to back off and figure out a better
    way to write your code for the sake of whoever has to read it 6 months
    later (and usually for robustness too as it's hard to be sure all rainy
    day cases are handled correctly in a lengthy and/or complicated regexp).

    Regexps are nothing for newbies.

    The inherent fine thing with Regexps is that you can incrementally
    compose them[*].[**]

    It seems you haven't found a sensible way to work with them?
    (And I'm really astonished about that since I know you worked with
    Regexps for years if not decades.)

    In those cases where Regexps *are* the tool for a specific task -
    I don't expect you to use them where they are inappropriate?! -
    what would be the better solution[***] then?

    Janis

    [*] Like the corresponding FSMs.

    [**] And you can also decompose them if they are merged in a huge
    expression, too large for you to grasp it. (BTW, I'm doing such
    decompositions also with other expressions in program code that
    are too bulky.)

    [***] Can you answer the question that another poster failed to do?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Wed Nov 20 16:38:15 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Wed, 20 Nov 2024 16:38:24 +0100
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> boring babbled:
    On 20.11.2024 12:30, Muttley@DastartdlyHQ.org wrote:
    Anything that can be done in regex can obviously also be done procedurally. >> At the point regex expression become unwieldy - usually when substitution
    variables raise their heads - I prefer procedural code as its also often
    easier to debug.

    You haven't even tried to honestly answer my (serious) question.

    You mean you can't figure out how to do something like string search and replace
    procedurally? I'm not going to show you, ask a kid who knows Python or Basic.

    With your statement above and your hostility below, it rather seems

    If you think my reply was hostile then I suggest you go find a safe space
    and cuddle your teddy bear snowflake.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Muttley@DastartdlyHQ.org on Wed Nov 20 17:54:22 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Muttley@DastartdlyHQ.org writes:

    [...]

    With your statement above and your hostility below, it rather seems

    If you think my reply was hostile then I suggest you go find a safe space
    and cuddle your teddy bear snowflake.

    There's surely no reason why anyone could ever think you were inclined
    to substitute verbal aggression for arguments.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Janis Papanagnou on Wed Nov 20 17:50:13 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    [...]

    Personally I think that writing bulky procedural stuff for something
    like [0-9]+ can only be much worse, and that further abbreviations
    like \d+ are the better direction to go if targeting a good interface.
    YMMV.

    Assuming that p is a pointer to the current position in a string, e is a pointer to the end of it (ie, point just past the last byte) and -
    that's important - both are pointers to unsigned quantities, the 'bulky'
    C equivalent of [0-9]+ is

    while (p < e && *p - '0' < 10) ++p;

    That's not too bad. And it's really a hell lot faster than a
    general-purpose automaton programmed to recognize the same pattern
    (which might not matter most of the time, but sometimes, it does).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Muttley on Wed Nov 20 21:43:41 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Wed, 20 Nov 2024 12:27:54 -0000 (UTC), Muttley wrote:

    Edge cases are regex achilles heal, eg an expression that only accounted
    for 1 -> N chars, not 0 -> N, or matches in the middle but not at the
    ends.

    That’s what “^” and “$” are for.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Thu Nov 21 08:13:39 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Wed, 20 Nov 2024 17:54:22 +0000
    Rainer Weikusat <rweikusat@talktalk.net> boring babbled: >Muttley@DastartdlyHQ.org writes:

    [...]

    With your statement above and your hostility below, it rather seems

    If you think my reply was hostile then I suggest you go find a safe space
    and cuddle your teddy bear snowflake.

    There's surely no reason why anyone could ever think you were inclined
    to substitute verbal aggression for arguments.

    I have zero time for anyone who claims hurt feelings or being slighted as
    soon as they're losing an argument.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Thu Nov 21 08:15:41 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Wed, 20 Nov 2024 21:43:41 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> boring babbled:
    On Wed, 20 Nov 2024 12:27:54 -0000 (UTC), Muttley wrote:

    Edge cases are regex achilles heal, eg an expression that only accounted
    for 1 -> N chars, not 0 -> N, or matches in the middle but not at the
    ends.

    That’s what “^” and “$” are for.

    Yes, but people forget about those (literal) edge cases.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Thu Nov 21 08:18:06 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Wed, 20 Nov 2024 10:03:47 -0800
    John Ames <commodorejohn@gmail.com> boring babbled:
    On Wed, 20 Nov 2024 17:54:22 +0000
    Rainer Weikusat <rweikusat@talktalk.net> wrote:

    There's surely no reason why anyone could ever think you were inclined
    to substitute verbal aggression for arguments.

    I mean, it's his whole thing - why would he stop now?

    Whats it like being so wet? Do you get cold easily?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Randal L. Schwartz@21:1/5 to All on Thu Nov 21 05:38:45 2024
    XPost: comp.unix.shell, comp.unix.programmer

    "Rainer" == Rainer Weikusat <rweikusat@talktalk.net> writes:

    Rainer> ¹ I used to use a JSON parser written in OO-Perl which made
    Rainer> extensive use of regexes for that. I've recently replaced that
    Rainer> with a C/XS version which - while slightly larger (617 vs 410
    Rainer> lines of text) - is over a hundred times faster and conceptually Rainer> simpler at the same time.

    I wonder if that was my famous "JSON parser in a single regex" from https://www.perlmonks.org/?node_id=995856, or from one of the two CPAN
    modules that incorporated it.

    --
    Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/> Perl/Dart/Flutter consulting, Technical writing, Comedy, etc. etc.
    Still trying to think of something clever for the fourth line of this .sig

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to commodorejohn@gmail.com on Thu Nov 21 14:13:37 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <20241120100347.00005f10@gmail.com>,
    John Ames <commodorejohn@gmail.com> wrote:
    On Wed, 20 Nov 2024 17:54:22 +0000
    Rainer Weikusat <rweikusat@talktalk.net> wrote:

    There's surely no reason why anyone could ever think you were inclined
    to substitute verbal aggression for arguments.

    I mean, it's his whole thing - why would he stop now?

    This is the guy who didn't know what a compiler is, right?

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to rweikusat@talktalk.net on Thu Nov 21 14:40:18 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <875xohbxre.fsf@doppelsaurus.mobileactivedefense.com>,
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    [...]

    Personally I think that writing bulky procedural stuff for something
    like [0-9]+ can only be much worse, and that further abbreviations
    like \d+ are the better direction to go if targeting a good interface.
    YMMV.

    Assuming that p is a pointer to the current position in a string, e is a >pointer to the end of it (ie, point just past the last byte) and -
    that's important - both are pointers to unsigned quantities, the 'bulky'
    C equivalent of [0-9]+ is

    while (p < e && *p - '0' < 10) ++p;

    That's not too bad. And it's really a hell lot faster than a
    general-purpose automaton programmed to recognize the same pattern
    (which might not matter most of the time, but sometimes, it does).

    It's also not exactly right. `[0-9]+` would match one or more
    characters; this possibly matches 0 (ie, if `p` pointed to
    something that wasn't a digit).

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Dan Cross on Thu Nov 21 15:07:42 2024
    XPost: comp.unix.shell, comp.unix.programmer

    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    [...]

    Personally I think that writing bulky procedural stuff for something
    like [0-9]+ can only be much worse, and that further abbreviations
    like \d+ are the better direction to go if targeting a good interface.
    YMMV.

    Assuming that p is a pointer to the current position in a string, e is a >>pointer to the end of it (ie, point just past the last byte) and -
    that's important - both are pointers to unsigned quantities, the 'bulky'
    C equivalent of [0-9]+ is

    while (p < e && *p - '0' < 10) ++p;

    That's not too bad. And it's really a hell lot faster than a >>general-purpose automaton programmed to recognize the same pattern
    (which might not matter most of the time, but sometimes, it does).

    It's also not exactly right. `[0-9]+` would match one or more
    characters; this possibly matches 0 (ie, if `p` pointed to
    something that wasn't a digit).

    The regex won't match any digits if there aren't any. In this case, the
    match will fail. I didn't include the code for handling that because it
    seemed pretty pointless for the example.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Thu Nov 21 16:06:01 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Thu, 21 Nov 2024 14:13:37 -0000 (UTC)
    cross@spitfire.i.gajendra.net (Dan Cross) boring babbled:
    In article <20241120100347.00005f10@gmail.com>,
    John Ames <commodorejohn@gmail.com> wrote:
    On Wed, 20 Nov 2024 17:54:22 +0000
    Rainer Weikusat <rweikusat@talktalk.net> wrote:

    There's surely no reason why anyone could ever think you were inclined
    to substitute verbal aggression for arguments.

    I mean, it's his whole thing - why would he stop now?

    This is the guy who didn't know what a compiler is, right?

    Wrong. Want another go?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Randal L. Schwartz on Thu Nov 21 17:01:48 2024
    XPost: comp.unix.shell, comp.unix.programmer

    merlyn@stonehenge.com (Randal L. Schwartz) writes:
    "Rainer" == Rainer Weikusat <rweikusat@talktalk.net> writes:
    Rainer> ¹ I used to use a JSON parser written in OO-Perl which made
    Rainer> extensive use of regexes for that. I've recently replaced that Rainer> with a C/XS version which - while slightly larger (617 vs 410
    Rainer> lines of text) - is over a hundred times faster and conceptually Rainer> simpler at the same time.

    I wonder if that was my famous "JSON parser in a single regex" from https://www.perlmonks.org/?node_id=995856, or from one of the two CPAN modules that incorporated it.

    No. One of my use-cases is an interactive shell running in a web browser
    using ActionCable messages to relay data between the browser and the
    shell process on the computer supposed to be accessed in this way. For
    this, I absolutely do need \u escapes. I also need this to be fast. Eg,
    one of the nice properties of JSON is that the type of a value can be determined by looking at the first character of it. This cries for an implementation based on an array of pointers to 'value parsing routines'
    of size 256 and determining the parser routine to use by using the first character as index into this table (which will either yield a pointer to
    the correct parser routine or NULL for a syntax error).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Janis Papanagnou on Thu Nov 21 19:12:03 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-11-20, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
    On 20.11.2024 09:21, Muttley@DastartdlyHQ.org wrote:
    Regex itself is clumsy beyond simple search and replace patterns. A lot of >> stuff I've seen done in regex would have better done procedurally at the
    expense of slightly more code but a LOT more readability. Also given its
    effectively a compact language with its own grammar and syntax IMO it should >> not be the core part of any language as it can lead to a syntatic mess, which
    is what often happens with Perl.

    I wouldn't look at it that way. I've seen Regexps as part of languages usually in well defined syntactical contexts. For example, like strings
    are enclosed in "...", Regexps could be seen within /.../ delimiters.
    GNU Awk (in recent versions) went towards first class "strongly typed" Regexps which are then denoted by the @/.../ syntax.

    These features solve the problem of regexes being stored as character
    strings not being recognized by the language compiler and then having
    to be compiled at run-time.

    They don't solve all the ergonomics of regexes that Muttley is talking
    about.

    I'm curious what you mean by Regexps presented in a "procedural" form.
    Can you give some examples?

    Here is an example: using a regex match to capture a C comment /* ... */
    in Lex compared to just recognizing the start sequence /* and handling
    the discarding of the comment in the action.

    Without non-greedy repetition matching, the regex for a C comment is
    quite obtuse. The procedural handling is straightforward: read
    characters until you see a * immediately followed by a /.

    In the wild, you see regexes being used for all sorts of stupid stuff,
    like checking whether numeric input is in a certain range, rather than converting it to a number and doing an arithmetic check.

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Muttley on Thu Nov 21 22:05:13 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Thu, 21 Nov 2024 08:15:41 -0000 (UTC), Muttley wrote:

    On Wed, 20 Nov 2024 21:43:41 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> boring babbled:

    On Wed, 20 Nov 2024 12:27:54 -0000 (UTC), Muttley wrote:

    Edge cases are regex achilles heal, eg an expression that only
    accounted for 1 -> N chars, not 0 -> N, or matches in the middle but
    not at the ends.

    That’s what “^” and “$” are for.

    Yes, but people forget about those (literal) edge cases.

    Those of us who are accustomed to using regexes do not.

    Another handy one is “\b” for word boundaries.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@DastartdlyHQ.org@21:1/5 to All on Fri Nov 22 10:09:48 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Thu, 21 Nov 2024 19:12:03 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> boring babbled:
    On 2024-11-20, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
    I'm curious what you mean by Regexps presented in a "procedural" form.
    Can you give some examples?

    Here is an example: using a regex match to capture a C comment /* ... */
    in Lex compared to just recognizing the start sequence /* and handling
    the discarding of the comment in the action.

    Without non-greedy repetition matching, the regex for a C comment is
    quite obtuse. The procedural handling is straightforward: read
    characters until you see a * immediately followed by a /.

    Its not that simple I'm afraid since comments can be commented out.

    eg:

    // int i; /*
    int j;
    /*
    int k;
    */
    ++j;

    A C99 and C++ compiler would see "int j" and compile it, a regex would
    simply remove everything from the first /* to */.

    Also the same probably applies to #ifdef's.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Rainer Weikusat on Fri Nov 22 12:14:32 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 20.11.2024 18:50, Rainer Weikusat wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    Personally I think that writing bulky procedural stuff for something
    like [0-9]+ can only be much worse, and that further abbreviations
    like \d+ are the better direction to go if targeting a good interface.
    YMMV.

    Assuming that p is a pointer to the current position in a string, e is a pointer to the end of it (ie, point just past the last byte) and -
    that's important - both are pointers to unsigned quantities, the 'bulky'
    C equivalent of [0-9]+ is

    while (p < e && *p - '0' < 10) ++p;

    That's not too bad. And it's really a hell lot faster than a
    general-purpose automaton programmed to recognize the same pattern
    (which might not matter most of the time, but sometimes, it does).

    Okay, I see where you're coming from (and especially in that simple
    case).

    Personally (and YMMV), even here in this simple case I think that
    using pointers is not better but worse - and anyway isn't [in this
    form] available in most languages; in other cases (and languages)
    such constructs get yet more clumsy, and for my not very complex
    example - /[0-9]+(ABC)?x*foo/ - even a "catastrophe" concerning
    readability, error-proneness, and maintainability.

    If that is what the other poster meant I'm fine with your answer;
    there's no need to even consider abandoning regular expressions
    in favor of explicitly codified parsing.

    Janis

    PS: And thanks for answering on behalf of the other poster whom I
    see in his followups just continuing his very personal style.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Kaz Kylheku on Fri Nov 22 12:17:56 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 21.11.2024 20:12, Kaz Kylheku wrote:
    [...]

    In the wild, you see regexes being used for all sorts of stupid stuff,

    No one can prevent folks using features for stupid things. Yes.

    like checking whether numeric input is in a certain range, rather than converting it to a number and doing an arithmetic check.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Lawrence D'Oliveiro on Fri Nov 22 12:47:16 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 21.11.2024 23:05, Lawrence D'Oliveiro wrote:
    On Thu, 21 Nov 2024 08:15:41 -0000 (UTC), Muttley wrote:
    On Wed, 20 Nov 2024 21:43:41 -0000 (UTC)
    Lawrence D'Oliveiro <ldo@nz.invalid> boring babbled:
    [...]

    That’s what “^” and “$” are for.

    Yes, but people forget about those (literal) edge cases.

    But *only* _literally_ "edge cases". Rather they're simple
    and basics of regexp parsers since their beginning.

    Those of us who are accustomed to using regexes do not.

    It's one of the first things that regexp newbies learn,
    I'd say.


    Another handy one is “\b” for word boundaries.

    I prefer \< and \> (that are quite commonly used) for such
    structural things, also \( and \) for allowing references
    to matched parts. And I prefer the \alpha regexp pattern
    extension forms for things like \d \D \w \W \s \S . (But
    that's not only a matter of taste but also a question of
    what any regexp parser actually supports.)

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Janis Papanagnou on Fri Nov 22 11:56:26 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 20.11.2024 18:50, Rainer Weikusat wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    Personally I think that writing bulky procedural stuff for something
    like [0-9]+ can only be much worse, and that further abbreviations
    like \d+ are the better direction to go if targeting a good interface.
    YMMV.

    Assuming that p is a pointer to the current position in a string, e is a
    pointer to the end of it (ie, point just past the last byte) and -
    that's important - both are pointers to unsigned quantities, the 'bulky'
    C equivalent of [0-9]+ is

    while (p < e && *p - '0' < 10) ++p;

    That's not too bad. And it's really a hell lot faster than a
    general-purpose automaton programmed to recognize the same pattern
    (which might not matter most of the time, but sometimes, it does).

    Okay, I see where you're coming from (and especially in that simple
    case).

    Personally (and YMMV), even here in this simple case I think that
    using pointers is not better but worse - and anyway isn't [in this
    form] available in most languages;

    That's a question of using the proper tool for the job. In C, that's
    pointer and pointer arithmetic because it's the simplest way to express something like this.

    in other cases (and languages)
    such constructs get yet more clumsy, and for my not very complex
    example - /[0-9]+(ABC)?x*foo/ - even a "catastrophe" concerning
    readability, error-proneness, and maintainability.

    Procedural code for matching strings constructed in this way is
    certainly much simpler¹ than the equally procedural code for a
    programmable automaton capable of interpreting regexes. Your statement
    is basically "If we assume that the code interpreting regexes doesn't
    exist, regexes need much less code than something equivalent which does
    exist." Without this assumption, the picture becomes a different one altogether.

    ¹ This doesn't even need a real state machine, just four subroutines
    executed in succession (and two of these can share an implementation as "matching ABC" and "matching foo" are both cases of matching a constant
    string.

    If that is what the other poster meant I'm fine with your answer;
    there's no need to even consider abandoning regular expressions
    in favor of explicitly codified parsing.

    This depends on the specific problem and the constraints applicable to a solution. For the common case, regexes, if easily available, are an
    obvious good solution. But not all cases are common.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to rweikusat@talktalk.net on Fri Nov 22 13:30:34 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <874j40sk01.fsf@doppelsaurus.mobileactivedefense.com>,
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    [...]

    Personally I think that writing bulky procedural stuff for something
    like [0-9]+ can only be much worse, and that further abbreviations
    like \d+ are the better direction to go if targeting a good interface. >>>> YMMV.

    Assuming that p is a pointer to the current position in a string, e is a >>>pointer to the end of it (ie, point just past the last byte) and -
    that's important - both are pointers to unsigned quantities, the 'bulky' >>>C equivalent of [0-9]+ is

    while (p < e && *p - '0' < 10) ++p;

    That's not too bad. And it's really a hell lot faster than a >>>general-purpose automaton programmed to recognize the same pattern
    (which might not matter most of the time, but sometimes, it does).

    It's also not exactly right. `[0-9]+` would match one or more
    characters; this possibly matches 0 (ie, if `p` pointed to
    something that wasn't a digit).

    The regex won't match any digits if there aren't any. In this case, the
    match will fail. I didn't include the code for handling that because it >seemed pretty pointless for the example.

    That's rather the point though, isn't it? The program snippet
    (modulo the promotion to signed int via the "usual arithmetic
    conversions" before the subtraction and comparison giving you
    unexpected values; nothing to do with whether `char` is signed
    or not) is a snippet that advances a pointer while it points to
    a digit, starting at the current pointer position; that is, it
    just increments a pointer over a run of digits.

    But that's not the same as a regex matcher, which has a semantic
    notion of success or failure. I could run your snippet against
    a string such as, say, "ZZZZZZ" and it would "succeed" just as
    it would against an empty string or a string of one or more
    digits. And then there are other matters of context; does the
    user intend for the regexp to match the _whole_ string? Or any
    portion of the string (a la `grep`)? So, for example, does the
    string "aaa1234aaa" match `[0-9]+`? As written, the above
    snippet is actually closer to advancing `p` over `^[0-9]*`. One
    might differentiate between `*` and `+` after the fact, by
    examining `p` against some (presumably saved) source value, but
    that's more code.

    These are just not equivalent. That's not to say that your
    snippet is not _useful_ in context, but to pretend that it's the
    same as the regular expression is pointlessly reductive.

    By the way, something that _would_ match `^[0-9]+$` might be:

    term% cat mdp.c
    #include <assert.h>
    #include <stdbool.h>
    #include <stddef.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>

    static bool
    mdigit(unsigned int c)
    {
    return c - '0' < 10;
    }

    bool
    mdp(const char *str, const char *estr)
    {
    if (str == NULL || estr == NULL || str == estr)
    return false;
    if (!mdigit(*str))
    return false;
    while (str < estr && mdigit(*str))
    str++;
    return str == estr;
    }

    bool
    probe(const char *s, bool expected)
    {
    if (mdp(s, s + strlen(s)) != expected) {
    fprintf(stderr, "test failure: `%s` (expected %s)\n",
    s, expected ? "true" : "false");
    return false;
    }
    return true;
    }

    int
    main(void)
    {
    bool success = true;

    success = probe("1234", true) && success;
    success = probe("", false) && success;
    success = probe("ab", false) && success;
    success = probe("0", true) && success;
    success = probe("0123456789", true) && success;
    success = probe("a0123456", false) && success;
    success = probe("0123456b", false) && success;
    success = probe("0123c456", false) && success;
    success = probe("0123#456", false) && success;

    return success ? EXIT_SUCCESS : EXIT_FAILURE;
    }
    term% cc -Wall -Wextra -Werror -pedantic -std=c11 mdp.c -o mdp
    term% ./mdp
    term% echo $?
    0
    term%

    Granted the test scaffolding and `#include` boilerplate makes
    this appear rather longer than it would be in context, but it's
    still not nearly as succinct.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Rainer Weikusat on Fri Nov 22 15:52:41 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Rainer Weikusat <rweikusat@talktalk.net> writes:

    [...]


    Something which would match [0-9]+ in its first argument (if any) would
    be:

    #include "string.h"
    #include "stdlib.h"

    int main(int argc, char **argv)
    {
    char *p;
    unsigned c;

    p = argv[1];
    if (!p) exit(1);
    while (c = *p, c && c - '0' > 10) ++p;

    This needs to be

    while (c = *p, c && c - '0' > 9) ++p

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Dan Cross on Fri Nov 22 15:41:09 2024
    XPost: comp.unix.shell, comp.unix.programmer

    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    [...]

    Personally I think that writing bulky procedural stuff for something >>>>> like [0-9]+ can only be much worse, and that further abbreviations
    like \d+ are the better direction to go if targeting a good interface. >>>>> YMMV.

    Assuming that p is a pointer to the current position in a string, e is a >>>>pointer to the end of it (ie, point just past the last byte) and - >>>>that's important - both are pointers to unsigned quantities, the 'bulky' >>>>C equivalent of [0-9]+ is

    while (p < e && *p - '0' < 10) ++p;

    That's not too bad. And it's really a hell lot faster than a >>>>general-purpose automaton programmed to recognize the same pattern >>>>(which might not matter most of the time, but sometimes, it does).

    It's also not exactly right. `[0-9]+` would match one or more
    characters; this possibly matches 0 (ie, if `p` pointed to
    something that wasn't a digit).

    The regex won't match any digits if there aren't any. In this case, the >>match will fail. I didn't include the code for handling that because it >>seemed pretty pointless for the example.

    That's rather the point though, isn't it? The program snippet
    (modulo the promotion to signed int via the "usual arithmetic
    conversions" before the subtraction and comparison giving you
    unexpected values; nothing to do with whether `char` is signed
    or not) is a snippet that advances a pointer while it points to
    a digit, starting at the current pointer position; that is, it
    just increments a pointer over a run of digits.

    That's the core part of matching someting equivalent to the regex [0-9]+
    and the only part of it is which is at least remotely interesting.

    But that's not the same as a regex matcher, which has a semantic
    notion of success or failure. I could run your snippet against
    a string such as, say, "ZZZZZZ" and it would "succeed" just as
    it would against an empty string or a string of one or more
    digits.

    Why do you believe that p being equivalent to the starting position
    would be considered a "successful match", considering that this
    obviously doesn't make any sense?

    [...]

    By the way, something that _would_ match `^[0-9]+$` might be:

    [too much code]

    Something which would match [0-9]+ in its first argument (if any) would
    be:

    #include "string.h"
    #include "stdlib.h"

    int main(int argc, char **argv)
    {
    char *p;
    unsigned c;

    p = argv[1];
    if (!p) exit(1);
    while (c = *p, c && c - '0' > 10) ++p;
    if (!c) exit(1);
    return 0;
    }

    but that's 14 lines of text, 13 of which have absolutely no relation to
    the problem of recognizing a digit.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to rweikusat@talktalk.net on Fri Nov 22 17:18:26 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <87zflrs1ti.fsf@doppelsaurus.mobileactivedefense.com>,
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    Rainer Weikusat <rweikusat@talktalk.net> writes:

    [...]


    Something which would match [0-9]+ in its first argument (if any) would
    be:

    #include "string.h"
    #include "stdlib.h"

    int main(int argc, char **argv)
    {
    char *p;
    unsigned c;

    p = argv[1];
    if (!p) exit(1);
    while (c = *p, c && c - '0' > 10) ++p;

    This needs to be

    while (c = *p, c && c - '0' > 9) ++p

    No, that's still wrong. Try actually running it.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Dan Cross on Fri Nov 22 17:35:29 2024
    XPost: comp.unix.shell, comp.unix.programmer

    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <87zflrs1ti.fsf@doppelsaurus.mobileactivedefense.com>,
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    Rainer Weikusat <rweikusat@talktalk.net> writes:

    [...]


    Something which would match [0-9]+ in its first argument (if any) would
    be:

    #include "string.h"
    #include "stdlib.h"

    int main(int argc, char **argv)
    {
    char *p;
    unsigned c;

    p = argv[1];
    if (!p) exit(1);
    while (c = *p, c && c - '0' > 10) ++p;

    This needs to be

    while (c = *p, c && c - '0' > 9) ++p

    No, that's still wrong. Try actually running it.

    If you know something that's wrong with that, why not write it instead
    of utilizing the claim for pointless (and wrong) snide remarks?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to rweikusat@talktalk.net on Fri Nov 22 17:43:24 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <87v7wfrx26.fsf@doppelsaurus.mobileactivedefense.com>,
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <87zflrs1ti.fsf@doppelsaurus.mobileactivedefense.com>,
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    Rainer Weikusat <rweikusat@talktalk.net> writes:

    [...]


    Something which would match [0-9]+ in its first argument (if any) would >>>> be:

    #include "string.h"
    #include "stdlib.h"

    int main(int argc, char **argv)
    {
    char *p;
    unsigned c;

    p = argv[1];
    if (!p) exit(1);
    while (c = *p, c && c - '0' > 10) ++p;

    This needs to be

    while (c = *p, c && c - '0' > 9) ++p

    No, that's still wrong. Try actually running it.

    If you know something that's wrong with that, why not write it instead
    of utilizing the claim for pointless (and wrong) snide remarks?

    I did, at length, in my other post.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to rweikusat@talktalk.net on Fri Nov 22 17:17:46 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <877c8vtgx6.fsf@doppelsaurus.mobileactivedefense.com>,
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    Rainer Weikusat <rweikusat@talktalk.net> wrote: >>>cross@spitfire.i.gajendra.net (Dan Cross) writes:
    [snip]
    It's also not exactly right. `[0-9]+` would match one or more
    characters; this possibly matches 0 (ie, if `p` pointed to
    something that wasn't a digit).

    The regex won't match any digits if there aren't any. In this case, the >>>match will fail. I didn't include the code for handling that because it >>>seemed pretty pointless for the example.

    That's rather the point though, isn't it? The program snippet
    (modulo the promotion to signed int via the "usual arithmetic
    conversions" before the subtraction and comparison giving you
    unexpected values; nothing to do with whether `char` is signed
    or not) is a snippet that advances a pointer while it points to
    a digit, starting at the current pointer position; that is, it
    just increments a pointer over a run of digits.

    That's the core part of matching someting equivalent to the regex [0-9]+
    and the only part of it is which is at least remotely interesting.

    Not really, no. The interesting thing in this case appears to
    be knowing whether or not the match succeeded, but you omited
    that part.

    But that's not the same as a regex matcher, which has a semantic
    notion of success or failure. I could run your snippet against
    a string such as, say, "ZZZZZZ" and it would "succeed" just as
    it would against an empty string or a string of one or more
    digits.

    Why do you believe that p being equivalent to the starting position
    would be considered a "successful match", considering that this
    obviously doesn't make any sense?

    Because absent any surrounding context, there's no indication
    that the source is even saved. You'll note that I did mention
    that as a means to differentiate later on, but that's not the
    snippet you posted.

    [...]

    By the way, something that _would_ match `^[0-9]+$` might be:

    [too much code]

    Something which would match [0-9]+ in its first argument (if any) would
    be:

    #include "string.h"
    #include "stdlib.h"

    int main(int argc, char **argv)
    {
    char *p;
    unsigned c;

    p = argv[1];
    if (!p) exit(1);
    while (c = *p, c && c - '0' > 10) ++p;
    if (!c) exit(1);
    return 0;
    }

    but that's 14 lines of text, 13 of which have absolutely no relation to
    the problem of recognizing a digit.

    This is wrong in many ways. Did you actually test that program?

    First of all, why `"string.h"` and not `<string.h>`? Ok, that's
    not technically an error, but it's certainly unconventional, and
    raises questions that are ultimately a distraction.

    Second, suppose that `argc==0` (yes, this can happen under
    POSIX).

    Third, the loop: why `> 10`? Don't you mean `< 10`? You are
    trying to match digits, not non-digits.

    Fourth, you exit with failure (`exit(1)`) if `!p` *and* if `!c`
    at the end, but `!c` there means you've reached the end of the
    string; which should be success.

    Fifth and finally, you `return 0;` which is EXIT_SUCCESS, in the
    failure case.

    Compare:

    #include <regex.h>
    #include <stddef.h>
    #include <stdio.h>
    #include <stdlib.h>

    int
    main(int argc, char *argv[])
    {
    regex_t reprog;
    int ret;

    if (argc != 2) {
    fprintf(stderr, "Usage: regexp pattern\n");
    return(EXIT_FAILURE);
    }
    (void)regcomp(&reprog, "^[0-9]+$", REG_EXTENDED | REG_NOSUB);
    ret = regexec(&reprog, argv[1], 0, NULL, 0);
    regfree(&reprog);

    return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
    }

    This is only marginally longer, but is correct.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to Dan Cross on Fri Nov 22 17:43:59 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <vhqfrs$bit$1@reader2.panix.com>,
    Dan Cross <cross@spitfire.i.gajendra.net> wrote:
    In article <87v7wfrx26.fsf@doppelsaurus.mobileactivedefense.com>,
    Rainer Weikusat <rweikusat@talktalk.net> wrote: >>cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <87zflrs1ti.fsf@doppelsaurus.mobileactivedefense.com>,
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    Rainer Weikusat <rweikusat@talktalk.net> writes:

    [...]


    Something which would match [0-9]+ in its first argument (if any) would >>>>> be:

    #include "string.h"
    #include "stdlib.h"

    int main(int argc, char **argv)
    {
    char *p;
    unsigned c;

    p = argv[1];
    if (!p) exit(1);
    while (c = *p, c && c - '0' > 10) ++p;

    This needs to be

    while (c = *p, c && c - '0' > 9) ++p

    No, that's still wrong. Try actually running it.

    If you know something that's wrong with that, why not write it instead
    of utilizing the claim for pointless (and wrong) snide remarks?

    I did, at length, in my other post.

    Cf. <vhqebq$c71$1@reader2.panix.com>

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Dan Cross on Fri Nov 22 17:48:37 2024
    XPost: comp.unix.shell, comp.unix.programmer

    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    Rainer Weikusat <rweikusat@talktalk.net> wrote: >>>>cross@spitfire.i.gajendra.net (Dan Cross) writes:
    [snip]
    It's also not exactly right. `[0-9]+` would match one or more
    characters; this possibly matches 0 (ie, if `p` pointed to
    something that wasn't a digit).

    The regex won't match any digits if there aren't any. In this case, the >>>>match will fail. I didn't include the code for handling that because it >>>>seemed pretty pointless for the example.

    That's rather the point though, isn't it? The program snippet
    (modulo the promotion to signed int via the "usual arithmetic
    conversions" before the subtraction and comparison giving you
    unexpected values; nothing to do with whether `char` is signed
    or not) is a snippet that advances a pointer while it points to
    a digit, starting at the current pointer position; that is, it
    just increments a pointer over a run of digits.

    That's the core part of matching someting equivalent to the regex [0-9]+ >>and the only part of it is which is at least remotely interesting.

    Not really, no. The interesting thing in this case appears to
    be knowing whether or not the match succeeded, but you omited
    that part.

    This of interest to you as it enables you to base an 'argumentation'
    (sarcasm) on arbitrary assumptions you've chosen to make. It's not
    something I consider interesting and it's besides the point of the
    example I posted.

    But that's not the same as a regex matcher, which has a semantic
    notion of success or failure. I could run your snippet against
    a string such as, say, "ZZZZZZ" and it would "succeed" just as
    it would against an empty string or a string of one or more
    digits.

    Why do you believe that p being equivalent to the starting position
    would be considered a "successful match", considering that this
    obviously doesn't make any sense?

    Because absent any surrounding context, there's no indication
    that the source is even saved.

    A text usually doesn't contain information about things which aren't
    part of its content. I congratulate you to this rather obvious observation.

    [...]

    Something which would match [0-9]+ in its first argument (if any) would
    be:

    #include "string.h"
    #include "stdlib.h"

    int main(int argc, char **argv)
    {
    char *p;
    unsigned c;

    p = argv[1];
    if (!p) exit(1);
    while (c = *p, c && c - '0' > 10) ++p;
    if (!c) exit(1);
    return 0;
    }

    but that's 14 lines of text, 13 of which have absolutely no relation to
    the problem of recognizing a digit.

    This is wrong in many ways. Did you actually test that program?

    First of all, why `"string.h"` and not `<string.h>`? Ok, that's
    not technically an error, but it's certainly unconventional, and
    raises questions that are ultimately a distraction.

    Such as your paragraph above.

    Second, suppose that `argc==0` (yes, this can happen under
    POSIX).

    It can happen in case of some piece of functionally hostile software intentionally creating such a situation. Tangential, irrelevant
    point. If you break it, you get to keep the parts.

    Third, the loop: why `> 10`? Don't you mean `< 10`? You are
    trying to match digits, not non-digits.

    Mistake I made. The opposite of < 10 is > 9.

    Fourth, you exit with failure (`exit(1)`) if `!p` *and* if `!c`
    at the end, but `!c` there means you've reached the end of the
    string; which should be success.

    Mistake you made: [0-9]+ matches if there's at least one digit in the
    string. That's why the loop terminates once one was found. In this case,
    c cannot be 0.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to rweikusat@talktalk.net on Fri Nov 22 18:12:34 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <87o727rwga.fsf@doppelsaurus.mobileactivedefense.com>,
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    Something which would match [0-9]+ in its first argument (if any) would >>>be:

    #include "string.h"
    #include "stdlib.h"

    int main(int argc, char **argv)
    {
    char *p;
    unsigned c;

    p = argv[1];
    if (!p) exit(1);
    while (c = *p, c && c - '0' > 10) ++p;
    if (!c) exit(1);
    return 0;
    }

    but that's 14 lines of text, 13 of which have absolutely no relation to >>>the problem of recognizing a digit.

    This is wrong in many ways. Did you actually test that program?

    First of all, why `"string.h"` and not `<string.h>`? Ok, that's
    not technically an error, but it's certainly unconventional, and
    raises questions that are ultimately a distraction.

    Such as your paragraph above.

    Second, suppose that `argc==0` (yes, this can happen under
    POSIX).

    It can happen in case of some piece of functionally hostile software >intentionally creating such a situation. Tangential, irrelevant
    point. If you break it, you get to keep the parts.

    Third, the loop: why `> 10`? Don't you mean `< 10`? You are
    trying to match digits, not non-digits.

    Mistake I made. The opposite of < 10 is > 9.

    I see. So you want to skip non-digits and exit the first time
    you see a digit. Ok, fair enough, though that program has
    already been written, and is called `grep`.

    Fourth, you exit with failure (`exit(1)`) if `!p` *and* if `!c`
    at the end, but `!c` there means you've reached the end of the
    string; which should be success.

    Mistake you made: [0-9]+ matches if there's at least one digit in the
    string. That's why the loop terminates once one was found. In this case,
    c cannot be 0.

    Ah, you are trying to match `[0-9]` (though you're calling it
    `[0-9]+`). Yeah, your program was not at all equivalent to one
    I wrote, though this is what you posted in response to mine, so
    I assumed you were trying to emulate that behavior (matching
    `^[0-9]+$`).

    But I see above that you mentioned `[0-9]+`. But as I mentioned
    above, really you're just matching any digit, so you may as well
    be matching `[0-9]`; again, this not the same as the actual
    regexp, because you are ignoring the semantics of what regular
    expressions actually describe.

    In any event, this seems simpler than what you posted:

    #include <stddef.h>
    #include <stdio.h>
    #include <stdlib.h>

    int
    main(int argc, char *argv[])
    {
    if (argc != 2) {
    fprintf(stderr, "Usage: matchd <str>\n");
    return EXIT_FAILURE;
    }

    for (const char *p = argv[1]; *p != '\0'; p++)
    if ('0' <= *p && *p <= '9')
    return EXIT_SUCCESS;

    return EXIT_FAILURE;
    }

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Rainer Weikusat on Fri Nov 22 18:14:48 2024
    XPost: comp.unix.shell, comp.unix.programmer

    Rainer Weikusat <rweikusat@talktalk.net> writes:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    Rainer Weikusat <rweikusat@talktalk.net> wrote: >>>cross@spitfire.i.gajendra.net (Dan Cross) writes:
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    [...]

    Personally I think that writing bulky procedural stuff for something >>>>>> like [0-9]+ can only be much worse, and that further abbreviations >>>>>> like \d+ are the better direction to go if targeting a good interface. >>>>>> YMMV.

    Assuming that p is a pointer to the current position in a string, e is a >>>>>pointer to the end of it (ie, point just past the last byte) and - >>>>>that's important - both are pointers to unsigned quantities, the 'bulky' >>>>>C equivalent of [0-9]+ is

    while (p < e && *p - '0' < 10) ++p;

    That's not too bad. And it's really a hell lot faster than a >>>>>general-purpose automaton programmed to recognize the same pattern >>>>>(which might not matter most of the time, but sometimes, it does).

    It's also not exactly right. `[0-9]+` would match one or more
    characters; this possibly matches 0 (ie, if `p` pointed to
    something that wasn't a digit).

    The regex won't match any digits if there aren't any. In this case, the >>>match will fail. I didn't include the code for handling that because it >>>seemed pretty pointless for the example.

    That's rather the point though, isn't it? The program snippet
    (modulo the promotion to signed int via the "usual arithmetic
    conversions" before the subtraction and comparison giving you
    unexpected values; nothing to do with whether `char` is signed
    or not) is a snippet that advances a pointer while it points to
    a digit, starting at the current pointer position; that is, it
    just increments a pointer over a run of digits.

    That's the core part of matching someting equivalent to the regex [0-9]+
    and the only part of it is which is at least remotely interesting.

    But that's not the same as a regex matcher, which has a semantic
    notion of success or failure. I could run your snippet against
    a string such as, say, "ZZZZZZ" and it would "succeed" just as
    it would against an empty string or a string of one or more
    digits.

    Why do you believe that p being equivalent to the starting position
    would be considered a "successful match", considering that this
    obviously doesn't make any sense?

    [...]

    By the way, something that _would_ match `^[0-9]+$` might be:

    [too much code]

    Something which would match [0-9]+ in its first argument (if any) would
    be:

    #include "string.h"
    #include "stdlib.h"

    int main(int argc, char **argv)
    {
    char *p;
    unsigned c;

    p = argv[1];
    if (!p) exit(1);
    while (c = *p, c && c - '0' > 10) ++p;
    if (!c) exit(1);
    return 0;
    }

    but that's 14 lines of text, 13 of which have absolutely no relation to
    the problem of recognizing a digit.

    Personally, I'd use:

    $ cat /tmp/a.c
    #include <stdint.h>
    #include <string.h>

    int
    main(int argc, const char **argv)
    {
    char *cp;
    uint64_t value;

    if (argc < 2) return 1;

    value = strtoull(argv[1], &cp, 10);
    if ((cp == argv[1])
    || (*cp != '\0')) {
    return 1;
    }
    return 0;
    }
    $ cc -o /tmp/a /tmp/a.c
    $ /tmp/a 13254
    $ echo $?
    0
    $ /tmp/a 23v23
    $ echo $?
    1

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Janis Papanagnou on Fri Nov 22 18:19:30 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-11-22, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
    On 21.11.2024 20:12, Kaz Kylheku wrote:
    [...]

    In the wild, you see regexes being used for all sorts of stupid stuff,

    No one can prevent folks using features for stupid things. Yes.

    But the thing is that "modern" regular expressions (Perl regex and its
    progeny) have features that are designed to exclusively cater to these
    folks.

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Muttley@DastartdlyHQ.org on Fri Nov 22 18:18:04 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 2024-11-22, Muttley@DastartdlyHQ.org <Muttley@DastartdlyHQ.org> wrote:
    On Thu, 21 Nov 2024 19:12:03 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> boring babbled:
    On 2024-11-20, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
    I'm curious what you mean by Regexps presented in a "procedural" form.
    Can you give some examples?

    Here is an example: using a regex match to capture a C comment /* ... */
    in Lex compared to just recognizing the start sequence /* and handling
    the discarding of the comment in the action.

    Without non-greedy repetition matching, the regex for a C comment is
    quite obtuse. The procedural handling is straightforward: read
    characters until you see a * immediately followed by a /.

    Its not that simple I'm afraid since comments can be commented out.

    Umm, no.

    eg:

    // int i; /*

    This /* sequence is inside a // comment, and so the machinery that
    recognizes /* as the start of a comment would never see it.

    Just like "int i;" is in a string literal and so not recognized
    as a keyword, whitespace, identifier and semicolon.

    int j;
    /*
    int k;
    */
    ++j;

    A C99 and C++ compiler would see "int j" and compile it, a regex would
    simply remove everything from the first /* to */.

    No, it won't, because that's not how regexes are used in a lexical
    analyzer. At the start of the input, the lexical analyzer faces
    the characters "// int i; /*\n". This will trigger the pattern match
    for // comments. Essentially that entire sequence through the newline
    is treated as a kind of token, equivalent to a space.

    Once a token is recognized and removed from the input, it is gone;
    no other regular expression can match into it.

    Also the same probably applies to #ifdef's.

    Lexically analyzing C requires implementing the translation phases
    as described in the standard. There are preprocessor phases which
    delimit the input into preprocessor tokens (pp-tokens). Comments
    are stripped in preprocessing. But logical lines (backslash
    continuations) are recognized below comments; i.e. this is one
    comment:

    \\ comment \
    split \
    into \
    physical \
    lines

    A lexical scanner can have an input routine which transparently handles
    this low-level detail, so that it doesn't have to deal with the
    line continuations in every token pattern.

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Lurndal@21:1/5 to Scott Lurndal on Fri Nov 22 18:22:45 2024
    XPost: comp.unix.shell, comp.unix.programmer

    scott@slp53.sl.home (Scott Lurndal) writes:
    Rainer Weikusat <rweikusat@talktalk.net> writes: >>cross@spitfire.i.gajendra.net (Dan Cross) writes:
    Rainer Weikusat <rweikusat@talktalk.net> wrote: >>>>cross@spitfire.i.gajendra.net (Dan Cross) writes:
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    [...]

    Personally I think that writing bulky procedural stuff for something >>>>>>> like [0-9]+ can only be much worse, and that further abbreviations >>>>>>> like \d+ are the better direction to go if targeting a good interface. >>>>>>> YMMV.

    Assuming that p is a pointer to the current position in a string, e is a >>>>>>pointer to the end of it (ie, point just past the last byte) and - >>>>>>that's important - both are pointers to unsigned quantities, the 'bulky' >>>>>>C equivalent of [0-9]+ is

    while (p < e && *p - '0' < 10) ++p;

    That's not too bad. And it's really a hell lot faster than a >>>>>>general-purpose automaton programmed to recognize the same pattern >>>>>>(which might not matter most of the time, but sometimes, it does).

    It's also not exactly right. `[0-9]+` would match one or more
    characters; this possibly matches 0 (ie, if `p` pointed to
    something that wasn't a digit).

    The regex won't match any digits if there aren't any. In this case, the >>>>match will fail. I didn't include the code for handling that because it >>>>seemed pretty pointless for the example.

    That's rather the point though, isn't it? The program snippet
    (modulo the promotion to signed int via the "usual arithmetic
    conversions" before the subtraction and comparison giving you
    unexpected values; nothing to do with whether `char` is signed
    or not) is a snippet that advances a pointer while it points to
    a digit, starting at the current pointer position; that is, it
    just increments a pointer over a run of digits.

    That's the core part of matching someting equivalent to the regex [0-9]+ >>and the only part of it is which is at least remotely interesting.

    But that's not the same as a regex matcher, which has a semantic
    notion of success or failure. I could run your snippet against
    a string such as, say, "ZZZZZZ" and it would "succeed" just as
    it would against an empty string or a string of one or more
    digits.

    Why do you believe that p being equivalent to the starting position
    would be considered a "successful match", considering that this
    obviously doesn't make any sense?

    [...]

    By the way, something that _would_ match `^[0-9]+$` might be:

    [too much code]

    Something which would match [0-9]+ in its first argument (if any) would
    be:

    #include "string.h"
    #include "stdlib.h"

    int main(int argc, char **argv)
    {
    char *p;
    unsigned c;

    p = argv[1];
    if (!p) exit(1);
    while (c = *p, c && c - '0' > 10) ++p;
    if (!c) exit(1);
    return 0;
    }

    but that's 14 lines of text, 13 of which have absolutely no relation to
    the problem of recognizing a digit.

    Personally, I'd use:

    Albeit this is limited to strings of digits that sum to less than
    ULONG_MAX...



    $ cat /tmp/a.c
    #include <stdint.h>
    #include <string.h>

    int
    main(int argc, const char **argv)
    {
    char *cp;
    uint64_t value;

    if (argc < 2) return 1;

    value = strtoull(argv[1], &cp, 10);
    if ((cp == argv[1])
    || (*cp != '\0')) {
    return 1;
    }
    return 0;
    }
    $ cc -o /tmp/a /tmp/a.c
    $ /tmp/a 13254
    $ echo $?
    0
    $ /tmp/a 23v23
    $ echo $?
    1

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to Scott Lurndal on Fri Nov 22 18:30:31 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <VZ30P.4664$YSkc.1894@fx40.iad>,
    Scott Lurndal <slp53@pacbell.net> wrote:
    scott@slp53.sl.home (Scott Lurndal) writes:
    Rainer Weikusat <rweikusat@talktalk.net> writes: >>>cross@spitfire.i.gajendra.net (Dan Cross) writes:
    Rainer Weikusat <rweikusat@talktalk.net> wrote: >>>>>cross@spitfire.i.gajendra.net (Dan Cross) writes:
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    [...]

    Personally I think that writing bulky procedural stuff for something >>>>>>>> like [0-9]+ can only be much worse, and that further abbreviations >>>>>>>> like \d+ are the better direction to go if targeting a good interface. >>>>>>>> YMMV.

    Assuming that p is a pointer to the current position in a string, e is a >>>>>>>pointer to the end of it (ie, point just past the last byte) and - >>>>>>>that's important - both are pointers to unsigned quantities, the 'bulky' >>>>>>>C equivalent of [0-9]+ is

    while (p < e && *p - '0' < 10) ++p;

    That's not too bad. And it's really a hell lot faster than a >>>>>>>general-purpose automaton programmed to recognize the same pattern >>>>>>>(which might not matter most of the time, but sometimes, it does). >>>>>>
    It's also not exactly right. `[0-9]+` would match one or more
    characters; this possibly matches 0 (ie, if `p` pointed to
    something that wasn't a digit).

    The regex won't match any digits if there aren't any. In this case, the >>>>>match will fail. I didn't include the code for handling that because it >>>>>seemed pretty pointless for the example.

    That's rather the point though, isn't it? The program snippet
    (modulo the promotion to signed int via the "usual arithmetic
    conversions" before the subtraction and comparison giving you
    unexpected values; nothing to do with whether `char` is signed
    or not) is a snippet that advances a pointer while it points to
    a digit, starting at the current pointer position; that is, it
    just increments a pointer over a run of digits.

    That's the core part of matching someting equivalent to the regex [0-9]+ >>>and the only part of it is which is at least remotely interesting.

    But that's not the same as a regex matcher, which has a semantic
    notion of success or failure. I could run your snippet against
    a string such as, say, "ZZZZZZ" and it would "succeed" just as
    it would against an empty string or a string of one or more
    digits.

    Why do you believe that p being equivalent to the starting position
    would be considered a "successful match", considering that this
    obviously doesn't make any sense?

    [...]

    By the way, something that _would_ match `^[0-9]+$` might be:

    [too much code]

    Something which would match [0-9]+ in its first argument (if any) would >>>be:

    #include "string.h"
    #include "stdlib.h"

    int main(int argc, char **argv)
    {
    char *p;
    unsigned c;

    p = argv[1];
    if (!p) exit(1);
    while (c = *p, c && c - '0' > 10) ++p;
    if (!c) exit(1);
    return 0;
    }

    but that's 14 lines of text, 13 of which have absolutely no relation to >>>the problem of recognizing a digit.

    Personally, I'd use:

    Albeit this is limited to strings of digits that sum to less than >ULONG_MAX...

    It's not quite equivalent to his program, which just exit's with
    success if it sees any input string with a digit in it; your's
    is closer to what I wrote, which matches `^[0-9]+$`. His is not
    an interesting program and certainly not a recognizable
    equivalent a regular expression matcher in any reasonable sense,
    but I think the cognitive dissonance is too strong to get that
    across.

    - Dan C.

    $ cat /tmp/a.c
    #include <stdint.h>
    #include <string.h>

    int
    main(int argc, const char **argv)
    {
    char *cp;
    uint64_t value;

    if (argc < 2) return 1;

    value = strtoull(argv[1], &cp, 10);
    if ((cp == argv[1])
    || (*cp != '\0')) {
    return 1;
    }
    return 0;
    }
    $ cc -o /tmp/a /tmp/a.c
    $ /tmp/a 13254
    $ echo $?
    0
    $ /tmp/a 23v23
    $ echo $?
    1

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Dan Cross on Fri Nov 22 18:48:55 2024
    XPost: comp.unix.shell, comp.unix.programmer

    cross@spitfire.i.gajendra.net (Dan Cross) writes:

    [...]

    In any event, this seems simpler than what you posted:

    #include <stddef.h>
    #include <stdio.h>
    #include <stdlib.h>

    int
    main(int argc, char *argv[])
    {
    if (argc != 2) {
    fprintf(stderr, "Usage: matchd <str>\n");
    return EXIT_FAILURE;
    }

    for (const char *p = argv[1]; *p != '\0'; p++)
    if ('0' <= *p && *p <= '9')
    return EXIT_SUCCESS;

    return EXIT_FAILURE;
    }

    It's not only 4 lines longer but in just about every individual aspect syntactically more complicated and more messy and functionally more
    clumsy. This is particularly noticable in the loop

    for (const char *p = argv[1]; *p != '\0'; p++)
    if ('0' <= *p && *p <= '9')
    return EXIT_SUCCESS;

    the loop header containing a spuriously qualified variable declaration,
    the loop body and half of the termination condition. The other half then follows as special-case in the otherwise useless loop body.

    It looks like a copy of my code which each individual bit redesigned
    under the guiding principle of "Can we make this more complicated?", eg,

    char **argv

    declares an array of pointers (as each pointer in C points to an array)
    and

    char *argv[]

    accomplishes exactly the same but uses both more characters and more
    different kinds of characters.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Scott Lurndal on Fri Nov 22 18:59:43 2024
    XPost: comp.unix.shell, comp.unix.programmer

    scott@slp53.sl.home (Scott Lurndal) writes:
    Rainer Weikusat <rweikusat@talktalk.net> writes:

    [...]

    Something which would match [0-9]+ in its first argument (if any) would
    be:

    #include "string.h"
    #include "stdlib.h"

    int main(int argc, char **argv)
    {
    char *p;
    unsigned c;

    p = argv[1];
    if (!p) exit(1);
    while (c = *p, c && c - '0' > 10) ++p;
    if (!c) exit(1);
    return 0;
    }

    but that's 14 lines of text, 13 of which have absolutely no relation to
    the problem of recognizing a digit.

    Personally, I'd use:

    $ cat /tmp/a.c
    #include <stdint.h>
    #include <string.h>

    int
    main(int argc, const char **argv)
    {
    char *cp;
    uint64_t value;

    if (argc < 2) return 1;

    value = strtoull(argv[1], &cp, 10);
    if ((cp == argv[1])
    || (*cp != '\0')) {
    return 1;
    }
    return 0;
    }

    This will accept a string of digits whose numerical value is <=
    ULLONG_MAX, ie, it's basically ^[0-9]+$ with unobvious length and
    content limits.

    return !strstr(argv[1], "0123456789");

    would be a better approximation, just a much more complicated algorithm
    than necessary. Even in strictly conforming ISO-C "digitness" of a
    character can be determined by a simple calculation instead of some kind
    of search loop.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to rweikusat@talktalk.net on Fri Nov 22 19:05:42 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <87h67zrtns.fsf@doppelsaurus.mobileactivedefense.com>,
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:

    [...]

    In any event, this seems simpler than what you posted:

    #include <stddef.h>
    #include <stdio.h>
    #include <stdlib.h>

    int
    main(int argc, char *argv[])
    {
    if (argc != 2) {
    fprintf(stderr, "Usage: matchd <str>\n");
    return EXIT_FAILURE;
    }

    for (const char *p = argv[1]; *p != '\0'; p++)
    if ('0' <= *p && *p <= '9')
    return EXIT_SUCCESS;

    return EXIT_FAILURE;
    }

    It's not only 4 lines longer but in just about every individual aspect >syntactically more complicated and more messy and functionally more
    clumsy.

    That's a lot of opinion, and not particularly well-founded
    opinion at that, given that your code was incorrect to begin
    with.

    This is particularly noticable in the loop

    for (const char *p = argv[1]; *p != '\0'; p++)
    if ('0' <= *p && *p <= '9')
    return EXIT_SUCCESS;

    the loop header containing a spuriously qualified variable declaration,

    Ibid. Const qualifying a pointer that I'm not going to assign
    through is just good hygiene, IMHO.

    the loop body and half of the termination condition.

    I think you're trying to project a value judgement onto that
    loop in order to make it fit a particular world view, but I
    think this is an odd way to look at it.

    Another way to loop at it is that the loop is only concerned
    with the iteration over the string, while the body is concerned
    with applying some predicate to the element, and doing something
    if that predicate evaluates it to true.

    The other half then
    follows as special-case in the otherwise useless loop body.

    That's a way to look at it, but I submit that's an outlier point
    of view.

    It looks like a copy of my code which each individual bit redesigned
    under the guiding principle of "Can we make this more complicated?", eg,

    Uh, no.

    char **argv

    declares an array of pointers

    No, it declares a pointer to a pointer to char.

    (as each pointer in C points to an array)

    That's absolutely not true. A pointer in C may refer to
    an array, or a scalar. Consider,

    char c;
    char *p = &c;
    char **pp = &p;

    For a concrete example of how this works in a real function,
    consider the second argument to `strtol` et al in the standard
    library.

    and

    char *argv[]

    accomplishes exactly the same but uses both more characters and more >different kinds of characters.

    "more characters" is a poor metric.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to rweikusat@talktalk.net on Fri Nov 22 19:15:07 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <87cyinrt5s.fsf@doppelsaurus.mobileactivedefense.com>,
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    scott@slp53.sl.home (Scott Lurndal) writes:
    Rainer Weikusat <rweikusat@talktalk.net> writes:

    [...]

    Something which would match [0-9]+ in its first argument (if any) would >>>be:

    #include "string.h"
    #include "stdlib.h"

    int main(int argc, char **argv)
    {
    char *p;
    unsigned c;

    p = argv[1];
    if (!p) exit(1);
    while (c = *p, c && c - '0' > 10) ++p;
    if (!c) exit(1);
    return 0;
    }

    but that's 14 lines of text, 13 of which have absolutely no relation to >>>the problem of recognizing a digit.

    Personally, I'd use:

    $ cat /tmp/a.c
    #include <stdint.h>
    #include <string.h>

    int
    main(int argc, const char **argv)
    {
    char *cp;
    uint64_t value;

    if (argc < 2) return 1;

    value = strtoull(argv[1], &cp, 10);
    if ((cp == argv[1])
    || (*cp != '\0')) {
    return 1;
    }
    return 0;
    }

    This will accept a string of digits whose numerical value is <=
    ULLONG_MAX, ie, it's basically ^[0-9]+$ with unobvious length and
    content limits.

    He acknowledged this already.

    return !strstr(argv[1], "0123456789");

    would be a better approximation,

    No it wouldn't. That's not even close. `strstr` looks for an
    instance of its second argument in its first, not an instance of
    any character in it's second argument in its first. Perhaps you
    meant something with `strspn` or similar. E.g.,

    const char *p = argv[1] + strspn(argv[1], "0123456789");
    return *p != '\0';

    just a much more complicated algorithm
    than necessary. Even in strictly conforming ISO-C "digitness" of a
    character can be determined by a simple calculation instead of some kind
    of search loop.

    Yes, one can do that, but why bother?

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Kaz Kylheku on Fri Nov 22 20:20:06 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 22.11.2024 19:19, Kaz Kylheku wrote:
    On 2024-11-22, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
    On 21.11.2024 20:12, Kaz Kylheku wrote:
    [...]

    In the wild, you see regexes being used for all sorts of stupid stuff,

    No one can prevent folks using features for stupid things. Yes.

    But the thing is that "modern" regular expressions (Perl regex and its progeny) have features that are designed to exclusively cater to these
    folks.

    Which ones are you specifically thinking of?

    Since I'm not using Perl I don't know all the Perl RE details. Besides
    the basic REs I'm aware of the abbreviations (like '\d') (that I like),
    then extensions of Chomsky-3 (like back-references) (that I also like
    to have in cases I need them; but one must know what we buy with them),
    then the minimum-match (as opposed to matching the longest substring)
    (which I think is useful to simplify some types of expressions), and
    there was another one that evades my memories, something like context
    dependent patterns (also useful), and wasn't there also some syntax to
    match subexpression-hierarchies (useful as well) (similar like in GNU
    Awk's gensub() (probably in a more primitive variant there), and also
    existing in Kornshell patterns that also supports some more from above [Perl-]features, like the abbreviations).

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Dan Cross on Fri Nov 22 19:24:23 2024
    XPost: comp.unix.shell, comp.unix.programmer

    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:

    [...]

    In any event, this seems simpler than what you posted:

    #include <stddef.h>
    #include <stdio.h>
    #include <stdlib.h>

    int
    main(int argc, char *argv[])
    {
    if (argc != 2) {
    fprintf(stderr, "Usage: matchd <str>\n");
    return EXIT_FAILURE;
    }

    for (const char *p = argv[1]; *p != '\0'; p++)
    if ('0' <= *p && *p <= '9')
    return EXIT_SUCCESS;

    return EXIT_FAILURE;
    }

    It's not only 4 lines longer but in just about every individual aspect >>syntactically more complicated and more messy and functionally more
    clumsy.

    That's a lot of opinion, and not particularly well-founded
    opinion at that, given that your code was incorrect to begin
    with.

    That's not at all an opinion but an observation. My opinion on this is
    that this is either a poor man's attempt at winning an obfuscation
    context or - simpler - exemplary bad code.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Rainer Weikusat on Fri Nov 22 20:33:24 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On 22.11.2024 12:56, Rainer Weikusat wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 20.11.2024 18:50, Rainer Weikusat wrote:
    [...]
    while (p < e && *p - '0' < 10) ++p;

    That's not too bad. And it's really a hell lot faster than a
    general-purpose automaton programmed to recognize the same pattern
    (which might not matter most of the time, but sometimes, it does).

    Okay, I see where you're coming from (and especially in that simple
    case).

    Personally (and YMMV), even here in this simple case I think that
    using pointers is not better but worse - and anyway isn't [in this
    form] available in most languages;

    That's a question of using the proper tool for the job. In C, that's
    pointer and pointer arithmetic because it's the simplest way to express something like this.

    Yes, in "C" you'd use that primitive (error-prone) pointer feature.
    That's what I said. And that in other languages it's less terse than
    in "C" but equally error-prone if you have to create all the parsing
    code yourself (without an existing engine and in a non-standard way).
    And if you extend the expression to parse it's IME much simpler done
    in Regex than adjusting the algorithm of the ad hoc procedural code.


    in other cases (and languages)
    such constructs get yet more clumsy, and for my not very complex
    example - /[0-9]+(ABC)?x*foo/ - even a "catastrophe" concerning
    readability, error-proneness, and maintainability.

    Procedural code for matching strings constructed in this way is
    certainly much simpler¹ than the equally procedural code for a
    programmable automaton capable of interpreting regexes.

    The point is that Regexps and the equivalence to FSA (with guaranteed
    runtime complexity) is an [efficient] abstraction with a formalized
    syntax; that are huge advantages compared to ad hoc parsing code in C
    (or in any other language).

    Your statement
    is basically "If we assume that the code interpreting regexes doesn't
    exist, regexes need much less code than something equivalent which does exist." Without this assumption, the picture becomes a different one altogether.

    I don't speak of assumptions. I speak about the fact that there's a well-understood model with existing [parsing-]implementations already
    available to handle a huge class of algorithms in a standardized way
    with a guaranteed runtime-efficiency and in an error-resilient way.

    Janis

    [...]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rainer Weikusat@21:1/5 to Dan Cross on Fri Nov 22 19:26:07 2024
    XPost: comp.unix.shell, comp.unix.programmer

    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <87cyinrt5s.fsf@doppelsaurus.mobileactivedefense.com>,
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    scott@slp53.sl.home (Scott Lurndal) writes:
    Rainer Weikusat <rweikusat@talktalk.net> writes:

    [...]

    Something which would match [0-9]+ in its first argument (if any) would >>>>be:

    #include "string.h"
    #include "stdlib.h"

    int main(int argc, char **argv)
    {
    char *p;
    unsigned c;

    p = argv[1];
    if (!p) exit(1);
    while (c = *p, c && c - '0' > 10) ++p;
    if (!c) exit(1);
    return 0;
    }

    but that's 14 lines of text, 13 of which have absolutely no relation to >>>>the problem of recognizing a digit.

    Personally, I'd use:

    $ cat /tmp/a.c
    #include <stdint.h>
    #include <string.h>

    int
    main(int argc, const char **argv)
    {
    char *cp;
    uint64_t value;

    if (argc < 2) return 1;

    value = strtoull(argv[1], &cp, 10);
    if ((cp == argv[1])
    || (*cp != '\0')) {
    return 1;
    }
    return 0;
    }

    This will accept a string of digits whose numerical value is <=
    ULLONG_MAX, ie, it's basically ^[0-9]+$ with unobvious length and
    content limits.

    He acknowledged this already.

    return !strstr(argv[1], "0123456789");

    would be a better approximation,

    No it wouldn't. That's not even close. `strstr` looks for an
    instance of its second argument in its first, not an instance of
    any character in it's second argument in its first. Perhaps you
    meant something with `strspn` or similar. E.g.,

    const char *p = argv[1] + strspn(argv[1], "0123456789");
    return *p != '\0';

    My bad.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to rweikusat@talktalk.net on Fri Nov 22 19:46:31 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <878qtbrs0o.fsf@doppelsaurus.mobileactivedefense.com>,
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    Rainer Weikusat <rweikusat@talktalk.net> wrote: >>>cross@spitfire.i.gajendra.net (Dan Cross) writes:

    [...]

    In any event, this seems simpler than what you posted:

    #include <stddef.h>
    #include <stdio.h>
    #include <stdlib.h>

    int
    main(int argc, char *argv[])
    {
    if (argc != 2) {
    fprintf(stderr, "Usage: matchd <str>\n");
    return EXIT_FAILURE;
    }

    for (const char *p = argv[1]; *p != '\0'; p++)
    if ('0' <= *p && *p <= '9')
    return EXIT_SUCCESS;

    return EXIT_FAILURE;
    }

    It's not only 4 lines longer but in just about every individual aspect >>>syntactically more complicated and more messy and functionally more >>>clumsy.

    That's a lot of opinion, and not particularly well-founded
    opinion at that, given that your code was incorrect to begin
    with.

    That's not at all an opinion but an observation. My opinion on this is
    that this is either a poor man's attempt at winning an obfuscation
    context or - simpler - exemplary bad code.

    Opinion (noun)
    a view or judgment formed about something, not necessarily based on
    fact or knowledge. "I'm writing to voice my opinion on an issue of
    little importance"

    You mentioned snark earlier. Physician, heal thyself.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Cross@21:1/5 to rweikusat@talktalk.net on Fri Nov 22 19:51:18 2024
    XPost: comp.unix.shell, comp.unix.programmer

    In article <874j3zrrxs.fsf@doppelsaurus.mobileactivedefense.com>,
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <87cyinrt5s.fsf@doppelsaurus.mobileactivedefense.com>,
    Rainer Weikusat <rweikusat@talktalk.net> wrote:
    scott@slp53.sl.home (Scott Lurndal) writes:
    Rainer Weikusat <rweikusat@talktalk.net> writes:

    [...]

    Something which would match [0-9]+ in its first argument (if any) would >>>>>be:

    #include "string.h"
    #include "stdlib.h"

    int main(int argc, char **argv)
    {
    char *p;
    unsigned c;

    p = argv[1];
    if (!p) exit(1);
    while (c = *p, c && c - '0' > 10) ++p;
    if (!c) exit(1);
    return 0;
    }

    but that's 14 lines of text, 13 of which have absolutely no relation to >>>>>the problem of recognizing a digit.

    Personally, I'd use:

    $ cat /tmp/a.c
    #include <stdint.h>
    #include <string.h>

    int
    main(int argc, const char **argv)
    {
    char *cp;
    uint64_t value;

    if (argc < 2) return 1;

    value = strtoull(argv[1], &cp, 10);
    if ((cp == argv[1])
    || (*cp != '\0')) {
    return 1;
    }
    return 0;
    }

    This will accept a string of digits whose numerical value is <= >>>ULLONG_MAX, ie, it's basically ^[0-9]+$ with unobvious length and
    content limits.

    He acknowledged this already.

    return !strstr(argv[1], "0123456789");

    would be a better approximation,

    No it wouldn't. That's not even close. `strstr` looks for an
    instance of its second argument in its first, not an instance of
    any character in it's second argument in its first. Perhaps you
    meant something with `strspn` or similar. E.g.,

    const char *p = argv[1] + strspn(argv[1], "0123456789");
    return *p != '\0';

    My bad.

    You've made a lot of "bad"s in this thread, and been rude about
    it to boot, crying foul when someone's pointed out ways that
    your code is deficient; claiming offense at what you perceive as
    "snark" while dishing the same out in kind, making basic errors
    that show you haven't done the barest minimum of testing, and
    making statements that show you have, at best, a limited grasp
    on the language you're choosing to use.

    I'm done being polite. My conclusion is that perhaps you are
    not as up on these things as you seem to think that you are.

    - Dan C.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to Janis Papanagnou on Fri Nov 22 20:41:21 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 22 Nov 2024 12:47:16 +0100, Janis Papanagnou wrote:

    On 21.11.2024 23:05, Lawrence D'Oliveiro wrote:

    Another handy one is “\b” for word boundaries.

    I prefer \< and \> (that are quite commonly used) for such structural
    things ...

    “\<” only matches the beginning of a word, “\>” only matches the end, “\b” matches both <https://www.gnu.org/software/emacs/manual/html_node/emacs/Regexp-Backslash.html>.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Muttley@dastardlyhq.com@21:1/5 to All on Sat Nov 23 11:40:37 2024
    XPost: comp.unix.shell, comp.unix.programmer

    On Fri, 22 Nov 2024 18:18:04 -0000 (UTC)
    Kaz Kylheku <643-408-1753@kylheku.com> gabbled:
    On 2024-11-22, Muttley@DastartdlyHQ.org <Muttley@DastartdlyHQ.org> wrote:
    Its not that simple I'm afraid since comments can be commented out.

    Umm, no.

    Umm, yes, they can.

    eg:

    // int i; /*

    This /* sequence is inside a // comment, and so the machinery that
    recognizes /* as the start of a comment would never see it.

    Yes, thats kind of the point. You seem to be arguing against yourself.

    A C99 and C++ compiler would see "int j" and compile it, a regex would
    simply remove everything from the first /* to */.

    No, it won't, because that's not how regexes are used in a lexical

    Yes, it will.

    Also the same probably applies to #ifdef's.

    Lexically analyzing C requires implementing the translation phases
    as described in the standard. There are preprocessor phases which
    delimit the input into preprocessor tokens (pp-tokens). Comments
    are stripped in preprocessing. But logical lines (backslash
    continuations) are recognized below comments; i.e. this is one
    comment:

    Not sure what your point is. A regex cannot be used to parse C comments because its doesn't know C/C++ grammar.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Tim Rentsch@21:1/5 to Rainer Weikusat on Sun Nov 24 06:42:59 2024
    Rainer Weikusat <rweikusat@talktalk.net> writes:

    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    [...]

    Personally I think that writing bulky procedural stuff for
    something like [0-9]+ can only be much worse, and that further
    abbreviations like \d+ are the better direction to go if targeting
    a good interface. YMMV.

    Assuming that p is a pointer to the current position in a string, e
    is a pointer to the end of it (ie, point just past the last byte)
    and - that's important - both are pointers to unsigned quantities,
    the 'bulky' C equivalent of [0-9]+ is

    while (p < e && *p - '0' < 10) ++p;

    To force the comparison to be done as unsigned:

    while (p < e && *p - '0' < 10u) ++p;

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Tim Rentsch@21:1/5 to Kaz Kylheku on Sun Nov 24 20:08:24 2024
    Kaz Kylheku <643-408-1753@kylheku.com> writes:

    Here is an example: using a regex match to capture a C comment /* ... */
    in Lex compared to just recognizing the start sequence /* and handling
    the discarding of the comment in the action.

    Without non-greedy repetition matching, the regex for a C comment is
    quite obtuse. The procedural handling is straightforward: read
    characters until you see a * immediately followed by a /.

    Regular expressions are neither greedy nor non-greedy. One of the
    key points of regular expressions is that they are declarative
    rather than procedural. Any procedural change of behavior overlaid
    on a regular expression is a property of the tool, not the regular
    expression. It's easy to write a regular expression that exactly
    matches a /* ... */ comment and that isn't hard to understand.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)