Arduino Forum

General Category => General Discussion => Topic started by: curious48 on Jul 18, 2016, 03:38 am

Title: [SOLVED] Arduino language
Post by: curious48 on Jul 18, 2016, 03:38 am
EDIT: To anyone coming here from a search engine, etc, I've now summarized everything I learned in this and a few related threads in the article "35-second Arduino language reference for expert programmers" (http://curious.boards.net/thread/50/second-arduino-language-reference-programmers).


The below is just preserved for historical reasons.


--

[original title was "Nomenclature: is Arduino a language?".  Original post:]


I am reviewing edits I might make to an article I wrote, based on feedback I received in our thread here. (http://forum.arduino.cc/index.php?topic=412962.0)  Someone suggested:

"There is no Arduino language (http://hackaday.com/2015/07/28/embed-with-elliot-there-is-no-arduino-language/)! This is part of why some people hate Arduino, because they never took the time to actually understand what Arduino is and is not. If there really was an Arduino language that would be a good reason to hate it but instead we're using real, professional, programming languages. Sure, the IDE takes care of a bit of the less beginner friendly stuff but you can override any of that if you want."

I've reviewed (meaning read through) the linked post, "Embed with Elliot: there is no Arduino 'language'."

To give you my qualifications for talking about programming languages: in purely chronological terms, i.e. if you measure the time that I first wrote a single line of any programming language, I've been programming since I was a young teenager.  This extends from basic scripting languages to compiled languages to things running on a browser.

The author of the "Embed with Elliot" piece writes:
>There is no "Arduino language" and your ".ino" files are three lines away from being standard C++

In my opinion, something can be called a language even if even three lines are not involved.  For example, on Windows you can rename a .docx word file to .zip, and open it with an archive program.  You can see images in there and other assets.  Does this mean that there is no such thing as a Word document, since inside it is actually a zip file?  Surely not.

Three lines is quite a transition. It means that someone who has spent a whole year writing Arduino code cannot write a C++ program without looking up the C++ language.  Since they have been writing in Arduino.  How should they figure out "#include" lines?  By definition then it's not the same language: only almost the same language.  The Arduino language is very close to C/C++.  I don't see the mistake in calling it a language.  Further .ino files are not the same as .c[pp] files.

So, I would say that it is fair to say "the Arduino language is almost exactly the same as/very close to C/C++".

Therefore, I would like to reject the edit suggestion to remove the phrasing that Arduino "is a language".  In my article I want to continue to use this phrasing.  Would I be technically correct?  (In light of my arguments above.)  Bear in mind that Arduino has a language reference page (https://www.arduino.cc/en/Reference/HomePage).  After reading it, you can begin to write in the Arduino language, without having to look up references that don't refer to that.

If in light of what I've written above, you judge that I am still confused, I would like your additional information.  I do find the Elliot post to be interesting, and I would say it means that those who happen to know C or C++ can easily add it to Arduino projects, since the Arduino IDE can use them easily.  Is this a fair way to rephrase the Elliot post?

Thanks for your information about these exact differences and your advice regarding my edit choice.
Title: Re: Nomenclature: is Arduino a language?
Post by: Power_Broker on Jul 18, 2016, 03:51 am
No, no, no.

Arduino is not a language. Here's why: Your .ino file is not what is uploaded to the board. The .ino file is converted to C++ via the compiler and sends the C++ code to the board. In a sense, the IDE serves similar to an autocoder, taking a more primitive version of the code and converts it to what the C++ code should be.

Arduino is not a language, its just that the IDE is more of an autocode generator.


P.S. I wish I started coding as young as you, sir  :) !
Title: Re: Nomenclature: is Arduino a language?
Post by: OldSteve on Jul 18, 2016, 03:58 am
The .ino file is converted to C++ via the compiler and sends the C++ code to the board. In a sense, the IDE serves similar to an autocoder, taking a more primitive version of the code and converts it to what the C++ code should be.
No, C++ code is not sent to the board at all. Machine code is uploaded to the chip.
This will clarify:-
Build Process (https://www.arduino.cc/en/Hacking/BuildProcess)

Title: Re: Nomenclature: is Arduino a language?
Post by: Nick_Pyner on Jul 18, 2016, 04:02 am
No, it's simply a brand name for a development system made up of hardware and a compiler. I believe the user language is a subset of C++, not that it matters, as the IDE sends machine code to the chip.
Title: Re: Nomenclature: is Arduino a language?
Post by: ChrisTenone on Jul 18, 2016, 05:01 am
Arduino is not a language, but when people speak of the "Arduino language', I believe they mean C++ with Arduino specific extensions loaded from the arduino.h library.
Title: Re: Nomenclature: is Arduino a language?
Post by: curious48 on Jul 18, 2016, 05:17 am
This thread is not really helping.  :D :D :D

Let me ask this way.  (A) If I write .ino with vim, can I then rename it to .cpp, send it to gcc, and upload the results?

In what way will this differ from (B) pasting the same thing I wrote into vim, into the Arduino IDE and uploading it that way?

I assume under the first hypothetical (A), gcc does the compilation; under the second hypothetical (B), the Arduino IDE has a built-in compiler.

Is all this correct?  Does this comparison break down anywhere?  (Specifically in sending an .ino file to gcc)?

Are .ino files ANSI standard C89?  If not, what standard do they follow?  Does Arduino know any C++ or only just C?

Finally, can you use the arduino IDE from the commandline like gcc?  Any other differences?

Please tell me the comparison of (A) and (B) and the results.  Thanks so much.
Title: Re: Nomenclature: is Arduino a language?
Post by: bperrybap on Jul 18, 2016, 05:22 am
curious48,
My view is that "Arduino" is definitely not a language. Not anywhere close.

The Arduino IDE provides a development/build environment and defines and provides a runtime operating environment that can be extended further using C++ code, but it sure isn't a language. The actual language being used is C++

I believe that things in Aduino-world are confusing because the founders call everything "Arduino".
The board, the IDE, the tools, the libraries, and even claim to use a language called "Arduino".
This makes it very difficult to refer to the individual components/pieces.
At one point several years ago, after one of them said that Arduino was actually more of a lifestyle, I responded with something like:

"I have an Arduino that I program in Arduino using Arduino" just to demonstrate the ludicrousness of it all.

But in terms of "Arduino" being an actual language, it seems like a pretty weak argument since the code (and sketches) are all using C++. All the IDE does is massage the users "sketch" into being valid C++ if it isn't already and then compile it.
That doesn't qualify it as a language since the "Arduino language" is not defining any grammar or syntax which is what any real language must do.

The IDE does comes with some code to provide some functionality for the supported boards as well some "libraries". While the IDE calls things "Arduino libraries" they are not really libraries but simply a collection of code that kind of sort of act like libraries in "normal" development systems.
The only code in the Arduino IDE system  that is a real library is the core code. That code is compiled and archived into a real library and linked against at link time.






Title: Re: Nomenclature: is Arduino a language?
Post by: OldSteve on Jul 18, 2016, 05:32 am
I forgot to say earlier, but I'm with the others. "Arduino" is most definitely not a language. The language is C++.
Dig into any Arduino function that you might call a part of the "Arduino" language, and the source files are C or C++.
"Arduino" is a just a brand name, a registered trademark. There's an Arduino IDE, Arduino boards, Arduino accessories but no Arduino language.
Title: Re: Nomenclature: is Arduino a language?
Post by: PaulMurrayCbr on Jul 18, 2016, 05:41 am
Arduino is not a language. It is a hardware platform and a programming environment. The language is simply C++. The main thing that the arduino gestalt has is a Hardware Abstraction Layer. That is, you can write digitalRead(3) without having to worry about the details of where the ports are memory-mapped to. If anything, that's the core of what makes it useful. But that would be nothing without hardware that's rugged enough to manage being handled and poked at by hobbyists. Let's also not forget the importance of shields and modules.

So:

* rugged(ish) hobbyist hardware
* open source makes it possible to make and sell 3rd-party plugins
* hardware abstraction layer - an API
* IDE that makes it easy to upload the machine code (a lot happens in the background)
* the community

But it certainly isn't "a language". Perl is a language. Lisp is a language. The IDE uses C++, but it could use anything else that could be compiled down to run on the AVR.

Quote
Let me ask this way.  (A) If I write .ino with vim, can I then rename it to .cpp, send it to gcc, and upload the results?
Yes. This is exactly what ordinarily happens when you git the 'go' button in the IDE. The code is sent to gcc, then it is linked with a runtime library same as any other C program - most notably it is linked with libc which is the standard C library that pretty much every C program uses. Then it is uploaded over the USB.

You could do all this with command-line tools if you wanted, and I think that that's how the IDE actually does do it: it issues java System.shell() commands.

If you replaced the arduino libraries with your own stuff implementing main() and the abstraction layer (digitalRead(), etc) - it would just be a regular C++ program.




Title: Re: Nomenclature: is Arduino a language?
Post by: bperrybap on Jul 18, 2016, 05:53 am
curious48,
You seem to be confusing several different things and trying to lump several together operations, from a lack of understanding how programs are converted from source code into executable machine code.

There are many different tools involved in building and uploading an Arduino sketch and none of them are a "language".
The Arduino IDE is simply a GUI wrapper tool that runs many commandline tools under the hood.

Much of what is in the IDE is a re-inventing of the wheel for what is in the tool 'make' to control the build process.
None of the actual compiling, linking, or uploading is done by the IDE itself.
i.e. the IDE simply decides what needs to be done/built and runs the appropriate commandline tool to do what needs to be done.

And yes the newer IDE versions can be run directly from the command line as well rather than interacting with as an actual GUI program.

The IDE first acts as a pre-processor that runs before the other tools to massage the .ino into a .cpp file to be a valid C++ code and to also insert the arduino header to pull in the Arduino environment defines/macros and classes.
That is pretty much the only thing that IDE actually does itself. Everything else, is done by commandline tools since it all involves using C++.

But it is possible to write your sketch such that it is already valid C++ code and contains everything needed to use the Arduino compile and runtime environment.

What is being called a "Hardware Abstraction Layer", is really a runtime environment, provided by the Arduino core code. But that environment is simply a collection of C & C++ code that provides a consistent API across multiple hardware platforms.

After the IDE pre-processes your .ino file to create the .cpp C++ file, it then runs a series of command line tools to compile the sketch (which is now valid C++) as well as all the other needed sources and link them together to create the .elf object file. It then runs additional command line tools to convert that to a .hex file and eventually runs an upload tool like avrdude to do the actual upload.
Again, the IDE is not actually doing this but simply calling other command line tools to do the actual work.
This is all possible because the "Arduino language" is actually C++ and so the IDE can use standard C/C++ embedded tools to do the actual compile, link, and upload.


--- bill


Title: Re: Nomenclature: is Arduino a language?
Post by: curious48 on Jul 18, 2016, 06:52 am
"I have an Arduino that I program in Arduino using Arduino" seems fine to me?

I read this as:
"I have an Arduino-compatible board, that I program in the Arduino [redacted], using the Arduino IDE".


In the word "redacted" is what this thread is about - obviously some people disagree that this word should be "language".

Let me ask this.  Many people in this thread are saying that the Arduino "language" is C++.

But in C++ this is how you change the size of an array:

c++ changing the size of an array]c++ changing the size of an array (https://www.google.com/search?q=c%2B%2B+changing+the+size+of+an+array)

There are two helpful answers:

Quote
Quote
n C++ you can do:

int *array; // declare a pointer of type int.
array = new int[someSize]; // dynamically allocate memory using new
and once you are done using the memory..de-allocate it using delete as:

delete[]array;



This is correct and insightful, but really, one should encourage the use of std::vector


and:

you want to use std::vector in most cases.

Quote
std::vector<int> array;

array.resize(someSize);
But if you insist on using new, then you have do to a bit more work than you do in Java.

int *array;
array = new int[someSize];

// then, later when you're done with array

delete [] array;
No c++ runtimes come with garbage collection by default, so the delete[] is required to avoid leaking memory. You can get the best of both worlds using a smart pointer type, but really, just use std::vector.




So, this is C++.  Will this work?  Is this appropriate usage?

If we look at the Arduino language reference (https://www.arduino.cc/en/Reference/HomePage), under array (https://www.arduino.cc/en/Reference/Array) it says:


Quote
Arrays in the C programming language, on which Arduino is based, can be complicated, but using simple arrays is relatively straightforward.

Creating (Declaring) an Array

All of the methods below are valid ways to create (declare) an array.

Quote
int myInts[6];
  int myPins[] = {2, 4, 8, 3, 6};
  int mySensVals[6] = {2, 4, -8, 3, 2};
  char message[6] = "hello";




So, at a minimum, this seems to mean that Arduino is only based on C, not C++.

Since this whole thread is kind of pedantic, it makes it really really weird that not one but two of the commentors wrote "C++" and the linked article also says "C++".

In what sense is Arduino possibly C++ as opposed to C?


People are writing "Arduino is not a language, but when people speak of the "Arduino language', I believe they mean C++ with Arduino specific extensions loaded from the arduino.h library."  <---- this should read "I believe they mean C with Arduino specific extensions", right?


bperrybap writes:

>The Arduino IDE provides a development/build environment and defines and provides a runtime operating environment that can be extended further using C++ code, but it sure isn't a language. The actual language being used is C++

Do you mean C?  "The actual language being used is C"?  (Not "C++").

Oldsteve writes:

>"Arduino" is most definitely not a language. The language is C++.

Again, does he mean C?

Paulmurray writes:

>Arduino is not a language. It is a hardware platform and a programming environment. The language is simply C++.

Again, does he mean C?


It seems incredibly odd that every single commentor would make this mistake in this pedantic thread.  Please explain why they are using the term C++ and not using the term C?

I am more confused than ever.  Note: I've programmed in both C and C++.  In general, C++ is a superset of C and you can use C constructs.  But not the other way around - I've never heard anyone refer to C code as C++ code, unless they're being incredibly casual (like "C/C++").  In this sense, sure, Arduino is "like C++ code".

But now that we're being very technically precise, shouldn't all of the above references to C++  be renamed as references to C?


[EDIT: this was all mistaken.  Arduino is not a "subset" of C++.  It is the Project's name for C++, which for marketing reasons it does not use.  The IDE also does some light translation before using a standard C++ compiler.]
Title: Re: Nomenclature: is Arduino a language?
Post by: BulldogLowell on Jul 18, 2016, 07:08 am
I am more confused than ever.  Note: I've programmed in both C and C++.
Maybe think of it as a patois.

 ;)

Title: Re: Nomenclature: is Arduino a language?
Post by: OldSteve on Jul 18, 2016, 07:13 am
Oldsteve writes:

>"Arduino" is most definitely not a language. The language is C++.

Again, does he mean C?
No. I meant what I wrote - C++.

C++ is backwards compatible.

There are errors in the documentation, but Arduino primarily uses C++, as we've all indicated.
Try this:-
Code: [Select]
void setup()
{
    Serial.begin(115200);
    int *pVal = new int[10];
    pVal[0] = 123;
    Serial.println(pVal[0]);
    delete[] pVal;
}

void loop() {}

'new' and 'delete' are only valid in C++, not in C. If Arduino used C, this would not compile.

You could also use 'malloc()' and 'free()', because of the backward compatibility, but in C the 'new' and 'delete' method of handling dynamic memory allocation would not work.

Disclaimer: I'm not in any way saying that dynamic memory allocation in embedded microcontrollers is a good thing, this is just an example. Easier than writing a 'class' example. :)

Quote
But now that we're being very technically precise, shouldn't all of the above references to C++  be renamed as references to C?
Definitely not. As we've all stated, it's C++, not C.

At some point you need to stop arguing and accept facts. :)
Title: Re: Nomenclature: is Arduino a language?
Post by: curious48 on Jul 18, 2016, 07:47 am
Disclaimer: I'm not in any way saying that dynamic memory allocation in embedded microcontrollers is a good thing, this is just an example. Easier than writing a 'class' example. :)
Definitely not. As we've all stated, it's C++, not C.

I didn't see as many examples like this.  Most examples just use the Arduino language reference things.  You just wrote that dynamic memory allocation isn't good in embedded microcontrollers.  What about classes and objects generally?

I am now confused regarding why / to what extent, then, Arduino (patois + culture + habits and what is encouraged) is different from C++.  Why not use C++ concepts such as classes extensively?  There is little overhead, it's more about how you think about things.
Title: Re: Nomenclature: is Arduino a language?
Post by: OldSteve on Jul 18, 2016, 07:59 am
I didn't see as many examples like this.  Most examples just use the Arduino language reference things.  You just wrote that dynamic memory allocation isn't good in embedded microcontrollers.  What about classes and objects generally?
Classes are fine, much of the Arduino code and libraries are written using classes.

Quote
Why not use C++ concepts such as classes extensively?  There is little overhead, it's more about how you think about things.
See my line above. :)

Take a bit of a look around in the source code. For instance, "Serial", which itself inherits from the "Stream" class:-
Code: [Select]
class HardwareSerial : public Stream
.
.
.
extern HardwareSerial Serial;


Edit: And "Print" is a class, with 'print()', 'println()' etc member functions, "Servo" is a class, "File" is a class, "Wire" is a class, ("TwoWire"), etc etc
Title: Re: Nomenclature: is Arduino a language?
Post by: nickgammon on Jul 18, 2016, 09:34 am
I did a fairly lengthy explanation of what the IDE does to your sketch here (http://arduino.stackexchange.com/a/13182).

The fact is, the .ino file is treated as C++, and is modified by the IDE pre-processor slightly to automatically generate function prototypes.

So, Arduino is not a language. You may as well argue that the output from the Visual C++ "wizards" are a new language. But they are not. The wizards just generate C++ for you.

@curious48 - you mention std::vector. That is a library (the Standard Template Library) which is written in C++. It is not, itself, part of C++. It is a library written in C++. Just like the works of Shakespeare are not a new language. They are written in English.

You can install implementations of the STL on the Arduino, and then you have std::vector (and std::map etc.). The same thing applies on "normal" C++ installations, except that they may have installed the STL for you, so you confuse the library with the language.
Title: Re: Nomenclature: is Arduino a language?
Post by: westfw on Jul 23, 2016, 09:59 pm
When programming, one has to distinguish between the "Language" and "everything else that goes into writing the program" - the "environment."   That includes the libraries, the operating system (if any), the compilers, and the build environment.   Some languages/systems will blur the distinctions - if you write a fortran program for an IBM370 system, it would be pretty significantly standardized fortran, and all or most of what makes it specific to a particular task would be handled by external setup (JCL in IBM-speak) that would map Fortran-style abstracted 'files' to actual disk images or card readers or printers or whatever.  The original Pascal was similar.

The best analogy I can think of offhand is Mac vs Windows.
You can take a lovely C++ program (that everyone agrees was written in C++) from a Windows system, and when you try to move it to a Mac, it won't work.  It won't even compile, and you probably need to do a lot of work before you can even attempt to compile it (What with "Windows Studio" - the common Windows IDE, not being nearly the same as XCode - the common Apple IDE.)
This doesn't mean that the program wasn't written in C++, or that the Mac doesn't support C++.  There is just "stuff that is different."

An embedded AVR (with 32k/2k of memory) is MUCH MORE DIFFERENT from a Windows PC than a Mac is from Windows, so the difference in programming is also higher.   Some things are added or subtracted from the Arduino to emphasize those differences (loop/setup vs main, for example.)  Some other things are avoided because they are unlikely to work well (or at all) in the Arduino environment (most of STL, exceptions, dynamic allocation.)  Some purists might claim that these mean that it's not "real C++" any more, but 1) Those aren't the people who usually miss-use the "Arduino Language" phrase and 2) They're wrong.

In favor of it being C++:



Title: Re: Nomenclature: is Arduino a language?
Post by: PaulMurrayCbr on Jul 25, 2016, 07:03 am
"I have an Arduino that I program in Arduino using Arduino" seems fine to me?
I read this as:
"I have an Arduino-compatible board, that I program in the Arduino [redacted], using the Arduino IDE".
You have just made up your mind, haven't you? Every single person on both threads has told you that you are simply wrong, many of them experts in programming and in hardware, both generally and with arduino specifically; and you are nevertheless determined to go ahead and misinform your readers anyway.

Quote
But in C++ this is how you change the size of an array:

c++ changing the size of an array]c++ changing the size of an array (https://www.google.com/search?q=c%2B%2B+changing+the+size+of+an+array)

… So, this is C++.  Will this work?  Is this appropriate usage?
Yes, it will work. No, it's not appropriate usage. You only have 2kb of memory, not gigabytes of the stuff. This is not a feature of the language, and you don't get this, or simply refuse to get it, because you have your own personal definition of what the phrase 'computing language' means and want to burden your readers with a privately-held point of view that they are going to have to unlearn later on.

Quote
bperrybap writes:

>The Arduino IDE provides a development/build environment and defines and provides a runtime operating environment that can be extended further using C++ code, but it sure isn't a language. The actual language being used is C++

Do you mean C?  "The actual language being used is C"?  (Not "C++").

Oldsteve writes:

>"Arduino" is most definitely not a language. The language is C++.

Again, does he mean C?

Paulmurray writes:

>Arduino is not a language. It is a hardware platform and a programming environment. The language is simply C++.

Again, does he mean C?
NO! WE EACH SAID WHAT WE MEANT! We are not stupid, we are not ignorant, we are not incapable of expressing what we mean.

The Adruino programming environment uses classes. It uses encapsulation, inheritance, and polymorphism. This is why Serial.println() works, why the HTTP libraries, not to mention every other 3rd-party library, looks the way it does. When you use an adafruit neopixel ring, you instantiate an OBJECT. The OBJECT has METHODS. You are using C++, not C.

It may be true that most arduino programmers on these boards don't use objects in their own code except to call libraries. Personally, I think they should. Please see the page in my sig block, where I discuss this style of programming.

Quote
It seems incredibly odd that every single commentor would make this mistake in this pedantic thread.  Please explain why they are using the term C++ and not using the term C?
No kidding! It would indeed be very puzzling that every single commenter has made exactly the same mistake. Isn't it so much more likely, dude, that there's only one person who has made a mistake here, and that person is you? You sound like every newb who insists they have found a bug in the compiler because their code doesn't work.

Quote
I am more confused than ever.
You are not "confused", you are simply refusing to accept that you are wrong even after being told so repeatedly by people who know quite a bit more about all this than you.

Quote
In general, C++ is a superset of C and you can use C constructs.  But not the other way around - I've never heard anyone refer to C code as C++ code, unless they're being incredibly casual (like "C/C++").  In this sense, sure, Arduino is "like C++ code".

But now that we're being very technically precise, shouldn't all of the above references to C++  be renamed as references to C?
NO! The arduino programming environment uses objects and references and methods. You cannot do that in C. Which you seem to know perfectly well. The problem isn't that you don't know this stuff. It's that you insist that everybody else call things what you call them. You have decided that "computing language" means something that other people don't mean, something that other people use different words for (platform, API, environment), and that everyone ought to adopt your usage.

If you were to reconcile yourself with using the same names for things that everyone else uses rather than attempting to impose your idiosyncratic vocabulary and view of the world on your readers, you'd find that your job as a writer - communicating - goes quite a bit more smoothly. As it stands, you are going to misinform your readers, making you a bad technical writer in that you will fail at the one job that a technical writer absolutely must do: get it right.

Title: Re: Nomenclature: is Arduino a language?
Post by: Robin2 on Jul 25, 2016, 09:28 am
I was beginning to be concerned that I had been a bit harsh in some comments I made in other recent Threads by this OP. But having skimmed this Thread I am no longer concerned.

This whole Thread is just a waste of time. Any information the OP required could easily be found with Google.

It seems to me the length of the OP's posts is in inverse proportion to his level  of exertise

...R
Title: Re: Nomenclature: is Arduino a language?
Post by: BulldogLowell on Jul 25, 2016, 08:11 pm
I was beginning to be concerned that I had been a bit harsh in some comments I made in other recent Threads by this OP. But having skimmed this Thread I am no longer concerned.
Looks like OP threw in the towel a while back, the rest is just the pundits waxing on in more florid detail...

;)
Title: Re: Nomenclature: is Arduino a language?
Post by: curious48 on Jul 26, 2016, 12:59 am
I did a fairly lengthy explanation of what the IDE does to your sketch here (http://arduino.stackexchange.com/a/13182).

The fact is, the .ino file is treated as C++, and is modified by the IDE pre-processor slightly to automatically generate function prototypes.

So, Arduino is not a language. You may as well argue that the output from the Visual C++ "wizards" are a new language. But they are not. The wizards just generate C++ for you.

Nick, the post you have linked (http://arduino.stackexchange.com/questions/13178/classes-and-objects-how-many-and-which-file-types-do-i-actually-need-to-use-the/13182#13182 (http://arduino.stackexchange.com/questions/13178/classes-and-objects-how-many-and-which-file-types-do-i-actually-need-to-use-the/13182#13182)) is amazingly detailed and unbelievably helpful!

I have these questions:

(https://forum.arduino.cc/index.php?action=dlattach;topic=413259.0;attach=175136)


Do you have a similar reference for the "build process" itself?  For example, it is clear that at the point of your third bullet point there is a "temporary compilation folder".  What is the program that actually builds it?

It must be a C++ compiler (like gcc).  I googled this (https://www.google.com/search?q=what+c%2B%2B+compiler+does+arduino+use) and found: " is passed directly to a C/C++ compiler (avr-g++)."

Is it avr-g++ in every case?  Or can other compilers be used at this step?

I find it extremely hard to understand why the 2000 words in your write-up and linked "more information" do not mention avr-g++ even a single time, if, in fact, it is the compiler actually used after the above compilation steps in every case.

Here are more questions:

-> If I manually performed the steps 1-10 could I then pass them to avr-G++ myself and receive a compiled program?  Why or why not?

-> What is avr-g++ (Google search "what is avr-g++ (https://www.google.com/search?q=what+is+avr-g%2B%2B)")?

People are accusing me of not googling.  The first Google result is "avr-g++: command not found" while compiling, using Arduino IDE 1.6".  It does not say what avr-g++ is.

The second link is "c++ - Using Arduino Libraries with AVR-G++ - Stack Overflow" and writes "Is there a simple way to use libraries intended for the Arduino IDE with the C and assembly code I write for AVR-G++/AVR-GCC?" and does not define what AVR-G++ is.

The third link is bizarre and seems to be a man page for gcc.  Does the Arduino just use gcc directly?

If so why can't people just use gcc directly, after performing steps 1-10 from your write-up?

Why aren't there more Arduino-templating-language compatible IDE's other than the Arduino IDE, if we define the Arduino-templating-language as simply meaning "perform steps #1-#10 to receive C++ files ready to hand off to gcc"?

C++ is a standard language based on standards.  It is not considered standard to be able to compile it using only a single compiler.  Why can't other compilers be used, other than gcc (if indeed that is what is being used)?

For example, an alternative to gcc is clang (LLVM).  If I personally perform steps 1-10 can I just pass it off to clang?  Why or why not?


Finally, based on the fact that steps 1-10 are performed how would you feel about my using the nomenclature "Arduino templating language" or to be more explicit "Arduino C++ templating language" which would make it clear that:

1: Code produced in the Arduino templating language is not ready to be passed on to GCC directly.  There is a bit of translationn involved.

2: It is a light translation that results in C++ code that is ready to be passed to the compiler.
[I rejected this possibility.]

This would make it clear that while a "templating language" Arduino qua language is essentially C++.  The only thing that makes it a (templating) "language" as opposed to wizard, is that it is written in text form, rather than by clicking buttons in a wizard. [rejected]

Would this usage be accurate?  Thank you.




Example of usage

Ambiguous:
"I have an Arduino that I program in Arduino using Arduino".

Explicit:
"I have an Arduino-compatible board, that I program in the Arduino templating language, using the Arduino IDE".


In other words, "Arduino language" should be written "Arduino templating language" or "Arduino C++ templating language." [rejected]

It would make it clear that it is a templating language that simply "turns into" C++ after steps 1-10 are performed. [rejected]

Thoughts?
Title: Re: Nomenclature: is Arduino a language?
Post by: westfw on Jul 26, 2016, 02:09 am

Quote
Explicit:
    "I have an Arduino-compatible board, that I program in the Arduino templating language, using the Arduino IDE".
How aout "I have an Arduino-compatible board that I program using the Arduino IDE" ?
The reason that you don't see the language explicitly called out is that hardly anyone cares.
If you must, it would be: "I have an Arduino-compatible board that I program in C++ using the Arduino IDE"

Quote
It would make it clear that it is a templating language
Everyone keeps telling you that it's C++, and any other wording is worse.  You say our answers are "very helpful", but you remain stubbornly unconvinced of that basic fact, and are making your description worse and more obscure the harder you try.

I give up.
Title: Re: Nomenclature: is Arduino a language?
Post by: curious48 on Jul 26, 2016, 03:31 am
"I have an Arduino-compatible board that I program in C++ using the Arduino IDE"
This is incredibly clear.  :D :D  It's too bad the Arduino web site and reference documents don't say this!  It means that calling it a 'sketch' is a distinction without a difference (https://www.google.com/search?q=distinction+without+a+difference).

Some people here have been acting like it's my fault for being confused, but it's not.  The Arduino project went through the lengths of inventing the word "sketch" for "C++ program' (if your suggestion is accurate.)   :-[

You write:

>I have an Arduino-compatible board that I program in C++ using the Arduino IDE

But where Arduino (the project) call its IDE an IDE with built-in C++ compiler?  Here is a picture on the front page:
(https://forum.arduino.cc/index.php?action=dlattach;topic=413259.0;attach=175143)

That is the front page.  I click "What is Arduino" and unfortunately, this is what I get.

(https://forum.arduino.cc/index.php?action=dlattach;topic=413259.0;attach=175145)

Let's zoom in here:

(https://forum.arduino.cc/index.php?action=dlattach;topic=413259.0;attach=175149)

Do you see the source of my confusion?  :D

If instead I click "learn arduino" I get this:

(https://forum.arduino.cc/index.php?action=dlattach;topic=413259.0;attach=175147)


You act like it's my fault for being confused!

If you are accurate and it is correct to write:


>"I have an Arduino-compatible board that I program in C++ using the Arduino IDE"


Then "Arduino software" should read differently.

Currently:

ARDUINO SOFTWARE
You can tell your Arduino what to do by writing code in the Arduino programming language and using the Arduino development environment.


Correctly:
ARDUINO SOFTWARE
You can tell your Arduino what to do by writing code in the C++ programming language and using the Arduino development environment.



And the "Learn arduino" reference I linked should, at some point, mention the word C++ don't you think?   :D   Have a read: https://www.arduino.cc/en/Guide/Introduction



I know C++.  I've programmed in C++.  On Linux and Windows.

When I started programming Arduino with a friend, whenever they would get stuck I would just try writing C++.  Simple things - like, "how do I check if it's odd"?  I don't know try "if (value % 2)" should work, this will tell you if dividing by 2 has a remainder.

Well, everything like that that I tried seemed to work.   8)   But that didn't mean to me that Arduino *is* C++ anymore than it means Java is C++ just because many things a C++ programmer who just guesses and tries, will happen to work.  Nor is Objective-C the same as C++.  Nor is Go the same as C++.  But Arduino is different - it really is C++.

So it turns out that Arduino literally is C++(not some subset).  Not C-like, or "like C++" or "based on C++".  Literally C++.  But you need to be told this.  It's kind of hidden away.

At no point in the introductory learning materials do you find any reference to C++, even though it is what you are writing.

In fact, isn't this odd, considering that you could copy and paste any code from any C++ site that does some kind of arithmetic or similar?

Here is an example of low-pass filter in C (https://www.quora.com/Whats-the-C-coding-for-a-low-pass-filter):

Code: [Select]

void lowPassFrequency(double* input, double* output, int points)
{
    double RC = 1.0/(CUTOFF*2*3.14);
    double dt = 1.0/SAMPLE_RATE;
    double alpha = dt/(RC+dt);
    output[0] = input[0]
    for(int i = 1; i < points; ++i)
    {
        output[i] = output[i-1] + (alpha*(input[i] - output[i-1]));
    }
}    


so, assuming CUTOFF and SAMPLE_RATE are defined, that will just work the same, take two arrays and the number of points, and that's it.

But why would someone learning Arduino know that based on the sample code, since they're not even told that Arduino is C/C++?   :-[

How would they know that if they didn't find some simple algorithm in "Arduino sketch" they can just copy it over from C and C++?  :-[

Why doesn't Arduino include any C or C++ tutorial?  :-[

It seems like it is trying very hard to hide what is "under the hood." There isn't the most passing reference to it anywhere.  In fact, even the word pointer or reference or stack or heap or malloc or free or class or any of that stuff is completely left out of the tutorials.  :-[

I was given no indication that I was coding in C++ or C rather than just something where all the syntax guesses I made happened to work.  I realize that C++ is "scary" but as someone who has programmed in C and C++ the only thing I saw was that anything I guess still worked.   :-[

But the same is true of Java and Javascript.  So for whatever reason, this is very poorly communicated.  :-[

Plus, the language reference tells you about Goto: https://www.arduino.cc/en/Reference/HomePage  but not classes?  There isn't a single example of any talk about pointers or references or anything like that?  :-[

I mean I realize that this stuff is "scary" but it makes people think that Arduino is a subset of C or C++.  It lets people make sketches without ever being told they're C or C++ programmers.  They never need to learn those skills.   :-[

So it's a "subset" but not because of the limitations of the "language" - but rather because those things are never taught or emphasized.   :-[  :-[

I'm sorry I didn't get this, but I'm a victim of the instructions, I swear!  With all this talk of an Arduino language, I thought there was one!
Title: Re: Nomenclature: is Arduino a language?
Post by: ieee488 on Jul 26, 2016, 03:55 am

I give up.

Don't waste you time with this guy.

LOOK at his other posts.

He asks questions then basically tells you you are wrong.  :smiley-roll:




Title: Re: Nomenclature: is Arduino a language?
Post by: OldSteve on Jul 26, 2016, 04:00 am
Having just read the OP's latest posts, I give up too. You can lead a horse to water.........

@curious48 , perhaps your time would be better spent learning the language and it's usage, then practising, than writing technical articles on something you appear to know very little about.
Title: Re: Nomenclature: is Arduino a language?
Post by: curious48 on Jul 26, 2016, 04:23 am
@curious48 , perhaps your time would be better spent learning the language and it's usage, then practising, than writing technical articles on something you appear to know very little about.
:D

There you go, I should "learn the language", technically, I've I've programmed C and C++ before the Arduino language existed, so since Arduino isn't a language, I've programmed the language before it existed :D :D :D :D

Seriously though:

There is a ton of muddying the waters done by the Arduino project, and the Wikipedia article makes clear why: "The goal was to create low cost, simple tools for non-engineers to create digital project".

So for the record: the questions I've posed in this thread are completely justified.  Arduino goes out of its way to hide the fact that there is no such thing as the Arduino programming language.

Arduino programs are a minimally processed set of C/C++ files.  I think I was asking a question about why the emperor isn't wearing any clothes. :D :D

But don't act like it's my fault for being mislead, asking and wanting to know.

Anyway, I began this thread by quoting (this wasn't directed at me):

>"There is no Arduino language! This is part of why some people hate Arduino, because they never took the time to actually understand what Arduino is and is not. If there really was an Arduino language that would be a good reason to hate it but instead we're using real, professional, programming languages. Sure, the IDE takes care of a bit of the less beginner friendly stuff but you can override any of that if you want.""

And part of this doesn't tell the whole story.  It's not that "because they never took the time to actually understand what Arduino is and is not."

In my case, I would rewrite the above as:

"The Arduino language is the Arduino project's name for C and C++.  They never use the latter phrasing to refer to Arduino code, and go so far as to call programs sketches."

This would clearly identify what is actually going on!   :D :D

Thanks for all of your answers, everyone.

[Edit: struck out my whining]
Title: Re: Nomenclature: is Arduino a language?
Post by: curious48 on Jul 27, 2016, 10:28 pm
I found this great resource:


http://arduino.stackexchange.com/questions/816/c-vs-the-arduino-language


Which includes several answers saying the same thing as is said here.  The questioner, like me, had experience with several programming languages, like JavaScript, PHP, Java and Visual Basic, but wrote asking "C++ vs. The Arduino Language: what are the advantages of each language when using the Arduino?", which is, obviously, a nonsensical question.

As happened in our threads here, several people corrected them.

A Professor stated "In any case, it won't harm you to start using the arduino language and the arduino IDE for a few days to get familiar with the arduino hardware and then move to C/C++ with Eclipse for really developing your project", again, repeating the nonsensical nomenclature.

Title: Re: Nomenclature: is Arduino a language?
Post by: 68tjs on Jul 27, 2016, 11:59 pm
Curious you are right: more you say nonsense, the more you feel Intelligent, but you're only stupid and ridiculous..
Yes Arduino is a true language as my feet are interplanetary vehicles.

Languages are Basic, PHP, Pascal, Ada, C, C ++, etc.

Wiring / Arduino is ONLY a SET of FUNCTIONS and CLASS writen in C or C ++, and an IDE.  An IDE is not  a language

Wiring / Arduino is
ONLY
a SET of FUNCTIONS

Please STOP, STOP, STOP to say nonsence.

Can a moderator could destroy this topic which is dangerous for beginners.
It is impossible to leave write such absurdities.
Title: Re: Nomenclature: is Arduino a language?
Post by: curious48 on Jul 28, 2016, 04:44 am
I've now written up what I've learned in this "35-second Arduino language reference for expert programmers (http://curious.boards.net/thread/50/second-arduino-language-reference-programmers)".

I don't have further questions on this issue and am closing this thread.  For those who contributed helpfully, thank you.
Title: Re: Nomenclature: is Arduino a language?
Post by: AWOL on Jul 28, 2016, 08:44 am
Quote
The Arduino Language is a simple macro that creates a loop that a microcontroller runs forever.
I stopped reading it at that point.
Title: Re: Nomenclature: is Arduino a language?
Post by: Robin2 on Jul 28, 2016, 12:50 pm
Quote
The Arduino Language is a simple macro that creates a loop that a microcontroller runs forever.
I stopped reading it at that point.
I try to help people who want to learn. But I have no time at all for people who want to teach without taking the trouble to learn first.

It is very disheartening to find that all that has been said by many people in answer to this OPs several Threads is reduced to such an inaccurate and misleading summary.

"Snake oil" salesmen have not all disappeared, it seems.

...R
Title: Re: Nomenclature: is Arduino a language?
Post by: Delta_G on Jul 29, 2016, 02:44 am
Quote
If so why can't people just use gcc directly, after performing steps 1-10 from your write-up?
They can.  That's the whole point of Arduino.  Doing those ten steps yourself is not intuitive and is more than many beginners can understand.  Arduino is a program that does those things for you so your don't have to.  You can program your Arduino board even if you haven't downloaded a single thing from Arduino.  You don't need the IDE, or any part of what comes with the Arduino package. But then you have to put the tool-chain together yourself.  That's how it was done before Arduino came around. 
Title: Re: Nomenclature: is Arduino a language?
Post by: Delta_G on Jul 29, 2016, 02:45 am
Quote
- These two functions must be present.  setup() contains the code that the microcontroller runs once upon being powered,  the loop() function contains the code that loops tightly forever.
loop is only tight if you write it tight.  If you write a bunch of blocking code in there then it won't loop so tightly anymore. 

And you can most definitely have your own main function if you don't want to use the setup / loop paradigm. 


Quote
It is simply passed to a C++ compiler to finish compilation.
Nope.  The C++ compiler doesn't finish the compilation for the IDE, it does the WHOLE compilation procedure.  What the IDE does before that is pre-processing, not compilation. 


Quote
In practical terms the basic Arduino program structure is not event-driven.
That depends on how you write your code.  Whether or not it is event driven has nothing to do with it being Arduino or not.  You can write event driven code with Arduino.

Quote
The loop() should poll heavily for any event it needs, blocking completely.
Polling a pin does not require b locking.  Read the pin and move on. 

Quote
All functions are blocking.
No, they're not.  You're on a single core, so you can't run two instructions at once, but that doesn't mean all the code is blocking. 

Quote
The rest of the arduino.h header file contains other functions commonly used. From a language specification perspective it is more precise than the official documentation.
I'll give you this one.  Documentation is scant around here.  Your best bet to understand any library is to understand the language and look at the source code. 
Title: Re: Nomenclature: is Arduino a language?
Post by: curious48 on Jul 29, 2016, 06:32 am
For anyone coming to this thread from anywhere else such as a search engine, in the 25 hours since it has been posted, over 1500 people have read the linked article (http://curious.boards.net/thread/50/second-arduino-language-reference-programmers), and it was reviewed favorably with good comments, privately and publicly, especially from programmers.  People found it a helpful overview of what, exactly, we're talking about when we say "Arduino language", at least, when it comes to an expert programmer who has programmed in several languages but may be new to Arduino.

I received good comments from expert Arduino users, but also some more questions from C++ programmers about the exact "differences".

I don't have further questions, except on event-driven practices which are mentioned briefly below and the subject of an upcoming article.  I will be asking about that in an up-coming thread.  Thanks to everyone for your help!
Title: Re: [SOLVED] Arduino language
Post by: Delta_G on Jul 29, 2016, 06:53 am
I only see one comment.  I think you're making this up. 
Title: Re: [SOLVED] Arduino language
Post by: curious48 on Jul 29, 2016, 08:19 am
I only see one comment.  I think you're making this up.  
I've PM'd you and a mod proof and asked you (and the mod) to remove your comment, at which point I'll remove this.  What I PM'd the mod was "Counts: http://goo.gl/RUr4NY questions e.g.: "Does it support interrupts ? If so, you can.." 500-1500+ programmers just learned about Arduino from my writeup (30 upvotes). His comment adds 0 but derails thread, abusively phrased (he could have asked)."
Title: Re: [SOLVED] Arduino language
Post by: AWOL on Jul 29, 2016, 08:29 am
I got bored moderating and moving the multiple threads on this topic, which seems to me to have degenerated to the level of "how many Arduinos can dance on the head of an I/O pin", and because the thread is marked "solved", I'm simply going to lock it.
Title: Re: [SOLVED] Arduino language
Post by: Coding Badly on Jul 29, 2016, 08:41 am

Curse you AWOL!  I just spent fifteen minutes composing an eloquent reply!

Oh well.  Better things to do.  FreeCAD calls...

Title: Re: [SOLVED] Arduino language
Post by: nickgammon on Jul 31, 2016, 08:37 am
Even though the thread is locked I'm going to answer a couple of questions posted earlier:

Quote
Do you have a similar reference for the "build process" itself?  For example, it is clear that at the point of your third bullet point there is a "temporary compilation folder".  What is the program that actually builds it?
The IDE generates build commands. You can see exactly what those are by turning on verbose compilation.

Basically it calls avr-g++ to do compiling and linking. Then it uses a couple of other programs in the AVR compiler toolchain to produce the final .hex file.


Quote
It must be a C++ compiler (like gcc).  I googled this and found: " is passed directly to a C/C++ compiler (avr-g++)."

Is it avr-g++ in every case?  Or can other compilers be used at this step?
I'm not sure about clang or similar. I doubt it you can make the IDE use a different compiler. You could make your own build script. For another compiler to be used it would have to support AVR compiling. avr-g++ is basically g++ converted to output AVR code.

See, for example: http://forum.arduino.cc/index.php?topic=308853.msg2145054#msg2145054 (http://forum.arduino.cc/index.php?topic=308853.msg2145054#msg2145054)

Title: Re: [SOLVED] Arduino language
Post by: nickgammon on Jul 31, 2016, 08:48 am
Quote
For example, an alternative to gcc is clang.  If I personally perform steps 1-10 can I just pass it off to clang?  Why or why not?
If you can find an avr-clang, yes that should work. A Google search seems to show such a program exists, or is a work in progress.

Quote
Finally, based on the fact that steps 1-10 are performed how would you feel about my using the nomenclature "Arduino C++ templating language", which would make it clear that:

1: Code produced in the Arduino templating language is not ready to be passed on to GCC directly.  There is a bit of translationn involved.

2: It is a light translation that results in C++ code that is ready to be passed to the compiler.
I don't know about the words "templating language" - what does that mean?

I think I would say:

Quote
The Arduino "sketch" files (that is, the .ino files) are concatenated, and then pre-processed by the IDE to add function prototypes for you. The concatenated file is also scanned for #include statements which guide the IDE as to what additional libraries to include in the build process. In addition, any .cpp, .c and .asm files are also added to the build process without modification.

Once that is done the files are compiled using avr-g++. The resulting object files are combined using avr-ar. This is then linked using avr-g++. Then the resulting .elf file is turned into a .hex file using avr-objcopy.
I don't like the idea of trying to describe it as another language. It is just a build process using an existing language: C++. In a similar vein some compilers pre-process include files to save time in programs where many .cpp files all use the same include files. This is not turning it into another language, this is just a convenience for the programmer.