Can Arduino itself be thought of as a library?

Hi all,

I'm in the process of trying to wrap my head around the similarities and differences between Processing, p5.js, and Arduino.

In this video (at timecode 3:10), Dan Shiffman describes p5.js as a library for the JavaScript programming language and Processing as a library for the Java programming language.

I'm wondering if it would be accurate to then say that the Arduino programming language is a library for the C/C++ programming languages?

What are your thoughts?

The Arduino programming language is C/C++.

There are libraries of code as part of the Arduino system to simplify many tasks. For example the Servo library.

...R

I think it would be more accurate to say that C++ is a subset of Arduino Language. All valid C++ code is valid Arduino Language code but you can write code in Arduino Language that is not valid C++.

The Arduino API is defined in C++ and C files in the cores subfolder of each hardware package. For Arduino AVR Boards:
https://github.com/arduino/ArduinoCore-avr/tree/master/cores/arduino
The declarations are introduced into the .ino files of Arduino sketches by the sketch preprocessor automatically adding the following line (unless it is already present) to the top of the primary .ino file (all other .ino files of the sketch are concatenated into one file before compiling):

#include <Arduino.h>

I do consider those files to be a library and I refer to it as the “core library” to differentiate it from Arduino’s other use of the term “core” to refer to the entire package of files that define an Arduino platform (e.g. Arduino AVR Boards).

To summarize, here is the process that justifies calling the code in the .ino files of Arduino sketches Arduino Language, rather than C++:

  • Concatenate all .ino files of the sketch, starting with the file that matches the folder name followed by the rest in alphabetical order.
  • If an #include directive for Arduino.h is not already present, add an #include directive for it to the start of the file.
  • Add function prototypes for any functions that don’t already have prototypes.

After that, the file is compiled as C++ using a standard C++ compiler. You can also add .h, .cpp, .c, and .S files to the sketch and these don’t undergo the sketch preprocessing. They are compiled as is using a standard compiler for C++/C/assembly.

Thanks so much for these detailed responses Robin2 and pert :slight_smile:

pert:
I think it would be more accurate to say that C++ is a subset of Arduino Language.

Kernighan and Ritchie and Stroustrup were thieves :slight_smile:

...R