Path: csiph.com!news.swapon.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c++ Subject: Re: Threads across programming languages Date: Mon, 03 Jun 2024 19:30:05 -0700 Organization: A noiseless patient Spider Lines: 65 Message-ID: <86mso1mocy.fsf@linuxsc.com> References: <20240503180102.00002f98@yahoo.com> <86ikzqtwqr.fsf@linuxsc.com> <86cyppru3q.fsf@linuxsc.com> <126394fbbc6a61aa1257379032ed4fc43689a61c.camel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Tue, 04 Jun 2024 04:30:06 +0200 (CEST) Injection-Info: dont-email.me; posting-host="2e3473276f70e973f0e20911b7f6b99d"; logging-data="136753"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/+zcUrdnvKaJM7C402mMgxe2Xhj4eD9Kc=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:XIetTb4nLpDqP37KgRpNRQtklNM= sha1:t3isA6GAdfT7oAgPanFPGf4WbPA= Xref: csiph.com comp.lang.c++:119460 wij writes: > On Tue, 2024-05-14 at 16:24 +0200, David Brown wrote: > >> On 14/05/2024 13:46, wij wrote: >> >>> On Tue, 2024-05-14 at 13:53 +0300, Paavo Helde wrote: >>> >>>> On 14.05.2024 05:43, Tim Rentsch wrote: >>>> >>>>> Paavo Helde writes: >>>>> >>>>>> On 07.05.2024 01:13, Tim Rentsch wrote: >>>>> >>>> >>>>>>> >>>>>>> C++ doesn't need nested functions because it has lambdas, which >>>>>>> are effectively equivalent. >>>>>> >>>>>> Lambdas are better than nested functions as one can specify explicitly >>>>>> which variables are shared and how. One can be lazy and pass [&], but >>>>>> one doesn't have to. >>>>> >>>>> To me that sounds like all the complications of nested functions, >>>>> and more besides, and no real advantages. The choice of which >>>>> variables to share is syntactic sugar, there is no difference >>>>> in expressive power. >>>> >>>> Most of what programming languages do is syntactic sugar. For just >>>> writing Turing complete code one programming language would be enough. >>> >>> The primary goal of high level language should be for reducing software >>> development/maintenance cost. >> >> Yes. And the main way to do that is to reduce the risk of errors >> passing into later stages of development. A language (and the >> programmer using the language) should aim to make it easy to write good >> code, hard to write bad code, easy to see that good code is good, and >> easy to see that bad code is bad. > > Sounds like Bjarne Stroustrup's tongue. But I don't feel C++ is steering > in that way. Since C++11 many features do not feel like what BS says in his > book. > >> "Syntactic sugar" is vital to this effort. And a key source of "power" >> of a language is not in what it allows you do to, but in what it stops >> you from doing, or allows you to restrict yourself. For example, often >> a correct program will work just as correctly, and just as efficiently, >> if all uses of "const" are removed. The "const" does not add to the >> things the language can do - it helps by restricting the errors you can >> make when using the language. > > I agree what you say, but pretty much every high level language would say > the same (how about BASIC?). I am more concerned about the practical side. > >> So Tim is completely wrong to say that specifying the variables >> accessible in a lambda gives "no real advantages". It doesn't give the >> compiler's code /generator/ any more information than it can deduce >> itself from [&] or [=], but it gives more information to the compiler's >> code /checker/ and to human programmers - those are big advantages and >> greater expressive power. Besides being self-centered, rude, arrogant, and generally careless in both his thinking and his writing, David Brown has misunderstood the meaning of my comments above.