Friday, December 9, 2022

Digest for comp.lang.c++@googlegroups.com - 25 updates in 4 topics

Bonita Montero <Bonita.Montero@gmail.com>: Dec 09 04:09AM +0100

I don't think this is a relevant comparison since most things which
are done in Java wouldn't be done in C++ and vice versa. C++ is used
when you need nearly optimal performance or system-level programming.
Lynn McGuire <lynnmcguire5@gmail.com>: Dec 08 09:15PM -0600

On 12/8/2022 9:09 PM, Bonita Montero wrote:
> I don't think this is a relevant comparison since most things which
> are done in Java wouldn't be done in C++ and vice versa. C++ is used
> when you need nearly optimal performance or system-level programming.
 
Or when you don't want to be sued by Oracle.
 
Lynn
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Dec 08 08:02PM -0800

On 12/8/2022 7:15 PM, Lynn McGuire wrote:
>> are done in Java wouldn't be done in C++ and vice versa. C++ is used
>> when you need nearly optimal performance or system-level programming.
 
> Or when you don't want to be sued by Oracle.
 
 
Yikes! Are lawyers are bigger than yours!
 
https://youtu.be/HEYrRNMr2kg
 
evil grin... ;^o
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Dec 08 08:03PM -0800

On 12/8/2022 8:02 PM, Chris M. Thomasson wrote:
>>> when you need nearly optimal performance or system-level programming.
 
>> Or when you don't want to be sued by Oracle.
 
> Yikes! Are lawyers are bigger than yours!
 
Are _into_ Our! yikes! sued for typo syndrome.
 
Bonita Montero <Bonita.Montero@gmail.com>: Dec 09 08:27PM +0100

Am 09.12.2022 um 04:15 schrieb Lynn McGuire:
 
>> are done in Java wouldn't be done in C++ and vice versa. C++ is used
>> when you need nearly optimal performance or system-level programming.
 
> Or when you don't want to be sued by Oracle.
 
There are not much redistributed applications written in Java running
on a PC. Java is mostly used for in-house server-applications. With
that you won't have to pay anything.
Lynn McGuire <lynnmcguire5@gmail.com>: Dec 09 02:38PM -0600

On 12/9/2022 1:27 PM, Bonita Montero wrote:
 
> There are not much redistributed applications written in Java running
> on a PC. Java is mostly used for in-house server-applications. With
> that you won't have to pay anything.
 
Most of the consumer devices out there run java now.
 
Lynn
scott@slp53.sl.home (Scott Lurndal): Dec 09 09:32PM


>There are not much redistributed applications written in Java running
>on a PC. Java is mostly used for in-house server-applications. With
>that you won't have to pay anything.
 
You're asserting facts about which you have no actual, you know,
bases for the assertion.
 
I use a Java application daily (via java web start).
 
And Lynn suggestion that Oracle sues java users is also incorrect.
 
Oracle did sue Google over a copyright dispute regarding
copyrightability at the API level; but they don't sue people who
distribute java applications.
scott@slp53.sl.home (Scott Lurndal): Dec 09 09:34PM

>> on a PC. Java is mostly used for in-house server-applications. With
>> that you won't have to pay anything.
 
>Most of the consumer devices out there run java now.
 
Actually, most of them run linux (android) with a application layer api (Dalvik)
that provides similar functionality to Java. Or they run IOS.
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Dec 09 01:57PM -0800

On 12/9/2022 1:34 PM, Scott Lurndal wrote:
 
>> Most of the consumer devices out there run java now.
 
> Actually, most of them run linux (android) with a application layer api (Dalvik)
> that provides similar functionality to Java. Or they run IOS.
 
How many of them have V8 installed?
Juha Nieminen <nospam@thanks.invalid>: Dec 09 12:52PM

> To be fair you could use the same argument about templating. Many times
> I've seem a template function thats only ever used for 2 different types.
 
Incidentally, one of the things I have learned to hate when reading other
people's code (and which I could write an entire book about), is useless
function overloading that serves no purpose.
 
Way too often do you see code out there that overloads a function for
different types even though there's literally no technical reason nor
any sort of advantage in overloading it. It's done purely as a naming
thing, and that's it. There's no technical reason or purpose behind it.
 
You wouldn't believe, just like with the over-use of 'auto', how
frustratingly difficult it can be to read code that uses too much
function overloading at the expense of code readability and
understandability. That's because excessive overloading tends to
mean that the function name doesn't tell very explicitly what
it's doing, because the same name is being used for a myriad of
different types. Not only can this cause ambiguity from the
compiler's perspective, but it very much can cause ambiguity for the
person who is reading the code.
 
