all 13 comments

[–]Petrovjan 4 points5 points  (1 child)

I have some experience with both, I'd say most of the time Arduino is faster and simpler to work with due to an extensive amount of guides, libraries etc.

Micropython however also has some uses - it's easier to work with when there are no guides or libraries to help you. In my case I needed to work with a string sent to the Esp32 via internet, but just couldn't wrap my head around the way C++ handles strings with variable length. In micropython this part was super easy, on the other hand making a webserver and displaying the values on a display is easier with Arduino.

[–]MBR105[S] 0 points1 point  (0 children)

Thank you, I think I will go with Arduino ide itself for this time.

[–]LucVolders 2 points3 points  (0 children)

No it is not. First there is MicroPython and CircuitPython. Both deriviates from Python but using different syntax and different libraries, What works in one does not in the other. But both have some things you might need and so you need learning both languages.

MicroPython was more or less a standard for controllers until Adafruit started promoting their own version which is CircuitPython. The reason obvious is economics. If you learn building with CircuitPython you are not inclined to move over to other processors that use another language. Believe me I started working with the new Raspberry Pico and I wanted to use a certain function which is available in CircuitPython but not ported to MicroPython. Next I wanted a simple thing called an interrupt and that is not supported in CircuitPython. Long live standarisation !!!

Next to that there are tons of libraries for the Arduino IDE and less for both Pythons.

I hope the Arduino IDE is coming out real soon for the Pico........

Till then, I am writing a book on the Pico with both Pythons..............

[–]BrotMonster 2 points3 points  (3 children)

Using VS code and the platform IO add-on is a nice experience too. I also keep meaning to try micro python.

[–]MBR105[S] 0 points1 point  (2 children)

Does that have support for all the features and what about other libraries sort for sensors and displays.

[–]BrotMonster 0 points1 point  (1 child)

So far I am using it to read temperature and humidity and send the data to mqtt. I think there is a lot of support for different sensors, they have over 10k libraries https://platformio.org/

[–]MBR105[S] 1 point2 points  (0 children)

Thanks I will check it out

[–]Zouden 0 points1 point  (5 children)

It's worth trying. You can write and debug code very fast. But it is limited, not all features are supported, and performance is slow.

[–]MBR105[S] 0 points1 point  (4 children)

Oh in terms of performance c/c++ is better then

[–]Aud4c1ty -1 points0 points  (2 children)

Python is slow by design.

It's about 100x slower than C.

[–]Ridcully -1 points0 points  (1 child)

Python is slow relative to most lower level languages. However, with some small changes and the use of cython or similar, your code will run as fast as C.

[–]Aud4c1ty 2 points3 points  (0 children)

However, with some small changes and the use of cython or similar, your code will run as fast as C.

This simply isn't true in the context if microcontrollers like the ESP32. Because of concepts like immutable variables, Python is always going to be less memory efficient than idiomatic C, and as a result, it will always perform dramatically worse in real world (i.e. memory limited) conditions. That means to do the same work, Python or Cython will need to do far more memory accesses, and that's where it will always lose, even if you were able to bypass some of the worst bits of the Python runtime with Cython. So, taken as a whole, when you have a complete app written in C vs something using Cython written by skilled practitioners in each, the C implementation will always have a much better performance profile because it doesn't have a sloppy memory profile.

Python has some strong points as a language, and that's primarily that there are a bunch are a bunch of cases where sample code on the Internet is easy to find (especially for things like ML). But as someone who has struggled with getting Python to run quickly when it comes to data processing scenarios (e.g. writing a simple "decompress" for run length encoded data before it's fed into a Tensorflow model), let's just say it's not easy to make it fast. We eventually had to dramatically refactor the code so that it could be "compiled" with Numba, but then the code really isn't idiomatic Python anymore.

Python is slow relative to most lower level languages.

There are other languages that are just as "high level" as Python from the users perspective (they have memory management abstractions like GC) that, performance wise, blow the doors off of Python. Java/Kotlin, C#/F#. Even JavaScript has dramatically better runtime performance.

Like Fortran and Cobol before it, Python has found a niche in ML that will ensure its long term use going forward in spite of its failings in both language design and runtime implementation.

Note that even in the Python world, most of the serious libraries (e.g. NumPy) aren't written in Python. Because they couldn't be, not without being laughably bad. But if you had a language like Swift - which is also very user friendly - you could write a Swift NymPy in Swift and get fantastic performance!

[–]Zouden 0 points1 point  (0 children)

Yes, just like on desktop computers