[SOLVED] Arduino language

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"

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.

westfw:
“I have an Arduino-compatible board that I program in C++ using the Arduino IDE”

This is incredibly clear. :smiley: :smiley: 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.

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:

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

Let’s zoom in here:

Do you see the source of my confusion? :smiley:

If instead I click “learn arduino” I get this:

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? :smiley: 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:

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!

westfw: 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. :roll_eyes:

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.

OldSteve:
@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.

:smiley:

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 :smiley: :smiley: :smiley: :smiley:

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.~~ :smiley: :smiley:

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! :smiley: :smiley:

Thanks for all of your answers, everyone.

[Edit: struck out my whining]

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.

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.

I've now written up what I've learned in this "35-second Arduino language reference for expert programmers".

I don't have further questions on this issue and am closing this thread. For those who contributed helpfully, thank you.

The Arduino Language is a simple macro that creates a loop that a microcontroller runs forever.

I stopped reading it at that point.

AWOL:

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

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.

  • 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.

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.

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.

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.

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.

The rest of the arduino.h header file contains other functions commonly used. [u]From a language specification perspective it is more precise than the official documentation[/u].

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.

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, 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!

I only see one comment. I think you're making this up.

Delta_G: 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)."

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.

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

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

Even though the thread is locked I'm going to answer a couple of questions posted earlier:

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.

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

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.

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:

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.