Re: Command Languages Versus Programming Languages

Liste des GroupesRevenir à cu shell 
Sujet : Re: Command Languages Versus Programming Languages
De : david.brown (at) *nospam* hesbynett.no (David Brown)
Groupes : comp.unix.shell comp.unix.programmer comp.lang.misc
Date : 06. Apr 2024, 15:44:13
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <uurjjf$2409m$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
User-Agent : Mozilla Thunderbird
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;
 

Date Sujet#  Auteur
29 Mar 24 * Command Languages Versus Programming Languages649Lawrence D'Oliveiro
29 Mar 24 +- Re: Command Languages Versus Programming Languages1candycanearter07
29 Mar 24 +* Re: Command Languages Versus Programming Languages19Janis Papanagnou
29 Mar 24 i+* Re: Command Languages Versus Programming Languages15Lawrence D'Oliveiro
30 Mar 24 ii`* Re: Command Languages Versus Programming Languages14Janis Papanagnou
30 Mar 24 ii +* Re: Command Languages Versus Programming Languages3Janis Papanagnou
30 Mar 24 ii i`* Re: Command Languages Versus Programming Languages2Keith Thompson
30 Mar 24 ii i `- Re: Command Languages Versus Programming Languages1Janis Papanagnou
30 Mar 24 ii +* Re: Command Languages Versus Programming Languages6Lawrence D'Oliveiro
30 Mar 24 ii i+* Re: Command Languages Versus Programming Languages3Keith Thompson
30 Mar 24 ii ii`* Re: Command Languages Versus Programming Languages2Lawrence D'Oliveiro
30 Mar 24 ii ii `- Re: Command Languages Versus Programming Languages1Keith Thompson
30 Mar 24 ii i`* Re: Command Languages Versus Programming Languages2Janis Papanagnou
30 Mar 24 ii i `- Re: Command Languages Versus Programming Languages1Lawrence D'Oliveiro
30 Mar 24 ii +* Re: Command Languages Versus Programming Languages3Keith Thompson
30 Mar 24 ii i`* Re: Command Languages Versus Programming Languages2Janis Papanagnou
30 Mar 24 ii i `- Re: Command Languages Versus Programming Languages1Keith Thompson
31 Mar 24 ii `- Re: Command Languages Versus Programming Languages1Lawrence D'Oliveiro
29 Mar 24 i`* Re: Command Languages Versus Programming Languages3Stefan Ram
30 Mar 24 i `* Re: Command Languages Versus Programming Languages2Janis Papanagnou
30 Mar 24 i  `- Re: Command Languages Versus Programming Languages1Lawrence D'Oliveiro
29 Mar 24 +* Re: Command Languages Versus Programming Languages168Muttley
29 Mar 24 i+- Re: Command Languages Versus Programming Languages1Josef Möllers
29 Mar 24 i+* Re: Command Languages Versus Programming Languages9Richard Kettlewell
29 Mar 24 ii`* Re: Command Languages Versus Programming Languages8Muttley
29 Mar 24 ii `* Re: Command Languages Versus Programming Languages7Kaz Kylheku
29 Mar 24 ii  `* Re: Command Languages Versus Programming Languages6Muttley
29 Mar 24 ii   `* Re: Command Languages Versus Programming Languages5Kaz Kylheku
30 Mar 24 ii    `* Re: Command Languages Versus Programming Languages4Muttley
30 Mar 24 ii     +- Re: Command Languages Versus Programming Languages1Janis Papanagnou
30 Mar 24 ii     `* Re: Command Languages Versus Programming Languages2Kaz Kylheku
1 Apr 24 ii      `- Re: Command Languages Versus Programming Languages1Muttley
29 Mar 24 i`* Re: Command Languages Versus Programming Languages157John Ames
29 Mar 24 i +* Re: Command Languages Versus Programming Languages155Muttley
29 Mar 24 i i+- Re: Command Languages Versus Programming Languages1John Ames
29 Mar 24 i i+* Re: Command Languages Versus Programming Languages149Kaz Kylheku
29 Mar 24 i ii`* Re: Command Languages Versus Programming Languages148Muttley
29 Mar 24 i ii +* Re: Command Languages Versus Programming Languages146Kaz Kylheku
29 Mar 24 i ii i+* Re: Command Languages Versus Programming Languages4David W. Hodgins
29 Mar 24 i ii ii+* Re: Command Languages Versus Programming Languages2Johanne Fairchild
30 Mar 24 i ii iii`- Re: Command Languages Versus Programming Languages1David W. Hodgins
30 Mar 24 i ii ii`- Re: Command Languages Versus Programming Languages1Janis Papanagnou
30 Mar 24 i ii i`* Re: Command Languages Versus Programming Languages141Muttley
30 Mar 24 i ii i `* Re: Command Languages Versus Programming Languages140Kaz Kylheku
1 Apr 24 i ii i  `* Re: Command Languages Versus Programming Languages139Muttley
1 Apr 24 i ii i   +* Re: Command Languages Versus Programming Languages137Johanne Fairchild
1 Apr 24 i ii i   i`* Re: Command Languages Versus Programming Languages136Muttley
1 Apr 24 i ii i   i +- Re: Command Languages Versus Programming Languages1Kaz Kylheku
2 Apr 24 i ii i   i `* Re: Command Languages Versus Programming Languages134Johanne Fairchild
2 Apr 24 i ii i   i  +* Re: Command Languages Versus Programming Languages113ram@zedat.fu-berlin.de (Stefan Ram)
2 Apr 24 i ii i   i  i+* Re: Command Languages Versus Programming Languages111Stefan Ram
2 Apr 24 i ii i   i  ii+* Re: Command Languages Versus Programming Languages109Stefan Ram
3 Apr 24 i ii i   i  iii`* Re: Command Languages Versus Programming Languages108Lawrence D'Oliveiro
3 Apr 24 i ii i   i  iii `* Re: Command Languages Versus Programming Languages107David Brown
3 Apr 24 i ii i   i  iii  +- Re: Command Languages Versus Programming Languages1Lawrence D'Oliveiro
3 Apr 24 i ii i   i  iii  +- Re: Command Languages Versus Programming Languages1John Ames
3 Apr 24 i ii i   i  iii  `* Re: Command Languages Versus Programming Languages104Keith Thompson
3 Apr 24 i ii i   i  iii   +* Re: Command Languages Versus Programming Languages99Richard Kettlewell
4 Apr 24 i ii i   i  iii   i+- Re: Command Languages Versus Programming Languages1Muttley
4 Apr 24 i ii i   i  iii   i`* Re: Command Languages Versus Programming Languages97Stefan Ram
5 Apr 24 i ii i   i  iii   i `* Re: Command Languages Versus Programming Languages96Lawrence D'Oliveiro
5 Apr 24 i ii i   i  iii   i  +* Re: Command Languages Versus Programming Languages49Muttley
5 Apr 24 i ii i   i  iii   i  i+* Re: Command Languages Versus Programming Languages3candycanearter07
5 Apr 24 i ii i   i  iii   i  ii`* Re: Command Languages Versus Programming Languages2Muttley
6 Apr 24 i ii i   i  iii   i  ii `- Re: Command Languages Versus Programming Languages1candycanearter07
6 Apr 24 i ii i   i  iii   i  i`* Re: Command Languages Versus Programming Languages45Lawrence D'Oliveiro
6 Apr 24 i ii i   i  iii   i  i `* Re: Command Languages Versus Programming Languages44Alan Bawden
6 Apr 24 i ii i   i  iii   i  i  +* Re: Command Languages Versus Programming Languages13Lawrence D'Oliveiro
8 Apr 24 i ii i   i  iii   i  i  i`* Re: Command Languages Versus Programming Languages12John Ames
9 Apr 24 i ii i   i  iii   i  i  i `* Re: Command Languages Versus Programming Languages11Lawrence D'Oliveiro
9 Apr 24 i ii i   i  iii   i  i  i  +* Re: Command Languages Versus Programming Languages9John Ames
9 Apr 24 i ii i   i  iii   i  i  i  i`* Re: Command Languages Versus Programming Languages8Richard Kettlewell
9 Apr 24 i ii i   i  iii   i  i  i  i +* Re: Command Languages Versus Programming Languages2Janis Papanagnou
9 Apr 24 i ii i   i  iii   i  i  i  i i`- Re: Command Languages Versus Programming Languages1Richard Kettlewell
9 Apr 24 i ii i   i  iii   i  i  i  i `* Re: Command Languages Versus Programming Languages5David Brown
9 Apr 24 i ii i   i  iii   i  i  i  i  `* Re: Command Languages Versus Programming Languages4Lawrence D'Oliveiro
9 Apr 24 i ii i   i  iii   i  i  i  i   `* Re: Command Languages Versus Programming Languages3David Brown
10 Apr 24 i ii i   i  iii   i  i  i  i    `* Re: Command Languages Versus Programming Languages2Lawrence D'Oliveiro
10 Apr 24 i ii i   i  iii   i  i  i  i     `- Re: Command Languages Versus Programming Languages1Kaz Kylheku
9 Apr 24 i ii i   i  iii   i  i  i  `- Re: Command Languages Versus Programming Languages1Kaz Kylheku
6 Apr 24 i ii i   i  iii   i  i  +* Re: Command Languages Versus Programming Languages3Kaz Kylheku
6 Apr 24 i ii i   i  iii   i  i  i`* Re: Command Languages Versus Programming Languages2David Brown
6 Apr 24 i ii i   i  iii   i  i  i `- Re: Command Languages Versus Programming Languages1Muttley
6 Apr 24 i ii i   i  iii   i  i  +- Re: Command Languages Versus Programming Languages1candycanearter07
6 Apr 24 i ii i   i  iii   i  i  `* Re: Command Languages Versus Programming Languages26Muttley
7 Apr 24 i ii i   i  iii   i  i   +* Re: Command Languages Versus Programming Languages22Alan Bawden
8 Apr 24 i ii i   i  iii   i  i   i`* Re: Command Languages Versus Programming Languages21Muttley
8 Apr 24 i ii i   i  iii   i  i   i `* Re: Command Languages Versus Programming Languages20David Brown
8 Apr 24 i ii i   i  iii   i  i   i  `* Re: Command Languages Versus Programming Languages19Muttley
8 Apr 24 i ii i   i  iii   i  i   i   +* Words to the wise (Was: Command Languages Versus Programming Languages)2Kenny McCormack
8 Apr 24 i ii i   i  iii   i  i   i   i`- Re: Words to the wise (Was: Command Languages Versus Programming Languages)1Muttley
8 Apr 24 i ii i   i  iii   i  i   i   `* Re: Command Languages Versus Programming Languages16Kaz Kylheku
8 Apr 24 i ii i   i  iii   i  i   i    +* Phrases that should be banned on Usenet (Was: Command Languages Versus Programming Languages)9Kenny McCormack
9 Apr 24 i ii i   i  iii   i  i   i    i`* Re: Phrases that should be banned on Usenet (Was: Command Languages Versus Programming Languages)8Janis Papanagnou
9 Apr 24 i ii i   i  iii   i  i   i    i +- Re: Phrases that should be banned on Usenet (Was: Command Languages Versus Programming Languages)1D
9 Apr 24 i ii i   i  iii   i  i   i    i `* Re: Phrases that should be banned on Usenet (Was: Command Languages Versus Programming Languages)6candycanearter07
9 Apr 24 i ii i   i  iii   i  i   i    i  `* Re: Phrases that should be banned on Usenet (Was: Command Languages Versus Programming Languages)5Janis Papanagnou
9 Apr 24 i ii i   i  iii   i  i   i    i   +- Re: Phrases that should be banned on Usenet (Was: Command Languages Versus Programming Languages)1candycanearter07
10 Apr 24 i ii i   i  iii   i  i   i    i   `* Re: Phrases that should be banned on Usenet (Was: Command Languages Versus Programming Languages)3Lawrence D'Oliveiro
10 Apr 24 i ii i   i  iii   i  i   i    i    +- Re: Phrases that should be banned on Usenet (Was: Command Languages Versus Programming Languages)1Chris Elvidge
10 Apr 24 i ii i   i  iii   i  i   i    i    `- Re: Phrases that should be banned on Usenet (Was: Command Languages Versus Programming Languages)1candycanearter07
9 Apr 24 i ii i   i  iii   i  i   i    `* Re: Command Languages Versus Programming Languages6Muttley
8 Apr 24 i ii i   i  iii   i  i   +- [meta] Re: Command Languages Versus Programming Languages1Janis Papanagnou
10 Apr 24 i ii i   i  iii   i  i   `* Re: Command Languages Versus Programming Languages2Keith Thompson
5 Apr 24 i ii i   i  iii   i  `* Re: Command Languages Versus Programming Languages46Janis Papanagnou
3 Apr 24 i ii i   i  iii   `* Re: Command Languages Versus Programming Languages4David Brown
2 Apr 24 i ii i   i  ii`- Re: Command Languages Versus Programming Languages1Kaz Kylheku
2 Apr 24 i ii i   i  i`- Re: Command Languages Versus Programming Languages1Kaz Kylheku
2 Apr 24 i ii i   i  `* Re: Command Languages Versus Programming Languages20Lawrence D'Oliveiro
1 Apr 24 i ii i   `- Re: Command Languages Versus Programming Languages1Lawrence D'Oliveiro
1 Apr 24 i ii `- Re: Command Languages Versus Programming Languages1Andreas Eder
29 Mar 24 i i+- Re: Command Languages Versus Programming Languages1Christian Weisgerber
30 Mar 24 i i+* Re: Command Languages Versus Programming Languages2David Brown
30 Sep 24 i i`- Re: Command Languages Versus Programming Languages1Bozo User
29 Mar 24 i `- Re: Command Languages Versus Programming Languages1Kaz Kylheku
29 Mar 24 +* Re: Command Languages Versus Programming Languages451Johanne Fairchild
29 Mar 24 +* Re: Command Languages Versus Programming Languages2David Brown
30 Mar 24 +* Re: Command Languages Versus Programming Languages3Dmitry A. Kazakov
30 Sep 24 `* Re: Command Languages Versus Programming Languages4Bozo User

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal