Hi Jerry:
I've seen statements like this:
????It's always been straight C (K&R or ANSII) if I want to code for speed or size
many times before, but I've never seen any a priori proof of this or articles that discuss it. It seems that it would make sense to be so, but I don't know if that's pushed into the generated code or if it's an increased load on the parser given the semantics of C++ versus C. Some even say that, because C++ uses templates in the libraries, the code generator can perform more optimizations on the code because it "knows" what you are doing ().
I don't have an answer, but I do try to follow the goals of C++ where it makes sense, especially encapsulation. If anyone has a definitive answer, I'd really like to know about it.
Jack, W8TEE
On Tuesday, July 3, 2018, 3:16:24 PM EDT, Jerry Gaffke via Groups.Io <jgaffke@...> wrote:
> I fail to see the their and there you are pointing out.? ? What do you mean? It's right their in this sentence:?
>>? ?"their" is possessional, "there" is positional, required in this context.
My gripes are mostly about a good technical discussions diverging into multiple threads. If you do start a new thread on an old subject then post links to both showing where the other thread can be found.?
Those posting without any history for context generally get ignored. If it's not worth your while to spend 5 seconds including context, it's certainly not worth it for?thousands of forum readers to go find it.
If anybody want's to pick apart my use of USAish or my C indentation style (or lack thereof), have at it. I'm quite capable of skipping over those posts too.
And while I'm at it, I've never seen any reason to get comfortable with C++. It's always been straight C (K&R or ANSII) if I want to code for speed or size, and for the last couple decades I've been resorting to Python for easy coding.? This violates my primary beef above, I do try not to be overly pendantic.
Jerry, KE7ER
toggle quoted message
Show quoted text
On Tue, Jul 3, 2018 at 09:49 am, Allen Merrell wrote:
On Tue, Jul 3, 2018 at 08:46 am, Dexter N Muir wrote:
Sorry to be a pedant, but that's me Allen: "their" is possessional, "there" is positional, required in this context. 73 Dex, ZL2DEX
Sorry Dexter, I'm not an english major but I fail to see the their and there you are pointing out. ? -- Allen ?Merrell
|
I can vouch for the size increase with C++.? When I was teaching
C and just getting my feet wet with C++, we did a direct
comparison.? The results showed a 1.5K executable for C and 80K
for C++ with the exact same code, simply renaming it .C++ instead
of .C.? It is due to the libraries being pulled in.? Speed is a
different issue since it is highly dependent on coding style.
Ron W7HD
On 07/03/2018 01:15 PM, Jack Purdum via
Groups.Io wrote:
Hi Jerry:
I've seen statements like this:
????It's always been straight C (K&R or
ANSII) if I want to code for speed or size
many times before, but I've never seen any a
priori proof of this or articles that discuss it. It
seems that it would make sense to be so, but I don't know
if that's pushed into the generated code or if it's an
increased load on the parser given the semantics of C++
versus C. Some even say that, because C++ uses templates
in the libraries, the code generator can perform more
optimizations on the code because it "knows" what you are
doing ().
I don't have an answer, but I do try to follow the
goals of C++ where it makes sense, especially
encapsulation. If anyone has a definitive answer, I'd
really like to know about it.
Jack, W8TEE
On Tuesday, July 3, 2018, 3:16:24 PM EDT, Jerry Gaffke
via Groups.Io <jgaffke@...> wrote:
> I fail to see the their and there you are
pointing out.?
?
What do you mean?
It's right their in this sentence:?
>>? ?"their" is possessional, "there" is
positional, required in this context.
My gripes are mostly about a good technical
discussions diverging into multiple threads.
If you do start a new thread on an old subject then
post links to both showing where the other thread can
be found.?
Those posting without any history for context
generally get ignored.
If it's not worth your while to spend 5 seconds
including context,
it's certainly not worth it for?thousands of forum
readers to go find it.
If anybody want's to pick apart my use of USAish or my
C indentation style (or lack thereof), have at it.
I'm quite capable of skipping over those posts too.
And while I'm at it, I've never seen any reason to get
comfortable with C++.
It's always been straight C (K&R or ANSII) if I
want to code for speed or size,
and for the last couple decades I've been resorting to
Python for easy coding.?
This violates my primary beef above, I do try not to
be overly pendantic.
Jerry, KE7ER
On Tue, Jul 3, 2018 at 09:49 am, Allen Merrell wrote:
On Tue, Jul 3, 2018 at 08:46 am, Dexter N
Muir wrote:
Sorry to be a pedant, but that's me
Allen: "their" is possessional, "there" is
positional, required in this context.
73
Dex, ZL2DEX
Sorry Dexter, I'm not an english major but I fail to
see the their and there you are pointing out.
?
--
Allen ?Merrell
--
Ron W7HD - NAQCC#7587 OMISS#9898 KX3#6966 LinuxUser#415320
Editor OVARC newsletter
|
Virtually everything done with the Arduino is C++. Every installable Arduino library is built as a C++ class.?
Many of the C++ standard libraries are not included or have been replaced by trimmed down versions. There is no official STL implementation for the Arduino. So, Arduino users are using C++ without issue.
Interestingly the String object library increases the size of a program very little. Pull in the standard C stdio library so one can use sprintf and the compiled code instantly bloats by several K bytes.
Compared to the 8748 processors I used to use in the type of application the Nano is now used in, it is like having a super computer. I did everything in assembly code back then, because even with processors that could be programmed in C, the overhead of C was just too much.?
Tom, wb6b
|
The String class for an Arduino environment is a crutch and there's no reason to use it. It also can lead to memory fragmentation. The sprintf() function is extremely powerful, but usually is an H-bomb to kill an ant. Rarely is there an Arduino program that uses more than a very small portion of its power. My experience is that using the standard str*() and mem*() functions instead will typically save 1.5K of memory.
Jack, W8TEE
On Tuesday, July 3, 2018, 8:01:06 PM EDT, Tom, wb6b <wb6b@...> wrote:
Virtually everything done with the Arduino is C++. Every installable Arduino library is built as a C++ class.?
Many of the C++ standard libraries are not included or have been replaced by trimmed down versions. There is no official STL implementation for the Arduino. So, Arduino users are using C++ without issue.
Interestingly the String object library increases the size of a program very little. Pull in the standard C stdio library so one can use sprintf and the compiled code instantly bloats by several K bytes.
Compared to the 8748 processors I used to use in the type of application the Nano is now used in, it is like having a super computer. I did everything in assembly code back then, because even with processors that could be programmed in C, the overhead of C was just too much.?
Tom, wb6b
|
Good grief! What compiler was it?
Jack, W8TEE
On Tuesday, July 3, 2018, 6:29:47 PM EDT, w7hd.rh <w7hd.rh@...> wrote:
I can vouch for the size increase with C++.? When I was teaching
C and just getting my feet wet with C++, we did a direct
comparison.? The results showed a 1.5K executable for C and 80K
for C++ with the exact same code, simply renaming it .C++ instead
of .C.? It is due to the libraries being pulled in.? Speed is a
different issue since it is highly dependent on coding style.
Ron W7HD
On 07/03/2018 01:15 PM, Jack Purdum via
Groups.Io wrote:
Hi Jerry:
I've seen statements like this:
????It's always been straight C (K&R or
ANSII) if I want to code for speed or size
many times before, but I've never seen any a
priori proof of this or articles that discuss it. It
seems that it would make sense to be so, but I don't know
if that's pushed into the generated code or if it's an
increased load on the parser given the semantics of C++
versus C. Some even say that, because C++ uses templates
in the libraries, the code generator can perform more
optimizations on the code because it "knows" what you are
doing ().
I don't have an answer, but I do try to follow the
goals of C++ where it makes sense, especially
encapsulation. If anyone has a definitive answer, I'd
really like to know about it.
Jack, W8TEE
On Tuesday, July 3, 2018, 3:16:24 PM EDT, Jerry Gaffke
via Groups.Io <jgaffke@...> wrote:
> I fail to see the their and there you are
pointing out.?
?
What do you mean?
It's right their in this sentence:?
>>? ?"their" is possessional, "there" is
positional, required in this context.
My gripes are mostly about a good technical
discussions diverging into multiple threads.
If you do start a new thread on an old subject then
post links to both showing where the other thread can
be found.?
Those posting without any history for context
generally get ignored.
If it's not worth your while to spend 5 seconds
including context,
it's certainly not worth it for?thousands of forum
readers to go find it.
If anybody want's to pick apart my use of USAish or my
C indentation style (or lack thereof), have at it.
I'm quite capable of skipping over those posts too.
And while I'm at it, I've never seen any reason to get
comfortable with C++.
It's always been straight C (K&R or ANSII) if I
want to code for speed or size,
and for the last couple decades I've been resorting to
Python for easy coding.?
This violates my primary beef above, I do try not to
be overly pendantic.
Jerry, KE7ER
On Tue, Jul 3, 2018 at 09:49 am, Allen Merrell wrote:
On Tue, Jul 3, 2018 at 08:46 am, Dexter N
Muir wrote:
Sorry to be a pedant, but that's me
Allen: "their" is possessional, "there" is
positional, required in this context.
73
Dex, ZL2DEX
Sorry Dexter, I'm not an english major but I fail to
see the their and there you are pointing out.
?
--
Allen ?Merrell
--
Ron W7HD - NAQCC#7587 OMISS#9898 KX3#6966 LinuxUser#415320
Editor OVARC newsletter
|
The Arduino design recommendations are to hide as much of the nitty gritty details from the users as possible. They even recommend not exposing the user to the horror of "char *" and use "char whatever[]" instead.?
I use the string class when it makes it easier for a user to understand what is going on or simply makes my programming effort go faster. The Arduino is not like a Unix machine at a company. it is usually running the same small set of tasks over and over again, so many of the memory allocations that would lead to memory fragmentation will settle out as the routines will find a home for their memory allotments in the memory blocks they the previously abandoned. So if the percentage of holes stabilize and is not a fantastically large percentage it seems a fair tradeoff.?
If I was short on memory and had to shoehorn yet another feature into the fixed resources of one processor, I'd regret using the String class. And I'd probably move to the chip manufacture's leaner tool chain. But, in a $3.50 Nano with only half the resources being used, the convenience of the String class is worth it. String provides a nice encapsulation of the things people do with strings.?So, depending on the situation I'll use convenience classes at one moment and do direct point manipulation in another.?
Tom, wb6b
|
Turbo C and Turbo C++ at first, then gcc and g++ later.? Without
a lot of compiler switches added in.
It certainly turned me off C++ coding.? I still program in C and
shell scripts whenever possible.?
I've written a LOT of programs over the last 30 years and can
crank out a working C program in a few hours.
Ron W7HD
On 07/03/2018 07:05 PM, Jack Purdum via
Groups.Io wrote:
Good grief! What compiler was it?
Jack, W8TEE
On Tuesday, July 3, 2018, 6:29:47 PM EDT, w7hd.rh
<w7hd.rh@...> wrote:
I can vouch for the size increase with C++.?
When I was teaching C and just getting my feet wet
with C++, we did a direct comparison.? The results
showed a 1.5K executable for C and 80K for C++ with
the exact same code, simply renaming it .C++ instead
of .C.? It is due to the libraries being pulled in.?
Speed is a different issue since it is highly
dependent on coding style.
Ron W7HD
On
07/03/2018 01:15 PM, Jack Purdum via Groups.Io
wrote:
Hi Jerry:
I've seen statements like this:
????It's always been straight C
(K&R or ANSII) if I want to code for
speed or size
many times before, but I've never
seen any a priori proof of this or
articles that discuss it. It seems that it
would make sense to be so, but I don't know
if that's pushed into the generated code or
if it's an increased load on the parser
given the semantics of C++ versus C. Some
even say that, because C++ uses templates in
the libraries, the code generator can
perform more optimizations on the code
because it "knows" what you are doing ().
I don't have an answer, but I do try to
follow the goals of C++ where it makes
sense, especially encapsulation. If anyone
has a definitive answer, I'd really like to
know about it.
Jack, W8TEE
On Tuesday, July 3, 2018, 3:16:24 PM
EDT, Jerry Gaffke via Groups.Io <jgaffke@...>
wrote:
> I fail to see the their and
there you are pointing out.?
?
What do you mean?
It's right their in this sentence:?
>>? ?"their" is possessional,
"there" is positional, required in this
context.
My gripes are mostly about a good
technical discussions diverging into
multiple threads.
If you do start a new thread on an old
subject then post links to both showing
where the other thread can be found.?
Those posting without any history for
context generally get ignored.
If it's not worth your while to spend 5
seconds including context,
it's certainly not worth it
for?thousands of forum readers to go
find it.
If anybody want's to pick apart my use
of USAish or my C indentation style (or
lack thereof), have at it.
I'm quite capable of skipping over those
posts too.
And while I'm at it, I've never seen any
reason to get comfortable with C++.
It's always been straight C (K&R or
ANSII) if I want to code for speed or
size,
and for the last couple decades I've
been resorting to Python for easy
coding.?
This violates my primary beef above, I
do try not to be overly pendantic.
Jerry, KE7ER
On Tue, Jul 3, 2018 at 09:49 am, Allen
Merrell wrote:
On Tue, Jul 3, 2018 at 08:46
am, Dexter N Muir wrote:
Sorry to be a pedant, but
that's me Allen: "their" is
possessional, "there" is positional,
required in this context.
73
Dex, ZL2DEX
Sorry Dexter, I'm not an english major
but I fail to see the their and there
you are pointing out.
?
--
Allen ?Merrell
--
Ron W7HD - NAQCC#7587 OMISS#9898 KX3#6966 LinuxUser#415320
Editor OVARC newsletter
--
Ron W7HD - NAQCC#7587 OMISS#9898 KX3#6966 LinuxUser#415320
Editor OVARC newsletter
|
Who is making these "Arduino design recommendations"? I don't see why a "user" would ever need to know if I was using char * versus char x[]. The difference is syntactic sugar. As to fragmentation, if the programmer knows this is going to happen and is willing to run that risk, that says something. Memory fragmentation never "settles out" and I doubt that you should rely on "if the percentage of holes stabilize". Simply knowing that it does, in fact, create holes is good enough reason not to use the String class.
To say that makes your programming effort go faster seems a bit odd to me, as the time savings between:
?? newString += oldString;
seems little different to me than:
?? strcat(newString, oldString);
It may take a little more effort up front to learn all of the string functions (see especially if you're coming from a Basic background, but it quickly become second nature to use them.
I, too, would regret using the String class...always, if for no other reason than fragmentation. The fact that you're willing to fritter away unused memory resources simply because they exist seems like burning all the firewood around your Alaskan cabin in the middle of summer...not a good reason to be wasteful. It also teaches bad/lazy programming habits.
Just my $0.02 worth...
Jack, W8TEE
On Tuesday, July 3, 2018, 10:59:42 PM EDT, Tom, wb6b <wb6b@...> wrote:
The Arduino design recommendations are to hide as much of the nitty gritty details from the users as possible. They even recommend not exposing the user to the horror of "char *" and use "char whatever[]" instead.?
I use the string class when it makes it easier for a user to understand what is going on or simply makes my programming effort go faster. The Arduino is not like a Unix machine at a company. it is usually running the same small set of tasks over and over again, so many of the memory allocations that would lead to memory fragmentation will settle out as the routines will find a home for their memory allotments in the memory blocks they the previously abandoned. So if the percentage of holes stabilize and is not a fantastically large percentage it seems a fair tradeoff.?
If I was short on memory and had to shoehorn yet another feature into the fixed resources of one processor, I'd regret using the String class. And I'd probably move to the chip manufacture's leaner tool chain. But, in a $3.50 Nano with only half the resources being used, the convenience of the String class is worth it. String provides a nice encapsulation of the things people do with strings.?So, depending on the situation I'll use convenience classes at one moment and do direct point manipulation in another.?
Tom, wb6b
|
Wow, I would never expect a 50:1 difference. True, C++ does drag in more overhead, but it shouldn't be that much. The gcc compiler is behind the Arduino IDE. Try using it to write a C versus C++ program and see if that difference holds. Some compilers bring in the entire I/O library if you use printf(). That shouldn't happen in the Arduino world. Take the code you used to come to those conclusions, but do it with the Arduino IDE. I'd love to hear the results. I'd be happy to run the test if you care to send the source code.
Jack, W8TEE
On Tuesday, July 3, 2018, 11:07:59 PM EDT, w7hd.rh <w7hd.rh@...> wrote:
Turbo C and Turbo C++ at first, then gcc and g++ later.? Without
a lot of compiler switches added in.
It certainly turned me off C++ coding.? I still program in C and
shell scripts whenever possible.?
I've written a LOT of programs over the last 30 years and can
crank out a working C program in a few hours.
Ron W7HD
On 07/03/2018 07:05 PM, Jack Purdum via
Groups.Io wrote:
Good grief! What compiler was it?
Jack, W8TEE
On Tuesday, July 3, 2018, 6:29:47 PM EDT, w7hd.rh
<w7hd.rh@...> wrote:
I can vouch for the size increase with C++.?
When I was teaching C and just getting my feet wet
with C++, we did a direct comparison.? The results
showed a 1.5K executable for C and 80K for C++ with
the exact same code, simply renaming it .C++ instead
of .C.? It is due to the libraries being pulled in.?
Speed is a different issue since it is highly
dependent on coding style.
Ron W7HD
On
07/03/2018 01:15 PM, Jack Purdum via Groups.Io
wrote:
Hi Jerry:
I've seen statements like this:
????It's always been straight C
(K&R or ANSII) if I want to code for
speed or size
many times before, but I've never
seen any a priori proof of this or
articles that discuss it. It seems that it
would make sense to be so, but I don't know
if that's pushed into the generated code or
if it's an increased load on the parser
given the semantics of C++ versus C. Some
even say that, because C++ uses templates in
the libraries, the code generator can
perform more optimizations on the code
because it "knows" what you are doing ().
I don't have an answer, but I do try to
follow the goals of C++ where it makes
sense, especially encapsulation. If anyone
has a definitive answer, I'd really like to
know about it.
Jack, W8TEE
On Tuesday, July 3, 2018, 3:16:24 PM
EDT, Jerry Gaffke via Groups.Io <jgaffke@...>
wrote:
> I fail to see the their and
there you are pointing out.?
?
What do you mean?
It's right their in this sentence:?
>>? ?"their" is possessional,
"there" is positional, required in this
context.
My gripes are mostly about a good
technical discussions diverging into
multiple threads.
If you do start a new thread on an old
subject then post links to both showing
where the other thread can be found.?
Those posting without any history for
context generally get ignored.
If it's not worth your while to spend 5
seconds including context,
it's certainly not worth it
for?thousands of forum readers to go
find it.
If anybody want's to pick apart my use
of USAish or my C indentation style (or
lack thereof), have at it.
I'm quite capable of skipping over those
posts too.
And while I'm at it, I've never seen any
reason to get comfortable with C++.
It's always been straight C (K&R or
ANSII) if I want to code for speed or
size,
and for the last couple decades I've
been resorting to Python for easy
coding.?
This violates my primary beef above, I
do try not to be overly pendantic.
Jerry, KE7ER
On Tue, Jul 3, 2018 at 09:49 am, Allen
Merrell wrote:
On Tue, Jul 3, 2018 at 08:46
am, Dexter N Muir wrote:
Sorry to be a pedant, but
that's me Allen: "their" is
possessional, "there" is positional,
required in this context.
73
Dex, ZL2DEX
Sorry Dexter, I'm not an english major
but I fail to see the their and there
you are pointing out.
?
--
Allen ?Merrell
--
Ron W7HD - NAQCC#7587 OMISS#9898 KX3#6966 LinuxUser#415320
Editor OVARC newsletter
--
Ron W7HD - NAQCC#7587 OMISS#9898 KX3#6966 LinuxUser#415320
Editor OVARC newsletter
|
On critical code, I prefer the direct correspondence of a vanilla C program to its executable. With C++, there are too many unseen gears turning to implement all those cool features. If I want easy coding of complicated algorithms and don't care about space or time, I write in python. It's clean and concise and powerful, I get far fewer coding errors than when writing in C/C++. If there are time critical functions to implement, write them in C and?call them from the?main python program. Here's an old Unix fortune cookie from 40 years ago: "The day-to-day travails of the IBM programmer are so amusing to most of us who are?
fortunate enough never to have been one? -- like watching Charlie Chaplin trying to cook a shoe."
We can argue if that applies better to the C or C++ programmer.
Jerry, KE7ER
he day-to-day travails of the IBM programmer are so amusing to most of us who are fortunate enough never to have been one
|
It was a simple printf("Hello world.\n") statement as the entire
content.? Probably the printf is what caused the overhead.
Ron W7HD
On 07/03/2018 08:31 PM, Jack Purdum via
Groups.Io wrote:
Wow, I would never expect a 50:1 difference. True, C++
does drag in more overhead, but it shouldn't be that much.
The gcc compiler is behind the Arduino IDE. Try using it to
write a C versus C++ program and see if that difference
holds. Some compilers bring in the entire I/O library if you
use printf(). That shouldn't happen in the Arduino
world. Take the code you used to come to those conclusions,
but do it with the Arduino IDE. I'd love to hear the
results. I'd be happy to run the test if you care to send
the source code.
Jack, W8TEE
On Tuesday, July 3, 2018, 11:07:59 PM EDT, w7hd.rh
<w7hd.rh@...> wrote:
Turbo C and Turbo C++ at first, then gcc and
g++ later.? Without a lot of compiler switches added
in.
It certainly turned me off C++ coding.? I still
program in C and shell scripts whenever possible.?
I've written a LOT of programs over the last 30
years and can crank out a working C program in a few
hours.
Ron W7HD
On
07/03/2018 07:05 PM, Jack Purdum via Groups.Io
wrote:
Good grief! What compiler was it?
Jack, W8TEE
On Tuesday, July 3, 2018, 6:29:47 PM
EDT, w7hd.rh <w7hd.rh@...>
wrote:
I can vouch for the size
increase with C++.? When I was
teaching C and just getting my feet
wet with C++, we did a direct
comparison.? The results showed a 1.5K
executable for C and 80K for C++ with
the exact same code, simply renaming
it .C++ instead of .C.? It is due to
the libraries being pulled in.? Speed
is a different issue since it is
highly dependent on coding style.
Ron W7HD
On
07/03/2018 01:15 PM, Jack Purdum via
Groups.Io wrote:
Hi Jerry:
I've seen statements like
this:
????It's always been
straight C (K&R or
ANSII) if I want to code for
speed or size
many times before, but
I've never seen any a
priori proof of this or
articles that discuss it. It
seems that it would make sense
to be so, but I don't know if
that's pushed into the
generated code or if it's an
increased load on the parser
given the semantics of C++
versus C. Some even say that,
because C++ uses templates in
the libraries, the code
generator can perform more
optimizations on the code
because it "knows" what you
are doing ().
I don't have an answer, but
I do try to follow the goals
of C++ where it makes sense,
especially encapsulation. If
anyone has a definitive
answer, I'd really like to
know about it.
Jack, W8TEE
On Tuesday, July 3, 2018,
3:16:24 PM EDT, Jerry Gaffke
via Groups.Io <jgaffke@...>
wrote:
> I fail to see the
their and there you are
pointing out.?
?
What do you mean?
It's right their in this
sentence:?
>>? ?"their" is
possessional, "there" is
positional, required in
this context.
My gripes are mostly about
a good technical
discussions diverging into
multiple threads.
If you do start a new
thread on an old subject
then post links to both
showing where the other
thread can be found.?
Those posting without any
history for context
generally get ignored.
If it's not worth your
while to spend 5 seconds
including context,
it's certainly not worth
it for?thousands of forum
readers to go find it.
If anybody want's to pick
apart my use of USAish or
my C indentation style (or
lack thereof), have at it.
I'm quite capable of
skipping over those posts
too.
And while I'm at it, I've
never seen any reason to
get comfortable with C++.
It's always been straight
C (K&R or ANSII) if I
want to code for speed or
size,
and for the last couple
decades I've been
resorting to Python for
easy coding.?
This violates my primary
beef above, I do try not
to be overly pendantic.
Jerry, KE7ER
On Tue, Jul 3, 2018 at
09:49 am, Allen Merrell
wrote:
On Tue, Jul 3,
2018 at 08:46 am, Dexter
N Muir wrote:
Sorry to be
a pedant, but that's
me Allen: "their" is
possessional, "there"
is positional,
required in this
context.
73
Dex, ZL2DEX
Sorry Dexter, I'm not an
english major but I fail
to see the their and
there you are pointing
out.
?
--
Allen ?Merrell
--
Ron W7HD - NAQCC#7587 OMISS#9898 KX3#6966 LinuxUser#415320
Editor OVARC newsletter
--
Ron W7HD - NAQCC#7587 OMISS#9898 KX3#6966 LinuxUser#415320
Editor OVARC newsletter
--
Ron W7HD - NAQCC#7587 OMISS#9898 KX3#6966 LinuxUser#415320
Editor OVARC newsletter
|
With C++, there are too many unseen gears turning to implement all those cool features.
In my C++ class the instructor would often start class with the quiz “How many constructors are called” for some simple code. Everybody’s answers would be low.? With some experience, there is little difference in in resulting code execution speed for C coders. ?There is a huge difference for C++ coders. And the good ones make a lot of money.
|
my community college had me learn C. I suspect ?the added functionality wasn't required.?
toggle quoted message
Show quoted text
With C++, there are too many unseen gears turning to implement all those cool features.
In my C++ class the instructor would often start class with the quiz “How many constructors are called” for some simple code. Everybody’s answers would be low.?
With some experience, there is little difference in in resulting code execution speed for C coders.? There is a huge difference for C++ coders. And the good ones make a lot of money.
|
The bloat in the Arduino IDE isn't nearly as bad as that. After all, you all have been using C++ the moment you used Serial.begin() in a program. Indeed, I don't think I've seen any Arduino libraries that weren't written in C++. I do agree that C is much easier to use and that's my preferred programming language. Still, the OOP Trillogy brings a lot to the table in terms of making one's code a little more bullet proof. The good news is that you can apply some of those safety concepts without really having to go full bore on C++. I, too, will stick with C, but I'm not against swiping some good stuff from C++ when I can.
Jack, W8TEE
On Wednesday, July 4, 2018, 8:17:54 AM EDT, w7hd.rh <w7hd.rh@...> wrote:
It was a simple printf("Hello world.\n") statement as the entire
content.? Probably the printf is what caused the overhead.
Ron W7HD
On 07/03/2018 08:31 PM, Jack Purdum via
Groups.Io wrote:
Wow, I would never expect a 50:1 difference. True, C++
does drag in more overhead, but it shouldn't be that much.
The gcc compiler is behind the Arduino IDE. Try using it to
write a C versus C++ program and see if that difference
holds. Some compilers bring in the entire I/O library if you
use printf(). That shouldn't happen in the Arduino
world. Take the code you used to come to those conclusions,
but do it with the Arduino IDE. I'd love to hear the
results. I'd be happy to run the test if you care to send
the source code.
Jack, W8TEE
On Tuesday, July 3, 2018, 11:07:59 PM EDT, w7hd.rh
<w7hd.rh@...> wrote:
Turbo C and Turbo C++ at first, then gcc and
g++ later.? Without a lot of compiler switches added
in.
It certainly turned me off C++ coding.? I still
program in C and shell scripts whenever possible.?
I've written a LOT of programs over the last 30
years and can crank out a working C program in a few
hours.
Ron W7HD
On
07/03/2018 07:05 PM, Jack Purdum via Groups.Io
wrote:
Good grief! What compiler was it?
Jack, W8TEE
On Tuesday, July 3, 2018, 6:29:47 PM
EDT, w7hd.rh <w7hd.rh@...>
wrote:
I can vouch for the size
increase with C++.? When I was
teaching C and just getting my feet
wet with C++, we did a direct
comparison.? The results showed a 1.5K
executable for C and 80K for C++ with
the exact same code, simply renaming
it .C++ instead of .C.? It is due to
the libraries being pulled in.? Speed
is a different issue since it is
highly dependent on coding style.
Ron W7HD
On
07/03/2018 01:15 PM, Jack Purdum via
Groups.Io wrote:
Hi Jerry:
I've seen statements like
this:
????It's always been
straight C (K&R or
ANSII) if I want to code for
speed or size
many times before, but
I've never seen any a
priori proof of this or
articles that discuss it. It
seems that it would make sense
to be so, but I don't know if
that's pushed into the
generated code or if it's an
increased load on the parser
given the semantics of C++
versus C. Some even say that,
because C++ uses templates in
the libraries, the code
generator can perform more
optimizations on the code
because it "knows" what you
are doing ().
I don't have an answer, but
I do try to follow the goals
of C++ where it makes sense,
especially encapsulation. If
anyone has a definitive
answer, I'd really like to
know about it.
Jack, W8TEE
On Tuesday, July 3, 2018,
3:16:24 PM EDT, Jerry Gaffke
via Groups.Io <jgaffke@...>
wrote:
> I fail to see the
their and there you are
pointing out.?
?
What do you mean?
It's right their in this
sentence:?
>>? ?"their" is
possessional, "there" is
positional, required in
this context.
My gripes are mostly about
a good technical
discussions diverging into
multiple threads.
If you do start a new
thread on an old subject
then post links to both
showing where the other
thread can be found.?
Those posting without any
history for context
generally get ignored.
If it's not worth your
while to spend 5 seconds
including context,
it's certainly not worth
it for?thousands of forum
readers to go find it.
If anybody want's to pick
apart my use of USAish or
my C indentation style (or
lack thereof), have at it.
I'm quite capable of
skipping over those posts
too.
And while I'm at it, I've
never seen any reason to
get comfortable with C++.
It's always been straight
C (K&R or ANSII) if I
want to code for speed or
size,
and for the last couple
decades I've been
resorting to Python for
easy coding.?
This violates my primary
beef above, I do try not
to be overly pendantic.
Jerry, KE7ER
On Tue, Jul 3, 2018 at
09:49 am, Allen Merrell
wrote:
On Tue, Jul 3,
2018 at 08:46 am, Dexter
N Muir wrote:
Sorry to be
a pedant, but that's
me Allen: "their" is
possessional, "there"
is positional,
required in this
context.
73
Dex, ZL2DEX
Sorry Dexter, I'm not an
english major but I fail
to see the their and
there you are pointing
out.
?
--
Allen ?Merrell
--
Ron W7HD - NAQCC#7587 OMISS#9898 KX3#6966 LinuxUser#415320
Editor OVARC newsletter
--
Ron W7HD - NAQCC#7587 OMISS#9898 KX3#6966 LinuxUser#415320
Editor OVARC newsletter
--
Ron W7HD - NAQCC#7587 OMISS#9898 KX3#6966 LinuxUser#415320
Editor OVARC newsletter
|
For those who did not understand your reference to Fortune Cookies.
_._
toggle quoted message
Show quoted text
On Wed, Jul 4, 2018 at 12:42 AM Jerry Gaffke via Groups.Io <jgaffke= [email protected]> wrote: On critical code, I prefer the direct correspondence of a vanilla C program to its executable. With C++, there are too many unseen gears turning to implement all those cool features.
If I want easy coding of complicated algorithms and don't care about space or time, I write in python. It's clean and concise and powerful, I get far fewer coding errors than when writing in C/C++. If there are time critical functions to implement, write them in C and?call them from the?main python program.
Here's an old Unix fortune cookie from 40 years ago: "The day-to-day travails of the IBM programmer are so amusing to most of us who are?
fortunate enough never to have been one? -- like watching Charlie Chaplin trying to cook a shoe."
We can argue if that applies better to the C or C++ programmer.
Jerry, KE7ER
he day-to-day travails of the IBM programmer are so amusing to most of us who are fortunate enough never to have been one
|
Forty years ago, programming might involve typing into an ADM-3 terminal with a 1200 baud? UART connection to a Vax-11/780 under BSD Unix. If you were lucky, could be worse. You could have been submitting decks of punched cards in Cobol? to some batch system. With several dozen other programmers sharing the same VAX,? might take a minute or two after submitting name and password before? you were fully logged in and had a shell prompt. So the sysadmin would generally have the fortune cookie program dump some text to the screen for you to ponder while twiddling thumbs. Here's another example, chosen from thousands:
'Twas midnight, and the UNIX hacks
Did gyre and gimble in their cave
All mimsy was the CS-VAX
And Cory raths outgrabe.
"Beware the software rot, my son!
The faults that bite, the jobs that thrash!
Beware the broken pipe, and shun
The frumious system crash!"
OK, now we're totally hijacked. Excellent name for the thread! Jerry
toggle quoted message
Show quoted text
On Wed, Jul 4, 2018 at 09:29 am, Arv Evans wrote:
For those who did not understand your reference to Fortune Cookies.
|
On 7/4/18 12:05 PM, Jerry Gaffke via Groups.Io wrote> Forty years ago ... could be worse. You could have been submitting decks of punched cards in Cobol to some batch system. ... That's how I started (IBM 370/168) but it was a bit more than 40 yr ago. After a while I got into cooler stuff like Pascal, a little FORTRAN on PDP 11's, assembler on various microprocessors, then C under various flavors of unix on minis & micros, C++ and finally Java on various platforms. Java is pretty cool but has gotten pretty bloated. C is still the best, IMO. I like to write code but don't seem to have the patience for it any more. It might be different if I was still getting paid for it. :) I can really appreciate the time & effort you guys put into it. 73... Mark AA7TA
|
Talk about bringing back memories!
I learned on a 300baud teletype in high school - my school was
the second in the nation (so I understand) to offer computer
programming, and I took it the second year it was offered.? We had
access to the school system's mainframe through the teletype.? We
also got introduced to our first computer game - "Star Trek".
Then I progressed to Fortran on punch cards.? And waited for the
(hopefully thin) stack of printout.? (For those who don't
understand, if you did the job right, you got a very thin stack of
fanfold paper.? If you made a mistake in your programming, you got
a big pile with all of the messages and errors caused by your
mistake.)
Back on Topic - I'd wondered why Arduino code seemed familiar and
why I had little problem figuring out the routines I needed.? I'd
studied C on my own several years ago.
On 07/04/2018 03:05 PM, Jerry Gaffke
via Groups.Io wrote:
toggle quoted message
Show quoted text
Forty years ago,
programming might involve typing into an ADM-3 terminal
with a 1200 baud? UART connection to a Vax-11/780 under BSD Unix.
If you were lucky, could be worse.
You could have been submitting decks of punched cards in Cobol?
to some batch system.
With several dozen other programmers sharing the same VAX,?
might take a minute or two after submitting name and password
before?
you were fully logged in and had a shell prompt.
So the sysadmin would generally have the fortune cookie program
dump
some text to the screen for you to ponder while twiddling thumbs.
Here's another example, chosen from thousands:
'Twas midnight, and the UNIX hacks
Did gyre and gimble in their cave
All mimsy was the CS-VAX
And Cory raths outgrabe.
"Beware the software rot, my son!
The faults that bite, the jobs that thrash!
Beware the broken pipe, and shun
The frumious system crash!"
OK, now we're totally hijacked.
Excellent name for the thread!
Jerry
On Wed, Jul 4, 2018 at 09:29 am, Arv Evans wrote:
For those who did not understand your reference to
Fortune Cookies.
|
I started with a 110 baud teletype (also in high school). ?We learned BASIC on it. ?Once I learned ‘C’ I never went back to BASIC.
I don’t recall getting reams of paper due to Fortran errors. ?I remember that you could get a very large stack of paper if you botched the first character (carriage control). ?It would feed the paper at maximum speed and only the CARRIAGE STOP button would stop it. ?It was always something to see the operator come flying out of their seat to reach over the printer and blindly slap the CARRIAGE STOP button (inconveniently located on the other side of the printer).
toggle quoted message
Show quoted text
On Jul 4, 2018, at 12:53 PM, Robert D. Bowers < n4fbz@...> wrote:
Talk about bringing back memories! I learned on a 300baud teletype in high school - my school was the second in the nation (so I understand) to offer computer programming, and I took it the second year it was offered.? We had access to the school system's mainframe through the teletype.? We also got introduced to our first computer game - "Star Trek".
Then I progressed to Fortran on punch cards.? And waited for the (hopefully thin) stack of printout.? (For those who don't understand, if you did the job right, you got a very thin stack of fanfold paper.? If you made a mistake in your programming, you got a big pile with all of the messages and errors caused by your mistake.) Back on Topic - I'd wondered why Arduino code seemed familiar and why I had little problem figuring out the routines I needed.? I'd studied C on my own several years ago.
|
Ah!! The days of the DEC 20/60 and VAX11/740 with IBM 29 card punches!! And the joy of COBOL!
Rhys? GW0DIV?
|