Go Down

Topic: [SOLVED] Arduino language (Read 4268 times) previous topic - next topic

Robin2

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
Two or three hours spent thinking and reading documentation solves most programming problems.

Delta_G

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. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

Delta_G

#32
Jul 29, 2016, 02:45 am Last Edit: Jul 29, 2016, 02:53 am by Delta_G
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. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

curious48

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!
Are you curious about the intersection of Arduino/Electronics/Raspberry Pi/Orange Pi/Beaglebone/niche manufacturing/starting from 0 and scaling?  Try: http://curious.boards.net

Delta_G

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

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

curious48

#35
Jul 29, 2016, 08:19 am Last Edit: Jul 29, 2016, 08:23 am by curious48
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)."
Are you curious about the intersection of Arduino/Electronics/Raspberry Pi/Orange Pi/Beaglebone/niche manufacturing/starting from 0 and scaling?  Try: http://curious.boards.net

AWOL

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.
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

Coding Badly

#37
Jul 29, 2016, 08:41 am Last Edit: Jul 29, 2016, 08:42 am by Coding Badly

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

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


nickgammon

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

Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

nickgammon

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.
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

Go Up