MicroPython As A First Language

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
bitninja
Posts: 165
Joined: Thu Sep 15, 2016 4:09 pm
Location: Spring, Texas

MicroPython As A First Language

Post by bitninja » Tue Apr 24, 2018 4:25 pm

Hi,
I've been avidly developing my MicroPython skills for a couple of years now (mainly on the ESP8266 port) and was wondering if I am missing some essential skills because I have not developed with the full CPython. I guess I am concerned about learning a module or technique that is not transferable to the world of microcontrollers. MicroPython seems remarkably complete... but as my first venture into Python programming, is it complete enough to say that I am a "python programmer"?

I've read the differences between the Pythons, but that means very little if you don't know the regular desktop Python very well.

A related question would be, is MicroPython a good way to teach Python programming to others? Sure a PC (or even a Raspberry Pi) with CPython is just as easy to come by... but there seems to be an added tangibility when programming a physical device.

Any thoughts?
Last edited by bitninja on Thu Apr 26, 2018 5:15 am, edited 1 time in total.

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: MicroPython As A First Lanuguage

Post by kevinkk525 » Tue Apr 24, 2018 4:57 pm

I guess micropython is good enough to learn basic python skills but it's quite far from "real" python.
I used to program in python 3 but micropython made me basically learn a new way of programming as I found myself having to care about every byte of RAM my program uses as the ESP8266 is quite limited. This often lead to a programming style I would absolutely not use in normal python environments. Micropython is a very specific and small "branch" of python.

So, while micropython is a pretty nice way to get into python and microcontroller, I would not say that if someone can program in micropython that he can call himself a "python programmer" but will have a very easy entry. Especially knowing how to use asyncio is a huge benefit.
(I probably cause a lot of discussion with this statement..)

Using a Raspberry could be an easier entry as you don't have to be careful about the specific needs and changes in micropython and just focus on learning python with a very good documentation and wikis easily available and you also have some gpios to play with.
(You don't have to watch RAM usage, garbage collection, ...)
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: MicroPython As A First Lanuguage

Post by OutoftheBOTS_ » Tue Apr 24, 2018 6:36 pm

Nice question to ask :)

I have only been programming for a year and a half and have played with both RPi and Micro-Python on both ESP8266 and ESP32.

For me programming on RPi was programming at a level more removed from the machine with more builtin libraries. It was an environment where you could just burn resources because you had so much of them. I then started to play with Micro-Python on ESP8266 because it was cheap and seemed a easy place to start. ESP8266 is a super tight place to run micropython and I like everyone else now had to learn ho to be very very efficient with resources. Also because Micro-Python is a cut down version of CPython it doesn't have all the libraries that r at your finger tips with CPython it forces you to write your own lower level libraries. I have now switched to ESP32 with psRAM and it seems huge amount of resources compared to ESP8266 and I don't find myself counting every byte like I did on the ESP8266.

One advantage that I found with learning MicroPython was it is much closer to the metal than CPtthon on RPi so I had to learn much more what is happening under the hood instead of put operating on the cockpit.

ARTaylor
Posts: 29
Joined: Fri Mar 23, 2018 4:04 pm
Contact:

Re: MicroPython As A First Lanuguage

Post by ARTaylor » Tue Apr 24, 2018 8:35 pm

I am no expert, but I would say by learning micropython you will have transferable skills for microcontroller programming in general. I've been working with Arduino for a lot longer, and Raspberry Pi in more recent years - I'm pretty new to Micropython but it's been a piece of cake so far as I generally just need to figure out how I need to ask the MCU to do what I already know it can do.

It's definitely worth investing in a Pi if you don't have one - there is a great youtube series by rdagger68 on programming the ESP32 in Micropython using the Pi as your interface, and doing lots of interesting things between the two devices - https://www.youtube.com/user/rdagger68
Grow something!

bitninja
Posts: 165
Joined: Thu Sep 15, 2016 4:09 pm
Location: Spring, Texas

Re: MicroPython As A First Language

Post by bitninja » Thu Apr 26, 2018 6:29 am

I really appreciate the insight given so far... I really like to hear other perspectives...

I should say, I have total access to desktop Python of course... it's just that... I am very happy working in these constrained environments! I think that working with a limited set of functionality and power is a great challenge that can offer a lot of satisfaction.

I'm not really after a title or anything, but rather... trying to strengthen my MicroPython skills, while not coming from a desktop Python background. As you can imagine, my code lacks some of the more elegant syntax styles, that seasoned Python programmers are so fluent in. The trouble I have now is wading through all the training for desktop Python... and seeing what can be applied in MicroPython. I know Python has extensive and extremely good documentation itself... but you still have to check it out in MicroPython to see if it works like the desktop version. Don't get me wrong... I'm not complaining... in fact, the reason I enjoy MicroPython so much is because of just how functional it is. Usually when I want to do something... it just works!

Actually I learn the most by reviewing other programmer's MicroPython code. Seeing new ways of doing things as well as things I never realized I could do is always fun.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: MicroPython As A First Language

Post by pythoncoder » Thu Apr 26, 2018 7:59 am

I think working in a resource-constrained environment is good training in programming. There is a tendency for Python programmers to pull in huge libraries to solve simple problems. Which is fine until the day comes when you need to iterate that piece of code a million times.

To some extent it depends on why you want to learn programming. If you want to write business applications you need to be familiar with many of the larger Python libraries. So there's a case for CPython.

But if you want to program microcontrollers then MicroPython is a good starting point, even if you later learn C, C++ or Assembler for the purpose. Those of us who started in the 60's learned hardware, then Assembler, then C, then C++...

So MicroPython came as a breath of fresh air. You make a mistake and get a traceback instead of a crashed machine.
Peter Hinch
Index to my micropython libraries.

Post Reply