what is better for effectively using memory?

hello.
i have a pretty simple question, if i use c/c++ to program an arduino uno will it be more cost effective in terms of memory or should i just stay with the native platform and use direct processor commands?
if i should use native processor commands is it a good idea to mix them with regular arduino code to save memory ?

What do you find "native processor commands"?

If the answer is assembly then yeah, assembly can be more efficient IF you are skilled enough.

But the power of a higher level programming language like C or C++ is that it's MUCH easier to write and thus quicker to write. Also, it's not processor specific (or at least if you don't use direct register manipulation) so you can use a different micro controller next time and reuse (a part of) your code.

And yet another power of a higher level programming language like C or C++ is that it's MUCH easier to maintain.

I've read the compiler is pretty efficient & effective.
If you select File:Preferences and turn on Verbose outputs, you can see the path where the interim files created towards the final .hex file are created. I'm pretty sure one of those has the assembly code that gets turned into the .hex file. Browse that and see if there's anything you would have done differently.

Most times I just use direct port manipulation with SPI.transfer() to by pass the code associated with digitalRead & DigitalWrite and things seems to work pretty well. I also avoid most libraries as a I don't feel like putting the time into to figure them out. I think VirtualWire was one of the few I've used outside of SPI.h and Wire.h, and Fastled.h recently when we couldn't get adafruit's WS2812B library responsive enough for blasting out bytes of data.

Maybe all of it will work if you use the Arduino IDE. Think of all the processors that you can use with Arduino and Energia gives you access to TI’s LaunchPads with no changes to your code.

globalturist:
if i use c/c++ to program an arduino uno will it be more cost effective in terms of memory or should i just stay with the native platform and use direct processor commands?

The standard Arduino programming language IS C/C++.

It includes many helper functions such as digitalWrite(, analogWrite() and analogRead() and you can improve performance by replacing some of those functions with code that directly writes to the Atmega registers. As well as the extra work involved (study of the Atmel datasheet is guaranteed to need several cups of coffee) the resulting code may not be transportable between different types of Arduino.

It is also much easier to get help here if you are using the standard functions that everyone is familiar with.

Use the standard functions until you have evidence that you need more performance.

...R

Is Serial a library? I use that regularly too. Or is it a class, or a macro? I don’t know or really care what it is referred to as.

Serial is a library written mostly as a class + code to already make a Serial object for you :slight_smile:

CrossRoads:
Is Serial a library?

I believe it is a library.

But it is considerably more complex than the effects of digitalWrite(), analogWrite() or analogRead() and I don't believe that DIY code to replace Serial would offer a sufficient advantage to justify the effort. But having done it for an Attiny1634 it is not that difficult.

It is the fact that those functions are written to be transportable between Arduino boards that makes them use more CPU cycles than DIY code that is written for a specific Arduino board.

...R

Serial is a built-in part of the Arduino runtime, not a library. The source is in a couple of files
called HardwareSerial.{h,cpp} in the runtime. (This is for AVR Arduino's, not sure about the others).

The function serialEventRun() is caled by main.cpp, so it has to be a built-in thing.

I would still call it a library although one that's loaded by default and part of the IDE package...