My personal opinion is: In the vast, vast majority of cases write
distinct function names for each distinct function (and the function
name should be quite clear about what it's doing, and how what
it's doing is different from the other functions that you would
have overloaded otherwise), and if you really, really need to
overload the function for some reason (eg. because the function is
being used in templated code), implement the overloads separately
and make them call the distinctively-named versions. And always use
the distinctively-named versions in your code unless there's an actual
good reason to use the overloaded versions. Readability is more important
than convenience.
Juha Nieminen <nospam@thanks.invalid>: Dec 09 12:56PM

> Yes but it is tedious. Some types are *LONG*, especially what templates
> can return.
 
So what? I very much oppose the brevity-over-clarity style of programming.
 
What exactly are you saving by shortening names (especially if shortening
them to something that tells absolutely nothing about the actual type)?
Disk space? Or are you really in such a hurty that you can't spend a few
seconds typing the longer name?
 
> Some are not possible to express. Like in functional
> programming:
 
C++ lambdas are special in that the standard explicitly states that
they don't have a named type and that the only way to handle them is
with 'auto'.
 
In this case there's a good *technical* reason to use 'auto'. It's
not merely used for convenience or avoiding writing a couple of extra
characters.
Michael S <already5chosen@yahoo.com>: Dec 09 05:03AM -0800

On Friday, December 9, 2022 at 2:52:59 PM UTC+2, Juha Nieminen wrote:
> the distinctively-named versions in your code unless there's an actual
> good reason to use the overloaded versions. Readability is more important
> than convenience.
 
You are maturing.
Few more years and you'll start to agree with your famous former compatriot.
 
"C++ is a horrible language. It's made more horrible by the fact that a lot
of substandard programmers use it, to the point where it's much much
easier to generate total and utter crap with it. Quite frankly, even if
the choice of C were to do *nothing* but keep the C++ programmers out,
that in itself would be a huge reason to use C.".
 
https://lwn.net/Articles/249460/
scott@slp53.sl.home (Scott Lurndal): Dec 09 02:15PM

>easier to generate total and utter crap with it. Quite frankly, even if
>the choice of C were to do *nothing* but keep the C++ programmers out,
>that in itself would be a huge reason to use C.".
 
Sturgeon's Law applies.
Muttley@dastardlyhq.com: Dec 09 03:52PM

On Thu, 08 Dec 2022 19:29:52 +0000
 
>You should use a template if there are N types where N > 1, and guess
>what? 2 > 1. Why? Because code duplication is bad even if there is only
>one duplicate. You seem to be fractally wrong about most things.
 
As usual you're confusing your opinion with fact.
"Öö Tiib" <ootiib@hot.ee>: Dec 09 07:57AM -0800

On Friday, 9 December 2022 at 14:56:48 UTC+2, Juha Nieminen wrote:
> them to something that tells absolutely nothing about the actual type)?
> Disk space? Or are you really in such a hurty that you can't spend a few
> seconds typing the longer name?
 
I was not talking about "name" but "type" with number of template
arguments some of what are also templates and nested.The simpler
cases are almost tolerable but real types to deal with get hairy fast:
std::map<std::string_view, std::function<int(void)>>::insert_return_type
That when one should know fully well what map::insert returns
pair of its iterator and bool.
 
 
> In this case there's a good *technical* reason to use 'auto'. It's
> not merely used for convenience or avoiding writing a couple of extra
> characters.
 
OK
Ben Bacarisse <ben.usenet@bsb.me.uk>: Dec 09 05:44PM

>> can return.
 
> So what? I very much oppose the brevity-over-clarity style of
> programming.
 
As usual, such rules oversimplify the issues. Sometime clarity can
actually come from brevity.
 
It's usually more enlightening to give what you consider good and bad
examples as well some examples on the boundary. For example, I rarely
want to know more about the type when I see
 
for (const auto &elem : <something>) ...
 
Where in your spectrum of clarity vs. brevity does this sort of use come?
 
--
Ben.
Andreas Dehmel <blackhole.8.zarquon42@spamgourmet.com>: Dec 09 09:01PM +0100

On Fri, 09 Dec 2022 17:44:27 +0000
 
> for (const auto &elem : <something>) ...
 
> Where in your spectrum of clarity vs. brevity does this sort of use
> come?
 
I'd say it's on the lowest end of the spectrum. As soon as people start
decorating their "auto" with things like "const", "*" or "&" it
_always_ is. Either the type is self-explanatory or irrelevant, in
which case plain "auto" will do, or it isn't, in which case "auto" is
conceptually wrong. Decorating "auto" like that is just a pathetic
attempt at hiding this simple fact.
 
 
Andreas
Ben Bacarisse <ben.usenet@bsb.me.uk>: Dec 09 08:47PM

