Hi all,
Thank you for reading this. In the general sense, is there an inherent disadvantage to using python instead of C/C++ for programming Arduino?
Thank you again.
Hi all,
Thank you for reading this. In the general sense, is there an inherent disadvantage to using python instead of C/C++ for programming Arduino?
Thank you again.
Python's big advantage is ease. It's much faster and easier to make a Python program than making a C++ app that does the same exact thing. It does, however, come at a cost...
C++ gives you a lot of low level control over what exactly your Arduino is doing. I don't think Python can replicate that (at least not very easily). Most of the time you're at the mercy of what "Python want's to do". Python is also generally slower due to large library/package overhead, however, MicroPython might be smart enough to optimize much of it away.
I've used both and personally I prefer to do Arduino projects in C++ and PC apps in Python.
Power_Broker:
Python's big advantage is ease. It's much faster and easier to make a Python program than making a C++ app that does the same exact thing. It does, however, come at a cost...C++ gives you a lot of low level control over what exactly your Arduino is doing. I don't think Python can replicate that (at least not very easily). Most of the time you're at the mercy of what "Python want's to do". Python is also generally slower due to large library/package overhead, however, MicroPython might be smart enough to optimize much of it away.
I've used both and personally I prefer to do Arduino projects in C++ and PC apps in Python.
Thank you for your response. If you don't mind telling me, what are some of the low level controls that can be modulated with C++ but not Python?
The most obvious thing is the ability to specify a variable's type and make sure the variable keeps it's type. For instance, if I do
h = 3
in Python, it will be a 32-bit number no matter what. On the other hand, if I want to optimize the code for a 16-bit processor Arduino, I can do the following in C++ instead:
int16_t h = 3;
I haven't messed with MicroPython a ton, but I'm also sure there are a lot of useful libraries that are in C++ that aren't ported to MicroPython packages. If someone has more experience on this, feel free to correct me.
Don't forget memory footprint. The Python interpreter uses more memory than most legacy Arduinos have available.
Power_Broker:
I haven't messed with MicroPython a ton, but I'm also sure there are a lot of useful libraries that are in C++ that aren't ported to MicroPython packages. If someone has more experience on this, feel free to correct me.
My MicroPython experience is limited to a couple quick "hello world"s via the REPL on an ESP8266, but I'm sure you're right. I'd guess there are some nice modules for MicroPython too, but we have thousands of C++ Arduino libraries available to us.
Arduino's upcoming Portenta H7 board is advertised as supporting Python. One of Arduino's Google Summer of Code students for this year is writing an Arduino to MicroPython Transcompiler, which is intended to partially automate the process of porting Arduino code to Python.
So we may start to see more use of Python in the Arduino world in the near future.
Right now, I use Python when my application is a bit beyond what is sensible to do in Bash.
However, working with them has traditionally been reserved for those with formal technical training, such as technicians and electrical engineers. The emergence of Arduino has made electronic application design much more accessible to all developers McDVOICE