Re: Hijacked: C vs C++

Jack, W8TEE

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

Join to automatically receive all group messages.