🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

177 total messages Page 3 of 4 Started by fir Sun, 22 Nov 2026 13:03
Page 3 of 4 • 177 total messages
Re: C and its peasant 'ancestors'
#1929
Author: Michael S
Date: Sat, 28 Nov 2026 18:13
36 lines
2748 bytes
On Sat, 28 Nov 2026 12:26:54 -0000 (UTC)
cross@spitfire.i.gajendra.net (Dan Cross) wrote:

> In article <11eds8o$2ahsb$2@raubtier-asyl.eternal-september.org>,
> Bonita Montero  <Bonita.Montero@gmail.com> wrote:
> >Am 28.11.2026 um 06:50 schrieb Lawrence D’Oliveiro:
> >  
> >> It *is* strongly-typed, and compiled.  
> >
> >Python is weakly typed.
> >Type annotations aren't enforced by the compiler.  
> 
> Lawrence is an idiot, but he's right about this.   Python
> is _strongly_ typed, but it is not _statically_ typed.
> 
> 	- Dan C.
> 

Weak or strong - it's not very important in practice.
That is, it is important that in python all type errors are caught.
Eventually. During execution of statements in question.  Unless hidden
by one or another sort of polymorphism.
But then again, 95% of such errors are caught at during execution even
in C (I am not talking about out-of-bound accesses, those are a
separate battle), at least as long a C is running on platform with
memory protection.
Yes, %5 matter, and knowing about 100% gives python programmer a warm
feeling, but more so in theory than in practice.

On the other hand, the fact that at compile time (or pre-compile time, I
don't know official term) Python catches very few type errors (if at
all) is very important in practice, although much more so for big
programs than for small ones.

Re: C and its peasant 'ancestors'
#1930
Author: Michael S
Date: Sat, 28 Nov 2026 18:18
110 lines
5888 bytes
On Sat, 28 Nov 2026 18:12:36 +0000
bartc <bc@freeuk.com> wrote:

> On 28/11/2026 16:31, Bonita Montero wrote:
> > Am 28.11.2026 um 16:28 schrieb bartc:
> >   
> >> Yet every example of C++ you've ever posted is always an
> >> unreadable, ugly mess of syntax.  
> > 
> > A very disordered opinion.
> >   
> >> Not all that is the fault of the language - you seem to delight in 
> >> using every obscure feature possible and have nested functions 
> >> everywhere.  
> > 
> > C++-developers understand my code since they're more skilled like
> > you.  
> 
> It's not a skills issue. The language as used like this is several
> times more complex than is needed.
> 
> 
> >> Below is a recent post of yours about sorting in C++. It took me a 
> >> while to realise it was actually testing two kinds of sort!  
> > 
> > I don't know why this should be hard to understand.
> > Maybe it's beyond your capabilities.  
> 
> Because it's a ******* mess. Here's a function you created simply for 
> copying one array to another:
> 
>     auto cpy = [&] { copy( origin.begin(), origin.end(), srt.begin()
> ); dummy += srt[0]; };
> 
> 37 tokens. Here is what I used:
> 
>    sdata := data
> 
> 3 tokens, and no functions. Even C needs only 12 tokens:
> 
>    memcpy(sdata, data, sizeof(data));
> 
> It's also ironic in that you go on about having to implement stuff in
> C that is provided in C++, yet you have to write your own vector copy?
> 
> Would 'src = origin' work, and if so why not just use it?
> 
> You just want to use as many toys as possible for no reason.
> 

Here I agree.

> 
> >> As for timings, then for 10000 sorts of 4096 random integers in
> >> the i32 range, they were:
> >>
> >>   C++/g++-O3 qsrt      3.5 seconds
> >>   C++/g++-O3 stdsort   1.5 seconds
> >>   My lang              2.5 seconds
> >>   C/gcc-O2             2.5 seconds
> >>   C/bcc                2.5 seconds  
> > 
> > As I said you can be on par with std::sort(),  
> 
> Why is your qsrt 40% slower than the most basic version in C?
> 
>  > but it makes a lot of work> since you've to implement the
>  > quicksort   
> yourself; including all optimi-
> > zations beyond the "homework-solution".  
> 
> I'm sure somebody has already written an optimised sort routine in C, 
> you just have to find it. Google-AI gave me a fast version of
> quicksort, and that has timing of 1.8 seconds the for the above task.
> 
> That's 20% slower than your stdsort. But if I tweak the task, so I
> sort 64K numbers 1000 times, then optimised C is 14% faster then
> optimised C++/stdsort.
> 
> 
> 
> 
> >> However, this is what happens when optimisation is turned off in
> >> all cases (in my tools, that just means locals stay in memory):
> >>
> >>   C++/g++-O0 qsrt      7.0 seconds
> >>   C++/g++-O0 stdsort  16.8 seconds
> >>   My lang -no          3.7 seconds
> >>   C/gcc-O0             4.0 seconds
> >>   C/bcc -no            4.0 seconds
> >> Now C++'s stdsort is more than twice as slow as your qsrt! And 4
> >> times as slow as that 'isort' in C.
> >> So unoptimised C++ is slower than a scripting language!  
> 
> > Where's the problem ?  
> 
> One problem is that compiling this 60-line C++ program took 2.6
> seconds, but compiling the now-90-line C version took 0.025 seconds
> (100 times faster).
> 
> This is with my non-optimising compiler, but it was still slightly 
> faster than C++ sort for N=64K (4.7s vs 4.8s).

Here I disagree.
std::sort is not just fast. It is also more convinient.



Re: C and its peasant 'ancestors'
#1931
Author: fir
Date: Sat, 28 Nov 2026 18:24
61 lines
3985 bytes
bartc pisze:
> I'm sure somebody has already written an optimised sort routine in C, 
> you just have to find it. Google-AI gave me a fast version of quicksort, 
> and that has timing of 1.8 seconds the for the above task.

here it is

typedef          int  I32;
typedef unsigned int UI32;

I32 * RadixSortSigned(I32 * pData, I32 * pTemp, size_t count)
{
size_t mIndex[4][256] = {0};            // index matrix
UI32 *pDst, *pSrc, *pTmp;
size_t i,j,m,n;
UI32 u;

     for(i = 0; i < count; i++){         // generate histograms
         u = pData[i];
         for(j = 0; j < 4; j++){
             if(j != 3)                  //  signed integer handling
                 mIndex[j][(size_t)(u & 0xff)]++;
             else
                 mIndex[j][(size_t)((u^0x80) & 0xff)]++;
             u >>= 8;
         }
     }
     for(j = 0; j < 4; j++){             // convert to indices
         n = 0;
         for(i = 0; i < 256; i++){
             m = mIndex[j][i];
             mIndex[j][i] = n;
             n += m;
         }
     }
     pDst = (UI32 *)pTemp;               // radix sort
     pSrc = (UI32 *)pData;
     for(j = 0; j < 4; j++){
         for(i = 0; i < count; i++){
             u = pSrc[i];
             if(j != 3)                  //  signed integer handling
                 m = (size_t)(u >> (j<<3)) & 0xff;
             else
                 m = (size_t)((u >> (j<<3))^0x80) & 0xff;
             pDst[mIndex[j][m]++] = u;
         }
         pTmp = pSrc;
         pSrc = pDst;
         pDst = pTmp;
     }
     return((I32 *)pSrc);
}

i not bother to test it now but when i measured few this years ago
it was beating c++ sort like four times (c++ sort 111 ms afair
and this (or its unsigned version) about 27 ms afair)

bonita claiming c++ be so good and stright pice of good c shows
its 4x times slower ;C

its absolutely brain devastating user
Re: C and its peasant 'ancestors'
#1932
Author: Kaz Kylheku
Date: Sat, 28 Nov 2026 18:30
45 lines
3509 bytes
On 2026-11-28, bartc <bc@freeuk.com> wrote:
> On 28/11/2026 16:31, Bonita Montero wrote:
>> Am 28.11.2026 um 16:28 schrieb bartc:
>> 
>>> Yet every example of C++ you've ever posted is always an unreadable, 
>>> ugly mess of syntax.
>> 
>> A very disordered opinion.
>> 
>>> Not all that is the fault of the language - you seem to delight in 
>>> using every obscure feature possible and have nested functions 
>>> everywhere.
>> 
>> C++-developers understand my code since they're more skilled like you.
>
> It's not a skills issue. The language as used like this is several times 
> more complex than is needed.

A program that uses every single feature of C++26 will be completely
understood by probably fewer than ten people on the planet, all of them
involved the process of making C++ ever more complex.

Everyone else looking at the program will have to study the ISO standard
and related references, white papers and whatnot; or maybe ask AI
questions.

The C++ features don't all have nice keywords attached that you could
look up in an alphabetical index.

Case in point:

>     auto cpy = [&] { copy( origin.begin(), origin.end(), srt.begin() ); 
> dummy += srt[0]; };

