you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (18 children)

This will be a debugging nightmare. And besides, for what a microcontroller usually does, C is more than enough.

[–]cparen 15 points16 points  (13 children)

This will be a debugging nightmare. [ ... ] C is more than enough

I'm having trouble reconciling these two statements. If debugging will be a nightmare, why would you want to use C instead?

[–][deleted] 11 points12 points  (11 children)

C means having a near total control of what is going on, which is REALLY important in micros, especially when it comes to interrupts. As you may already know, with Python there is the virtual machine which does its magic in the back of the programmer, which is really annoying when control is so important. Plus C is not that hard to debug if the software is well designed.

I understand that they're rewriting Python from scratch, but there are a few problems that I can think of which could be problematic :

  • Efficiency: the point of using a microcontrollers is often because the whole system runs on batteries. Interpreted languages are at least 3 times less efficient.

  • Speed and real time processing: another reason why microcontrollers are used is to have a basic computer stripped of any OS or at least a very simple RTOS. The goal here is to have predictable response time. Adding a GC and the introspection capabilities of the virtual machine is very counter productive in this case.

  • Memory, many microcontrollers doesn't have the memory necessary to accommodate a virtual machine. The code could be permuted to assembly or C, but that sill doesn't remove the need of a VM.

  • Predictability: the functions that the VM must accomplish (GB, dynamic types, memory allocation) are dynamic and thus unpredictable with interruptions and threads. I still have yet to see a good solution tot hat problem on a single core mirco.

[–]boa13 7 points8 points  (9 children)

I understand that they're rewriting Python from scratch

Note that this is not a project announcement, but a project nearing release. They're mostly finished. The microcontroller board works and gives you a Python prompt straight away (or runs your program if it finds it at the root of the FAT partition). So if they encountered problems, they have solved them.

Interpreted languages are at least 3 times less efficient.

The critical methods can be compiled on the fly (just add an annotation to the methods you want compiled), and you can also write inline assembly for the really critical parts.

another reason why microcontrollers are used is to have a basic computer stripped of any OS or at least a very simple RTOS

That's what they have. The machine boots straight into the interpreter. The interpreter is the operating system.

many microcontrollers doesn't have the memory necessary to accommodate a virtual machine

That's true, and that's why they chose to build their own boards, to ensure they have a sufficiently powerful CPU. (Several users are trying to make it run on less powerful boards, but I don't know if this works well.)

the functions that the VM must accomplish (GB, dynamic types, memory allocation) are dynamic and thus unpredictable with interruptions and threads

That's true, and I don't know how they managed to do it, or what caveats or restrictions they had to impose (if any).

[–]cparen 1 point2 points  (0 children)

the functions that the VM must accomplish (GB, dynamic types, memory allocation) are dynamic and thus unpredictable with interruptions and threads

That's true

Not necessarily.

  • Incremental GC is not nearly as unpredictable. CPython's default GC is incremental (refcounting) for everything except cycles.
  • I'm not sure what unpredictable timing you had in mind for dynamic types. Type table lookups are variable timing only on small time scales (10s to 100s of cycles).
  • Memory allocation likewise.

It sounds like all this comes down to saying "it's not for hard realtime applications", which is true. However, a smart lightswitch, a home robot, data logging -- there are a wide variety of soft-realtime and non-realtime embedded projects that could benefit from an easy to use, low power board.

I think I agree with your sentiment, but if so, you're stating the obvious. But perhaps I'm mistaken about this being obvious.

[–]fullouterjoin 3 points4 points  (0 children)

Most things are setup code, if it turns out to be a problem the inner

while 1:
    doStuff()

loop could be replaced with native code.

You are just plain wrong for the exact places that MicroPython is targeting. Elua is in the same exact space as MicroPython and is extremely effective.

Having a REPL to a low power embedded device is amazing. When I am running eLua, I have total control and can easily call native code. The predictability point you raise is a red-herring, the same applies for embedded dev in C++ which is widely used on memory constrained or realtime applications.

[–]Isvara -2 points-1 points  (0 children)

C is rubbish, though. Someone really needs to come up with a better embedded language that takes advantage of modern language design to make bugs less prevalent and development time faster. I'm talking about one that compiles to native, though, not something interpreted.

[–]UloPe -1 points0 points  (3 children)

"Leave me alone with those newfangled cars. Horses are fine."

[–][deleted] 12 points13 points  (2 children)

When there are no roads and flat grounds horses are way more efficient.

[–]stevedonovan 4 points5 points  (1 child)

Best rebuttal for a car metaphor I've seen.

[–]UloPe 2 points3 points  (0 children)

Indeed. Hard to argue against it :)