> which case plain "auto" will do, or it isn't, in which case "auto" is
> conceptually wrong. Decorating "auto" like that is just a pathetic
> attempt at hiding this simple fact.
 
If I read you correctly, you think that adding const means the auto is
almost always wrong. Is that your position?
 
--
Ben.
Tim Rentsch <tr.17687@z991.linuxsc.com>: Dec 09 01:05PM -0800

>> can return.
 
> So what? I very much oppose the brevity-over-clarity style of
> programming.
 
There is a tacit assumption in that statement that longer is
always easier to read or more readily comprehended. The
assumption is wrong. Good writers appreciate the difference
between lengthy phrasing and concise phrasing, using each as
appropriate, and varying wording choices between the two, to make
their writing more effective. That advice applies to programming
as much as it does to writing prose.
Tim Rentsch <tr.17687@z991.linuxsc.com>: Dec 09 01:07PM -0800

> which case plain "auto" will do, or it isn't, in which case "auto" is
> conceptually wrong. Decorating "auto" like that is just a pathetic
> attempt at hiding this simple fact.
 
The assertion that "auto" is conceptually wrong is an opinion,
not a fact.
Lynn McGuire <lynnmcguire5@gmail.com>: Dec 09 03:25PM -0600

On 12/8/2022 6:31 AM, Juha Nieminen wrote:
> in gitlab. Try reviewing code when you can't even see what the types
> being used are.
 
> Man, have I learned to hate the overuse of 'auto'...
 
Amen, brother ! Preach on !
 
Lynn
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Dec 08 04:45PM -0800

On 12/8/2022 3:38 AM, Paavo Helde wrote:
> a need to recalculate same things in different threads, on those copies.
 
> It looks like if I want to use another approach with keeping more data
> in shared use I will indeed need to learn more about atomics and RCU.
 
Exactly. Keep things separated out as much as possible, indeed. If you
absolutely _must_ use shared data, think again... After thinking hard,
if you still need to use shared data, then so be it. Damn. Now, there
are many different way to use shared data, and some are a heck of a lot
better than others. They all have their trade offs. RCU is geared toward
"read-mostly" usage patterns. So, a database that experiences a shi%load
of reads, and not so many writes per say, second, well, RCU just might
be of use. Also, a proxy collector might work out for you. Basically,
separate out reads and writes in your logic. If its read heavy, well,
RCU might be able to help you out.
Malcolm McLean <malcolm.arthur.mclean@gmail.com>: Dec 09 04:35AM -0800

On Tuesday, 6 December 2022 at 11:36:42 UTC, Juha Nieminen wrote:
> situations tend to be very rare and far-in-between. And when you do
> have such situations you can make faster versions of things for that
> alone.
 
However often you are writing low-level, general purpose routines.
 
For instance I have a routine which calcuates the arc length of a Bezier.
There's no closed form for doing this, so it is simple but intensive. It takes
a large number of points onthe curve and approximates by straight lines.
 
Now a lot of the time, the curves are entered by the user. It will take him three
or four seconds to draw a curve. So any optimisation is pointless.
However the routine could be called in the inner loop of some very intensive
higher level function, on a large number of candidate curves. So the function does
in fact have to be micro-optimised.
Tim Rentsch <tr.17687@z991.linuxsc.com>: Dec 09 12:50PM -0800

> Now, 'immature' is completely different story. This word is
> translated rather close to original. But Knuth said 'premature'
> rather than 'immature' and that provokes difficulties in translation.
 
In English there is a significant difference between "early" and
"premature". (It hadn't occurred to me that premature might be
derived from mature.)
 
The original source was written in English. It was written
by Don Knuth, whose native language is English. The posting
here was written in English. Furthermore the comment here
is written as a quotation, and mentions that the saying is
wrongly quoted. Once we are in the realm of quoting rather
than paraphrasing there is no room for latitude.
 
I am sympathetic to those whose native language is other than
English and post in English. More than sympathetic, I admire
them for their language skills, an area where I am woefully much
less than fully competent. Even so, it behooves any non-native
speaker to make an effort to use English correctly, and to want
to use English correctly, when writing in English. And that
especially applies when citing or quoting from a source written
in English.
Juha Nieminen <nospam@thanks.invalid>: Dec 09 12:57PM

> point of folds is not having to manually iterate the arguments yourself as
> with 2011 which is little better than C's varargs (and probably less efficient
> due to recursion vs pointer incrementing).
 
Well, if you can come up with a fold expression that does what you want,
go right ahead.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: