Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Arduino programming language is not fully documented #623

Open
per1234 opened this issue Jun 13, 2019 · 6 comments
Open

The Arduino programming language is not fully documented #623

per1234 opened this issue Jun 13, 2019 · 6 comments
Labels

Comments

@per1234
Copy link
Collaborator

per1234 commented Jun 13, 2019

The Arduino Language Reference is the only official documentation of the Arduino programming language, but it is far from complete.

Some examples of important things that are not mentioned in the the Arduino Language Reference:

  • C string functions
  • Default arguments
  • Overloaded functions
  • enum
  • Templates
  • Classes

How can users be expected to learn these parts of the Arduino programming language from the current documentation?

In my own learning journey with Arduino I started writing sketches using the Arduino Language Reference as a guide and quickly reached a point where I said to myself "Is that all there is to the Arduino programming language? I need more." I was about to give up on Arduino and move on to a more capable microcontroller platform when I stumbled across a post on the Arduino Forum that made me realize that there was so much more to the Arduino programming language, but I would need to use a C++ programming reference to discover it.

Once I realized this, I knew Arduino was the right choice. So it worked out OK for me, but this is far from an ideal learning path. How many other users in my situation would never chance upon that forum post? I know I'm not the only one who has had this sort of experience because it comes up regularly on the forum.


I can see two possible solutions:

Document the differences between the Arduino programming language and C++

Create a new page on arduino.cc that explains what the Arduino programming language is:

  • A brief history (Processing, Wiring).
  • A description of the sketch preprocessing processes that make the Arduino programming language different from C++:
    • Concatenate .ino files, starting with the file that matches the folder, followed by the rest in alphabetical order. Save the resulting file with a .cpp file extension.
    • Add #include <Arduino.h> if not already present.
    • Add function prototypes for any functions that don't already have one.
  • A link to an external C++ language reference (e.g., http://www.cplusplus.com, https://en.cppreference.com)
  • Add a link to the new page from the description at the top of the Arduino Language Reference home page.

This means the Arduino Language Reference only needs to document the Arduino core API and some basics to get beginners started, which it already does a good job of.

Advantages:

  • Easy to implement and maintain. Others are responsible for the huge task of completely documenting the language.
  • Makes it easy for the user to understand how to apply their Arduino programming language knowledge to writing C++ as well (e.g., writing Arduino libraries).

Disadvantages:

  • The external C++ reference will contain information that is not applicable to Arduino. The reader will need to have some intuitive filter for which parts of that documentation are useful and which can be ignored.

Fully document the Arduino programming Language in the Arduino Language Reference

Advantages:

  • We can custom tailor the documentation for Arduino.
  • We may be able to write the documentation so that it is easier to understand for the target audience than the external C++ documentation.

Disadvantages:

  • A huge amount of work to implement and maintain.
  • Has the potential to make the Arduino Language Reference less friendly to beginners. I think we would need to have some way of separating the advanced topics that beginners should not be immediately exposed to from the rest.

Related

@animeshsrivastava24
Copy link
Contributor

@per1234 Please can you guide on how to proceed to work on this issue. I want to work to resolve this issue by providing relevant documentation.
Also, can you guide me on how to work on "Arduino Core Documentation", I want to work on it both voluntarily and as a way to make my Season of Docs application stronger.

@per1234
Copy link
Collaborator Author

per1234 commented Jun 18, 2019

Please can you guide on how to proceed to work on this issue. I want to work to resolve this issue by providing relevant documentation.

Thanks for your offer to help! My goal for this issue was to start a discussion on how to resolve this. Hopefully some folks from Arduino will participate because this is a big decision.

Until we have decided on how to proceed, no documentation work for this issue can be done. If we were to chose my second proposed solution, it would create a lot of documentation work on which help from the community would be very welcome.

can you guide me on how to work on "Arduino Core Documentation", I want to work on it both voluntarily and as a way to make my Season of Docs application stronger.

Since this will be new documentation, I think some internal discussion at Arduino will be required before we create the page where it will be published. That likely would only happen after a Season of Docs application for the Arduino Core Documentation project was selected. However, you are welcome to write some documentation and publish it to your own GitHub repository, blog, Arduino Project Hub project, etc. There is a tremendous amount of excellent Arduino documentation available online from 3rd parties who wrote and published it on their own initiative without any interaction with the Arduino organization.

@animeshsrivastava24
Copy link
Contributor

animeshsrivastava24 commented Jun 21, 2019

@matthijskooijman
Copy link
Collaborator

I would be very much in favor of the first solution. One additional advantage is that making users aware of the relation to C++ would also open up a lot of extra resources (documentation, tutorials, stackoverflow posts, etc.) to them, which they previously did not realize applied to Arduino (this is different from the advantage you already listed, which is about applying Arduino docs and experience to C++ projects).

In addition to the things you already listed, I think we should make explicit that:

  • Exceptions are disabled in Arduino (at least on AVR, but I think we do this on all platforms?).
  • The C++ library (libstdc++) and STL is not available on all platforms (in particular not on AVR, not sure about all others).
  • The C++ version might vary per platform.

@theHacker
Copy link

Hi, Arduino newbie here. I just stumped upon this issue. I read the language reference and was puzzled by "How are libraries able to use additional language features like class and I am not?", until I tried out using the same syntax and it just worked.

Since this issue has been open for several years, might I suggest a pragmatic approach to improve the situation without committing to any direction:
Just add an info box to the language reference page, sth like

Please note:
This reference is not fully complete. There are more language features similar to C++.
A list of missing features can be found {link to this PR}.

This will point anybody who wants more information in the right direction.

@MacDada
Copy link

MacDada commented Aug 2, 2023

language features similar to C++

They are not similar - they are the same. Arduino "language" is not a separate language -> it IS C++.

The difference is not in the language itself, it is the fact that not all stuff from C++ standard library is available + there is extra (pre)pre-processing done on top of standard C++ build stuff. It is just GCC under the hood. GCC does not claim that it compiles some separate "arduino language" xd

@per1234 per1234 added the bug label Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants