• Re: Isn't that beauty ?

    From Bonita Montero@3:633/10 to All on Thu Mar 12 08:36:45 2026
    Fucking autocompletion of group names.

    Am 12.03.2026 um 07:24 schrieb Bonita Montero:
    There was a programming-"contest" on comp.lang.c and I wanted to show
    the simpler code in C, here it is:

    #include <iostream>
    #include <sstream>
    #include <iomanip>
    #include <optional>
    #include <algorithm>

    using namespace std;

    static optional<size_t> parse( const char *str );

    int main( int argc, char **argv )
    {
    ’’’’if( argc < 3 )
    ’’’’’’’ return EXIT_FAILURE;
    ’’’’optional<size_t>
    ’’’’’’’ pRows = parse( argv[1] ),
    ’’’’’’’ pCols = parse( argv[2] );
    ’’’’if( !pRows || !pCols )
    ’’’’’’’ return EXIT_FAILURE;
    ’’’’size_t rows = *pRows, cols = *pCols;
    ’’’’optional<size_t> pClip( rows * cols );
    ’’’’if( argc >= 4 && !(pClip = parse( argv[3] )) )
    ’’’’’’’ return EXIT_FAILURE;
    ’’’’size_t clip = min( *pClip, rows * cols );
    ’’’’streamsize width = (ostringstream() << clip).str().length();
    ’’’’for( size_t row = 1; row <= min( rows, clip ); ++row )
    ’’’’{
    ’’’’’’’ bool head = true;
    ’’’’’’’ for( size_t value = row; value <= clip; value += rows, head =
    false )
    ’’’’’’’’’’’ cout << " "sv.substr( head, !head ) << right <<
    setw( width ) << value;
    ’’’’’’’ cout << endl;
    ’’’’}
    }

    static optional<size_t> parse( const char *str )
    {
    ’’’’istringstream iss( str );
    ’’’’size_t ret;
    ’’’’iss >> ret;
    ’’’’if( !iss || !iss.eof() )
    ’’’’’’’ return nullopt;
    ’’’’return ret;
    }

    C++ really rocks since you've to deal with much less details than in C.



    --- PyGate Linux v1.5.12
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Thu Mar 12 11:36:35 2026
    Am 12.03.2026 um 09:32 schrieb Janis Papanagnou:

    Concerning your subject; it wouldn't appear to me to use the term
    "beauty" in context of C++. C++ inherited so much ugly syntax and
    concepts (from "C") and it added yet more syntactic infelicities.
    (And I'm saying that as someone who liked to program in C++, also professionally, for many many years.)

    My perception of beauty is just as subjective as your perception of the
    ugly aspects of C++. I like the span of lowleven means in C++ that are inherited from C to higher level abstractions C++ has inherited from
    other more moderrn language.
    And if you don't the subjektive part of beauty or ugly parts of this
    language C++ is several times more effective than C, i.e. you need
    only a fraction of the code size while mostly maintaining the same
    performance.

    --- PyGate Linux v1.5.12
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Thu Mar 12 20:15:29 2026
    On 12.03.26 11:36, Bonita Montero wrote:
    Am 12.03.2026 um 09:32 schrieb Janis Papanagnou:

    Concerning your subject; it wouldn't appear to me to use the term
    "beauty" in context of C++. C++ inherited so much ugly syntax and
    concepts (from "C") and it added yet more syntactic infelicities.
    (And I'm saying that as someone who liked to program in C++, also
    professionally, for many many years.)

    My perception of beauty is just as subjective as your perception of the
    ugly aspects of C++. I like the span of lowleven means in C++ that are inherited from C to higher level abstractions C++ has inherited from
    other more moderrn language.

    Or even from older languages, like classes and inheritance from Simula, type-safety (string type checking) as provided by many older langauges, functional principles (cf. STL) from functional languages, and whatnot.

    And if you don't the subjektive part of beauty or ugly parts of this
    language C++ is several times more effective than C, i.e. you need
    only a fraction of the code size while mostly maintaining the same performance.

    Yes, I have agreed on that part, what you functionally get with C++.

    Concerning the terms beauty and ugliness being subjective is obvious.

    I was particularly speaking about syntax. - If you happen to know a
    sufficient set of (modern or historic) languages - and I have no
    reason to believe you haven't - you can observe that there are many
    languages that are _a lot_ clearer designed than C++, and much safer
    to use. Languages where the time span from design to a running system
    is much shorter than in a language where it's easy to make subtle or
    blatant errors.

    You mentioned an IMO noteworthy specific aspect of C++; you seem to
    like the low-to-high-level option. - Myself I also like both levels
    to program in, depending on the application area. - But I consider
    it a problem if the syntax and semantics of the inherited low-level
    language taints the abstract concepts of a language. Personally I'd
    prefer here a readable and powerful high level language with an
    *interface* to connect arbitrary code from low-level languages. IMO
    there's no need to do all levels in one language. And there are also
    existing paragons that support that language design principle.

    Janis


    --- PyGate Linux v1.5.12
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)