[ and & have multiple meanings, so even if these symbols appear in an
index before the letter A, you will likely have to go down a few rabbit
holes before hitting on the answer.

Whereas a nice Lisp language that has a "lambda" keyword will have
direct, relevant references under "L".

-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
Re: C and its peasant 'ancestors'
#1933
Author: Scott Lurndal
Date: Sat, 28 Nov 2026 18:47
28 lines
2443 bytes
Lawrence =?iso-8859-13?q?D=FFOliveiro?= <ldo@nz.invalid> writes:
>On Thu, 26 Nov 2026 12:48:26 +0100, Bonita Montero wrote:
>
>> Am 26.11.2026 um 12:36 schrieb fir:
>>
>>> 1. the bloat of terrible c++ syntax (oop and those generix and
>>> those all other non sane additions)
>>
>> It’s only "bloat" if you aren’t up to the task of handling it. I
>> actually find C to be much more bloated, because the things you end
>> up having to do alongside C++ often require a significant amount of
>> real work.
>
>Would you like to take the Linus Torvalds challenge? He famously hates
>C++, and won’t allow it into the Linux kernel.

I've worked on a full scale, massively parallel operating
system and a distributed virtual machine manager, both written
in C++ very successfully.

Of course, one must carefully choose _which_ C++ features
are used (limited use of templates, no exceptions, no RTTI
very limited STL (which didn't exist when the OS project
started in 1989) for optimal performance.

C with classes isn't a bad description - one receives all the
benefits of data hiding and inheritance provided by the class paradigm without
the overhead required for stack unwinding and dynamic_cast<>.
Re: C and its peasant 'ancestors'
#1934
Author: Scott Lurndal
Date: Sat, 28 Nov 2026 18:49
16 lines
1776 bytes
Bonita Montero <Bonita.Montero@gmail.com> writes:
>Am 28.11.2026 um 16:28 schrieb bartc:
>
>> Yet every example of C++ you've ever posted is always an unreadable, 
>> ugly mess of syntax.
>
>A very disordered opinion.
>
>> Not all that is the fault of the language - you seem to delight in using 
>> every obscure feature possible and have nested functions everywhere.
>
>C++-developers understand my code since they're more skilled like you.

That's a bullshit argument.   A _good_ programmer writes maintainable
code.
Re: C and its peasant 'ancestors'
#1935
Author: fir
Date: Sat, 28 Nov 2026 18:53
162 lines
6422 bytes
fir pisze:
> bartc pisze:
>> I'm sure somebody has already written an optimised sort routine in C, 
>> you just have to find it. Google-AI gave me a fast version of 
>> quicksort, and that has timing of 1.8 seconds the for the above task.
> 
> here it is
> 
> typedef          int  I32;
> typedef unsigned int UI32;
> 
> I32 * RadixSortSigned(I32 * pData, I32 * pTemp, size_t count)
> {
> size_t mIndex[4][256] = {0};            // index matrix
> UI32 *pDst, *pSrc, *pTmp;
> size_t i,j,m,n;
> UI32 u;
> 
>      for(i = 0; i < count; i++){         // generate histograms
>          u = pData[i];
>          for(j = 0; j < 4; j++){
>              if(j != 3)                  //  signed integer handling
>                  mIndex[j][(size_t)(u & 0xff)]++;
>              else
>                  mIndex[j][(size_t)((u^0x80) & 0xff)]++;
>              u >>= 8;
>          }
>      }
>      for(j = 0; j < 4; j++){             // convert to indices
>          n = 0;
>          for(i = 0; i < 256; i++){
>              m = mIndex[j][i];
>              mIndex[j][i] = n;
>              n += m;
>          }
>      }
>      pDst = (UI32 *)pTemp;               // radix sort
>      pSrc = (UI32 *)pData;
>      for(j = 0; j < 4; j++){
>          for(i = 0; i < count; i++){
>              u = pSrc[i];
>              if(j != 3)                  //  signed integer handling
>                  m = (size_t)(u >> (j<<3)) & 0xff;
>              else
>                  m = (size_t)((u >> (j<<3))^0x80) & 0xff;
>              pDst[mIndex[j][m]++] = u;
>          }
>          pTmp = pSrc;
>          pSrc = pDst;
>          pDst = pTmp;
>      }
>      return((I32 *)pSrc);
> }
> 
> i not bother to test it now but when i measured few this years ago
> it was beating c++ sort like four times (c++ sort 111 ms afair
> and this (or its unsigned version) about 27 ms afair)
> 
> bonita claiming c++ be so good and stright pice of good c shows
> its 4x times slower ;C
> 
> its absolutely brain devastating user

or maybe i tale this pain
(in recent times i become lazy and sadly i dont want to go in depth in 
some codes..probably getting old)

measured it as i found in in old framework - pieces of those test

void RunFrame(int advance)
{
    InitialiseRomTab();
   // printf("\n initialised SUM = %d", CalculateSum());

    ClearFrameData(0x000080);

   if(!q_pressed)
   {
      CopyTab();

        std::vector<int> myvector (tab, tab+tab_max);
        std::sort (myvector.begin(), myvector.begin() + tab_max);

///     printf("\n 11SUM = %d", CalculateSum());
   }
   else
   {
      CopyTab();

      RadixSortSigned((int*)tab, ( int*)tab2, tab_max);

   /////     printf("\n 22SUM = %d", CalculateSum2());

   ////   printf("\n 21SUM = %d", CalculateSum());


   }

const int tab_max = 1000*1000;

  int tab2[tab_max];
int tab[tab_max];



unsigned GenerateRand32bits()
{
       unsigned a1 = (rand()&0xfff)<<20;
       unsigned a2 = (rand()&0xfff)<<8;
       unsigned a3 = (rand()&0xff);
       return a1+a2+a3;
}

void InitialiseRomTab()
{
     static int initialised =0;
     if(initialised) return;
     initialised = 1;

     for(int i=0; i<tab_max; i++)
     {
       tab_rom[i] = GenerateRand32bits();
        //tab_rom[i] = rand()%10000;
     }
}

void CopyTab()
{
     for(int i=0; i<tab_max; i++)
     {
       tab[i] = tab_rom[i];
     }

}


int CalculateSum()
{
   int sum = 0;

   for(int i=0; i<tab_max; i++)
     sum +=tab[i];

   return sum;

}

int CalculateSum2()
{
   int sum = 0;

   for(int i=0; i<tab_max; i++)
     sum +=tab2[i];

   return sum;

}

std lib c++ 71 ms and my c radix srt (taken from net 14 ms)
differences in sole sorting are even bigger becouse i measure whole 
frame data in my framework and clear frame + copy tab take
some time though its not much probbaly about 1 ms
Re: C and its peasant 'ancestors'
#1936
Author: Bonita Montero
Date: Sat, 28 Nov 2026 19:13
49 lines
3904 bytes
Am 28.11.2026 um 19:12 schrieb bartc:

> It's not a skills issue. The language as used like this is several times 
> more complex than is needed.

You're overburdened.
>     auto cpy = [&] { copy( origin.begin(), origin.end(), srt.begin() ); 
> dummy += srt[0]; };
> 
> 37 tokens. Here is what I used:
> 
>    sdata := data
> 
> 3 tokens, and no functions. Even C needs only 12 tokens:
> 
>    memcpy(sdata, data, sizeof(data));

copy() works with iterators. Iterators have bounds checking while
debugging. Therefore I prefer copy() over memcpy(). The compiler
replaces this with memcpy() on itself with optimized builds.
I put this into a lambda since I needed it three times and I like
to save redundant code with that.
Understood ?

>>>   C++/g++-O3 qsrt      3.5 seconds
>>>   C++/g++-O3 stdsort   1.5 seconds
>>>   My lang              2.5 seconds
>>>   C/gcc-O2             2.5 seconds
>>>   C/bcc                2.5 seconds
>>
>> As I said you can be on par with std::sort(),
> 
> Why is your qsrt 40% slower than the most basic version in C?

Mine is 1.5 seconds and the fastest.

> I'm sure somebody has already written an optimised sort routine in C, 
> you just have to find it. Google-AI gave me a fast version of quicksort, 
> and that has timing of 1.8 seconds the for the above task.

std::sort is highly optimized through functional programming by making
the sort-lambda inline. The swap-operation std::sort uses is also much
faster than swapping through a memcpy().

> One problem is that compiling this 60-line C++ program took 2.6 seconds, 
> but compiling the now-90-line C version took 0.025 seconds (100 times 
> faster).

I use C++20 modules, so this doesn't matter for me.
Re: C and its peasant 'ancestors'
#1937
Author: Bonita Montero
Date: Sat, 28 Nov 2026 19:17
48 lines
3637 bytes
Am 28.11.2026 um 19:24 schrieb fir:

> bartc pisze:

>> I'm sure somebody has already written an optimised sort routine in C, 
>> you just have to find it. Google-AI gave me a fast version of 
>> quicksort, and that has timing of 1.8 seconds the for the above task.

> here it is
Here's the C++-version:

#include <vector>
#include <algorithm>
#include <array>

template<unsigned Base = 10, std::forward_iterator ForwardIt>
	requires (Base > 1) && std::unsigned_integral<std::iter_value_t<ForwardIt>>
void radix_sort(ForwardIt begin, ForwardIt end) {
     using namespace std;

	if(begin == end)
         return;

     using uint_t = iter_value_t<ForwardIt>;
     uint_t max = *max_element(begin, end);
     array<vector<uint_t>, Base> partitions;
     uint_t factor, nextFactor = 1;

	do {
         factor = nextFactor;

         for(ForwardIt it = begin; it != end; ++it)
             partitions[*it / factor % Base].emplace_back(*it);

         for(ForwardIt it = begin; vector<uint_t> &vec: partitions) {
             it = copy(vec.begin(), vec.end(), it);
             vec.clear();
		}
	} while((nextFactor = factor * Base) / Base == factor && nextFactor <= 
max);
}

Works with any integer type, the radix is a configurable constant,
works with any forward-iterator, i. e. with a lot of containers.
That's much more than C allows.
Nevertheless radixsort applies only to integers and special
distributions; otherwise it sucks, or more precisely: mostly.
Re: C and its peasant 'ancestors'
#1938
Author: Bonita Montero
Date: Sat, 28 Nov 2026 19:20
21 lines
2978 bytes
Am 28.11.2026 um 19:30 schrieb Kaz Kylheku:

> A program that uses every single feature of C++26 will be completely
> understood by probably fewer than ten people on the planet, all of them
> involved the process of making C++ ever more complex.
> 
> Everyone else looking at the program will have to study the ISO standard
> and related references, white papers and whatnot; or maybe ask AI
> questions.

You can learn the essentials from half a dozen books. For any specific
questions, there’s cppreference.com.

>>      auto cpy = [&] { copy( origin.begin(), origin.end(), srt.begin() );
>> dummy += srt[0]; };

> [ and & have multiple meanings, so even if these symbols appear in an
> index before the letter A, you will likely have to go down a few rabbit
> holes before hitting on the answer.

Where's the problem ???
Re: C and its peasant 'ancestors'
#1939
Author: David Brown
Date: Sat, 28 Nov 2026 19:27
100 lines
5934 bytes
On 28/11/2026 19:18, Michael S wrote:
> On Sat, 28 Nov 2026 18:12:36 +0000
> bartc <bc@freeuk.com> wrote:
> 
>> On 28/11/2026 16:31, Bonita Montero wrote:
>>> Am 28.11.2026 um 16:28 schrieb bartc:
>>>    
>>>> Yet every example of C++ you've ever posted is always an
>>>> unreadable, ugly mess of syntax.
>>>
>>> A very disordered opinion.
>>>    
>>>> Not all that is the fault of the language - you seem to delight in
>>>> using every obscure feature possible and have nested functions
>>>> everywhere.
>>>
>>> C++-developers understand my code since they're more skilled like
>>> you.
>>
>> It's not a skills issue. The language as used like this is several
>> times more complex than is needed.
>>
>>
>>>> Below is a recent post of yours about sorting in C++. It took me a
>>>> while to realise it was actually testing two kinds of sort!
>>>
>>> I don't know why this should be hard to understand.
>>> Maybe it's beyond your capabilities.
>>
>> Because it's a ******* mess. Here's a function you created simply for
>> copying one array to another:
>>
>>      auto cpy = [&] { copy( origin.begin(), origin.end(), srt.begin()
>> ); dummy += srt[0]; };
>>
>> 37 tokens. Here is what I used:
>>
>>     sdata := data
>>
>> 3 tokens, and no functions. Even C needs only 12 tokens:
>>
>>     memcpy(sdata, data, sizeof(data));
>>
>> It's also ironic in that you go on about having to implement stuff in
>> C that is provided in C++, yet you have to write your own vector copy?
>>
>> Would 'src = origin' work, and if so why not just use it?
>>
>> You just want to use as many toys as possible for no reason.
>>
> 
> Here I agree.

Except, bizarrely, the useful ones.  Vectors in C++ can be copied by 
assignment.  A vector can be sorted with "std::ranges::sort(srt);".  If 
Bonita had intentionally tried to write ugly, messy C++ code, it would 
be hard to get worse.

>>
>>
>>>> However, this is what happens when optimisation is turned off in
>>>> all cases (in my tools, that just means locals stay in memory):

Timings without using standard available toolchain optimisations are 
useless - regardless of the compiler or language.  (That does not 
detract from it being nice that Bart's languages are pretty fast - but 
it is dishonest to compare the speed of generated code while crippling 
the tools' abilities to generate fast code.)

>>
>> This is with my non-optimising compiler, but it was still slightly
>> faster than C++ sort for N=64K (4.7s vs 4.8s).
> 
> Here I disagree.
> std::sort is not just fast. It is also more convinient.
> 

Yes.  Bonita's code misses all the benefits of C++ sort.  The point of 
C++'s sort is that the same function template works for any container 
(as long as you can access the elements in any order), any contained 
type, any comparison function, any special requirements for swapping.

And it generates code that is fine-tuned to the types involved, and to 
the size of the container being sorted.  This is especially apparent for 
small fixed-size containers, with inlined near-optimal code rather than 
generic pre-compiled library code that swaps between different sorting 
algorithms at runtime depending on sizes.

Being able to handle type-specific comparison and swapping is very 
convenient if you have more interesting data structures - like string 
types that hold some data directly (like length, and a pointer to the 
string data).  These things can be more efficient, and easier to get 
correct, when the generated code takes the types into account instead of 
using generic memmove and memcmp type operations.  (Of course you can 
always write your own manual sort functions in other languages - as Bart 
did with his "isort" function - but it is very nice to get it 
pre-written by the language and standard library.


Re: C and its peasant 'ancestors'
#1940
Author: fir
Date: Sat, 28 Nov 2026 19:28
64 lines
4474 bytes
Bonita Montero pisze:
> Am 28.11.2026 um 19:24 schrieb fir:
> 
>> bartc pisze:
> 
>>> I'm sure somebody has already written an optimised sort routine in C, 
>>> you just have to find it. Google-AI gave me a fast version of 
>>> quicksort, and that has timing of 1.8 seconds the for the above task.
> 
>> here it is
> Here's the C++-version:
> 
> #include <vector>
> #include <algorithm>
> #include <array>
> 
> template<unsigned Base = 10, std::forward_iterator ForwardIt>
>      requires (Base > 1) && 
> std::unsigned_integral<std::iter_value_t<ForwardIt>>
> void radix_sort(ForwardIt begin, ForwardIt end) {
>      using namespace std;
> 
>      if(begin == end)
>          return;
> 
>      using uint_t = iter_value_t<ForwardIt>;
>      uint_t max = *max_element(begin, end);
>      array<vector<uint_t>, Base> partitions;
>      uint_t factor, nextFactor = 1;
> 
>      do {
>          factor = nextFactor;
> 
>          for(ForwardIt it = begin; it != end; ++it)
>              partitions[*it / factor % Base].emplace_back(*it);
> 
>          for(ForwardIt it = begin; vector<uint_t> &vec: partitions) {
>              it = copy(vec.begin(), vec.end(), it);
>              vec.clear();
>          }
>      } while((nextFactor = factor * Base) / Base == factor && nextFactor 
> <= max);
> }
> 
> Works with any integer type, the radix is a configurable constant,
> works with any forward-iterator, i. e. with a lot of containers.
> That's much more than C allows.
> Nevertheless radixsort applies only to integers and special
> distributions; otherwise it sucks, or more precisely: mostly.
> 
you suck comparing qsort which takes callbask nobody except maybe child 
that learns programming would use it (by nobody i mean no serious normal 
c programmer)

btw the qusort with stub of insert sort i once wrote (it took me not 
much like half a day without a lot of testing) take 74 ms when std c++ 
sort 71 ms so both suck

good c programmer as im an example take radix sort and has 14 ms
lame bonita takes qsort and c++ stdosort

btw if youre measuring milisceond how fast that radix sort
was? you may give resolt for c++ and normal c
Re: C and its peasant 'ancestors'
#1941
Author: fir
Date: Sat, 28 Nov 2026 19:32
166 lines
6978 bytes
fir pisze:
> fir pisze:
>> bartc pisze:
>>> I'm sure somebody has already written an optimised sort routine in C, 
>>> you just have to find it. Google-AI gave me a fast version of 
>>> quicksort, and that has timing of 1.8 seconds the for the above task.
>>
>> here it is
>>
>> typedef          int  I32;
>> typedef unsigned int UI32;
>>
>> I32 * RadixSortSigned(I32 * pData, I32 * pTemp, size_t count)
>> {
>> size_t mIndex[4][256] = {0};            // index matrix
>> UI32 *pDst, *pSrc, *pTmp;
>> size_t i,j,m,n;
>> UI32 u;
>>
>>      for(i = 0; i < count; i++){         // generate histograms
>>          u = pData[i];
>>          for(j = 0; j < 4; j++){
>>              if(j != 3)                  //  signed integer handling
>>                  mIndex[j][(size_t)(u & 0xff)]++;
>>              else
>>                  mIndex[j][(size_t)((u^0x80) & 0xff)]++;
>>              u >>= 8;
>>          }
>>      }
>>      for(j = 0; j < 4; j++){             // convert to indices
>>          n = 0;
>>          for(i = 0; i < 256; i++){
>>              m = mIndex[j][i];
>>              mIndex[j][i] = n;
>>              n += m;
>>          }
>>      }
>>      pDst = (UI32 *)pTemp;               // radix sort
>>      pSrc = (UI32 *)pData;
>>      for(j = 0; j < 4; j++){
>>          for(i = 0; i < count; i++){
>>              u = pSrc[i];
>>              if(j != 3)                  //  signed integer handling
>>                  m = (size_t)(u >> (j<<3)) & 0xff;
>>              else
>>                  m = (size_t)((u >> (j<<3))^0x80) & 0xff;
>>              pDst[mIndex[j][m]++] = u;
>>          }
>>          pTmp = pSrc;
>>          pSrc = pDst;
>>          pDst = pTmp;
>>      }
>>      return((I32 *)pSrc);
>> }
>>
>> i not bother to test it now but when i measured few this years ago
>> it was beating c++ sort like four times (c++ sort 111 ms afair
>> and this (or its unsigned version) about 27 ms afair)
>>
>> bonita claiming c++ be so good and stright pice of good c shows
>> its 4x times slower ;C
>>
>> its absolutely brain devastating user
> 
> or maybe i tale this pain
> (in recent times i become lazy and sadly i dont want to go in depth in 
> some codes..probably getting old)
> 
> measured it as i found in in old framework - pieces of those test
> 
> void RunFrame(int advance)
> {
>     InitialiseRomTab();
>    // printf("\n initialised SUM = %d", CalculateSum());
> 
>     ClearFrameData(0x000080);
> 
>    if(!q_pressed)
>    {
>       CopyTab();
> 
>         std::vector<int> myvector (tab, tab+tab_max);
>         std::sort (myvector.begin(), myvector.begin() + tab_max);
> 
> ///     printf("\n 11SUM = %d", CalculateSum());
>    }
>    else
>    {
>       CopyTab();
> 
>       RadixSortSigned((int*)tab, ( int*)tab2, tab_max);
> 
>    /////     printf("\n 22SUM = %d", CalculateSum2());
> 
>    ////   printf("\n 21SUM = %d", CalculateSum());
> 
> 
>    }
> 
> const int tab_max = 1000*1000;
> 
>   int tab2[tab_max];
> int tab[tab_max];
> 
> 
> 
> unsigned GenerateRand32bits()
> {
>        unsigned a1 = (rand()&0xfff)<<20;
>        unsigned a2 = (rand()&0xfff)<<8;
>        unsigned a3 = (rand()&0xff);
>        return a1+a2+a3;
> }
> 
> void InitialiseRomTab()
> {
>      static int initialised =0;
>      if(initialised) return;
>      initialised = 1;
> 
>      for(int i=0; i<tab_max; i++)
>      {
>        tab_rom[i] = GenerateRand32bits();
>         //tab_rom[i] = rand()%10000;
>      }
> }
> 
> void CopyTab()
> {
>      for(int i=0; i<tab_max; i++)
>      {
>        tab[i] = tab_rom[i];
>      }
> 
> }
> 
> 
> int CalculateSum()
> {
>    int sum = 0;
> 
>    for(int i=0; i<tab_max; i++)
>      sum +=tab[i];
> 
>    return sum;
> 
> }
> 
> int CalculateSum2()
> {
>    int sum = 0;
> 
>    for(int i=0; i<tab_max; i++)
>      sum +=tab2[i];
> 
>    return sum;
> 
> }
> 
> std lib c++ 71 ms and my c radix srt (taken from net 14 ms)
> differences in sole sorting are even bigger becouse i measure whole 
> frame data in my framework and clear frame + copy tab take
> some time though its not much probbaly about 1 ms

so to be clear what showed COMPETENT C of fir beat GENERIC BIGOTRY C++ 
of bonite exactly 5x
Re: C and its peasant 'ancestors'
#1942
Author: David Brown
Date: Sat, 28 Nov 2026 19:34
47 lines
3868 bytes
On 28/11/2026 19:47, Scott Lurndal wrote:
> Lawrence =?iso-8859-13?q?D=FFOliveiro?= <ldo@nz.invalid> writes:
>> On Thu, 26 Nov 2026 12:48:26 +0100, Bonita Montero wrote:
>>
>>> Am 26.11.2026 um 12:36 schrieb fir:
>>>
>>>> 1. the bloat of terrible c++ syntax (oop and those generix and
>>>> those all other non sane additions)
>>>
>>> It’s only "bloat" if you aren’t up to the task of handling it. I
>>> actually find C to be much more bloated, because the things you end
>>> up having to do alongside C++ often require a significant amount of
>>> real work.
>>
>> Would you like to take the Linus Torvalds challenge? He famously hates
>> C++, and won’t allow it into the Linux kernel.
> 
> I've worked on a full scale, massively parallel operating
> system and a distributed virtual machine manager, both written
> in C++ very successfully.
> 
> Of course, one must carefully choose _which_ C++ features
> are used (limited use of templates, no exceptions, no RTTI
> very limited STL (which didn't exist when the OS project
> started in 1989) for optimal performance.
> 
> C with classes isn't a bad description - one receives all the
> benefits of data hiding and inheritance provided by the class paradigm without
> the overhead required for stack unwinding and dynamic_cast<>.

There's a /lot/ more than just "C with classes" that is appropriate for 
low-level, bare metal and/or embedded programming in C++.  It is 
typically more a matter of what you want to avoid - dynamic memory, 
virtual functions (usually), exceptions, and anything else that has 
unexpected or unpredictable runtime costs.  I use a large number of C++ 
features in my small-systems embedded programming, but you do have to 
know what to avoid.  (I also avoid malloc/free and a number of other 
features and functions of C in embedded programming, but it is more 
obvious which should be avoided.)

To be fair, the C++ language and toolchains are far better suited to 
embedded programming than they were in 1989 !

(And they are getting better - there is progress being made specifically 
towards more features suitable for freestanding systems, such as 
inplace_vector.)
Re: C and its peasant 'ancestors'
#1943
Author: fir
Date: Sat, 28 Nov 2026 19:35
73 lines
4800 bytes
fir pisze:
> Bonita Montero pisze:
>> Am 28.11.2026 um 19:24 schrieb fir:
>>
>>> bartc pisze:
>>
>>>> I'm sure somebody has already written an optimised sort routine in 
>>>> C, you just have to find it. Google-AI gave me a fast version of 
>>>> quicksort, and that has timing of 1.8 seconds the for the above task.
>>
>>> here it is
>> Here's the C++-version:
>>
>> #include <vector>
>> #include <algorithm>
>> #include <array>
>>
>> template<unsigned Base = 10, std::forward_iterator ForwardIt>
>>      requires (Base > 1) && 
>> std::unsigned_integral<std::iter_value_t<ForwardIt>>
>> void radix_sort(ForwardIt begin, ForwardIt end) {
>>      using namespace std;
>>
>>      if(begin == end)
>>          return;
>>
>>      using uint_t = iter_value_t<ForwardIt>;
>>      uint_t max = *max_element(begin, end);
>>      array<vector<uint_t>, Base> partitions;
>>      uint_t factor, nextFactor = 1;
>>
>>      do {
>>          factor = nextFactor;
>>
>>          for(ForwardIt it = begin; it != end; ++it)
>>              partitions[*it / factor % Base].emplace_back(*it);
>>
>>          for(ForwardIt it = begin; vector<uint_t> &vec: partitions) {
>>              it = copy(vec.begin(), vec.end(), it);
>>              vec.clear();
>>          }
>>      } while((nextFactor = factor * Base) / Base == factor && 
>> nextFactor <= max);
>> }
>>
>> Works with any integer type, the radix is a configurable constant,
>> works with any forward-iterator, i. e. with a lot of containers.
>> That's much more than C allows.
>> Nevertheless radixsort applies only to integers and special
>> distributions; otherwise it sucks, or more precisely: mostly.
>>
> you suck comparing qsort which takes callbask nobody except maybe child 
> that learns programming would use it (by nobody i mean no serious normal 
> c programmer)
> 
> btw the qusort with stub of insert sort i once wrote (it took me not 
> much like half a day without a lot of testing) take 74 ms when std c++ 
> sort 71 ms so both suck
> 

i mean it took half a day rith testing..tu build some tool in c that 
take half a day and than you may use it for ears is not a big cost

(though as said poth c++ sort and handwritten qsory generally suck)


> good c programmer as im an example take radix sort and has 14 ms
> lame bonita takes qsort and c++ stdosort
> 
> btw if youre measuring milisceond how fast that radix sort
> was? you may give resolt for c++ and normal c
> 
Re: C and its peasant 'ancestors'
#1944
Author: Michael S
Date: Sat, 28 Nov 2026 20:15
59 lines
4311 bytes
On Sat, 28 Nov 2026 20:34:10 +0100
David Brown <david.brown@hesbynett.no> wrote:

> On 28/11/2026 19:47, Scott Lurndal wrote:
> > Lawrence =?iso-8859-13?q?D=FFOliveiro?= <ldo@nz.invalid> writes:  
> >> On Thu, 26 Nov 2026 12:48:26 +0100, Bonita Montero wrote:
> >>  
> >>> Am 26.11.2026 um 12:36 schrieb fir:
> >>>  
> >>>> 1. the bloat of terrible c++ syntax (oop and those generix and
> >>>> those all other non sane additions)  
> >>>
> >>> It’s only "bloat" if you aren’t up to the task of handling it. I
> >>> actually find C to be much more bloated, because the things you
> >>> end up having to do alongside C++ often require a significant
> >>> amount of real work.  
> >>
> >> Would you like to take the Linus Torvalds challenge? He famously
> >> hates C++, and won’t allow it into the Linux kernel.  
> > 
> > I've worked on a full scale, massively parallel operating
> > system and a distributed virtual machine manager, both written
> > in C++ very successfully.
> > 
> > Of course, one must carefully choose _which_ C++ features
> > are used (limited use of templates, no exceptions, no RTTI
> > very limited STL (which didn't exist when the OS project
> > started in 1989) for optimal performance.
> > 
> > C with classes isn't a bad description - one receives all the
> > benefits of data hiding and inheritance provided by the class
> > paradigm without the overhead required for stack unwinding and
> > dynamic_cast<>.  
> 
> There's a /lot/ more than just "C with classes" that is appropriate
> for low-level, bare metal and/or embedded programming in C++.  It is 
> typically more a matter of what you want to avoid - dynamic memory, 
> virtual functions (usually), exceptions, and anything else that has 
> unexpected or unpredictable runtime costs.  I use a large number of
> C++ features in my small-systems embedded programming, but you do
> have to know what to avoid.  (I also avoid malloc/free and a number
> of other features and functions of C in embedded programming, but it
> is more obvious which should be avoided.)
> 
> To be fair, the C++ language and toolchains are far better suited to 
> embedded programming than they were in 1989 !
> 
> (And they are getting better - there is progress being made
> specifically towards more features suitable for freestanding systems,
> such as inplace_vector.)
>

Try C in your next project.
You will be pleasantly surprised by productivity gain from using
simpler language. May be, less so during initial coding, more so during
later maintenance.
Re: C and its peasant 'ancestors'
#1945
Author: Keith Thompson
Date: Sat, 28 Nov 2026 20:27
26 lines
2628 bytes
Lawrence D’Oliveiro <ldo@nz.invalid> writes:
> On Sat, 28 Nov 2026 07:27:38 +0100, Bonita Montero wrote:
>> Am 28.11.2026 um 06:50 schrieb Lawrence D’Oliveiro:
>>> It *is* strongly-typed, and compiled.
>> 
>> Python is weakly typed.
>
>     ldo@theon:~> python3
>     Python 3.14.10 (main, Oct 26 2026, 15:12:11) [GCC 16.2.0] on linux
>     Type "help", "copyright", "credits" or "license" for more information.
>     >>> 1 + "1"
>     Traceback (most recent call last):
>       File "<python-input-0>", line 1, in <module>
>         1 + "1"
>         ~~^~~~~
>     TypeError: unsupported operand type(s) for +: 'int' and 'str'
>     >>> 

Has any debate over the meaning of "strongly-typed" led to a meaningful
conclusion?

Is comp.lang.c the best place to have such a discussion about Python?

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Re: C and its peasant 'ancestors'
#1946
Author: Michael S
Date: Sat, 28 Nov 2026 20:39
30 lines
2781 bytes
On Sat, 28 Nov 2026 12:27:45 -0800
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:

> Lawrence D’Oliveiro <ldo@nz.invalid> writes:
> > On Sat, 28 Nov 2026 07:27:38 +0100, Bonita Montero wrote:  
> >> Am 28.11.2026 um 06:50 schrieb Lawrence D’Oliveiro:  
> >>> It *is* strongly-typed, and compiled.  
> >> 
> >> Python is weakly typed.  
> >  
> >     ldo@theon:~> python3  
> >     Python 3.14.10 (main, Oct 26 2026, 15:12:11) [GCC 16.2.0] on
> > linux Type "help", "copyright", "credits" or "license" for more
> > information.  
> >     >>> 1 + "1"  
> >     Traceback (most recent call last):
> >       File "<python-input-0>", line 1, in <module>
> >         1 + "1"
> >         ~~^~~~~
> >     TypeError: unsupported operand type(s) for +: 'int' and 'str'  
> >     >>>   
> 
> Has any debate over the meaning of "strongly-typed" led to a
> meaningful conclusion?
> 
> Is comp.lang.c the best place to have such a discussion about Python?
> 

It does not hurt. IMHO.
Re: C and its peasant 'ancestors'
#1947
Author: Chris M. Thomasson
Date: Sat, 28 Nov 2026 20:43
9 lines
2023 bytes
On 11/28/2026 11:34 AM, David Brown wrote:
[...]
> (And they are getting better - there is progress being made specifically 
> towards more features suitable for freestanding systems, such as 
> inplace_vector.)
> 

inplace_vector? I need to study up on it... Well, that is excellent! 
That helps for sure.
Re: C and its peasant 'ancestors'
#1948
Author: Keith Thompson
Date: Sat, 28 Nov 2026 20:47
14 lines
2174 bytes
Michael S <already5chosen@yahoo.com> writes:
> On Sat, 28 Nov 2026 12:27:45 -0800
> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
[...]
>> Is comp.lang.c the best place to have such a discussion about Python?
>
> It does not hurt. IMHO.

IMHO it does hurt.  It damages the signal-to-noise ratio of this
newsgroup.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Re: C and its peasant 'ancestors'
#1949
Author: bartc
Date: Sat, 28 Nov 2026 21:27
15 lines
2300 bytes
On 28/11/2026 20:47, Keith Thompson wrote:
> Michael S <already5chosen@yahoo.com> writes:
>> On Sat, 28 Nov 2026 12:27:45 -0800
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> [...]
>>> Is comp.lang.c the best place to have such a discussion about Python?
>>
>> It does not hurt. IMHO.
> 
> IMHO it does hurt.  It damages the signal-to-noise ratio of this
> newsgroup.
> 


You should see what the SNR looks like when you disable your killfile.
Re: C and its peasant 'ancestors'
#1950
Author: Lawrence D’Oliveiro
Date: Sat, 28 Nov 2026 21:55
10 lines
2291 bytes
On Sat, 28 Nov 2026 08:57:16 +0100, Bonita Montero wrote:

> Am 28.11.2026 um 08:04 schrieb Lawrence D’Oliveiro:
>
>> But it’s true. C-based Git has better performance than C++-based
>> Monotone.
>
> That's a matter of the implementation, not the language.

Prove it, then.
Re: C and its peasant 'ancestors'
#1951
Author: Lawrence D’Oliveiro
Date: Sat, 28 Nov 2026 21:57
26 lines
2579 bytes
On Sat, 28 Nov 2026 08:58:09 +0100, Bonita Montero wrote:

> Am 28.11.2026 um 08:05 schrieb Lawrence D’Oliveiro:
>>
>> On Sat, 28 Nov 2026 07:27:38 +0100, Bonita Montero wrote:
>>
>>> Am 28.11.2026 um 06:50 schrieb Lawrence D’Oliveiro:
>>>
>>>> It *is* strongly-typed, and compiled.
>>>
>>> Python is weakly typed.
>>
>>      ldo@theon:~> python3
>>      Python 3.14.10 (main, Oct 26 2026, 15:12:11) [GCC 16.2.0] on linux
>>      Type "help", "copyright", "credits" or "license" for more information.
>>      >>> 1 + "1"
>>      Traceback (most recent call last):
>>        File "<python-input-0>", line 1, in <module>
>>          1 + "1"
>>          ~~^~~~~
>>      TypeError: unsupported operand type(s) for +: 'int' and 'str'
>>      >>>
>
> That's runtime error.

You didn’t say anything about “compile time” versus “runtime”.
Re: C and its peasant 'ancestors'
#1952
Author: Michael S
Date: Sat, 28 Nov 2026 21:59
22 lines
2488 bytes
On Sat, 28 Nov 2026 21:27:35 +0000
bartc <bc@freeuk.com> wrote:

> On 28/11/2026 20:47, Keith Thompson wrote:
> > Michael S <already5chosen@yahoo.com> writes:  
> >> On Sat, 28 Nov 2026 12:27:45 -0800
> >> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:  
> > [...]  
> >>> Is comp.lang.c the best place to have such a discussion about
> >>> Python?  
> >>
> >> It does not hurt. IMHO.  
> > 
> > IMHO it does hurt.  It damages the signal-to-noise ratio of this
> > newsgroup.
> >   
> 
> 
> You should see what the SNR looks like when you disable your killfile.

Exactly. Lowering it any further does not look possible.
Re: C and its peasant 'ancestors'
#1953
Author: David Brown
Date: Sat, 28 Nov 2026 21:59
72 lines
5033 bytes
On 28/11/2026 21:15, Michael S wrote:
> On Sat, 28 Nov 2026 20:34:10 +0100
> David Brown <david.brown@hesbynett.no> wrote:
> 
>> On 28/11/2026 19:47, Scott Lurndal wrote:
>>> Lawrence =?iso-8859-13?q?D=FFOliveiro?= <ldo@nz.invalid> writes:
>>>> On Thu, 26 Nov 2026 12:48:26 +0100, Bonita Montero wrote:
>>>>   
>>>>> Am 26.11.2026 um 12:36 schrieb fir:
>>>>>   
>>>>>> 1. the bloat of terrible c++ syntax (oop and those generix and
>>>>>> those all other non sane additions)
>>>>>
>>>>> It’s only "bloat" if you aren’t up to the task of handling it. I
>>>>> actually find C to be much more bloated, because the things you
>>>>> end up having to do alongside C++ often require a significant
>>>>> amount of real work.
>>>>
>>>> Would you like to take the Linus Torvalds challenge? He famously
>>>> hates C++, and won’t allow it into the Linux kernel.
>>>
>>> I've worked on a full scale, massively parallel operating
>>> system and a distributed virtual machine manager, both written
>>> in C++ very successfully.
>>>
>>> Of course, one must carefully choose _which_ C++ features
>>> are used (limited use of templates, no exceptions, no RTTI
>>> very limited STL (which didn't exist when the OS project
>>> started in 1989) for optimal performance.
>>>
>>> C with classes isn't a bad description - one receives all the
>>> benefits of data hiding and inheritance provided by the class
>>> paradigm without the overhead required for stack unwinding and
>>> dynamic_cast<>.
>>
>> There's a /lot/ more than just "C with classes" that is appropriate
>> for low-level, bare metal and/or embedded programming in C++.  It is
>> typically more a matter of what you want to avoid - dynamic memory,
>> virtual functions (usually), exceptions, and anything else that has
>> unexpected or unpredictable runtime costs.  I use a large number of
>> C++ features in my small-systems embedded programming, but you do
>> have to know what to avoid.  (I also avoid malloc/free and a number
>> of other features and functions of C in embedded programming, but it
>> is more obvious which should be avoided.)
>>
>> To be fair, the C++ language and toolchains are far better suited to
>> embedded programming than they were in 1989 !
>>
>> (And they are getting better - there is progress being made
>> specifically towards more features suitable for freestanding systems,
>> such as inplace_vector.)
>>
> 
> Try C in your next project.
> You will be pleasantly surprised by productivity gain from using
> simpler language. May be, less so during initial coding, more so during
> later maintenance.
> 

I work with both C and C++ projects.  When starting a new project, /I/ 
make the choice of language.  You make it sound like moving to C would 
be something new for me.  I moved to C++ from C as my usual choice 
precisely because it lets me write better code with fewer bugs, with 
similar or better efficiency.  To me, it is a clear step above C in most 
projects - just as C is a clear step above the assembly I used to use.

Of course, I have to use C++ appropriately for the task in hand - not 
like Bonita's junk code.

And I will still use C if there is good reason for it (there can be a 
number of good reasons for sticking to C).
Re: C and its peasant 'ancestors'
#1954
Author: David Brown
Date: Sat, 28 Nov 2026 22:02
16 lines
2392 bytes
On 28/11/2026 21:43, Chris M. Thomasson wrote:
> On 11/28/2026 11:34 AM, David Brown wrote:
> [...]
>> (And they are getting better - there is progress being made 
>> specifically towards more features suitable for freestanding systems, 
>> such as inplace_vector.)
>>
> 
> inplace_vector? I need to study up on it... Well, that is excellent! 
> That helps for sure.

It is a structure that acts mostly like a vector, but has fixed capacity 
(which is part of its type).  It is not far off being like a 
std::array<> with an attached current size, except that unused entries 
don't exist (and therefore don't need to be constructed or initialised).
Re: C and its peasant 'ancestors'
#1955
Author: fir
Date: Sat, 28 Nov 2026 22:02
39 lines
3529 bytes
bartc pisze:
> On 28/11/2026 20:47, Keith Thompson wrote:
>> Michael S <already5chosen@yahoo.com> writes:
>>> On Sat, 28 Nov 2026 12:27:45 -0800
>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>> [...]
>>>> Is comp.lang.c the best place to have such a discussion about Python?
>>>
>>> It does not hurt. IMHO.
>>
>> IMHO it does hurt.  It damages the signal-to-noise ratio of this
>> newsgroup.
>>
> 
> 
> You should see what the SNR looks like when you disable your killfile.

this group has to less users and generally "old media" are dying for 
years - epsecially chats/irc - and it is very bad its kinda bad sign 
about humanity

becouse those old media rules was imo far more pluralistic than the
present media i dont even know how to name it.. becouse i dont get the 
difference why old better media like usenet or chat/irc die and those 
more new get popular

diskord fo r example is kinda trash usually..some could say in a way 
same pathology as on irce appears but for some reasons its wrse..like 
people much more dont care and like much more anonymous, much less energy

there was era of "forums" which could be a concurency to usened in turn 
but those forums were usually apodictic trash and now even forums died..
in some way youtube can be seen now as an oldschool media and in some 
way youtube is not bad

probably decline of usenet is sorta the same thing as decline of rap
or decline of c etc - all good movements need people on some level to
uphold the level of given thing and then populist came and dissolve 
everything in stupidity
Re: C and its peasant 'ancestors'
#1956
Author: fir
Date: Sat, 28 Nov 2026 22:10
49 lines
4108 bytes
fir pisze:
> bartc pisze:
>> On 28/11/2026 20:47, Keith Thompson wrote:
>>> Michael S <already5chosen@yahoo.com> writes:
>>>> On Sat, 28 Nov 2026 12:27:45 -0800
>>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>>> [...]
>>>>> Is comp.lang.c the best place to have such a discussion about Python?
>>>>
>>>> It does not hurt. IMHO.
>>>
>>> IMHO it does hurt.  It damages the signal-to-noise ratio of this
>>> newsgroup.
>>>
>>
>>
>> You should see what the SNR looks like when you disable your killfile.
> 
> this group has to less users and generally "old media" are dying for 
> years - epsecially chats/irc - and it is very bad its kinda bad sign 
> about humanity
> 
> becouse those old media rules was imo far more pluralistic than the
> present media i dont even know how to name it.. becouse i dont get the 
> difference why old better media like usenet or chat/irc die and those 
> more new get popular
> 
> diskord fo r example is kinda trash usually..some could say in a way 
> same pathology as on irce appears but for some reasons its wrse..like 
> people much more dont care and like much more anonymous, much less energy
> 
> there was era of "forums" which could be a concurency to usened in turn 
> but those forums were usually apodictic trash and now even forums died..
> in some way youtube can be seen now as an oldschool media and in some 
> way youtube is not bad
> 
> probably decline of usenet is sorta the same thing as decline of rap
> or decline of c etc - all good movements need people on some level to
> uphold the level of given thing and then populist came and dissolve 
> everything in stupidity

i kinda could say i like that stack overflow died though ;c
(orc its a simplification as i got nothing to technical posts/articles - 
but people on SO was so damn disgustingly way stupid its cryminal,

quite common for such place was their "downwoting" the good answers or 
questions upvoting the idiotc - so many crazy populists - i i can name a 
populist some ways of pathology..various forums also hosted a pathology 
but noticably not in so high intense ;c)
Re: C and its peasant 'ancestors'
#1957
Author: Ross Finlayson
Date: Sat, 28 Nov 2026 22:18
261 lines
9230 bytes
On 11/28/2026 07:28 AM, bartc wrote:
> On 28/11/2026 04:54, Bonita Montero wrote:
>> Am 27.11.2026 um 22:36 schrieb Lawrence D’Oliveiro:
>>
>>> ... the end result is a horrible and unmaintainable mess.
>> The abstractions of C++ make C++ more readable and maintaineable as C.
>>
>
> Yet every example of C++ you've ever posted is always an unreadable,
> ugly mess of syntax.
>
> Not all that is the fault of the language - you seem to delight in using
> every obscure feature possible and have nested functions everywhere.
>
> Below is a recent post of yours about sorting in C++. It took me a while
> to realise it was actually testing two kinds of sort!
>
> It is frankly diabolical. It seems designed to obfuscate as much as
> possible.
>
> Below yours, is a version in my language, just to show the contrast.
> This one only tests a qsort approach, but everything about it is
> straightforward.
>
> And below that, is a C port. Not quite as clean, but considerably less
> scary-looking than your C++.
>
> As for timings, then for 10000 sorts of 4096 random integers in the i32
> range, they were:
>
>   C++/g++-O3 qsrt      3.5 seconds
>   C++/g++-O3 stdsort   1.5 seconds
>   My lang              2.5 seconds
>   C/gcc-O2             2.5 seconds
>   C/bcc                2.5 seconds
>
> But I don't know what's going on in your qsrt, and I don't know what
> stdsort does; these will be algorithmic differences.
>
> However, this is what happens when optimisation is turned off in all
> cases (in my tools, that just means locals stay in memory):
>
>   C++/g++-O0 qsrt      7.0 seconds
>   C++/g++-O0 stdsort  16.8 seconds
>   My lang -no          3.7 seconds
>   C/gcc-O0             4.0 seconds
>   C/bcc -no            4.0 seconds
>
> Now C++'s stdsort is more than twice as slow as your qsrt! And 4 times
> as slow as that 'isort' in C.
>
> There is a more than 10:1 difference between optimised/unoptimised for
> this C++ standard sort. Here is one more timing:
>
>   QQ                  15.0 seconds
>
> This is my dynamic scripting language on the same task. The sort routine
> (same as isort) is implemented /in the language/, it is not called as an
> internal function written in native code.
>
> So unoptimised C++ is slower than a scripting language!
>
>
> -----------------------------------------
> #include <iostream>
> #include <algorithm>
> #include <cstdlib>
> #include <chrono>
> #include <vector>
> #include <random>
>
> using namespace std;
> using namespace chrono;
>
> int main()
> {
>      constexpr size_t
>          N = 0x1000,
>          Rounds = 10'000;
>      auto test = []( auto fn ) -> double
>      {
>          time_point start = steady_clock::now();
>          for( size_t r = Rounds; r; --r )
>              fn();
>          duration dur = steady_clock::now() - start;
>          return (double)duration_cast<nanoseconds>( dur ).count();
>      };
>      vector<int>
>          origin( N ),
>          srt( N );
>      mt19937_64 mt;
>      for( int &i : origin )
>          i = (int)mt();
>      int dummy = 0;
>      auto cpy = [&] { copy( origin.begin(), origin.end(), srt.begin() );
> dummy += srt[0]; };
>      double tRef = test( cpy );
>      auto qsrt = [&]
>          {
>              cpy();
>              qsort( srt.data(), srt.size(), sizeof( int ), +[]( const
> void *lhs, const void *rhs ) -> int
>                  {
>                      int &iLhs = *(int *)lhs, &iRhs = *(int *)rhs;
>                      if( iLhs == iRhs )
>                          return 0;
>                      return iLhs < iRhs ? -1 : 1;
>                  } );
>              dummy += srt[0];
>          };
>      double tQsrt = test( qsrt ) - tRef;
>      auto stdSrt = [&]
>          {
>              cpy();
>              sort( srt.begin(), srt.end(), less() );
>              dummy += srt[0];
>          };
>      double tStdSrt = test( stdSrt ) - tRef;
>      cout << tQsrt / tStdSrt << endl;
>      return dummy;
> }
> -----------------------------------------
>
> proc main =
>      const nn = 4096
>      [nn]int data, sdata          # int is i64
>
>      for i to nn do
>          data[i] := mrandomrange(i32.min, i32.max)
>      end
>
>      to 10'000 do
>          sdata := data
>          isort(sdata, 1, sdata.len)
>      end
>
>      for i to nn when i not in 10..nn-10 do
>          println i, sdata[i]
>      end
> end
>
> proc isort([]int &data, int ll, rr)=
>      int pivot, i := ll, j := rr
>
>      pivot:=data[(ll+rr)/2]
>
>      repeat
>          while pivot > data[i] and i<rr do ++i end
>          while pivot < data[j] and j>ll do --j end
>
>          if i<=j then
>              swap(data[i], data[j])
>              ++i
>              --j
>          end
>      until i>j
>
>      if ll<j then isort(data, ll, j) end
>      if i<rr then isort(data, i, rr) end
> end
>
> --------------------------------------
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
>
> void isort(int* data, int ll, int rr) {
>      int pivot, i = ll, j = rr, t;
>
>      pivot = data[(ll+rr)/2];
>
>      do {
>          while (pivot > data[i] && i<rr) ++i;
>          while (pivot < data[j] && j>ll) --j;
>
>          if (i<=j) {
>              t=data[i]; data[i]=data[j]; data[j]=t;
>              ++i;
>              --j;
>          }
>      } while (!(i>j));
>
>      if (ll<j) isort(data, ll, j);
>      if (i<rr) isort(data, i, rr);
> }
>
> int main(void) {
>      enum {N=4096};
>      int data[N], sdata[N], i;
>
>      for (i=0; i<N; ++i) data[i] = (rand()<<15) | rand();
>
>      for (i=0; i<10000; ++i) {
>          memcpy(sdata, data, sizeof(data));
>          isort(sdata, 0, N-1);
>      }
>
>      for (i=0; i<N; ++i) if (i<10 || i>(N-10)) printf("%4d %d\n", i,
> sdata[i]);
> }
>
>
>
>


Montero's style has changed over the years, for example
when since introducing lambdas, accounts like the more
labeled style vis-a-vis the tail-recursion style,
various accounts of inclusion of annotations and like
likely and so on, various accounts of consideration of
exceptions, it varies.

Agreeably, it's obscurantic.


#ifndef H__STANDARD
#define H__STANDARD

#include <stddef.h>
#include <stdint.h>
#include <limits.h>


#define C_AUTO __auto_type
#define C_NODISCARD __attribute__((warn_unused_result))

typedef unsigned char byte_t;
typedef char char_t;

typedef enum {
LEN_BUF_LINE = 64,
LEN_BUF_PAGE = 4096,
LEN_BUF_HUGE = 2 * 1024 * 1024
} len_buf_enum_t;

typedef byte_t buf_line_t[LEN_BUF_LINE];
typedef byte_t buf_page_t[LEN_BUF_PAGE];
typedef byte_t buf_huge_t[LEN_BUF_HUGE];

typedef enum {
LEN_NAME_SHORT = 16,
LEN_NAME = 32,
LEN_NAME_LONG = 64,
LEN_NAME_MAX = NAME_MAX
} len_name_enum_t;

typedef char_t name_short_t[LEN_NAME_SHORT];
typedef char_t name_t[LEN_NAME];
typedef char_t name_long_t[LEN_NAME_LONG];
typedef char_t name_max_t[LEN_NAME_MAX];


typedef timespec timespec_t;



#endif /* H__STANDARD */

Re: C and its peasant 'ancestors'
#1958
Author: fir
Date: Sat, 28 Nov 2026 22:19
34 lines
3242 bytes
Michael S pisze:
> On Sat, 28 Nov 2026 21:27:35 +0000
> bartc <bc@freeuk.com> wrote:
> 
>> On 28/11/2026 20:47, Keith Thompson wrote:
>>> Michael S <already5chosen@yahoo.com> writes:
>>>> On Sat, 28 Nov 2026 12:27:45 -0800
>>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>>> [...]
>>>>> Is comp.lang.c the best place to have such a discussion about
>>>>> Python?
>>>>
>>>> It does not hurt. IMHO.
>>>
>>> IMHO it does hurt.  It damages the signal-to-noise ratio of this
>>> newsgroup.
>>>    
>>
>>
>> You should see what the SNR looks like when you disable your killfile.
> 
> Exactly. Lowering it any further does not look possible.
> 

if someone is complaining about so called 'signal' then blame your own 
focus...i posted recently few good post on c (like c hole or bag in c)
and people are not enough focused to answer

i in turn cant just talk on very narrow c becouse i know c too much it 
seems, not very much basic c topics to say yet..so there is naturat 
extension to talk on c programming or eventual syntax changes/ideas end 
so on ..as this group overally has a lack of activity imo its good maybe 
in a sense to talk on core c topics but if ther set gets low imo talkin
on ideas or c programming should be also ok
Re: C and its peasant 'ancestors'
#1959
Author: Ross Finlayson
Date: Sat, 28 Nov 2026 22:29
155 lines
7481 bytes
On 11/28/2026 10:18 AM, Michael S wrote:
> On Sat, 28 Nov 2026 18:12:36 +0000
> bartc <bc@freeuk.com> wrote:
>
>> On 28/11/2026 16:31, Bonita Montero wrote:
>>> Am 28.11.2026 um 16:28 schrieb bartc:
>>>
>>>> Yet every example of C++ you've ever posted is always an
>>>> unreadable, ugly mess of syntax.
>>>
>>> A very disordered opinion.
>>>
>>>> Not all that is the fault of the language - you seem to delight in
>>>> using every obscure feature possible and have nested functions
>>>> everywhere.
>>>
>>> C++-developers understand my code since they're more skilled like
>>> you.
>>
>> It's not a skills issue. The language as used like this is several
>> times more complex than is needed.
>>
>>
>>>> Below is a recent post of yours about sorting in C++. It took me a
>>>> while to realise it was actually testing two kinds of sort!
>>>
>>> I don't know why this should be hard to understand.
>>> Maybe it's beyond your capabilities.
>>
>> Because it's a ******* mess. Here's a function you created simply for
>> copying one array to another:
>>
>>      auto cpy = [&] { copy( origin.begin(), origin.end(), srt.begin()
>> ); dummy += srt[0]; };
>>
>> 37 tokens. Here is what I used:
>>
>>     sdata := data
>>
>> 3 tokens, and no functions. Even C needs only 12 tokens:
>>
>>     memcpy(sdata, data, sizeof(data));
>>
>> It's also ironic in that you go on about having to implement stuff in
>> C that is provided in C++, yet you have to write your own vector copy?
>>
>> Would 'src = origin' work, and if so why not just use it?
>>
>> You just want to use as many toys as possible for no reason.
>>
>
> Here I agree.
>
>>
>>>> As for timings, then for 10000 sorts of 4096 random integers in
>>>> the i32 range, they were:
>>>>
>>>>    C++/g++-O3 qsrt      3.5 seconds
>>>>    C++/g++-O3 stdsort   1.5 seconds
>>>>    My lang              2.5 seconds
>>>>    C/gcc-O2             2.5 seconds
>>>>    C/bcc                2.5 seconds
>>>
>>> As I said you can be on par with std::sort(),
>>
>> Why is your qsrt 40% slower than the most basic version in C?
>>
>>   > but it makes a lot of work> since you've to implement the
>>   > quicksort
>> yourself; including all optimi-
>>> zations beyond the "homework-solution".
>>
>> I'm sure somebody has already written an optimised sort routine in C,
>> you just have to find it. Google-AI gave me a fast version of
>> quicksort, and that has timing of 1.8 seconds the for the above task.
>>
>> That's 20% slower than your stdsort. But if I tweak the task, so I
>> sort 64K numbers 1000 times, then optimised C is 14% faster then
>> optimised C++/stdsort.
>>
>>
>>
>>
>>>> However, this is what happens when optimisation is turned off in
>>>> all cases (in my tools, that just means locals stay in memory):
>>>>
>>>>    C++/g++-O0 qsrt      7.0 seconds
>>>>    C++/g++-O0 stdsort  16.8 seconds
>>>>    My lang -no          3.7 seconds
>>>>    C/gcc-O0             4.0 seconds
>>>>    C/bcc -no            4.0 seconds
>>>> Now C++'s stdsort is more than twice as slow as your qsrt! And 4
>>>> times as slow as that 'isort' in C.
>>>> So unoptimised C++ is slower than a scripting language!
>>
>>> Where's the problem ?
>>
>> One problem is that compiling this 60-line C++ program took 2.6
>> seconds, but compiling the now-90-line C version took 0.025 seconds
>> (100 times faster).
>>
>> This is with my non-optimising compiler, but it was still slightly
>> faster than C++ sort for N=64K (4.7s vs 4.8s).
>
> Here I disagree.
> std::sort is not just fast. It is also more convinient.
>
>
>
>


One might consider SIMD "shake-sort" for regions then merge-sort
and up and down, since the smaller unit's an order of magnitude faster,
vis-a-vis, usual accounts of all one speed the linear.


The "shake-sort" is usually considered among the slowest approaches
in accounts of sort algorithms, like "Tim-sort" and so on, yet,
in the tribological has that it's how nature sorts many things.

SIMD is basically only "linear-speedup", say, yet, the
alias/stall/branch/call/fault-less is quite a large constant the on the
order
of 1000, for example when sorting things like less than on the order of 10.

When people say hash-map is constant-time, it's thoroughly aggravating,
yet I figure they're just repeating what they were told, instead of
looking at it and seeing it out, and getting more performance in the
telling, like fishermen with the biggest fish that got away.


It's like map-reduce and uniform keys, vis-a-vis the entirely usual
account of:

"modes, principals, majors, minors, lessers, and the long tail",

vis-a-vis "the normal distribution" or "it's linear" when "it's < 5".


I have a statistics minor so people talking about "Big Data and the
Power Law" get a low estimate of statistical confidence.


Accounts of "Numerical approximations of NP-hard problems in polynomial
time", has that that's a great book from the 1990's that gets into
whether "factorial-time" is less than "exponential-time", and for
example whether that's independent standard number theory: "Ramsey
theory", about Ramsey theory and non-standard Ramsey theory in asymptotics.





Re: C and its peasant 'ancestors'
#1960
Author: Chris M. Thomasson
Date: Sat, 28 Nov 2026 22:56
19 lines
2520 bytes
On 11/28/2026 2:02 PM, David Brown wrote:
> On 28/11/2026 21:43, Chris M. Thomasson wrote:
>> On 11/28/2026 11:34 AM, David Brown wrote:
>> [...]
>>> (And they are getting better - there is progress being made 
>>> specifically towards more features suitable for freestanding systems, 
>>> such as inplace_vector.)
>>>
>>
>> inplace_vector? I need to study up on it... Well, that is excellent! 
>> That helps for sure.
> 
> It is a structure that acts mostly like a vector, but has fixed capacity 
> (which is part of its type).  It is not far off being like a 
> std::array<> with an attached current size, except that unused entries 
> don't exist (and therefore don't need to be constructed or initialised).
> 

Very nice!
Re: C and its peasant 'ancestors'
#1961
Author: Janis Papanagnou
Date: Sun, 29 Nov 2026 03:47
33 lines
2891 bytes
On 2026-11-28 22:57, Lawrence D’Oliveiro wrote:
> On Sat, 28 Nov 2026 08:58:09 +0100, Bonita Montero wrote:
> 
>> Am 28.11.2026 um 08:05 schrieb Lawrence D’Oliveiro:
>>>
>>> On Sat, 28 Nov 2026 07:27:38 +0100, Bonita Montero wrote:
>>>
>>>> Am 28.11.2026 um 06:50 schrieb Lawrence D’Oliveiro:
>>>>
>>>>> It *is* strongly-typed, and compiled.
>>>>
>>>> Python is weakly typed.
>>>
>>>       ldo@theon:~> python3
>>>       Python 3.14.10 (main, Oct 26 2026, 15:12:11) [GCC 16.2.0] on linux
>>>       Type "help", "copyright", "credits" or "license" for more information.
>>>       >>> 1 + "1"
>>>       Traceback (most recent call last):
>>>         File "<python-input-0>", line 1, in <module>
>>>           1 + "1"
>>>           ~~^~~~~
>>>       TypeError: unsupported operand type(s) for +: 'int' and 'str'
>>>       >>>
>>
>> That's runtime error.
> 
> You didn’t say anything about “compile time” versus “runtime”.

The whole point was about languages that do type-checking during
compile time (versus those that don't).

Janis
Re: C and its peasant 'ancestors'
#1962
Author: Janis Papanagnou
Date: Sun, 29 Nov 2026 04:03
48 lines
3363 bytes
On 2026-11-28 19:13, Michael S wrote:
> On Sat, 28 Nov 2026 12:26:54 -0000 (UTC)
> cross@spitfire.i.gajendra.net (Dan Cross) wrote:
> 
>> In article <11eds8o$2ahsb$2@raubtier-asyl.eternal-september.org>,
>> Bonita Montero  <Bonita.Montero@gmail.com> wrote:
>>> Am 28.11.2026 um 06:50 schrieb Lawrence D’Oliveiro:
>>>   
>>>> It *is* strongly-typed, and compiled.
>>>
>>> Python is weakly typed.
>>> Type annotations aren't enforced by the compiler.
>>
>> Lawrence is an idiot, but he's right about this.   Python
>> is _strongly_ typed, but it is not _statically_ typed.
>>
>> 	- Dan C.
>>
> 
> Weak or strong - it's not very important in practice.
> That is, it is important that in python all type errors are caught.
> Eventually. During execution of statements in question.  Unless hidden
> by one or another sort of polymorphism.

This reads as if you are advocating that it would be sufficient to
notify errors during runtime, and abort execution as LDO's example
seems to indicate. (I'm thinking of what our customers back then
would have said if our systems behaved that way for these types of
errors. Of course we used only statically typed languages for our
professional software. It certainly was important in practice to
reduce errors beforehand and not gamble with our reputation.)

Janis

> But then again, 95% of such errors are caught at during execution even
> in C (I am not talking about out-of-bound accesses, those are a
> separate battle), at least as long a C is running on platform with
> memory protection.
> Yes, %5 matter, and knowing about 100% gives python programmer a warm
> feeling, but more so in theory than in practice.
> 
> On the other hand, the fact that at compile time (or pre-compile time, I
> don't know official term) Python catches very few type errors (if at
> all) is very important in practice, although much more so for big
> programs than for small ones.
> 
> 
Re: C and its peasant 'ancestors'
#1963
Author: Dan Cross
Date: Sun, 29 Nov 2026 04:22
51 lines
2938 bytes
In article <20261128201354.000064be@yahoo.com>,
Michael S  <already5chosen@yahoo.com> wrote:
>On Sat, 28 Nov 2026 12:26:54 -0000 (UTC)
>cross@spitfire.i.gajendra.net (Dan Cross) wrote:
>
>> In article <11eds8o$2ahsb$2@raubtier-asyl.eternal-september.org>,
>> Bonita Montero  <Bonita.Montero@gmail.com> wrote:
>> >Am 28.11.2026 um 06:50 schrieb Lawrence D’Oliveiro:
>> >
>> >> It *is* strongly-typed, and compiled.
>> >
>> >Python is weakly typed.
>> >Type annotations aren't enforced by the compiler.
>>
>> Lawrence is an idiot, but he's right about this.   Python
>> is _strongly_ typed, but it is not _statically_ typed.
>
>Weak or strong - it's not very important in practice.

You mean static versus dynamic.  Strong versus weak is a
different axis.

And I profoundly disagree.  I've seen too many errors in dynamic
languages hit production that would have been trivially caught
in a statically typed language.

>That is, it is important that in python all type errors are caught.
>Eventually. During execution of statements in question.  Unless hidden
>by one or another sort of polymorphism.

That's all well and good until you're doing an emergency push to
prod to stop a cascading error taking down a live service in an
entire data center because someone left some code in that tried
to do arithmetic on a tuple.

>But then again, 95% of such errors are caught at during execution even
>in C (I am not talking about out-of-bound accesses, those are a
>separate battle), at least as long a C is running on platform with
>memory protection.
>Yes, %5 matter, and knowing about 100% gives python programmer a warm
>feeling, but more so in theory than in practice.
>
>On the other hand, the fact that at compile time (or pre-compile time, I
>don't know official term) Python catches very few type errors (if at
>all) is very important in practice, although much more so for big
>programs than for small ones.

Or small programs running big services.

	- Dan C.
Re: C and its peasant 'ancestors'
#1964
Author: Bonita Montero
Date: Sun, 29 Nov 2026 05:44
12 lines
2773 bytes
Am 28.11.2026 um 20:28 schrieb fir:

> btw the qusort with stub of insert sort i once wrote (it took me not 
> much like half a day without a lot of testing) take 74 ms when std c++ 
> sort 71 ms so both suck

You are too muddled to stay on topic. The discussion concerned
a comparison between C and C++ using otherwise identical code.
You can assume that 95% of what is written in C can be implemented
in C++ with significantly less code—resulting in something much
clearer, more maintainable, and more secure.
Re: C and its peasant 'ancestors'
#1970
Author: Scott Lurndal
Date: Sun, 29 Nov 2026 16:19
27 lines
2616 bytes
David Brown <david.brown@hesbynett.no> writes:
>On 28/11/2026 19:47, Scott Lurndal wrote:
>> Lawrence =?iso-8859-13?q?D=FFOliveiro?= <ldo@nz.invalid> writes:
>>> On Thu, 26 Nov 2026 12:48:26 +0100, Bonita Montero wrote:
 <snip>
>> C with classes isn't a bad description - one receives all the
>> benefits of data hiding and inheritance provided by the class paradigm without
>> the overhead required for stack unwinding and dynamic_cast<>.
>
>There's a /lot/ more than just "C with classes" that is appropriate for 
>low-level, bare metal and/or embedded programming in C++.  It is 
>typically more a matter of what you want to avoid - dynamic memory, 
>virtual functions (usually),

Commercial operating systems have used "virtual functions" in C pretty
extensively over the last forty years (consider the Unix VFS layer
or generic device driver interfaces for example).

> exceptions, and anything else that has 
>unexpected or unpredictable runtime costs.  I use a large number of C++ 
>features in my small-systems embedded programming, but you do have to 
>know what to avoid.  (I also avoid malloc/free and a number of other 
>features and functions of C in embedded programming, but it is more 
>obvious which should be avoided.)

Agreed.
Re: C and its peasant 'ancestors'
#1974
Author: Kaz Kylheku
Date: Sun, 29 Nov 2026 18:18
31 lines
3080 bytes
On 2026-11-29, Scott Lurndal <scott@slp53.sl.home> wrote:
> David Brown <david.brown@hesbynett.no> writes:
>>On 28/11/2026 19:47, Scott Lurndal wrote:
>>> Lawrence =?iso-8859-13?q?D=FFOliveiro?= <ldo@nz.invalid> writes:
>>>> On Thu, 26 Nov 2026 12:48:26 +0100, Bonita Montero wrote:
> <snip>
>>> C with classes isn't a bad description - one receives all the
>>> benefits of data hiding and inheritance provided by the class paradigm without
>>> the overhead required for stack unwinding and dynamic_cast<>.
>>
>>There's a /lot/ more than just "C with classes" that is appropriate for 
>>low-level, bare metal and/or embedded programming in C++.  It is 
>>typically more a matter of what you want to avoid - dynamic memory, 
>>virtual functions (usually),
>
> Commercial operating systems have used "virtual functions" in C pretty
> extensively over the last forty years (consider the Unix VFS layer
> or generic device driver interfaces for example).

In the late 1990s I dug into the source code of a popular telnet
package used by distros and was surprised to find C++ with abstract
base classes and virtual functions, dating back to the early 1990s.

(The issue I patched for myself at that time was that the telnet program
aborted the connection at any socket error bubbling up whatsoever, even
temporary unreachable conditions, like my PPP connection re-dialing.)

-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
Re: C and its peasant 'ancestors'
#1975
Author: Bonita Montero
Date: Sun, 29 Nov 2026 19:08
12 lines
2313 bytes
Am 29.11.2026 um 17:19 schrieb Scott Lurndal:

> Commercial operating systems have used "virtual functions" in C pretty
> extensively over the last forty years (consider the Unix VFS layer
> or generic device driver interfaces for example).

Virtual functions in C++ need less storage since you need only one
virtual method table pointer per baseclass. C-code is typically with
one fuction pointer as a struct member. And C++ virtual functions are
easier to handle since they're automatically set by the constructor.

Re: C and its peasant 'ancestors'
#1976
Author: Lawrence D’Oliveiro
Date: Sun, 29 Nov 2026 19:21
6 lines
1941 bytes
On Sun, 29 Nov 2026 20:08:10 +0100, Bonita Montero wrote:

> Virtual functions in C++ need less storage since you need only one
> virtual method table pointer per baseclass.

That’s actually a limitation, because it disallows “monkey-patching”.
Re: C and its peasant 'ancestors'
#1977
Author: Bonita Montero
Date: Sun, 29 Nov 2026 19:36
12 lines
2322 bytes
Am 29.11.2026 um 20:21 schrieb Lawrence D’Oliveiro:

> On Sun, 29 Nov 2026 20:08:10 +0100, Bonita Montero wrote:

>> Virtual functions in C++ need less storage since you need only one
>> virtual method table pointer per baseclass.

> That’s actually a limitation, because it disallows “monkey-patching”.

When do you need to change the polymorphic type of a class at
runtime. In OOP languages no one has missed that feature so far.
Re: C and its peasant 'ancestors'
#1979
Author: Chris M. Thomasson
Date: Sun, 29 Nov 2026 21:19
36 lines
3196 bytes
On 11/29/2026 8:19 AM, Scott Lurndal wrote:
> David Brown <david.brown@hesbynett.no> writes:
>> On 28/11/2026 19:47, Scott Lurndal wrote:
>>> Lawrence =?iso-8859-13?q?D=FFOliveiro?= <ldo@nz.invalid> writes:
>>>> On Thu, 26 Nov 2026 12:48:26 +0100, Bonita Montero wrote:
>   <snip>
>>> C with classes isn't a bad description - one receives all the
>>> benefits of data hiding and inheritance provided by the class paradigm without
>>> the overhead required for stack unwinding and dynamic_cast<>.
>>
>> There's a /lot/ more than just "C with classes" that is appropriate for
>> low-level, bare metal and/or embedded programming in C++.  It is
>> typically more a matter of what you want to avoid - dynamic memory,
>> virtual functions (usually),
> 
> Commercial operating systems have used "virtual functions" in C pretty
> extensively over the last forty years (consider the Unix VFS layer
> or generic device driver interfaces for example).

For sure! Actually, here is an old one of mine:

https://pastebin.com/raw/f52a443b1
(no ads, raw text for sure)


> 
>> exceptions, and anything else that has
>> unexpected or unpredictable runtime costs.  I use a large number of C++
>> features in my small-systems embedded programming, but you do have to
>> know what to avoid.  (I also avoid malloc/free and a number of other
>> features and functions of C in embedded programming, but it is more
>> obvious which should be avoided.)
> 
> Agreed.
> 
Re: C and its peasant 'ancestors'
#1980
Author: Michael S
Date: Sun, 29 Nov 2026 22:07
29 lines
2420 bytes
On Sun, 29 Nov 2026 04:22:25 -0000 (UTC)
cross@spitfire.i.gajendra.net (Dan Cross) wrote:

> In article <20261128201354.000064be@yahoo.com>,
> Michael S  <already5chosen@yahoo.com> wrote:
> >On Sat, 28 Nov 2026 12:26:54 -0000 (UTC)
> >cross@spitfire.i.gajendra.net (Dan Cross) wrote:
> >  
> >> In article <11eds8o$2ahsb$2@raubtier-asyl.eternal-september.org>,
> >> Bonita Montero  <Bonita.Montero@gmail.com> wrote:  
> >> >Am 28.11.2026 um 06:50 schrieb Lawrence D’Oliveiro:
> >> >  
> >> >> It *is* strongly-typed, and compiled.  
> >> >
> >> >Python is weakly typed.
> >> >Type annotations aren't enforced by the compiler.  
> >>
> >> Lawrence is an idiot, but he's right about this.   Python
> >> is _strongly_ typed, but it is not _statically_ typed.  
> >
> >Weak or strong - it's not very important in practice.  
> 
> You mean static versus dynamic. 

No, I meant exactly what I wrote.
Python is strongly typed. It is of little practical importance.
Python lacks static checks. It is of higher importance.
Re: C and its peasant 'ancestors'
#1981
Author: Dan Cross
Date: Sun, 29 Nov 2026 22:45
26 lines
1933 bytes
In article <11ehuri$3ps8n$1@raubtier-asyl.eternal-september.org>,
Bonita Montero  <Bonita.Montero@gmail.com> wrote:
>Am 29.11.2026 um 20:21 schrieb Lawrence D’Oliveiro:
>
>> On Sun, 29 Nov 2026 20:08:10 +0100, Bonita Montero wrote:
>
>>> Virtual functions in C++ need less storage since you need only one
>>> virtual method table pointer per baseclass.
>
>> That’s actually a limitation, because it disallows “monkey-patching”.
>
>When do you need to change the polymorphic type of a class at
>runtime. In OOP languages no one has missed that feature so far.

It's actually not even that hard.  Most class instances have a
single pointer to a vtbl; you can "monkey patch" C++ just by
replacing that with a pointer to a different table that points
to a different thunk.

To bring this back to C, though, space-efficient dispatch
through function pointers has been part of the language since
nearly the beginning: consider the device switches in early
Unix.

	- Dan C.
Re: C and its peasant 'ancestors'
#1982
Author: Dan Cross
Date: Sun, 29 Nov 2026 22:48
44 lines
2449 bytes
In article <20261130000723.0000290f@yahoo.com>,
Michael S  <already5chosen@yahoo.com> wrote:
>On Sun, 29 Nov 2026 04:22:25 -0000 (UTC)
>cross@spitfire.i.gajendra.net (Dan Cross) wrote:
>
>> In article <20261128201354.000064be@yahoo.com>,
>> Michael S  <already5chosen@yahoo.com> wrote:
>> >On Sat, 28 Nov 2026 12:26:54 -0000 (UTC)
>> >cross@spitfire.i.gajendra.net (Dan Cross) wrote:
>> >
>> >> In article <11eds8o$2ahsb$2@raubtier-asyl.eternal-september.org>,
>> >> Bonita Montero  <Bonita.Montero@gmail.com> wrote:
>> >> >Am 28.11.2026 um 06:50 schrieb Lawrence D’Oliveiro:
>> >> >
>> >> >> It *is* strongly-typed, and compiled.
>> >> >
>> >> >Python is weakly typed.
>> >> >Type annotations aren't enforced by the compiler.
>> >>
>> >> Lawrence is an idiot, but he's right about this.   Python
>> >> is _strongly_ typed, but it is not _statically_ typed.
>> >
>> >Weak or strong - it's not very important in practice.
>>
>> You mean static versus dynamic.
>
>No, I meant exactly what I wrote.

What you wrote was unclear.

>Python is strongly typed. It is of little practical importance.

Then you're wrong.  Strong typing is _essential_ to avoid
getting garbage results.  Adding 1 to a linked-list is a mistake
that should be caught somehow; whether at runtime (as in a
dynamic) language or at compile-time as in a statically typed
langauge is, as I said, a different axis.

>Python lacks static checks. It is of higher importance.

Without strong typing what would it check?

	- Dan C.
Re: C and its peasant 'ancestors'
#1983
Author: Michael S
Date: Sun, 29 Nov 2026 23:01
57 lines
3299 bytes
On Sun, 29 Nov 2026 22:48:51 -0000 (UTC)
cross@spitfire.i.gajendra.net (Dan Cross) wrote:

> In article <20261130000723.0000290f@yahoo.com>,
> Michael S  <already5chosen@yahoo.com> wrote:
> >On Sun, 29 Nov 2026 04:22:25 -0000 (UTC)
> >cross@spitfire.i.gajendra.net (Dan Cross) wrote:
> >  
> >> In article <20261128201354.000064be@yahoo.com>,
> >> Michael S  <already5chosen@yahoo.com> wrote:  
> >> >On Sat, 28 Nov 2026 12:26:54 -0000 (UTC)
> >> >cross@spitfire.i.gajendra.net (Dan Cross) wrote:
> >> >  
> >> >> In article
> >> >> <11eds8o$2ahsb$2@raubtier-asyl.eternal-september.org>, Bonita
> >> >> Montero  <Bonita.Montero@gmail.com> wrote:  
> >> >> >Am 28.11.2026 um 06:50 schrieb Lawrence
> >> >> >D’Oliveiro:
> >> >> >  
> >> >> >> It *is* strongly-typed, and compiled.  
> >> >> >
> >> >> >Python is weakly typed.
> >> >> >Type annotations aren't enforced by the compiler.  
> >> >>
> >> >> Lawrence is an idiot, but he's right about this.   Python
> >> >> is _strongly_ typed, but it is not _statically_ typed.  
> >> >
> >> >Weak or strong - it's not very important in practice.  
> >>
> >> You mean static versus dynamic.  
> >
> >No, I meant exactly what I wrote.  
> 
> What you wrote was unclear.
> 
> >Python is strongly typed. It is of little practical importance.  
> 
> Then you're wrong.  Strong typing is _essential_ to avoid
> getting garbage results. 

There is a whole continuum of possibilities between strongly typed and
untyped.

> Adding 1 to a linked-list is a mistake
> that should be caught somehow; whether at runtime (as in a
> dynamic) language or at compile-time as in a statically typed
> langauge is, as I said, a different axis.
> 
> >Python lacks static checks. It is of higher importance.  
> 
> Without strong typing what would it check?
> 
> 	- Dan C.
> 

Re: C and its peasant 'ancestors'
#1984
Author: Dan Cross
Date: Sun, 29 Nov 2026 23:10
57 lines
2938 bytes
In article <20261130010153.00003664@yahoo.com>,
Michael S  <already5chosen@yahoo.com> wrote:
>On Sun, 29 Nov 2026 22:48:51 -0000 (UTC)
>cross@spitfire.i.gajendra.net (Dan Cross) wrote:
>
>> In article <20261130000723.0000290f@yahoo.com>,
>> Michael S  <already5chosen@yahoo.com> wrote:
>> >On Sun, 29 Nov 2026 04:22:25 -0000 (UTC)
>> >cross@spitfire.i.gajendra.net (Dan Cross) wrote:
>> >
>> >> In article <20261128201354.000064be@yahoo.com>,
>> >> Michael S  <already5chosen@yahoo.com> wrote:
>> >> >On Sat, 28 Nov 2026 12:26:54 -0000 (UTC)
>> >> >cross@spitfire.i.gajendra.net (Dan Cross) wrote:
>> >> >
>> >> >> In article
>> >> >> <11eds8o$2ahsb$2@raubtier-asyl.eternal-september.org>, Bonita
>> >> >> Montero  <Bonita.Montero@gmail.com> wrote:
>> >> >> >Am 28.11.2026 um 06:50 schrieb Lawrence
>> >> >> >D’Oliveiro:
>> >> >> >
>> >> >> >> It *is* strongly-typed, and compiled.
>> >> >> >
>> >> >> >Python is weakly typed.
>> >> >> >Type annotations aren't enforced by the compiler.
>> >> >>
>> >> >> Lawrence is an idiot, but he's right about this.   Python
>> >> >> is _strongly_ typed, but it is not _statically_ typed.
>> >> >
>> >> >Weak or strong - it's not very important in practice.
>> >>
>> >> You mean static versus dynamic.
>> >
>> >No, I meant exactly what I wrote.
>>
>> What you wrote was unclear.
>>
>> >Python is strongly typed. It is of little practical importance.
>>
>> Then you're wrong.  Strong typing is _essential_ to avoid
>> getting garbage results.
>
>There is a whole continuum of possibilities between strongly typed and
>untyped.

Then you should explain yourself.

"Python is strongly typed.  It is of little practical
importance."  What, precisely, did you mean?  And why do you
consider it of, "little importance?"

To tie this back to C, C is a weakly-typed language; add a
number to a string literal and the result is a pointer.  This
has been a source of a _huge_ number of bugs over the years.

	- Dan C.
Re: C and its peasant 'ancestors'
#1985
Author: Ross Finlayson
Date: Sun, 29 Nov 2026 23:35
92 lines
4992 bytes
On 11/29/2026 03:10 PM, Dan Cross wrote:
> In article <20261130010153.00003664@yahoo.com>,
> Michael S  <already5chosen@yahoo.com> wrote:
>> On Sun, 29 Nov 2026 22:48:51 -0000 (UTC)
>> cross@spitfire.i.gajendra.net (Dan Cross) wrote:
>>
>>> In article <20261130000723.0000290f@yahoo.com>,
>>> Michael S  <already5chosen@yahoo.com> wrote:
>>>> On Sun, 29 Nov 2026 04:22:25 -0000 (UTC)
>>>> cross@spitfire.i.gajendra.net (Dan Cross) wrote:
>>>>
>>>>> In article <20261128201354.000064be@yahoo.com>,
>>>>> Michael S  <already5chosen@yahoo.com> wrote:
>>>>>> On Sat, 28 Nov 2026 12:26:54 -0000 (UTC)
>>>>>> cross@spitfire.i.gajendra.net (Dan Cross) wrote:
>>>>>>
>>>>>>> In article
>>>>>>> <11eds8o$2ahsb$2@raubtier-asyl.eternal-september.org>, Bonita
>>>>>>> Montero  <Bonita.Montero@gmail.com> wrote:
>>>>>>>> Am 28.11.2026 um 06:50 schrieb Lawrence
>>>>>>>> D’Oliveiro:
>>>>>>>>
>>>>>>>>> It *is* strongly-typed, and compiled.
>>>>>>>>
>>>>>>>> Python is weakly typed.
>>>>>>>> Type annotations aren't enforced by the compiler.
>>>>>>>
>>>>>>> Lawrence is an idiot, but he's right about this.   Python
>>>>>>> is _strongly_ typed, but it is not _statically_ typed.
>>>>>>
>>>>>> Weak or strong - it's not very important in practice.
>>>>>
>>>>> You mean static versus dynamic.
>>>>
>>>> No, I meant exactly what I wrote.
>>>
>>> What you wrote was unclear.
>>>
>>>> Python is strongly typed. It is of little practical importance.
>>>
>>> Then you're wrong.  Strong typing is _essential_ to avoid
>>> getting garbage results.
>>
>> There is a whole continuum of possibilities between strongly typed and
>> untyped.
>
> Then you should explain yourself.
>
> "Python is strongly typed.  It is of little practical
> importance."  What, precisely, did you mean?  And why do you
> consider it of, "little importance?"
>
> To tie this back to C, C is a weakly-typed language; add a
> number to a string literal and the result is a pointer.  This
> has been a source of a _huge_ number of bugs over the years.
>
> 	- Dan C.
>

That's still a char* in type, that's not type's fault.
The bounds-checking and type-checking are two separate
concerns, unless each gets its own type and own model
of arithmetic and in the language at both compile-time
and run-time, the arithmetization and the algebraization.

Agreeably, C has a variety of ways to break type-inference,
also usually the compiler can be strict and reliably balk at them.
Then, a certain number of fixed-size types can make overloads that
underload and results at least for usual algorithms that the
bounds are fixed.

It's sort of like, the, "RDBMS", relational database management
system, one of the first acroynyms (or initialisms if you must)
that most people in computers or IT ever bothered to remember.
Anyways, it's said to be an account of a relational algebra like
as of E.F. Codd's, yet, quite universally they have
"rows" and "nulls", which don't exist in the theory.

I suppose there's OCaml or Haskell, which when one first heard
about that might have reminded of Eddie Haskell, that toothy tagalong
of The Beaver's older brother, yet is for Haskell Curry, who
in the era of Church, who about when asked what what the "lambda"
in "lambda" represented, said "it doesn't mean anything,
signed 'Lonzo".

https://en.wikipedia.org/wiki/Lambda_calculus
https://en.wikipedia.org/wiki/Curry%E2%80%93Howard_correspondence




Re: C and its peasant 'ancestors'
#1986
Author: Chris M. Thomasson
Date: Sun, 29 Nov 2026 23:48
53 lines
3311 bytes
On 11/29/2026 3:01 PM, Michael S wrote:
> On Sun, 29 Nov 2026 22:48:51 -0000 (UTC)
> cross@spitfire.i.gajendra.net (Dan Cross) wrote:
> 
>> In article <20261130000723.0000290f@yahoo.com>,
>> Michael S  <already5chosen@yahoo.com> wrote:
>>> On Sun, 29 Nov 2026 04:22:25 -0000 (UTC)
>>> cross@spitfire.i.gajendra.net (Dan Cross) wrote:
>>>   
>>>> In article <20261128201354.000064be@yahoo.com>,
>>>> Michael S  <already5chosen@yahoo.com> wrote:
>>>>> On Sat, 28 Nov 2026 12:26:54 -0000 (UTC)
>>>>> cross@spitfire.i.gajendra.net (Dan Cross) wrote:
>>>>>   
>>>>>> In article
>>>>>> <11eds8o$2ahsb$2@raubtier-asyl.eternal-september.org>, Bonita
>>>>>> Montero  <Bonita.Montero@gmail.com> wrote:
>>>>>>> Am 28.11.2026 um 06:50 schrieb Lawrence
>>>>>>> D’Oliveiro:
>>>>>>>   
>>>>>>>> It *is* strongly-typed, and compiled.
>>>>>>>
>>>>>>> Python is weakly typed.
>>>>>>> Type annotations aren't enforced by the compiler.
>>>>>>
>>>>>> Lawrence is an idiot, but he's right about this.   Python
>>>>>> is _strongly_ typed, but it is not _statically_ typed.
>>>>>
>>>>> Weak or strong - it's not very important in practice.
>>>>
>>>> You mean static versus dynamic.
>>>
>>> No, I meant exactly what I wrote.
>>
>> What you wrote was unclear.
>>
>>> Python is strongly typed. It is of little practical importance.
>>
>> Then you're wrong.  Strong typing is _essential_ to avoid
>> getting garbage results.
> 
> There is a whole continuum of possibilities between strongly typed and
> untyped.
> 
>> Adding 1 to a linked-list is a mistake
>> that should be caught somehow; whether at runtime (as in a
>> dynamic) language or at compile-time as in a statically typed
>> langauge is, as I said, a different axis.
>>
>>> Python lacks static checks. It is of higher importance.
>>
>> Without strong typing what would it check?
Are you a fan of duck typing? ;^)
Re: C and its peasant 'ancestors'
#1987
Author: Keith Thompson
Date: Mon, 30 Nov 2026 00:04
60 lines
4176 bytes
cross@spitfire.i.gajendra.net (Dan Cross) writes:
> In article <20261130010153.00003664@yahoo.com>,
> Michael S  <already5chosen@yahoo.com> wrote:
[...]
>>There is a whole continuum of possibilities between strongly typed and
>>untyped.
>
> Then you should explain yourself.
>
> "Python is strongly typed.  It is of little practical
> importance."  What, precisely, did you mean?  And why do you
> consider it of, "little importance?"

I think this is devolving into an debate that's mostly about the
meanings of English phrases like "strongly typed" rather than about the
semantics of various programming languages.

I do agree that if someone is going to say a language is "strongly
typed", they should probably explain just what they mean by that.

I'm not aware that there's any widely accepted definition of
"strongly typed".  And I would argue that "strong typing" cannot
be measured along a single continuum, with "weakly typed" languages
at one end and "strongly typed" languages at the other.  One language
might have strong typing enforced at run time; another might have
weak typing enforced at compile time.

> To tie this back to C, C is a weakly-typed language; add a
> number to a string literal and the result is a pointer.  This
> has been a source of a _huge_ number of bugs over the years.

I can imagine a definition of "weakly-typed" that applies to C,
probably based on its rather promiscuous implicit conversions.  On
the other hand, every C expression has an unambiguous type, determined
entirely by the expression itself and the rules of the language.
(The conversion/adjustment of expressions of function an array
type is arguably an exception to this, but one that's completely
specified by the language rules).

Adding an integer to a string literal yields a pointer because
(a) an array expression, such as a string literal, is "converted"
to a pointer expression in most contexts, and (b) there exists an
addition operator that takes a pointer and an integer and yields
a pointer.  (And I'm skeptical that this has been a source of a
huge number of bugs.)  Python allows a string to be multiplied by
an integer; "foo" * 3 yields "foofoofoo".

In a typical assembly language, you can load two floating-point values
into registers and apply a bitwise xor to them as easily as you can
multiply them.  You can't do that in most higher-level languages,
including C, without extra steps that make the weirdness explicit.  In
Python, you can assign an expression of any type to a variable named
"x"; the type is associated with the value, not with the variable.
C doesn't do that.  I would argue that most assembly languages are
very weakly typed, but I wouldn't necessary say that C is more
strongly typed than Python is or vice versa.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Page 3 of 4 • 177 total messages
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads