Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Everyone has a purpose in life. Perhaps yours is watching television. -- David Letterman


devel / comp.lang.c / Re: "C Is The Greenest Programming Language" by: Chris Lott

SubjectAuthor
* "C Is The Greenest Programming Language" by: Chris LottLynn McGuire
+* Re: "C Is The Greenest Programming Language" by: Chris LottChris M. Thomasson
|`* Re: "C Is The Greenest Programming Language" by: Chris LottJuha Nieminen
| +* Re: "C Is The Greenest Programming Language" by: Chris LottChris M. Thomasson
| |`* Re: "C Is The Greenest Programming Language" by: Chris LottJuha Nieminen
| | `* Re: "C Is The Greenest Programming Language" by: Chris LottPhilipp Klaus Krause
| |  `- Re: "C Is The Greenest Programming Language" by: Chris LottDavid Brown
| `- Re: "C Is The Greenest Programming Language" by: Chris LottChris M. Thomasson
+* Re: "C Is The Greenest Programming Language" by: Chris LottRichard Damon
|+* Re: "C Is The Greenest Programming Language" by: Chris LottJuha Nieminen
||+- Re: "C Is The Greenest Programming Language" by: Chris LottThiago Adams
||+* Re: "C Is The Greenest Programming Language" by: Chris LottGuillaume
|||`- Re: "C Is The Greenest Programming Language" by: Chris LottJuha Nieminen
||`* Re: "C Is The Greenest Programming Language" by: Chris LottLynn McGuire
|| `- Re: "C Is The Greenest Programming Language" by: Chris LottScott Lurndal
|`- Re: "C Is The Greenest Programming Language" by: Chris LottPhilipp Klaus Krause
+* Re: "C Is The Greenest Programming Language" by: Chris LottOtto J. Makela
|+* Re: "C Is The Greenest Programming Language" by: Chris LottDozingDog
||`* Re: "C Is The Greenest Programming Language" by: Chris LottOtto J. Makela
|| `- Re: "C Is The Greenest Programming Language" by: Chris LottDozingDog
|`* Re: "C Is The Greenest Programming Language" by: Chris LottLynn McGuire
| `* Re: "C Is The Greenest Programming Language" by: Chris LottOtto J. Makela
|  `- Re: "C Is The Greenest Programming Language" by: Chris LottLynn McGuire
+* Re: "C Is The Greenest Programming Language" by: Chris LottBonita Montero
|`* Re: "C Is The Greenest Programming Language" by: Chris LottDozingDog
| `* Re: "C Is The Greenest Programming Language" by: Chris LottRichard Damon
|  +* Re: "C Is The Greenest Programming Language" by: Chris LottBonita Montero
|  |+* Re: "C Is The Greenest Programming Language" by: Chris LottRichard Damon
|  ||`* Re: "C Is The Greenest Programming Language" by: Chris LottBonita Montero
|  || +- Re: "C Is The Greenest Programming Language" by: Chris LottMalcolm McLean
|  || `* Re: "C Is The Greenest Programming Language" by: Chris LottRichard Damon
|  ||  `* Re: "C Is The Greenest Programming Language" by: Chris LottBonita Montero
|  ||   `* Re: "C Is The Greenest Programming Language" by: Chris LottRichard Damon
|  ||    `* Re: "C Is The Greenest Programming Language" by: Chris LottBonita Montero
|  ||     `* Re: "C Is The Greenest Programming Language" by: Chris LottRichard Damon
|  ||      `- Re: "C Is The Greenest Programming Language" by: Chris LottBonita Montero
|  |`- Re: "C Is The Greenest Programming Language" by: Chris LottMalcolm McLean
|  `* Re: "C Is The Greenest Programming Language" by: Chris LottDozingDog
|   `* Re: "C Is The Greenest Programming Language" by: Chris LottRichard Damon
|    `* Re: "C Is The Greenest Programming Language" by: Chris LottDozingDog
|     +* Re: "C Is The Greenest Programming Language" by: Chris LottJuha Nieminen
|     |`- Re: "C Is The Greenest Programming Language" by: Chris LottDozingDog
|     `* Re: "C Is The Greenest Programming Language" by: Chris LottRichard Damon
|      +- Re: "C Is The Greenest Programming Language" by: Chris LottDozingDog
|      `- Re: "C Is The Greenest Programming Language" by: Chris LottThiago Adams
+* Re: "C Is The Greenest Programming Language" by: Chris LottManfred
|+* Re: "C Is The Greenest Programming Language" by: Chris LottKenny McCormack
||+* Re: "C Is The Greenest Programming Language" by: Chris LottDavid Brown
|||+* Re: "C Is The Greenest Programming Language" by: Chris LottDozingDog
||||+- Re: "C Is The Greenest Programming Language" by: Chris LottRichard Damon
||||`* Re: "C Is The Greenest Programming Language" by: Chris LottDavid Brown
|||| `* Re: "C Is The Greenest Programming Language" by: Chris LottRichard Damon
||||  `- Re: "C Is The Greenest Programming Language" by: Chris LottDavid Brown
|||`* Re: "C Is The Greenest Programming Language" by: Chris LottManfred
||| +* Re: "C Is The Greenest Programming Language" by: Chris LottBart
||| |+* Re: "C Is The Greenest Programming Language" by: Chris LottIan Collins
||| ||`- Re: "C Is The Greenest Programming Language" by: Chris LottBart
||| |+* Re: "C Is The Greenest Programming Language" by: Chris LottDavid Brown
||| ||`* Re: "C Is The Greenest Programming Language" by: Chris LottBart
||| || `* Re: "C Is The Greenest Programming Language" by: Chris Lottantispam
||| ||  `- Re: "C Is The Greenest Programming Language" by: Chris LottBart
||| |`- Re: "C Is The Greenest Programming Language" by: Chris LottManfred
||| `* Re: "C Is The Greenest Programming Language" by: Chris LottDavid Brown
|||  `* Re: "C Is The Greenest Programming Language" by: Chris LottManfred
|||   `- Re: "C Is The Greenest Programming Language" by: Chris LottBart
||`- Re: "C Is The Greenest Programming Language" by: Chris LottManfred
|+- Re: "C Is The Greenest Programming Language" by: Chris LottBart
|`* Re: "C Is The Greenest Programming Language" by: Chris LottPhilipp Klaus Krause
| +* Re: "C Is The Greenest Programming Language" by: Chris LottKeith Thompson
| |+* Re: "C Is The Greenest Programming Language" by: Chris LottDavid Brown
| ||`- Re: "C Is The Greenest Programming Language" by: Chris LottPhilipp Klaus Krause
| |`- Re: "C Is The Greenest Programming Language" by: Chris LottPhilipp Klaus Krause
| `* Re: "C Is The Greenest Programming Language" by: Chris LottPhilipp Klaus Krause
|  `* Re: "C Is The Greenest Programming Language" by: Chris LottBart
|   +- Re: "C Is The Greenest Programming Language" by: Chris LottPhilipp Klaus Krause
|   `* Re: "C Is The Greenest Programming Language" by: Chris Lottantispam
|    `* Re: "C Is The Greenest Programming Language" by: Chris LottBart
|     `* [OT] Lisp. Was: "C Is The Greenest Programming Language" by: Chris LottBen Bacarisse
|      `* Re: "C Is The Greenest Programming Language"Dave Dunfield
|       `* Re: "C Is The Greenest Programming Language"Ben Bacarisse
|        `* Re: "C Is The Greenest Programming Language"Dave Dunfield
|         `* Re: "C Is The Greenest Programming Language"Ben Bacarisse
|          `* Re: "C Is The Greenest Programming Language"Dave Dunfield
|           `- Re: "C Is The Greenest Programming Language"Ben Bacarisse
+* Re: "C Is The Greenest Programming Language" by: Chris LottChris M. Thomasson
|`- Re: "C Is The Greenest Programming Language" by: Chris LottManfred
`* Re: "C Is The Greenest Programming Language" by: Chris LottPaavo Helde
 +* Re: "C Is The Greenest Programming Language" by: Chris LottChris M. Thomasson
 |`* Re: "C Is The Greenest Programming Language" by: Chris LottMalcolm McLean
 | `* Re: "C Is The Greenest Programming Language" by: Chris LottChris M. Thomasson
 |  `- Re: "C Is The Greenest Programming Language" by: Chris LottChris M. Thomasson
 +* Re: "C Is The Greenest Programming Language" by: Chris LottManfred
 |`- Re: "C Is The Greenest Programming Language" by: Chris LottPaavo Helde
 `- Re: "C Is The Greenest Programming Language" by: Chris LottBonita Montero

Pages:1234
Re: "C Is The Greenest Programming Language" by: Chris Lott

<snlmuo$ktp$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19219&group=comp.lang.c#19219

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!aioe.org!BKzeqmo2UYxb4eR2zKm0zw.user.46.165.242.91.POSTED!not-for-mail
From: Dozing...@thekennel.co
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Date: Wed, 24 Nov 2021 15:49:44 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <snlmuo$ktp$1@gioia.aioe.org>
References: <snh51g$c1q$1@dont-email.me> <87ilwjoykx.fsf@tigger.extechop.net>
<snj6ai$jkn$1@gioia.aioe.org>
<87mtlt99i1.fsf@tigger.extechop.net>
Injection-Info: gioia.aioe.org; logging-data="21433"; posting-host="BKzeqmo2UYxb4eR2zKm0zw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
 by: Dozing...@thekennel.co - Wed, 24 Nov 2021 15:49 UTC

On Wed, 24 Nov 2021 11:40:54 +0200
om@iki.fi (Otto J. Makela) wrote:
>DozingDog@thekennel.co wrote:
>
>> On Tue, 23 Nov 2021 14:17:50 +0200
>> om@iki.fi (Otto J. Makela) wrote:
>>>Lynn McGuire <lynnmcguire5@gmail.com> wrote:
>>>
>>>> "C Is The Greenest Programming Language" by: Chris Lott
>>>> https://hackaday.com/2021/11/18/c-is-the-greenest-programming-language/
>>>
>>>Perhaps one contributing factor is that not so much development is any
>>>longer done using C or C++, and the programs that are run (and still
>>>being developed) were originally created in the era when CPU power was
>>>much lower than these days, so code optimization was more important.
>>
>> Its good to see the attitude of just throw more CPU at something
>> instead of optimising it is still around. These days when server
>> farms are taking up a siginificant percentage of the planet's
>> electrical output its beholder on programmers to make their code
>> as efficient as is reasonable.
>
>I keep rereading that first sentence, is the meaning reversed?

No.

Re: "C Is The Greenest Programming Language" by: Chris Lott

<2otnJ.21405$b%.15512@fx24.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19220&group=comp.lang.c#19220

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx24.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Newsgroups: comp.lang.c,comp.lang.c++
References: <snh51g$c1q$1@dont-email.me> <hGVmJ.45875$Gco3.43326@fx01.iad> <sni4pq$1v37$1@gioia.aioe.org> <snk2qp$2hc$1@dont-email.me>
Lines: 26
Message-ID: <2otnJ.21405$b%.15512@fx24.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Wed, 24 Nov 2021 16:04:14 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Wed, 24 Nov 2021 16:04:14 GMT
X-Received-Bytes: 1826
 by: Scott Lurndal - Wed, 24 Nov 2021 16:04 UTC

Lynn McGuire <lynnmcguire5@gmail.com> writes:
>On 11/23/2021 1:21 AM, Juha Nieminen wrote:
>> In comp.lang.c++ Richard Damon <Richard@damon-family.org> wrote:

>> Ironically, the programming world has in the last couple of decades awakened
>> to the harsh realization that this complete disregard of memory usage
>> actually causes inefficiencies in modern CPU architectures (because
>> cache misses are very expensive).
>>
>> Oh well. As long as it works, who cares? Buy a faster computer.
>
>Not in California.

And Hawaii, Colorado, Oregon, Vermont and Washington State.

Why did you single out California?

And one can certainly purchase the most powerful computers in all of those
states by assembling them personally - note also that servers aren't covered
by the regulation, only desktop systems.

Did you actually read the article you posted a link to?

Here's an article without the panic, and with actual, you know, facts.

https://www.makeuseof.com/why-the-california-ban-on-power-hogging-pcs-is-a-good-thing/

Re: "C Is The Greenest Programming Language" by: Chris Lott

<t7unJ.62044$np6.13355@fx46.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19221&group=comp.lang.c#19221

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx46.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.3.2
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Content-Language: en-US
Newsgroups: comp.lang.c,comp.lang.c++
References: <snh51g$c1q$1@dont-email.me> <sniqts$6ks$1@dont-email.me>
<snj6e1$l3e$1@gioia.aioe.org> <Ww9nJ.30462$KV.13562@fx14.iad>
<snlmsh$jnc$1@gioia.aioe.org>
From: Rich...@Damon-Family.org (Richard Damon)
In-Reply-To: <snlmsh$jnc$1@gioia.aioe.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 75
Message-ID: <t7unJ.62044$np6.13355@fx46.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Wed, 24 Nov 2021 11:54:50 -0500
X-Received-Bytes: 4387
 by: Richard Damon - Wed, 24 Nov 2021 16:54 UTC

