Deutsch   English   Français   Italiano  
<van9kt$3g7l8$1@raubtier-asyl.eternal-september.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita Montero <Bonita.Montero@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: Top 10 most common hard skills listed on resumes...
Date: Wed, 28 Aug 2024 15:45:03 +0200
Organization: A noiseless patient Spider
Lines: 52
Message-ID: <van9kt$3g7l8$1@raubtier-asyl.eternal-september.org>
References: <vab101$3er$1@reader1.panix.com>
 <vad7ns$1g27b$1@raubtier-asyl.eternal-september.org>
 <vad8lr$1fv5u$1@dont-email.me> <vaf7f0$k51$2@reader1.panix.com>
 <vafgb2$1to4v$2@dont-email.me>
 <vafkdk$1ut4h$2@raubtier-asyl.eternal-september.org>
 <20240825192810.0000672c@yahoo.com>
 <vafs6u$21ofd$1@raubtier-asyl.eternal-september.org>
 <20240825220016.00002793@yahoo.com> <86bk1e4y7t.fsf@linuxsc.com>
 <vajn50$2rqra$2@raubtier-asyl.eternal-september.org>
 <vajnha$2rtl3$1@dont-email.me>
 <vajns4$2rvg8$1@raubtier-asyl.eternal-september.org>
 <vajspc$2so1b$1@dont-email.me>
 <vajtdo$2ssc8$1@raubtier-asyl.eternal-september.org>
 <valodj$35rt8$7@dont-email.me>
 <vamarr$3btll$1@raubtier-asyl.eternal-september.org>
 <van0h7$3eqvr$1@dont-email.me>
 <van1sb$3f45o$1@raubtier-asyl.eternal-september.org>
 <van2ok$3f3q8$1@dont-email.me>
 <van6td$3frfe$1@raubtier-asyl.eternal-september.org>
 <van934$3g2ip$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 28 Aug 2024 15:45:01 +0200 (CEST)
Injection-Info: raubtier-asyl.eternal-september.org; posting-host="533d64590f09fbd7a1b41b803c3065f2";
	logging-data="3677864"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+4NRIAv6oQr2ghxBrII7WkKjHFfRUNoro="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:VvISc1lZo1C97bp7vTpnxFBAAkk=
In-Reply-To: <van934$3g2ip$1@dont-email.me>
Content-Language: de-DE
Bytes: 3829

Am 28.08.2024 um 15:35 schrieb Thiago Adams:

> In C you learn how to write less code.

You do th same in C, but manually.

> RAII, destructor, constructor is a bad idea, but I don't know if it is a 
> good place to talk about it. I also don't know if I will be able to 
> convince you.

If you have a allocated resource you've to deallocate it at the end of
the scope. In C you do that error-prone with goto-orgies like in the
Linux-kernel. In C++ there's no goto necessary and the resulting code
is the same.

> One problem of RAII and destructor we cannot disable it.

If you've got to deallocate the memory you need the destructor.
If you move your container elsewhere and the compiler sees that
the destructor is opimized away for the non-exception code-path.

> By the way, in C++ we cannot move const objects. This is ridiculous.

Const-objects are there not to be modified. If you've got logical
constness you can cast away the const with const_cast and move its
contents. But casting away const is unclean mostly in C and C++.

> How we call it does not change the fact is the someone else wrote the 
> code. Then we write less code if we use other people code.

Such code from the standard library is optimal in terms of performance.
And using C++23' mdspan results in the same code and a tenth of the
LOCs

> #include <memory>
> 
> struct base2 {
>      virtual std::unique_ptr<struct base> clone();
> };
> struct derived2 : public base2 {
>      struct std::unique_ptr<struct derived> clone() override{
>          return this;
>      }
> };

In C you've no OOP and no unique_ptr, everything is done manually
with ten times the code.

> string_view was a "fix" and then we will have a fix for a fix etc..

string_view isn't a fix, it's a very useful feature.