[SOLVED] is there standard for the Arduino language, or based on Arduino does

What I'll call The arduino templating language (known as sketches)
~~-- which is referred to in this "Language reference": https://www.arduino.cc/en/Reference/HomePage~~
Or which the description of this forum section refers to when it writes "Understanding the language, error messages, etc"
-- is actually just lightly templated C++.
Essentially, it is C++ with a few steps performed prior to being handed off to the avr-G++ compiler.
I'd like to know whether the steps performed to get Arduino to C++ are included in a Standards document anywhere, or if, instead, they are just whatever the Arduino IDE actually does?
For example, if the next version of the Arduino IDE were to introduce some new functionality / that would make it no longer do the exact same steps, then would it no longer be following some standard, or would this be written down in some new standard - or would it just be the new de-facto standard?
In other words, is there any standards document defining its steps, what is part of the standard or what is implementation-specific. Thanks so much. I'm still trying to get my head around exactly what "Arduino" really means in the end.

[This question had errors and I'm removing it after complaints.]

It is a subset C++ with library extensions that simplify access to hardware functionality. Not all the 'standard' C++ libraries make sense in the Arduino environment as there is very limited flash memory and RAM.

You can also use straight C if you want and it works as well, or in fact not use the hardware access extensions at all.

I would say that 'Arduino' refers to a development environment (hardware and software) that is based on C++ that simplifies the creation of portable code for devices that support the ecosystem.It is designed to lower the entry barriers for beginners at the expense of some speed or efficiency.

marco_c:
It is a subset C++ with library extensions that simplify access to hardware functionality. Not all the 'standard' C++ libraries make sense in the Arduino environment as there is very limited flash memory and RAM.
You can also use straight C if you want and it works as well, or in fact not use the hardware access extensions at all.
I would say that 'Arduino' refers to a development environment (hardware and software) that is based on C++ that simplifies the creation of portable code for devices that support the ecosystem.It is designed to lower the entry barriers for beginners at the expense of some speed or efficiency.

This is a detailed answer but I believe it is mistaken. You write "it is a subset [of] C++ with library extensions" but in fact it should be full, standard C++ (the language) - not in any way or sense a subset. Of course, you cannot compile Firefox with it, even though Firefox is written in C++, but not because Arduino is a "subset of C++" (the language) but rather because the compiler target is a microcontroller with the limitations that you've specified.
Here I am asking about C++ the language, rather than C++ the development environment.
As such, if I would like an alternative set of tools to translate a Sketch (in the arduino [templating] language' into a compiled program, other than using the default Arduino IDE, then I could do so if I followed the same standard.
It sounds like from your answer that there is no such standard. I could only just make a work-alike. But that the Arduino IDE could change its behavior slightly in future versions.

[This question had errors and I'm removing it after complaints.]

curious48:
This is a detailed answer but I believe it is mistaken.

You have really got a lot of nerve.

You ask a question, then you have the audacity to say that the answer you received is wrong? ? ?

HUH.

If you already know the answer, don't bother coming here. It simply wastes people's time.

By the way, the full answer that marco_c gave is It is a subset C++ with library extensions that simplify access to hardware functionality. Your learning to read would help too.

standard C++ (the language)

Yes the language is full implementation because it uses the gcc compiler that supports. However, I consider the C++ standard to include some of the standard libraries that you expect in most implementations to make code portable and, while these may compile, it makes no sense to do so. We are saying the same thing, I think.

If you are saying that the IDE is not the tool you want to use, then there are a lot of alternatives. I use Visual C++ with the Visual Micro Arduino extensions. Others use the Atmel toolchain. Still others use tools that I have never heard of. Depends on your OS (Windows, Mac or Linux) and what you are used to for other programming. There are also some visual programming tools implemented.

Lots of info for this in the forum. Most of it seems to be in "Other Software Development".

marco_c:
Yes the language is full implementation because it uses the gcc compiler that supports. However, I consider the C++ standard to include some of the standard libraries that you expect in most implementations to make code portable and, while these may compile, it makes no sense to do so. We are saying the same thing, I think.

If you are saying that the IDE is not the tool you want to use, then there are a lot of alternatives. I use Visual C++ with the Visual Micro Arduino extensions. Others use the Atmel toolchain. Still others use tools that I have never heard of. Depends on your OS (Windows, Mac or Linux) and what you are used to for other programming. There are also some visual programming tools implemented.

Lots of info for this in the forum. Most of it seems to be in "Other Software Development".

Thanks so much for this detailed answer.

I'd like your opinion on something. See this article on "Alternatives to standard Arduino IDE"?

See where they write:

Another problem that can be solved with an advanced IDE is by writing code in other languages that the standard Arduino programming language. In theory, it’s not possible to write sketches in other language than the C like Arduino code

Would it be accurate to write what they've written as:

Another problem that can be solved with an advanced IDE is by writing code in other languages that the standard Arduino programming language**, which is C++**. In theory, it’s not possible to write sketches in other language than the C like Arduino code [C++].

This would be more accurate, right? But the author continues:

, but if you write a compiler for the chip and define a series of built-in functions, you can transmit the compiled code via the serial port to the Arduino microcontroller. In this case, you can write your code in Python and uploaded it to the Arduino board, which is a good case for a developer with a lot of experience in a particular programming language

What do you think they're referring to, exactly, with the words "write your code in Python and uploaded it to the Arduino board"? (given that Pyton is a scripting language.)

It is clear that all of these IDE's are IDE's for C++ with Arduino libraries or extensions, correct?

2. How do they stay compatible?
Now that there are all these IDE's, how do they stay compatible with each other? Is the Arduino official IDE a leader and curator of the de facto practice of what Arduino IDE's should do before handing the code off to the C++ compiler? Also is there a reason Clang can't be used?
3.

However, I consider the C++ standard to include some of the standard libraries that you expect in most implementations to make code portable and, while these may compile, it makes no sense to do so.

So I'd like you to give me more information on this, please. I realize that the target may have 128 KB of memory and run under 20 mhz, so this would severely limit what it could execute. But the "standard libraries that you expect in most implementations" do not have these limitations, so could you explain what you have in mind here?

[These questions had errors and I'm removing them.]

I never heard any one programming in python and uploading to Arduino.

One thing an IDE possibly could do is, translate what ever the user writes, to a language Arduino can understand, that is C. Just like .NET converts C# or VB.NET to IL.

  1. The standard for what you can do for an embedded processor is firstly set by the features of the processor, then by the tool chain that allows you to compile and link program code (Assembler, C, C++, Forth, Basic, Python, whatever) into an executable program for that processor. The processor runs binary code, not C++. There is no operating system, so you are running on bare bones hardware. Except for the bootloader at the start (which you can eliminate as well), whatever you write is the only thing running on the processor.

The fact that C++ is the standard for Arduino is just because it is. There are also Forth interpreters (written in C or C++), Basic interpreters (written in C or C++) and the C++ compiler running on the PC itself is probably written in C as well. If someone could work out a way for Python to be compiled into something that makes sense on an Arduino (Python -> C++ -> Binary, maybe), it would run just as well as anything else.

C is often the first choice for new processors because it is a really compact language that is easily transportable - what it was designed to be, btw - and still allows for complex structures and control to be implemented relatively painlessly. Easier than assembler, anyway :-).

  1. The only thing they have in common is that the code they create needs to run on an Arduino compatible processor. That is the only compatibility requirement. The rest of the tool chain can be implemented however you like. Most tools default to the gcc tool chain because a lot of the hard work has already been done by someone else.

target may have 128 KB of memory

If you have an Uno (a very common Arduino board) you have 32kB or Flash memory (that is, read only at execution time) to store the program data (code and PROGMEM) and 2kB of RAM for your variables and data structures (yes, 2048 bytes). the most critical resource is RAM. Many of the C++ standard libraries make use of dynamic memory allocation to do their work when the library is invoked. In the embedded processor environment this is not recommended as you can run out of RAM very quickly, and then the software fails. A good example of this in the Arduino environment is the 'String' object that causes no end of issues for users who don't get the RAM constraint.

thanks @sarouje and @marco!

extremely detailed answers and I don't have a lot more questions.

marco_c:
A good example of this in the Arduino environment is the 'String' object that causes no end of issues for users who don't get the RAM constraint.

so, my forum has readers from a programming background moving into electronics for the first time.

I'd like to write for the benefit of programmers, what some of the limitations are that they will bump into first. I'm personally not an expert but collecting this information

-> Other than String, what do you think some of the most common walls to hit are when first programming in the Arduino environment?

I mean from the point of view of someone coming from C++ or Java and starting to do Arduino.

thanks.

In no particular order:

  1. There is no main() but a setup() and a loop(). main() is hidden in the library. understand what setup() and loop() are for.
  2. Many examples use delay(). People coming from a multitasking environment would assume this is some form of yielding to another process. It is in fact a dead stop in the code and waits for specified time before moving on to the next line. NOTHING HAPPENS during a delay. Need to learn the BlinkWithoutDelay() technique to multitask stuff.
  3. They never read the documentation!
  4. The hardware interface is often not straightforward (eg, switches need to be debounced to work properly)
  5. Nothing happens automatically - if you don't write the code it does not happen.

The stickies at the top of each forum generally captures what the main issues that keep coming up are. If people would just read them ...

curious48:
so, my forum has readers from a programming background moving into electronics for the first time.

Start with floating inputs. Will get you automatically to resistors which can lead to output current for LEDs (and and relays and ...) and the limitations of the micro controller (20mA max, 40mA absolute max, total allowed current per port and on Vcc and GND pins).

Explain 5V vs 3.3V and why a 5V output can't drive a 3.3V input and why a 3.3V output can't drive a 5V input (might depend on micro controller; in practice it might work but according to the 328 datasheet it will not (0.7 * Vcc = 3.5V for Vil(min)).

How is this Thread different from your other pointless Thread or this other one

If you want to use the Arduino IDE for an Arduino project you are very welcome to do so.

If your only aim in life is to be provocative please go away and leave us to our own little world where we are quite happy.

...R

I really interested to know, have you started programming in Arduino? After seeing the threads pointed by @Robin, seems like you are confused a lot and shows a lack of experience in programming.

I suggest give some time to learn programming, if your interest is in Arduino, give it a try.

Understand a little bit about compilers in general is also a worth.

sterretje:
Explain 5V vs 3.3V and why a 5V output can't drive a 3.3V input and why a 3.3V output can't drive a 5V input (might depend on micro controller; in practice it might work but according to the 328 datasheet it will not (0.7 * Vcc = 3.5V for Vil(min)).

Where in the datasheet did you see that?

I see

32.2. Common DC Characteristics

Minimum Input High Voltage, except XTAL1 and RESET pins =
0.7 VCC when VCC = 1.8 V to 2.4 V
0.6 VCC when VCC = 2.4 V to 5.5 V

(06/2016 revision of the datasheet; section 30.2 in 05/2015 revision)

That means anything from 3 to 5 volts is high on a 5 V input.

PS. The two-wire section does say minimum VIH = 0.7 VCC regardless of VCC.

I searched the datasheet and the first Vih I found was probably the one for I2C. Did not look further which was a omission from my side.

sarouje:
I really interested to know, have you started programming in Arduino? After seeing the threads pointed by @Robin, seems like you are confused a lot and shows a lack of experience in programming.

I suggest give some time to learn programming, if your interest is in Arduino, give it a try.

Understand a little bit about compilers in general is also a worth.

Yes, I programmed in Arduino. I also programmed in C++ more than 5 years before Arduino existed (if we take 2004 as the earliest possible date since that's when Wiring was created).

I did not realize that the Arduino language was the C++ language. (Not a dialect/a patois/a version of/a subset of). The reason I didn't realize this is because it's not stated clearly.

@marco_c - those were some great examples of beginner trip-ups!! Thanks a lot.

EDIT: I've now written up what I've learned in this "35-second Arduino language reference for expert programmers". Thanks for everyone who contributed.