On 11/24/21 10:48 AM, DozingDog@thekennel.co wrote:
> On Tue, 23 Nov 2021 12:28:12 -0500
> Richard Damon <Richard@Damon-Family.org> wrote:
>> On 11/23/21 11:55 AM, DozingDog@thekennel.co wrote:
>>> On Tue, 23 Nov 2021 14:39:08 +0100
>>> Bonita Montero <Bonita.Montero@gmail.com> wrote:
>>>> Developing in C is a magnitude more effort than in C++, and if you've
>>>
>>> That depends on the problem. If you're writing code that needs to store a
>>> lot of structured data then C wouldn't be your first choice of language. But
>>> if you're writing something that simply interfaces with system calls then
>>> there's probably not much if any extra effort in using C over C++.
>>>
>>
>> I would disagree. With a decent compiler, C code can generate close to
>> assembly level optimizations for most problems. (Maybe it doesn't have
>
> So can a C++ compiler and with modern additions such constexpr C++ can optimise
> in ways that C simply can't.
>
>> ANYTHING in terms of data-structures that another language can generate,
>> you can generate in C.
>
> True, but you have to re-invent the wheel each time because frankly the level
> of complex data structure library support in the standard library in C is
> woeful. Eg the hsearch() and bsearch() functionality are frankly rubbish (only
> 1 tree/hash per process!) and Berkeley DB is a PITA to use.

Right, I never said it was the BEST way, especially if you include
programmer productivity.

If your goal is ABSOLUTELY TOP CPU EFFICIENCY, then 'standard libraries'
become just optional (use only if it IS the best for YOUR job).

Yes, this might mean 3 years of programming to say a millisecond of
execution, but it still puts the hand crafted code ahead of the higher
level langauge in RAW efficiency.

>
>> The big disadvantage is that YOU as the programmer need to deal with a
>> lot of the issues rather than to compiler doing things for you, but that
>> is exactly why you can do things possibly more efficiently then the
>> compiler. You could have always generated the same algorithm that the
>> compiler did.
>
> I doubt I could for example write a RB tree system better than that implemented
> in the C++ STL. It has 30 years of refining behind it.

So you can directly implement that algorithm in C. yes, it gets messier,
but you CAN do it.

And, yes, it also means you need to research (or look at implementations
and 'borrow') the best methods. Lots of programmer effort to get the
greenest code.

>
>> Now, if you want to talk of the efficiency of WRITING the code, (as
>> opposed to executing it) all this power it gives you is a negative,
>> which seems to be what you are talking about.
>
> Indeed, but your argument that C always produces more efficient code than C++
> probably hasn't been true for 20 years.
>

FLAW: Not ALWAYS, but CAN, big difference.

Yes, C++ idioms can generate complex code faster than C, and allows
things to be put into libraries that C can't readily do, and thus an
expert can right the library and 'lend' that expertise to an ordinary
code by them using the library. A custom coded C version can do just as
well, because you can express the same instruction sequences in C as
were generated in C++, you just need to be or explicit about it.

Re: "C Is The Greenest Programming Language" by: Chris Lott

<snlsuo$cbj$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19222&group=comp.lang.c#19222

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Date: Wed, 24 Nov 2021 18:32:07 +0100
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <snlsuo$cbj$1@dont-email.me>
References: <snh51g$c1q$1@dont-email.me> <sniqts$6ks$1@dont-email.me>
<snj6e1$l3e$1@gioia.aioe.org> <Ww9nJ.30462$KV.13562@fx14.iad>
<snjagc$ut6$1@dont-email.me> <0CanJ.130244$831.28837@fx40.iad>
<snjdag$kpa$1@dont-email.me> <rqhnJ.56108$JZ3.27705@fx05.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 24 Nov 2021 17:32:08 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f18ac2d2c231ecc3c50a61f805b7d6aa";
logging-data="12659"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ZGANEjvRpy/BFJJ6GvODQxs/AIZTu44c="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.3.2
Cancel-Lock: sha1:WA1X3ZlSQ27EWhJUKyWspMfcDJ4=
In-Reply-To: <rqhnJ.56108$JZ3.27705@fx05.iad>
Content-Language: de-DE
 by: Bonita Montero - Wed, 24 Nov 2021 17:32 UTC

Am 24.11.2021 um 03:27 schrieb Richard Damon:
> On 11/23/21 1:53 PM, Bonita Montero wrote:
>> Am 23.11.2021 um 19:41 schrieb Richard Damon:
>>
>>> For instance, I regularly use a variant of std:string that the char
>>> const* constructor checks if the input is from 'read only' memory,
>>> and if it is reuses that data instead of making a copy, at least
>>> until in wants to change it. ...
>>
>> Then use string_view.
>>
>
> Doesn't work.
>
> I have a lot of long lived object that store a string with a 'name' of
> the object.
>
> Most are created with a fixed compile time name that I pass as a const
> char* string to a read only literal.
>
> A few cases need to dynaically create a name based on specific usages,
> so these need that name stored as a dynamic value, but that memory wants
> to be reclaimed if/when the long lived object does go away.
>
> string_view doesn't help here, as when I create the few dynamic names,
> there is no place to keep that char array that is holding the name.

A class having a variant<string_view, string> member and an interface
to get or modify that string ? F.e. you could add a modify-interface
that does a copy-on-write modification of the string_view state,
chaning it into a string-state ?

Re: "C Is The Greenest Programming Language" by: Chris Lott

<I%unJ.89033$Z0a.17961@fx17.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19223&group=comp.lang.c#19223

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx17.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.3.2
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Content-Language: en-US
Newsgroups: comp.lang.c,comp.lang.c++
References: <snh51g$c1q$1@dont-email.me> <sniqts$6ks$1@dont-email.me>
<snj6e1$l3e$1@gioia.aioe.org> <Ww9nJ.30462$KV.13562@fx14.iad>
<snjagc$ut6$1@dont-email.me> <0CanJ.130244$831.28837@fx40.iad>
<snjdag$kpa$1@dont-email.me> <rqhnJ.56108$JZ3.27705@fx05.iad>
<snlsuo$cbj$1@dont-email.me>
From: Rich...@Damon-Family.org (Richard Damon)
In-Reply-To: <snlsuo$cbj$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 49
Message-ID: <I%unJ.89033$Z0a.17961@fx17.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Wed, 24 Nov 2021 12:54:49 -0500
X-Received-Bytes: 3087
 by: Richard Damon - Wed, 24 Nov 2021 17:54 UTC

On 11/24/21 12:32 PM, Bonita Montero wrote:
> Am 24.11.2021 um 03:27 schrieb Richard Damon:
>> On 11/23/21 1:53 PM, Bonita Montero wrote:
>>> Am 23.11.2021 um 19:41 schrieb Richard Damon:
>>>
>>>> For instance, I regularly use a variant of std:string that the char
>>>> const* constructor checks if the input is from 'read only' memory,
>>>> and if it is reuses that data instead of making a copy, at least
>>>> until in wants to change it. ...
>>>
>>> Then use string_view.
>>>
>>
>> Doesn't work.
>>
>> I have a lot of long lived object that store a string with a 'name' of
>> the object.
>>
>> Most are created with a fixed compile time name that I pass as a const
>> char* string to a read only literal.
>>
>> A few cases need to dynaically create a name based on specific usages,
>> so these need that name stored as a dynamic value, but that memory
>> wants to be reclaimed if/when the long lived object does go away.
>>
>> string_view doesn't help here, as when I create the few dynamic names,
>> there is no place to keep that char array that is holding the name.
>
> A class having a variant<string_view, string> member and an interface
> to get or modify that string ? F.e. you could add a modify-interface
> that does a copy-on-write modification of the string_view state,
> chaning it into a string-state ?
>

Your getting very heavy now.

It was much simpler to just implement the version of string I wanted,
which kept a pointer to the data, and an allocation size.

When constructed from a char const* value, it checked if this pointer
was to the read only block of memory, and if so didn't copy that string,
but just kept the original pointer, with an allocated size of 0 (to make
it easy to see if it was a read only string or a writable).

If your use case doesn't fit what the library supports well, you can
make you own.

Re: "C Is The Greenest Programming Language" by: Chris Lott

<87h7c1h15h.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19224&group=comp.lang.c#19224

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Date: Wed, 24 Nov 2021 10:14:02 -0800
Organization: None to speak of
Lines: 36
Message-ID: <87h7c1h15h.fsf@nosuchdomain.example.com>
References: <snh51g$c1q$1@dont-email.me> <snivri$15p1$1@gioia.aioe.org>
<snl5oc$8vo$1@solani.org>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="44ab1e6578847028e9d4263a74fcaa5f";
logging-data="29041"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1958ZuMWIxanOLLYb3zV1d8"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:0b9bC9t+zv4mDK6aJrbbt1M3i2A=
sha1:DtUkWVpTKw6zg8VHmXoXANYrA2Y=
 by: Keith Thompson - Wed, 24 Nov 2021 18:14 UTC

Philipp Klaus Krause <pkk@spth.de> writes:
> Am 23.11.21 um 16:03 schrieb Manfred:
>> On 11/22/2021 11:19 PM, Lynn McGuire wrote:
>>> Our results show interesting find- ings, such as, slower/faster
>>> languages consuming less/more energy, and how memory usage influences
>>> energy consump- tion
>>
>> I find the correlation slower/faster language respectively less/more
>> energy quite confusing. In fact I believe it is the opposite.
>>
>
> Well, the do state in the paper that the common assumption is that
> faster languages are more energy efficient. And their data supports that
> this assumption actually hold for many languages.
>
> But the surprising, and thus interesting result from their paper is that
> this is not universally true. You can see one example when looking at
> the data for Go and Lisp in the paper:
>
> Go is fast (only 183% slower than C), but energy inefficient (323% more
> energy consumed than C).

What does "183% slower" mean? I presume it doesn't run backwards at 83%
of C's speed.

For that matter, does "323% more energy consumed" mean 3.23 times as
much energy or 4.23 times as much energy? (Consider that "10%" more
means "1.1 times as much.)

> Lisp is slow (240% slower than C) but energy efficient (127% more energy
> consumed than C).

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: "C Is The Greenest Programming Language" by: Chris Lott

<snm1rl$i75$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19225&group=comp.lang.c#19225

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Date: Wed, 24 Nov 2021 19:55:49 +0100
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <snm1rl$i75$1@dont-email.me>
References: <snh51g$c1q$1@dont-email.me> <snivri$15p1$1@gioia.aioe.org>
<snl5oc$8vo$1@solani.org> <87h7c1h15h.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 24 Nov 2021 18:55:49 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="2c7321d55ebece1a08f5585d85c90b94";
logging-data="18661"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/CmpILG6hKtW59u8tL8D9nQlhBCQJ9KJ8="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:H3+CS6vq7qRG1UmGTi4uDSpQdlQ=
In-Reply-To: <87h7c1h15h.fsf@nosuchdomain.example.com>
Content-Language: en-GB
 by: David Brown - Wed, 24 Nov 2021 18:55 UTC

On 24/11/2021 19:14, Keith Thompson wrote:
> Philipp Klaus Krause <pkk@spth.de> writes:
>> Am 23.11.21 um 16:03 schrieb Manfred:
>>> On 11/22/2021 11:19 PM, Lynn McGuire wrote:
>>>> Our results show interesting find- ings, such as, slower/faster
>>>> languages consuming less/more energy, and how memory usage influences
>>>> energy consump- tion
>>>
>>> I find the correlation slower/faster language respectively less/more
>>> energy quite confusing. In fact I believe it is the opposite.
>>>
>>
>> Well, the do state in the paper that the common assumption is that
>> faster languages are more energy efficient. And their data supports that
>> this assumption actually hold for many languages.
>>
>> But the surprising, and thus interesting result from their paper is that
>> this is not universally true. You can see one example when looking at
>> the data for Go and Lisp in the paper:
>>
>> Go is fast (only 183% slower than C), but energy inefficient (323% more
>> energy consumed than C).
>
> What does "183% slower" mean? I presume it doesn't run backwards at 83%
> of C's speed.
>

I would guess it means it takes 1.83 times as long to handle the same
basic task. I can't really see any logical alternative explanation.
But "183% slower" is not exactly a good way to express that!

> For that matter, does "323% more energy consumed" mean 3.23 times as
> much energy or 4.23 times as much energy? (Consider that "10%" more
> means "1.1 times as much.)
>

I would guess 3.32 times as much energy, based on similarity to my
interpretation of "183% slower". Again, I agree that it's a poor way to
express it.

>> Lisp is slow (240% slower than C) but energy efficient (127% more energy
>> consumed than C).
>

Re: "C Is The Greenest Programming Language" by: Chris Lott

<snm56r$bfn$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19226&group=comp.lang.c#19226

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Date: Wed, 24 Nov 2021 20:52:59 +0100
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <snm56r$bfn$1@dont-email.me>
References: <snh51g$c1q$1@dont-email.me> <sniqts$6ks$1@dont-email.me>
<snj6e1$l3e$1@gioia.aioe.org> <Ww9nJ.30462$KV.13562@fx14.iad>
<snjagc$ut6$1@dont-email.me> <0CanJ.130244$831.28837@fx40.iad>
<snjdag$kpa$1@dont-email.me> <rqhnJ.56108$JZ3.27705@fx05.iad>
<snlsuo$cbj$1@dont-email.me> <I%unJ.89033$Z0a.17961@fx17.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 24 Nov 2021 19:52:59 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f18ac2d2c231ecc3c50a61f805b7d6aa";
logging-data="11767"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Gfm3/G3rdUHD4Z1mHVyHCGakIzaNUhH0="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.3.2
Cancel-Lock: sha1:Ns/yzXMwqMEBWs1HnZFCa4Z2CzA=
In-Reply-To: <I%unJ.89033$Z0a.17961@fx17.iad>
Content-Language: de-DE
 by: Bonita Montero - Wed, 24 Nov 2021 19:52 UTC

>> A class having a variant<string_view, string> member and an interface
>> to get or modify that string ? F.e. you could add a modify-interface
>> that does a copy-on-write modification of the string_view state,
>> chaning it into a string-state ?

> Your getting very heavy now.

Ok, developing a variant-string-class with all constructors,
methods and operators would be complex. But having s simple
variant<string, string_view> is easy.

Re: "C Is The Greenest Programming Language" by: Chris Lott

<snm6af$r0l$1@solani.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19227&group=comp.lang.c#19227

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: pkk...@spth.de (Philipp Klaus Krause)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Date: Wed, 24 Nov 2021 21:11:59 +0100
Message-ID: <snm6af$r0l$1@solani.org>
References: <snh51g$c1q$1@dont-email.me> <snivri$15p1$1@gioia.aioe.org>
<snl5oc$8vo$1@solani.org> <87h7c1h15h.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 24 Nov 2021 20:11:59 -0000 (UTC)
Injection-Info: solani.org;
logging-data="27669"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Cancel-Lock: sha1:33T4QWAeGmQWraW0GKEB4703LlM=
In-Reply-To: <87h7c1h15h.fsf@nosuchdomain.example.com>
X-User-ID: eJwFwYEBwCAIA7CbFFrhnBXX/08wQXBxThJMGDb6uL09Vt2KSP48YtxvWolNyMoQyjXLDy1cEbQ=
Content-Language: en-US
 by: Philipp Klaus Krause - Wed, 24 Nov 2021 20:11 UTC

Am 24.11.21 um 19:14 schrieb Keith Thompson:
> Philipp Klaus Krause <pkk@spth.de> writes:
>> Am 23.11.21 um 16:03 schrieb Manfred:
>>> On 11/22/2021 11:19 PM, Lynn McGuire wrote:
>>>> Our results show interesting find- ings, such as, slower/faster
>>>> languages consuming less/more energy, and how memory usage influences
>>>> energy consump- tion
>>>
>>> I find the correlation slower/faster language respectively less/more
>>> energy quite confusing. In fact I believe it is the opposite.
>>>
>>
>> Well, the do state in the paper that the common assumption is that
>> faster languages are more energy efficient. And their data supports that
>> this assumption actually hold for many languages.
>>
>> But the surprising, and thus interesting result from their paper is that
>> this is not universally true. You can see one example when looking at
>> the data for Go and Lisp in the paper:
>>
>> Go is fast (only 183% slower than C), but energy inefficient (323% more
>> energy consumed than C).
>
> What does "183% slower" mean? I presume it doesn't run backwards at 83%
> of C's speed.

By "183% slower", I meant "takes 183% more time to execute", i.e. 2.83
times the execution time.

>
> For that matter, does "323% more energy consumed" mean 3.23 times as
> much energy or 4.23 times as much energy? (Consider that "10%" more
> means "1.1 times as much.)

That was a mistake, that should have been "223% more energy consumed",
i.e. 3.23 times the energy of the C program.

Philipp

Re: "C Is The Greenest Programming Language" by: Chris Lott

<snm6cn$r0l$2@solani.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19228&group=comp.lang.c#19228

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: pkk...@spth.de (Philipp Klaus Krause)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Date: Wed, 24 Nov 2021 21:13:11 +0100
Message-ID: <snm6cn$r0l$2@solani.org>
References: <snh51g$c1q$1@dont-email.me> <snivri$15p1$1@gioia.aioe.org>
<snl5oc$8vo$1@solani.org> <87h7c1h15h.fsf@nosuchdomain.example.com>
<snm1rl$i75$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 24 Nov 2021 20:13:11 -0000 (UTC)
Injection-Info: solani.org;
logging-data="27669"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Content-Language: en-US
X-User-ID: eJwFwQkBwDAIA0BL5QkQOaMF/xJ2BwuJmx4Ix2J5VOzirbLJ4AFR8s2mDe886xK+hhcj1fMHDAoQaw==
In-Reply-To: <snm1rl$i75$1@dont-email.me>
Cancel-Lock: sha1:6zzJSiTKjvq9Emoi6pUP+wHBemw=
 by: Philipp Klaus Krause - Wed, 24 Nov 2021 20:13 UTC

Am 24.11.21 um 19:55 schrieb David Brown:
> Again, I agree that it's a poor way to
> express it.

Yes. I should have written that differently.

Re: "C Is The Greenest Programming Language" by: Chris Lott

<M1xnJ.77079$iq.58718@fx10.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19229&group=comp.lang.c#19229

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx10.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.3.2
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Content-Language: en-US
Newsgroups: comp.lang.c,comp.lang.c++
References: <snh51g$c1q$1@dont-email.me> <sniqts$6ks$1@dont-email.me>
<snj6e1$l3e$1@gioia.aioe.org> <Ww9nJ.30462$KV.13562@fx14.iad>
<snjagc$ut6$1@dont-email.me> <0CanJ.130244$831.28837@fx40.iad>
<snjdag$kpa$1@dont-email.me> <rqhnJ.56108$JZ3.27705@fx05.iad>
<snlsuo$cbj$1@dont-email.me> <I%unJ.89033$Z0a.17961@fx17.iad>
<snm56r$bfn$1@dont-email.me>
From: Rich...@Damon-Family.org (Richard Damon)
In-Reply-To: <snm56r$bfn$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 31
Message-ID: <M1xnJ.77079$iq.58718@fx10.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Wed, 24 Nov 2021 15:13:32 -0500
X-Received-Bytes: 2569
 by: Richard Damon - Wed, 24 Nov 2021 20:13 UTC

On 11/24/21 2:52 PM, Bonita Montero wrote:
>>> A class having a variant<string_view, string> member and an interface
>>> to get or modify that string ? F.e. you could add a modify-interface
>>> that does a copy-on-write modification of the string_view state,
>>> chaning it into a string-state ?
>
>> Your getting very heavy now.
>
> Ok, developing a variant-string-class with all constructors,
> methods and operators would be complex. But having s simple
> variant<string, string_view> is easy.

Building a variant<string, string_view> may be easy but would be a HOG.

My variant-string class implement all the functionality I needed, and
none of the stuff I wanted, and saved a LOT of memory as the standard
string class include a LOT of virtual functions to do things I don't
need, and my implementation isn't smart enough to do the whole program
recompile to trim out unneeded virtual functions.

For 1 day of work I saves about 25% of my programs size becuase I could
drop all the locale support that I didn't need.

The first cut string version was to fix a program to big error for an
embedded system because std::string pulled in WAY too much code just to
exist.

The second cut added the const char* string optimization to save a lot
of ram.

Situation awareness is key here.

Re: "C Is The Greenest Programming Language" by: Chris Lott

<snm6l8$r4e$1@solani.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19230&group=comp.lang.c#19230

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: pkk...@spth.de (Philipp Klaus Krause)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Date: Wed, 24 Nov 2021 21:17:43 +0100
Message-ID: <snm6l8$r4e$1@solani.org>
References: <snh51g$c1q$1@dont-email.me> <snivri$15p1$1@gioia.aioe.org>
<snl5oc$8vo$1@solani.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 24 Nov 2021 20:17:44 -0000 (UTC)
Injection-Info: solani.org;
logging-data="27790"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
In-Reply-To: <snl5oc$8vo$1@solani.org>
X-User-ID: eJwFwYEBwCAIA7CXHFJazpmy/n/CEux66jILlTBsng8vPGxZ7ovEUBzC6wQitSa5PWKz4wcoOhDb
Content-Language: en-US
Cancel-Lock: sha1:ZLJjKaPJ1Vk2jO60r5LnNeb6Ltk=
 by: Philipp Klaus Krause - Wed, 24 Nov 2021 20:17 UTC

Let's do this again:

When normalizing to the energy use and execution time of C (i.e. C is
1.0 for both energy use and execution time):

Go code takes 3.23 energy, and 2.83 execution time.

Lisp code takes 2.27 energy, and 3.40 execution time.

Re: "C Is The Greenest Programming Language" by: Chris Lott

<snm835$1bb$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19231&group=comp.lang.c#19231

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Date: Wed, 24 Nov 2021 20:42:14 +0000
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <snm835$1bb$1@dont-email.me>
References: <snh51g$c1q$1@dont-email.me> <snivri$15p1$1@gioia.aioe.org>
<snl5oc$8vo$1@solani.org> <snm6l8$r4e$1@solani.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 24 Nov 2021 20:42:13 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="40422f3da9d96b7683c985fb7fdd6cd4";
logging-data="1387"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+maRTxPDEYjdwQ9mKwy8GyX2kOexnFxBk="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.3.1
Cancel-Lock: sha1:jrScRaPKAm41o4z/QUpfxpiAQw0=
In-Reply-To: <snm6l8$r4e$1@solani.org>
 by: Bart - Wed, 24 Nov 2021 20:42 UTC

On 24/11/2021 20:17, Philipp Klaus Krause wrote:
> Let's do this again:
>
> When normalizing to the energy use and execution time of C (i.e. C is
> 1.0 for both energy use and execution time):
>
> Go code takes 3.23 energy, and 2.83 execution time.
>
> Lisp code takes 2.27 energy, and 3.40 execution time.
>

Do you have direct links/locations to those figures?

The OP's PDF link seems to be making using the Shootout benchmarks,
which I don't rate that highly.

There can be half a dozen different versions even in the same language,
using different algorithms.

The actual tasks are dubious too; a benchmark based around one
bottleneck is a long way from real code.

(Also, how did Lisp manage to be only 3 times as slow as C? It was both
interpreted /and/ dynamically typed last I looked.)

Re: "C Is The Greenest Programming Language" by: Chris Lott

<snmaq6$k7u$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19232&group=comp.lang.c#19232

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: lynnmcgu...@gmail.com (Lynn McGuire)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Date: Wed, 24 Nov 2021 15:28:36 -0600
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <snmaq6$k7u$1@dont-email.me>
References: <snh51g$c1q$1@dont-email.me> <87ilwjoykx.fsf@tigger.extechop.net>
<snk2tk$2hc$2@dont-email.me> <87r1b599uf.fsf@tigger.extechop.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 24 Nov 2021 21:28:38 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f6a5bfb77a213922d820ce1e7254b603";
logging-data="20734"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19tPjwYYQn8wSlGrzVmGIKT"
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.3.2
Cancel-Lock: sha1:H0Gwa6Pw83qPOWNrkEdCGq3DP2w=
In-Reply-To: <87r1b599uf.fsf@tigger.extechop.net>
Content-Language: en-US
 by: Lynn McGuire - Wed, 24 Nov 2021 21:28 UTC

On 11/24/2021 3:33 AM, Otto J. Makela wrote:
> Lynn McGuire <lynnmcguire5@gmail.com> wrote:
>
>> On 11/23/2021 6:17 AM, Otto J. Makela wrote:
>>> Lynn McGuire <lynnmcguire5@gmail.com> wrote:
>>>> "C Is The Greenest Programming Language" by: Chris Lott
>>>> https://hackaday.com/2021/11/18/c-is-the-greenest-programming-language/
>>> Perhaps one contributing factor is that not so much development
>>> is any longer done using C or C++, and the programs that are run
>>> (and still being developed) were originally created in the era
>>> when CPU power was much lower than these days, so code
>>> optimization was more important.
>>
>> I write C++ and Fortran code just about every day for our software
>> products.
>
> Do you consider this to be a common situation?

I really have no idea.

Lynn

Re: "C Is The Greenest Programming Language" by: Chris Lott

<snmdbn$6vb$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19233&group=comp.lang.c#19233

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Date: Wed, 24 Nov 2021 14:12:04 -0800
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <snmdbn$6vb$1@dont-email.me>
References: <snh51g$c1q$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 24 Nov 2021 22:12:07 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c1ed685eadf045f7fb92b885911e62f8";
logging-data="7147"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX192oG6D1HhEmfZXkdZQs2UuTBX+jU10F8M="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.3.2
Cancel-Lock: sha1:iL6Z2z9QJS5+lEpbr7n2sVkZgzI=
In-Reply-To: <snh51g$c1q$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 24 Nov 2021 22:12 UTC

On 11/22/2021 2:19 PM, Lynn McGuire wrote:
> "C Is The Greenest Programming Language" by: Chris Lott
>    https://hackaday.com/2021/11/18/c-is-the-greenest-programming-language/
>
> "Have you ever wondered if there is a correlation between a computer’s
> energy consumption and the choice of programming languages? Well, a
> group Portuguese university researchers did and set out to quantify it.
> Their 2017 research paper entitled Energy Efficiency across Programming
> Languages / How Do Energy, Time, and Memory Relate?  may have escaped
> your attention, as it did ours."
>    https://greenlab.di.uminho.pt/wp-content/uploads/2017/10/sleFinal.pdf
>
> "Abstract: This paper presents a study of the runtime, memory usage and
> energy consumption of twenty seven well-known soft- ware languages. We
> monitor the performance of such lan- guages using ten different
> programming problems, expressed in each of the languages. Our results
> show interesting find- ings, such as, slower/faster languages consuming
> less/more energy, and how memory usage influences energy consump- tion.
> We show how to use our results to provide software engineers support to
> decide which language to use when energy efficiency is a concern."
>

Humm... Perhaps, a main question can be, is there such a thing as a
"green" programmer? One can write crappy and bloated code in C, that
goes much slower than, say Python. However, one can write really
efficient code in C... Therefore, the quality of a programmer seems to
just want to come into play, so to speak...

Using undefined behavior wrt the standard can be a key aspect to writing
faster, more efficient code. Possible scenario: This os has built-in
User-space Read-Copy-Update (URCU). However, if I use it then my program
is no longer portable...

Can things be greener with a talented programmer and a low-level
language... Yes!

Can things be greener with a crappy programmer and a low-level
language... Humm, No? By chance? Unknown...?

Re: "C Is The Greenest Programming Language" by: Chris Lott

<snme4c$ur0$1@solani.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19234&group=comp.lang.c#19234

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: pkk...@spth.de (Philipp Klaus Krause)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Date: Wed, 24 Nov 2021 23:25:16 +0100
Message-ID: <snme4c$ur0$1@solani.org>
References: <snh51g$c1q$1@dont-email.me> <snivri$15p1$1@gioia.aioe.org>
<snl5oc$8vo$1@solani.org> <snm6l8$r4e$1@solani.org>
<snm835$1bb$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 24 Nov 2021 22:25:16 -0000 (UTC)
Injection-Info: solani.org;
logging-data="31584"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
X-User-ID: eJwNwoENACAIA7CXENmAcwTD/ydoWmwuthtBw3zh6mGoGl2RQTRubsm5LpscPfh8SpDS5wECERCF
Content-Language: en-US
Cancel-Lock: sha1:7yHOsCz7ghzjVOcbbM4Z4hr+LEI=
In-Reply-To: <snm835$1bb$1@dont-email.me>
 by: Philipp Klaus Krause - Wed, 24 Nov 2021 22:25 UTC

Am 24.11.21 um 21:42 schrieb Bart:
> On 24/11/2021 20:17, Philipp Klaus Krause wrote:
>> Let's do this again:
>>
>> When normalizing to the energy use and execution time of C (i.e. C is
>> 1.0 for both energy use and execution time):
>>
>> Go code takes 3.23 energy, and 2.83 execution time.
>>
>> Lisp code takes 2.27 energy, and 3.40 execution time.
>>
>
> Do you have direct links/locations to those figures?

Table 4 in the paper at the link the OP gave
(https://greenlab.di.uminho.pt/wp-content/uploads/2017/10/sleFinal.pdf).

Re: "C Is The Greenest Programming Language" by: Chris Lott

<snnqbn$1fj9$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19235&group=comp.lang.c#19235

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!news.niel.me!aioe.org!Puiiztk9lHEEQC0y3uUjRA.user.46.165.242.75.POSTED!not-for-mail
From: non...@add.invalid (Manfred)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Date: Thu, 25 Nov 2021 12:00:07 +0100
Organization: Aioe.org NNTP Server
Message-ID: <snnqbn$1fj9$1@gioia.aioe.org>
References: <snh51g$c1q$1@dont-email.me> <snmdbn$6vb$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="48745"; posting-host="Puiiztk9lHEEQC0y3uUjRA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.3.2
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Manfred - Thu, 25 Nov 2021 11:00 UTC

On 11/24/2021 11:12 PM, Chris M. Thomasson wrote:
> On 11/22/2021 2:19 PM, Lynn McGuire wrote:
>> "C Is The Greenest Programming Language" by: Chris Lott
>>
>> https://hackaday.com/2021/11/18/c-is-the-greenest-programming-language/
>>
>> "Have you ever wondered if there is a correlation between a computer’s
>> energy consumption and the choice of programming languages? Well, a
>> group Portuguese university researchers did and set out to quantify
>> it. Their 2017 research paper entitled Energy Efficiency across
>> Programming Languages / How Do Energy, Time, and Memory Relate?  may
>> have escaped your attention, as it did ours."
>>     https://greenlab.di.uminho.pt/wp-content/uploads/2017/10/sleFinal.pdf
>>
>> "Abstract: This paper presents a study of the runtime, memory usage
>> and energy consumption of twenty seven well-known soft- ware
>> languages. We monitor the performance of such lan- guages using ten
>> different programming problems, expressed in each of the languages.
>> Our results show interesting find- ings, such as, slower/faster
>> languages consuming less/more energy, and how memory usage influences
>> energy consump- tion. We show how to use our results to provide
>> software engineers support to decide which language to use when energy
>> efficiency is a concern."
>>
>
> Humm... Perhaps, a main question can be, is there such a thing as a
> "green" programmer? One can write crappy and bloated code in C, that
> goes much slower than, say Python.

Everything is possible, but achieving that requires some specialized
skillset(!)

However, one can write really
> efficient code in C... Therefore, the quality of a programmer seems to
> just want to come into play, so to speak...
>
> Using undefined behavior wrt the standard can be a key aspect to writing
> faster, more efficient code. Possible scenario: This os has built-in
> User-space Read-Copy-Update (URCU). However, if I use it then my program
> is no longer portable...
>
> Can things be greener with a talented programmer and a low-level
> language... Yes!
>
> Can things be greener with a crappy programmer and a low-level
> language... Humm, No? By chance? Unknown...?
>

The issue is about idiomatic constructs, i.e. the mass of code running
out there. I think that special circumstances and perverse cases do not
really matter.
Even more considering that C code that is so bad as to manage to perform
worse than some interpreted language is most likely pretty much
unmaintainable too, so doomed to fast extinction in the digital ecosystem.

Re: "C Is The Greenest Programming Language" by: Chris Lott

<snnr25$1qmu$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19236&group=comp.lang.c#19236

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!aioe.org!Puiiztk9lHEEQC0y3uUjRA.user.46.165.242.75.POSTED!not-for-mail
From: non...@add.invalid (Manfred)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Date: Thu, 25 Nov 2021 12:12:05 +0100
Organization: Aioe.org NNTP Server
Message-ID: <snnr25$1qmu$1@gioia.aioe.org>
References: <snh51g$c1q$1@dont-email.me> <snivri$15p1$1@gioia.aioe.org>
<snj2k7$vojf$1@news.xmission.com> <snj65u$tmi$1@dont-email.me>
<snjh78$8k0$1@gioia.aioe.org> <snjk6i$7qo$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="60126"; posting-host="Puiiztk9lHEEQC0y3uUjRA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.3.2
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Manfred - Thu, 25 Nov 2021 11:12 UTC

On 11/23/2021 9:50 PM, Bart wrote:
> On 23/11/2021 19:59, Manfred wrote:
>> On 11/23/2021 5:51 PM, David Brown wrote:
>>> On 23/11/2021 16:50, Kenny McCormack wrote:
>>>> In article <snivri$15p1$1@gioia.aioe.org>, Manfred
>>>> <noname@add.invalid> wrote:
>>>>> On 11/22/2021 11:19 PM, Lynn McGuire wrote:
>>>>>> Our results show interesting find- ings, such as, slower/faster
>>>>>> languages consuming less/more energy, and how memory usage influences
>>>>>> energy consump- tion
>>>>>
>>>>> I find the correlation slower/faster language respectively less/more
>>>>> energy quite confusing. In fact I believe it is the opposite.
>>>>
>>>> Yes.  I think this was misstated/sloppily-written in the original text.
>>>>
>>>> It depends, of course, on what exactly you mean by a "slower" language.
>>>> It is true that if you run the CPU at a slower speed (and that would
>>>> make
>>>> for a slower processing model), then you will use less energy.
>>>>
>>>
>>> It is /not/ true that running the CPU at a slower speed uses less energy
>>> - at least, it is often not true.  It is complicated.
>>>
>>> There are many aspects that affect how much energy is taken for a given
>>> calculation.
>>>
>>> Regarding programming languages, it is fairly obvious that a compiled
>>> language that takes fewer instructions to do a task using optimised
>>> assembly is going to use less energy than a language that has less
>>> optimisation and more assembly instructions, or does some kind of
>>> interpretation.  Thus C (and other optimised compiled languages like
>>> C++, Rust or Ada) are going to come out top.
>>>
>>> It is less obvious how the details matter.  Optimisation flags have an
>>> effect, as do choices of instruction (as functional blocks such as SIMD
>>> units or floating point units) may be dynamically enabled.  For some
>>> target processors, unrolling a loop to avoid branches will reduce energy
>>> consumption - on others, rolled loops to avoid cache misses will be
>>> better.  Some compilers targeting embedded systems (where power usage is
>>> often more important) have "optimise for power" as a third option to the
>>> traditional "optimise for speed" and "optimise for size".
>>>
>>> The power consumption for a processor is the sum of the static power and
>>> the dynamic power.  Dynamic power is proportional to the frequency and
>>> the square of the voltage.  And energy usage is power times time.
>>>
>>> A processor that is designed to run at high frequency is likely to have
>>> high-leakage transistors, and therefore high static power - when the
>>> circuits are enabled.  But the faster you get the work done, the higher
>>> a proportion of the time you can have in low-power modes with minimal
>>> static power.  On the other hand, higher frequencies may need higher
>>> voltages.
>>>
>>> As a rule of thumb, it is better to run your cpu at its highest
>>> frequency - or at the highest it can do without raising the voltage -
>>> and get the calculation done fast.  Then you can spend more time in
>>> low-power sleep modes.  However, entering and exiting sleep modes takes
>>> time and energy, so you don't want to do it too often - hence the
>>> "big-little" processor combinations where you have a slower core that
>>> can be switched on and off more efficiently.
>>>
>>
>> I am not sure about that "rule" - in general modern integrated
>> electronics waste most energy during state transitions, and that is
>> directly coupled with clock frequency, but I admit there may be more
>> to it that I don't know.
>>
>> One consideration about the balance between clock speed and efficiency
>> is that it is totally relative to how old the technology is. I am
>> pretty confident that an old Pentium is much less efficient than a
>> modern i7 (just to consider popular PC stuf only), even if the latter
>> runs faster than the former.
>> The reason is not just because of the added value of the environmental
>> footprint in today's public opinion; the fact is that heat dissipation
>> is a major bottleneck in IC technology, so in order for a modern
>> processor to perform according to nowadays' standards and not melt
>> after a few minutes of operation, it /has/ to be built with efficient
>> technology.
>
>> But then comes "modern" programming, with all its fuzz of managed
>> code, JIT gibber, thousands of DLL dependencies, etc., not to forget
>> "modern" OS's that eat Tflops just to perform even the simplest of
>> tasks, and there goes all of that efficiency.
>
> This is why talk of the greenest language is nonsense.

Not really, this study does show a significant difference between
language choices for the same task.

>
> How about writing efficient applications?
Yes, and that includes choosing the right language.

And efficient OSes (there
> might be 1000 processes on my PC right now).
That's a different matter than applications. It still affects overall
energy consumption of course. The choice of the language still matters
for OS processes, but general OS design has a major impact as well.
My critics is addressed to components that are shipped with many OS's,
yet are not technically part of the core OS infrastructure. Think e.g.
the Windows Update infrastructure - it's probably one of the most
bloated features I've ever seen.

>
> Access any webpage, and the fast download speeds mask how much data is
> being transmitted, which all still requires code to process it. Hardware
> can barely keep up.
>
> Or, how about efficient compilers? David Brown always contemptuously
> dismisses mine even though they are fast, yet they show that the basic
> job of source->binary translation can be done 1-2 magnitutes faster than
> the heavy-duty compilers he favours.

As others have pointed out, this does not matter, since compilers are
not part of a typical runtime environment.

>
> (For a couple of years one of my compilers was run as interpreted,
> dynamic bytecode. It was still double the speed of gcc!)

Re: "C Is The Greenest Programming Language" by: Chris Lott

<snnrfn$1mt$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19237&group=comp.lang.c#19237

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!aioe.org!BKzeqmo2UYxb4eR2zKm0zw.user.46.165.242.91.POSTED!not-for-mail
From: Dozing...@thekennel.co
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Date: Thu, 25 Nov 2021 11:19:19 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <snnrfn$1mt$1@gioia.aioe.org>
References: <snh51g$c1q$1@dont-email.me> <sniqts$6ks$1@dont-email.me>
<snj6e1$l3e$1@gioia.aioe.org> <Ww9nJ.30462$KV.13562@fx14.iad>
<snlmsh$jnc$1@gioia.aioe.org>
<t7unJ.62044$np6.13355@fx46.iad>
Injection-Info: gioia.aioe.org; logging-data="1757"; posting-host="BKzeqmo2UYxb4eR2zKm0zw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
 by: Dozing...@thekennel.co - Thu, 25 Nov 2021 11:19 UTC

On Wed, 24 Nov 2021 11:54:50 -0500
Richard Damon <Richard@Damon-Family.org> wrote:
>On 11/24/21 10:48 AM, DozingDog@thekennel.co wrote:
>> I doubt I could for example write a RB tree system better than that
>implemented
>> in the C++ STL. It has 30 years of refining behind it.
>
>So you can directly implement that algorithm in C. yes, it gets messier,
>but you CAN do it.

But there's no guarantee that it would be any faster.

>> Indeed, but your argument that C always produces more efficient code than C++
>
>> probably hasn't been true for 20 years.
>>
>
>FLAW: Not ALWAYS, but CAN, big difference.
>
>Yes, C++ idioms can generate complex code faster than C, and allows
>things to be put into libraries that C can't readily do, and thus an
>expert can right the library and 'lend' that expertise to an ordinary
>code by them using the library. A custom coded C version can do just as
>well, because you can express the same instruction sequences in C as
>were generated in C++, you just need to be or explicit about it.

Not always. eg:

#include <iostream>

constexpr int func(int cnt)
{ int val = 1;
while(--cnt) val *= 2;
return val;
}

int main()
{ constexpr int val = func(10);
std::cout << val << std::endl;
return 0;
}

In C++14 and onwards func() will literally be run by the compiler at compile
time and the result hard coded into the binary. No C compiler can do that not
because the language couldn't do it in theory, but because its never been
specified in the standard.

Re: "C Is The Greenest Programming Language" by: Chris Lott

<snnt3e$rp2$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19238&group=comp.lang.c#19238

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!aioe.org!NK0c7qMEn6mmBWqphs27pg.user.46.165.242.75.POSTED!not-for-mail
From: nos...@thanks.invalid (Juha Nieminen)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Date: Thu, 25 Nov 2021 11:46:56 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <snnt3e$rp2$1@gioia.aioe.org>
References: <snh51g$c1q$1@dont-email.me> <sniqts$6ks$1@dont-email.me> <snj6e1$l3e$1@gioia.aioe.org> <Ww9nJ.30462$KV.13562@fx14.iad> <snlmsh$jnc$1@gioia.aioe.org> <t7unJ.62044$np6.13355@fx46.iad> <snnrfn$1mt$1@gioia.aioe.org>
Injection-Info: gioia.aioe.org; logging-data="28450"; posting-host="NK0c7qMEn6mmBWqphs27pg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: tin/2.4.3-20181224 ("Glen Mhor") (UNIX) (Linux/5.4.42-grsec-kapsi (x86_64))
X-Notice: Filtered by postfilter v. 0.9.2
 by: Juha Nieminen - Thu, 25 Nov 2021 11:46 UTC

In comp.lang.c++ DozingDog@thekennel.co wrote:
> constexpr int func(int cnt)
> {
> int val = 1;
> while(--cnt) val *= 2;
> return val;
> }
>
>
> int main()
> {
> constexpr int val = func(10);
> std::cout << val << std::endl;
> return 0;
> }
>
>
> In C++14 and onwards func() will literally be run by the compiler at compile
> time and the result hard coded into the binary. No C compiler can do that not
> because the language couldn't do it in theory, but because its never been
> specified in the standard.

Actually gcc (and probably clang) will inline that function and calculate it
at compile time in C. You'll need a much more complicated constexpr function
for it to not be calculated at compile time by the compiler in C.

Re: "C Is The Greenest Programming Language" by: Chris Lott

<NZKnJ.36295$Ak2.28704@fx20.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19239&group=comp.lang.c#19239

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!feeder1.feed.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx20.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.3.2
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Content-Language: en-US
Newsgroups: comp.lang.c,comp.lang.c++
References: <snh51g$c1q$1@dont-email.me> <sniqts$6ks$1@dont-email.me>
<snj6e1$l3e$1@gioia.aioe.org> <Ww9nJ.30462$KV.13562@fx14.iad>
<snlmsh$jnc$1@gioia.aioe.org> <t7unJ.62044$np6.13355@fx46.iad>
<snnrfn$1mt$1@gioia.aioe.org>
From: Rich...@Damon-Family.org (Richard Damon)
In-Reply-To: <snnrfn$1mt$1@gioia.aioe.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 62
Message-ID: <NZKnJ.36295$Ak2.28704@fx20.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Thu, 25 Nov 2021 07:04:54 -0500
X-Received-Bytes: 3247
 by: Richard Damon - Thu, 25 Nov 2021 12:04 UTC

On 11/25/21 6:19 AM, DozingDog@thekennel.co wrote:
> On Wed, 24 Nov 2021 11:54:50 -0500
> Richard Damon <Richard@Damon-Family.org> wrote:
>> On 11/24/21 10:48 AM, DozingDog@thekennel.co wrote:
>>> I doubt I could for example write a RB tree system better than that
>> implemented
>>> in the C++ STL. It has 30 years of refining behind it.
>>
>> So you can directly implement that algorithm in C. yes, it gets messier,
>> but you CAN do it.
>
> But there's no guarantee that it would be any faster.
>
>>> Indeed, but your argument that C always produces more efficient code than C++
>>
>>> probably hasn't been true for 20 years.
>>>
>>
>> FLAW: Not ALWAYS, but CAN, big difference.
>>
>> Yes, C++ idioms can generate complex code faster than C, and allows
>> things to be put into libraries that C can't readily do, and thus an
>> expert can right the library and 'lend' that expertise to an ordinary
>> code by them using the library. A custom coded C version can do just as
>> well, because you can express the same instruction sequences in C as
>> were generated in C++, you just need to be or explicit about it.
>
> Not always. eg:
>
> #include <iostream>
>
> constexpr int func(int cnt)
> {
> int val = 1;
> while(--cnt) val *= 2;
> return val;
> }
>
>
> int main()
> {
> constexpr int val = func(10);
> std::cout << val << std::endl;
> return 0;
> }
>
>
> In C++14 and onwards func() will literally be run by the compiler at compile
> time and the result hard coded into the binary. No C compiler can do that not
> because the language couldn't do it in theory, but because its never been
> specified in the standard.
>

But you as the C programmer can do that too.

Rather than write the expression func(10), since for this to work in
C++, that 10 MUST be a known constant, I can manually compute the value.

Again, the claim is that you can write the optimal code in C, but it may
be a lot of work. It can be optimal for the use of CPU, but may well not
be optimal for the use of Programmer.

Re: "C Is The Greenest Programming Language" by: Chris Lott

<snobq1$9dc$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19242&group=comp.lang.c#19242

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!aioe.org!BKzeqmo2UYxb4eR2zKm0zw.user.46.165.242.91.POSTED!not-for-mail
From: Dozing...@thekennel.co
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Date: Thu, 25 Nov 2021 15:57:53 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <snobq1$9dc$1@gioia.aioe.org>
References: <snh51g$c1q$1@dont-email.me> <sniqts$6ks$1@dont-email.me> <snj6e1$l3e$1@gioia.aioe.org> <Ww9nJ.30462$KV.13562@fx14.iad> <snlmsh$jnc$1@gioia.aioe.org> <t7unJ.62044$np6.13355@fx46.iad> <snnrfn$1mt$1@gioia.aioe.org> <snnt3e$rp2$1@gioia.aioe.org>
Injection-Info: gioia.aioe.org; logging-data="9644"; posting-host="BKzeqmo2UYxb4eR2zKm0zw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
 by: Dozing...@thekennel.co - Thu, 25 Nov 2021 15:57 UTC

On Thu, 25 Nov 2021 11:46:56 -0000 (UTC)
Juha Nieminen <nospam@thanks.invalid> wrote:
>In comp.lang.c++ DozingDog@thekennel.co wrote:
>> constexpr int func(int cnt)
>> {
>> int val = 1;
>> while(--cnt) val *= 2;
>> return val;
>> }
>>
>>
>> int main()
>> {
>> constexpr int val = func(10);
>> std::cout << val << std::endl;
>> return 0;
>> }
>>
>>
>> In C++14 and onwards func() will literally be run by the compiler at compile
>> time and the result hard coded into the binary. No C compiler can do that not
>
>> because the language couldn't do it in theory, but because its never been
>> specified in the standard.
>
>Actually gcc (and probably clang) will inline that function and calculate it
>at compile time in C. You'll need a much more complicated constexpr function
>for it to not be calculated at compile time by the compiler in C.

Possibly if you set optimisation quite high (and remove the constexpr keyword),
but you can't rely on it, whereas you can in C++ because its in the standard.

Re: "C Is The Greenest Programming Language" by: Chris Lott

<snobt0$am6$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19243&group=comp.lang.c#19243

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!aioe.org!BKzeqmo2UYxb4eR2zKm0zw.user.46.165.242.91.POSTED!not-for-mail
From: Dozing...@thekennel.co
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Date: Thu, 25 Nov 2021 15:59:28 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <snobt0$am6$1@gioia.aioe.org>
References: <snh51g$c1q$1@dont-email.me> <sniqts$6ks$1@dont-email.me>
<snj6e1$l3e$1@gioia.aioe.org> <Ww9nJ.30462$KV.13562@fx14.iad>
<snlmsh$jnc$1@gioia.aioe.org> <t7unJ.62044$np6.13355@fx46.iad>
<snnrfn$1mt$1@gioia.aioe.org>
<NZKnJ.36295$Ak2.28704@fx20.iad>
Injection-Info: gioia.aioe.org; logging-data="10950"; posting-host="BKzeqmo2UYxb4eR2zKm0zw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
 by: Dozing...@thekennel.co - Thu, 25 Nov 2021 15:59 UTC

On Thu, 25 Nov 2021 07:04:54 -0500
Richard Damon <Richard@Damon-Family.org> wrote:
>On 11/25/21 6:19 AM, DozingDog@thekennel.co wrote:
>> because the language couldn't do it in theory, but because its never been
>> specified in the standard.
>>
>
>But you as the C programmer can do that too.
>
>Rather than write the expression func(10), since for this to work in
>C++, that 10 MUST be a known constant, I can manually compute the value.

You could manually compute logarithm and trig tables but I imagine you'd
prefer to use log() and sin() instead.

>Again, the claim is that you can write the optimal code in C, but it may
>be a lot of work. It can be optimal for the use of CPU, but may well not
>be optimal for the use of Programmer.

Well quite.

Re: "C Is The Greenest Programming Language" by: Chris Lott

<snojog$5fr$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19245&group=comp.lang.c#19245

  copy link   Newsgroups: comp.lang.c comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c,comp.lang.c++
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
Date: Thu, 25 Nov 2021 19:13:36 +0100
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <snojog$5fr$1@dont-email.me>
References: <snh51g$c1q$1@dont-email.me> <sniqts$6ks$1@dont-email.me>
<snj6e1$l3e$1@gioia.aioe.org> <Ww9nJ.30462$KV.13562@fx14.iad>
<snjagc$ut6$1@dont-email.me> <0CanJ.130244$831.28837@fx40.iad>
<snjdag$kpa$1@dont-email.me> <rqhnJ.56108$JZ3.27705@fx05.iad>
<snlsuo$cbj$1@dont-email.me> <I%unJ.89033$Z0a.17961@fx17.iad>
<snm56r$bfn$1@dont-email.me> <M1xnJ.77079$iq.58718@fx10.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 25 Nov 2021 18:13:36 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="654af12644a99d9f6d66368029395516";
logging-data="5627"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1927Mi3RrZfL2EkIWcV8gH0FRvKdW7+oQc="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.3.2
Cancel-Lock: sha1:bvaOFuRCP3WkdDEBtfozStqp53Q=
In-Reply-To: <M1xnJ.77079$iq.58718@fx10.iad>
Content-Language: de-DE
 by: Bonita Montero - Thu, 25 Nov 2021 18:13 UTC

> My variant-string class implement all the functionality I needed, and
> none of the stuff I wanted, and saved a LOT of memory as the standard
> string class include a LOT of virtual functions to do things I don't
> need, ...

basic_string<> doesn't include virtual functions and if basic_string<>
would use virtual functions, they would take only one VMT-pointer per
object.

Re: "C Is The Greenest Programming Language" by: Chris Lott

<90059985-e401-4567-a9f8-d6ff5a9dba45n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19253&group=comp.lang.c#19253

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:3187:: with SMTP id bi7mr13357088qkb.534.1637926663281;
Fri, 26 Nov 2021 03:37:43 -0800 (PST)
X-Received: by 2002:a05:6214:13d1:: with SMTP id cg17mr11441493qvb.131.1637926663052;
Fri, 26 Nov 2021 03:37:43 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Fri, 26 Nov 2021 03:37:42 -0800 (PST)
In-Reply-To: <NZKnJ.36295$Ak2.28704@fx20.iad>
Injection-Info: google-groups.googlegroups.com; posting-host=189.6.248.114; posting-account=xFcAQAoAAAAoWlfpQ6Hz2n-MU9fthxbY
NNTP-Posting-Host: 189.6.248.114
References: <snh51g$c1q$1@dont-email.me> <sniqts$6ks$1@dont-email.me>
<snj6e1$l3e$1@gioia.aioe.org> <Ww9nJ.30462$KV.13562@fx14.iad>
<snlmsh$jnc$1@gioia.aioe.org> <t7unJ.62044$np6.13355@fx46.iad>
<snnrfn$1mt$1@gioia.aioe.org> <NZKnJ.36295$Ak2.28704@fx20.iad>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <90059985-e401-4567-a9f8-d6ff5a9dba45n@googlegroups.com>
Subject: Re: "C Is The Greenest Programming Language" by: Chris Lott
From: thiago.a...@gmail.com (Thiago Adams)
Injection-Date: Fri, 26 Nov 2021 11:37:43 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 59
 by: Thiago Adams - Fri, 26 Nov 2021 11:37 UTC

On Thursday, November 25, 2021 at 9:05:17 AM UTC-3, Richard Damon wrote:
> On 11/25/21 6:19 AM, Dozi...@thekennel.co wrote:
> > On Wed, 24 Nov 2021 11:54:50 -0500
> > Richard Damon <Ric...@Damon-Family.org> wrote:
> >> On 11/24/21 10:48 AM, Dozi...@thekennel.co wrote:
> >>> I doubt I could for example write a RB tree system better than that
> >> implemented
> >>> in the C++ STL. It has 30 years of refining behind it.
> >>
> >> So you can directly implement that algorithm in C. yes, it gets messier,
> >> but you CAN do it.
> >
> > But there's no guarantee that it would be any faster.
> >
> >>> Indeed, but your argument that C always produces more efficient code than C++
> >>
> >>> probably hasn't been true for 20 years.
> >>>
> >>
> >> FLAW: Not ALWAYS, but CAN, big difference.
> >>
> >> Yes, C++ idioms can generate complex code faster than C, and allows
> >> things to be put into libraries that C can't readily do, and thus an
> >> expert can right the library and 'lend' that expertise to an ordinary
> >> code by them using the library. A custom coded C version can do just as
> >> well, because you can express the same instruction sequences in C as
> >> were generated in C++, you just need to be or explicit about it.
> >
> > Not always. eg:
> >
> > #include <iostream>
> >
> > constexpr int func(int cnt)
> > {
> > int val = 1;
> > while(--cnt) val *= 2;
> > return val;
> > }
> >
> >
> > int main()
> > {
> > constexpr int val = func(10);
> > std::cout << val << std::endl;
> > return 0;
> > }
> >
> >
> > In C++14 and onwards func() will literally be run by the compiler at compile
> > time and the result hard coded into the binary. No C compiler can do that not
> > because the language couldn't do it in theory, but because its never been
> > specified in the standard.
> >
> But you as the C programmer can do that too.
>
> Rather than write the expression func(10), since for this to work in
> C++, that 10 MUST be a known constant, I can manually compute the value.

Yes, and the compilation does not need to recalculate this every time.

Pages:1234
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor