Live data from Hacker News

MicroPython – Python for Microcontrollers

micropython.org

61–70 of 106 posts

Re: MicroPython – Python for Microcontrollers

#61
post #56

Earlier quoted context omitted.

I agree that the user experience, onboarding etc. are very well executed for Arduino (and especially for the ESP32 port of uPython could use some polishing)... > rinse and repeat until you are familiar with idioms for all sorts of things Except that the idioms you learn are really not suitable for anything but toy examples. Arduino is rotten from the core: "setup", "loop" and "delay" are the worst imaginable way to w…

> "setup", "loop" and "delay" are the worst imaginable way to write embedded software I agree with "delay", but why do you say setup and loop are the worst imaginable way to write embedded software?

> why do you say setup and loop are the worst imaginable way to write embedded software?

Because there's neither abstraction nor ways to combine things. Say you have a device that needs to do two things, and you look up some examples of how to do each thing. Each example is going to have its own loop() function--but how do you combine them? There's no notion of tasks or threads. There's no abstraction for device drivers. Arduino is a system that paints you straight into a corner.

[edit to add] Any reasonable software environment needs to provide three things, quoting "Structure and Interpretation of Computer Programs" here [1]:

* primitive expressions, which represent the simplest entities the language is concerned with,

* means of combination, by which compound elements are built from simpler ones, and

* means of abstraction, by which compound elements can be named and manipulated as units.

Arduino only provides the first.

[1]: https://mitpress.mit.edu/sites/default/files/sicp/full-text/...

Re: MicroPython – Python for Microcontrollers

#62
post #48

Earlier quoted context omitted.

Nim, Zig, Julia, Rust, so many languages lately ... anyone else with language-choice anxiety?

Not really. Probably only a single-digit percentage of software developers will ever get to use any of these professionally. Howl in protest if you will, but the truth is that all of these (and more) are mostly the domain of students and hobbyists. If you are already in the industry, and part of the 90+% unwashed masses, then you already know this. If you are a student or hobbyist who hasn't clued into this reality y…

While at it dont forget TinyGo. Im a hobbyist occasionally working on potentially commercial ideas. ARduino is great to start learning. PlatformIO i found very supportive with tools for everything I needed and wide board support. Used to code a lot in Python. My next project i will use TinyGo to see the degree of correspondence with full desktop Go and beyond that im inclined to try Ada next as for bare metal code the idea of using Ada just seems to make a whole lot of sense given its application to control systems over the decades.

My 2c

Re: MicroPython – Python for Microcontrollers

#63

A language with meaningful whitespace and indentation does not make a good language for UART or other serial interaction. At the point you can use a higher level interaction, why stop at Python? Go full codeless checkboxes on webpages. If the alleged problem that micropython solves is complexity of actually coding microcontrollers, why settle for Python, which can only ever wrap/call native functionality that is hidd…

> A language with meaningful whitespace and indentation does not make a good language for UART or other serial interaction.

This is a nonsensical nonsequitur. The whitespace of the language you use has nothing to do with what communication it can do. Python works great for talking to my plotter over RS232.

Re: MicroPython – Python for Microcontrollers

#65

I hope we see JS for microcontrollers fast enough so we can enjoy bloated Electron apps running on microcontrollers. :) I mean, who wants anything but the fastest, leanest languages running on microcontrollers?

> who wants anything but the fastest, leanest languages running on microcontrollers? Me. I value speed and comfort of development more than micro-optimizations. Coincidentally this is why Electron is popular.

Electron needs to work on it's debuggability.

Seriously. That crap is a nightmare. Especially in production mode. Or maybe I just need more time with node, but trying to debug the main loop sans IDE is an act best described as excruciating. Once you start spawning new processes as well, you end up having to custom roll code to massage the port the spawn emits the inspect-brk for, which can end up getting quite complex if you have enough different entrypoints.

Re: MicroPython – Python for Microcontrollers

#66
i do embedded programming as a hobby for high power rocketry ( altimeters, orientation sensors and, someday, control, and other stuff ). Micropython is great for what I do and the repl is especially handy (i just start a screen session and there it is). I've tried lots of different boards but settled on the stm32 Feather from Adafruit. Adafruit's circuit python is really handy because they have a lot of drivers already written for common sensors and other things. Heh it was a bit of a shock when i realized in embedded programming you read need to read a datasheet and write your own device drivers.

I originally tried C using hardware debuggers and the whole 9 yards. It just took too long to get the toolchain setup and all the init required to get to a blinking LED (the helloworld of embedded). I also tried platformIO which looks very very cool but my boards weren't 100% supported. Next was the stm32 ide which helps you get a lot of the low level config off the ground but it still seemed the long way around. I also tried some of the hardware OS's like FreeRTOS but, again, not my cup of tea and "operating system" means something very different in the embedded world than what i'm use to.

i have a pi zero w and it really has my ears up too because i can run the same micropython there, can ssh to it directly, has a file system, runs linux etc. I have a really convenient pwm control board with an i2c interface so the non-realtime operating system on the pi zero isn't so much of an issue for what i do.

Re: MicroPython – Python for Microcontrollers

#67
And with a little bit of coercing, it can be used the other way: To embed Python in Desktop apps giving you a fairly light-weight Python interpreter.

I used it for a little Windows macro program ( https://github.com/seligman/microkeys ) . I got it to a POC stage to solve the precise problem I have, basically I needed to be able to do some simple text parsing on whatever's in the clipboard and type out the results, so I'm happy. I'm always curious if it potentially fills a need for others as well.

Re: MicroPython – Python for Microcontrollers

#68

Earlier quoted context omitted.

The company I work for uses MicroPython commercially to build medical devices. It hasn't fallen apart for us. Indeed, it's helped deliver high-quality solutions quickly...

You have to have the right people. They have to like Python and want to use it, but not because they think "C is too hard". They have to be happy writing Python code and confident enough to write modules in C and work on MicroPython itself. There is some steps necessary to go from "prototyping MicroPython" to "production MicroPython" and many people either forget about them, are not skilled enough to do them (which i…

> You have to have the right people.

Yes, true! I presented a lightning talk to colleagues on "Ingredients for Commercial MicroPython Success". One of the key points is "People are critical". Maybe folks here might find it useful:

https://docs.google.com/presentation/d/e/2PACX-1vR3DJk-dNTvE...

Re: MicroPython – Python for Microcontrollers

#69
post #56

Earlier quoted context omitted.

> "setup", "loop" and "delay" are the worst imaginable way to write embedded software I agree with "delay", but why do you say setup and loop are the worst imaginable way to write embedded software?

> why do you say setup and loop are the worst imaginable way to write embedded software? Because there's neither abstraction nor ways to combine things. Say you have a device that needs to do two things, and you look up some examples of how to do each thing. Each example is going to have its own loop() function--but how do you combine them? There's no notion of tasks or threads. There's no abstraction for device driv…

You don't have to use `setup` and `loop` tough. We use Arduino as a library in C++ using PlatformIO as tooling. Best of both worlds.

The thing you are hating on is pretty much this file: https://github.com/arduino/ArduinoCore-avr/blob/master/cores...

Arduino is C++ with some boilerplate and a library.

Re: MicroPython – Python for Microcontrollers

#70

Earlier quoted context omitted.

My company uses it for medical device development, ama if it will help!

Very cool. Are you prototyping or manufacturing at scale? What kind of sensors have you attached?

Manufacturing at scale. Though these are medical - not consumer - devices so we're not talking hundreds of thousands of units. Think high-quality, injection molded, moderately sophisticated devices. Typically hundreds and up to several thousands of units, depending on the project.

We use all manner of sensors; temperature, pressure, cap touch, photodiode detection, cameras.

Post reply on HN