If you are using new, then you'll have to call delete at appropriate times. You may still run out of memory, if you create huge classes and use a lot of them in deeply nested functions, but in general you aren't going to run into trouble until you start dealing with new and free functions. So as long as you aren't using new or similar memory allocation functions to create new objects, then you won't have to worry about leaks. If i were a class, it would similarly be disposed of once the function ended. Then you'll find that led and i don't grow or leak, no matter how many times you call blinkTimes. It does manage variables in scope - if you write: int led = 13 Thus, "The arduino language" is C++ or C.Ĭ++ is not garbage collected. Much of the underlying system is not object oriented, but it could be. In fact many of the libraries are written in C++. What are the advantages of C++ vs the Arduino language when using Arduino? I'm experienced in preprocessed languages like JavaScript, PHP, and have fiddled with languages like Java and Visual Basic.įirst, the Arduino compiler/IDE accepts C and C++ as-is. That should give you all the advantages of C++, along with the Arduino libraries.
There are workarounds in all cases (as far as I'm aware), but they are sometimes quite frustrating.įor full flexibility, use a third-party IDE (such as Eclipse) with a plug-in to support Arduino. It's also worth noting that if you're using the official Arduino IDE then there are all sorts of annoying quirks and limitations on how you setup your code. A lot of the differences are common to all embedded programming though (such as limited memory and processing power).
Having said all of that, programming for Arduino isn't exactly the same as general C++ programming. However, going back the other way may require some minor editing.
However, they are directly equivalent to bool and unsigned char.Īll of these things mean you can probably port general C++ code directly to Arduino without difficulty. For example, boolean and byte are not in the C++ standard.
In addition to the functions, the libraries add alternative names for some types. It's fast, but it can be quite hard to learn and understand. That's how embedded programming is usually done. If you didn't have those functions, you'd need to fiddle directly with special registers to control everything. These add on various features, such as functions you can call to control the hardware. It's really just C++ with some domain-specific libraries. There isn't really an Arduino language as such.