Article View: comp.lang.c
Article #1939Re: C and its peasant 'ancestors'
From: David Brown
Date: Sat, 28 Nov 2026 19:27
Date: Sat, 28 Nov 2026 19:27
100 lines
5934 bytes
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.
Technical Details
Message-ID:
<11ef9ur$2rvk1$1@dont-email.me>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<11dup6q$v4j9$1@dont-email.me> <11e0kde$1jpvu$1@dont-email.me> <11e0r13$1lqm6$1@dont-email.me> <11e0uc0$1mtpv$1@raubtier-asyl.eternal-september.org> <11e7fj4$37l9$1@dont-email.me> <11e8oro$ft4l$1@raubtier-asyl.eternal-september.org> <11e8stp$hajr$1@dont-email.me> <11e8ti0$hhqa$1@dont-email.me> <11e8v24$i2mc$2@raubtier-asyl.eternal-september.org> <11e9045$ihk3$1@dont-email.me> <11e90a8$ikh0$1@dont-email.me> <11e90mv$io87$2@raubtier-asyl.eternal-september.org> <11e91ns$j5dv$1@dont-email.me> <11e92ff$jclo$1@raubtier-asyl.eternal-september.org> <11e95j2$kimu$1@dont-email.me> <11e96aa$kpta$1@raubtier-asyl.eternal-september.org> <11ect54$20qpr$3@dont-email.me> <11edmpn$2938p$1@raubtier-asyl.eternal-september.org> <11eerur$2me3k$1@dont-email.me> <11eevkk$2nu8b$1@raubtier-asyl.eternal-september.org> <11ef5ik$2q9c9$1@dont-email.me> <20261128201856.00000619@yahoo.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: David Brown <david.brown@hesbynett.no> Newsgroups: comp.lang.c Subject: Re: C and its peasant 'ancestors' Date: Sat, 28 Nov 2026 20:27:23 +0100 Organization: A noiseless patient Spider Lines: 100 Message-ID: <11ef9ur$2rvk1$1@dont-email.me> References: <11dup6q$v4j9$1@dont-email.me> <11e0kde$1jpvu$1@dont-email.me> <11e0r13$1lqm6$1@dont-email.me> <11e0uc0$1mtpv$1@raubtier-asyl.eternal-september.org> <11e7fj4$37l9$1@dont-email.me> <11e8oro$ft4l$1@raubtier-asyl.eternal-september.org> <11e8stp$hajr$1@dont-email.me> <11e8ti0$hhqa$1@dont-email.me> <11e8v24$i2mc$2@raubtier-asyl.eternal-september.org> <11e9045$ihk3$1@dont-email.me> <11e90a8$ikh0$1@dont-email.me> <11e90mv$io87$2@raubtier-asyl.eternal-september.org> <11e91ns$j5dv$1@dont-email.me> <11e92ff$jclo$1@raubtier-asyl.eternal-september.org> <11e95j2$kimu$1@dont-email.me> <11e96aa$kpta$1@raubtier-asyl.eternal-september.org> <11ect54$20qpr$3@dont-email.me> <11edmpn$2938p$1@raubtier-asyl.eternal-september.org> <11eerur$2me3k$1@dont-email.me> <11eevkk$2nu8b$1@raubtier-asyl.eternal-september.org> <11ef5ik$2q9c9$1@dont-email.me> <20261128201856.00000619@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 28 Nov 2026 19:27:24 +0000 (UTC) Injection-Info: dont-email.me; logging-data="3014273"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+4Wjq7bLlqgwzMKGYffhhTpz3MZYupQIc="; posting-host="830fabbfeda36f3c3fabbdfcbd22e3d2" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:kxLv5pybr4wRhDZAsYnu+MeK8gY= sha256:nUdA71GLtsX9/FNt962ty/8Y0iVqT6ktrEvXq7Qi5VA= sha1:BJAf1SnduO7IFPhHXxHAL75xILg= sha256:Cht9IwS+YC8JyQ8No6C2X6V1ai737LjX3T05CYneuXw= Content-Language: en-GB In-Reply-To: <20261128201856.00000619@yahoo.com>