Stories
Slash Boxes
Comments

SoylentNews is people

posted by martyb on Sunday June 08 2014, @02:36PM   Printer-friendly

Micro Python is a re-write of CPython meant to be run 100% on microcontrollers and includes "a complete parser, compiler, virtual machine, runtime system, garbage collector, and support libraries to run on a microcontroller". It was funded with a Kickstarter which included manufacturing of the microcontrollers which are now being shipped out to backers.

From InfoWorld:

Right now, the language is targeted at 32-bit ARM processors that use the Thumb v2 instruction set. To that end, the project's creator, Damien George, a theoretical physicist at the University of Cambridge, has created just such a board using the STM32F405 processor.

Previous work has been done to get a modified / tuned version of CPython to run on devices such as the Raspberry Pi but this is the first I've seen that tries to get Python on a device from the ground up.

Editor's note: back when I got started with personal computers (think TRS-80 era), you could count on a "PC" having some flavor of BASIC. It provided a means for exploration of programming with immediate feedback.

This story suggests that a relatively low-spec processor is capable of running something similar in usability to the BASIC of old. I'm curious as to people's thoughts on the idea that python could be poised to become the new, ubiquitous BASIC? What would it take?

This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 3, Interesting) by kaszz on Sunday June 08 2014, @03:10PM

    by kaszz (4211) on Sunday June 08 2014, @03:10PM (#52954) Journal

    If there's going to be a new "BASIC" it better be without indentation fascism like with Perl using Microperl [www.foo.be] that can fit in microcontroller systems at cirka 1.2 MByte. If that isn't possible. Then BASIC may do just fine. Python just have so many enforced rules.

    Think of current breed of ARM and MIPS systems like a 1999 era x86-PC. They could do quite a lot. Let's say some editor and a C-compiler.. Even Amiga 500 using 68000 at 7.14 MHz with 1 MB RAM and 2,5 MB of storage could pull that of.

    • (Score: 2) by Tork on Sunday June 08 2014, @03:24PM

      by Tork (3914) Subscriber Badge on Sunday June 08 2014, @03:24PM (#52958)
      'Indentation facism'... seriously? Tomorrow at work I'm going to have to deal with bracket fascism.
      --
      🏳️‍🌈 Proud Ally 🏳️‍🌈
      • (Score: 2) by skullz on Sunday June 08 2014, @03:28PM

        by skullz (2532) on Sunday June 08 2014, @03:28PM (#52960)

        I'm stuck fixing up a VB.NET port. "End If" fascism.

        • (Score: 2) by Foobar Bazbot on Sunday June 08 2014, @03:59PM

          by Foobar Bazbot (37) on Sunday June 08 2014, @03:59PM (#52967) Journal

          Thanks, Stephen Bourne, for introducing fi fascism to the world.

      • (Score: 2) by Subsentient on Monday June 09 2014, @01:49AM

        by Subsentient (1111) on Monday June 09 2014, @01:49AM (#53092) Homepage Journal

        Allman braces nuff said.

        --
        "It is no measure of health to be well adjusted to a profoundly sick society." -Jiddu Krishnamurti
      • (Score: 0) by Anonymous Coward on Monday June 09 2014, @02:38AM

        by Anonymous Coward on Monday June 09 2014, @02:38AM (#53110)

        Really? Brackets embrace you. Whitespace surrounds you.

    • (Score: 5, Insightful) by Thexalon on Sunday June 08 2014, @04:00PM

      by Thexalon (636) on Sunday June 08 2014, @04:00PM (#52969)

      without indentation fascism

      Serious question for you: Please show me some code that would be more clear and easier to read with something other than strict indentation within control structures.

      Because every single bit of good code I've ever read uses some kind of indentation standard, in just about every language I've read code in: C and its many descendants, LISP and its descendants, bash scripting, Basic and its descendants, Perl, Ruby, and Python. It's a technique for quickly showing the effects of control structures which every single programming language in existence makes use of.

      "But", you cry, "when there are lots of layers of control structures, indentation makes it harder to follow!" To which there's a clear response: "Don't do that." More than about 4 indents and you should be thinking about refactoring if you want anyone who has to read and maintain your code to remain sane (simplest approach: take what is currently a code block buried deeply in the indentation and make it a function or method).

      And yes, I'm an indentation fascist, because it's easy enough for anyone to learn to do, and it helps a lot in figuring out how someone else's code works.

      --
      The only thing that stops a bad guy with a compiler is a good guy with a compiler.
      • (Score: 2) by VLM on Sunday June 08 2014, @04:31PM

        by VLM (445) on Sunday June 08 2014, @04:31PM (#52975)

        "To which there's a clear response: "Don't do that.""

        Everyone gets burned on this once, then when they see the signs they run if something like that appears on the horizon. I would run like hell from python for this reason alone, even though I know its not actually that crippled and if you have to do something unwise it'll let you.

        Likewise, when you hear "whitespace is your control flow method" it sounds like a joke language because you immediately imagine spending time fixing bugs because of embedded whitespace issues, especially UTF8 issues. I thought python was related to this when I first found out about both:

        http://esolangs.org/wiki/whitespace [esolangs.org]

        I'm reminded how until recently Scala case classes (perhaps in play framework) crapped out around 18 parameters or some such, so any time anyone complained they'd get attacked by people who didn't like that the implementer crossed their personal line in the sand and the victim should have known better so the victim should be punished. Classic shoot the victim behavior. It was fun to watch. "So I'm trying to store 24 hours of hourly scientific data and only the first 18 hours can be made to work ..." etc. Or biweekly annual data. It was hilarious watching the language devs demand that when the irresistible force of real world and/or business requirements crashed and burned into the immovable object of the ivory tower, well, I guess the real world is just wrong, so walk off the job and get a new one. No, I rather think I'll just use a language that degrades gracefully, aka doesn't suck.

        So yeah I'd definitely run from python not just avoid it. Weird sociological culture and all that, best avoided.

        The idea of a microcontroller with an embedded "native-ish" language other than assembly, forth, C or BASIC is novel and cool, even if I don't particularly like python or its style at all.

        Sooner or later someone's going to put LOGO on a mc with VGA out, or something like that, which sounds cool.

        • (Score: 2) by skullz on Sunday June 08 2014, @04:55PM

          by skullz (2532) on Sunday June 08 2014, @04:55PM (#52977)

          Actually the Python interpreter checks the code for weird whitespaces before it runs it and yes, there is always the headache of mixing and matching \t with spaces. The only problem you run into is if you are not using an IDE with code block folding and you have large block of code. Then you have to put your finger on the screen and scroll down until you find the "right" number of tabs to use to close a block, which is always fun. Same thing with putting a statement on the wrong side of a curly brace in C.

          But you would never have a problem with input whitespace mucking up your Python code unless you were doing something crazy like "exec(cmd_from_db)". Yeah, don't do that.

        • (Score: 2) by physicsmajor on Sunday June 08 2014, @06:31PM

          by physicsmajor (1471) on Sunday June 08 2014, @06:31PM (#53000)

          Never once when I've used Python, even with a significant number of nested control structures, have I ever said to myself "wow, I wish I had to count brackets to figure out what structure I'm in."

          Getting burned by this is actually harder than it is to leave out a closing brace. Sure you can make a mistake, but it's because you are used to a different standard.

          If you want to attack Python, go ahead, give it your best shot. Nothing is perfect; there are legitimate complaints that can be levied. I don't see them here, however, and I'll also go ahead and ignore your points if you insist on using completely unrelated Scala-strawmen as "evidence" for your position.

          • (Score: 2) by skullz on Sunday June 08 2014, @08:56PM

            by skullz (2532) on Sunday June 08 2014, @08:56PM (#53026)

            Careful, they might mention the GIL.

        • (Score: 0) by Anonymous Coward on Wednesday June 11 2014, @09:33PM

          by Anonymous Coward on Wednesday June 11 2014, @09:33PM (#54309)

          So yeah I'd definitely run from python not just avoid it. Weird sociological culture and all that, best avoided.

          You really don't have a clue about Python. You just don't know what you're talking about. Yet still, you talk. Why is that?

          "It's better to keep your mouth shut and be thought a fool, than to open your mouth and remove all doubt."

          About that random rambling anecdote about Scala... it's totally irrelevant! Not even useful as an analogy.

          Back in the real world, a lot of people are using Python to get actual work done. https://www.python.org/about/success/ [python.org]

      • (Score: 2) by kaszz on Sunday June 08 2014, @05:36PM

        by kaszz (4211) on Sunday June 08 2014, @05:36PM (#52987) Journal

        Indentation is fine, just not the enforcing of a particular indentation style. And that without exceptions. Indentation for control structures is necessity but not the particular style.

        • (Score: 3, Informative) by physicsmajor on Sunday June 08 2014, @06:25PM

          by physicsmajor (1471) on Sunday June 08 2014, @06:25PM (#52997)

          You do realize that Python is perfectly happy to execute whatever you throw at it, so long as your style is consistent.

          Two space indentation? Fine. All tabs? Fine.

          Every IDE worth using can be set to exclusively use your preferred number of spaces instead of \t when you press Tab.

          I'm really not seeing your argument here.

        • (Score: 2) by skullz on Sunday June 08 2014, @08:54PM

          by skullz (2532) on Sunday June 08 2014, @08:54PM (#53025)

          This is a philosophical debate around the merits of '\t' vs '}'. Style? Srsly? You should be concerned with design / pattern style, not the whitespaces vs. end-of-block identifiers.

          There is no style in coding, just doing. Indention is the least of your worries.

          • (Score: 2) by Tork on Sunday June 08 2014, @09:36PM

            by Tork (3914) Subscriber Badge on Sunday June 08 2014, @09:36PM (#53036)
            but.. but.. but... having a strong opinion makes me appear smarter than everybody else!
            --
            🏳️‍🌈 Proud Ally 🏳️‍🌈
      • (Score: 2) by Snotnose on Monday June 09 2014, @02:05AM

        by Snotnose (1623) on Monday June 09 2014, @02:05AM (#53099)

        If nothing else it prevents adding an "if(false)" for debugging.

        I love Python, I've written a lot of code in it. But I really hate the idea of indentation delimiting blocks of code.

        --
        My ducks are not in a row. I don't know where some of them are, and I'm pretty sure one of them is a turkey.
        • (Score: 0) by Anonymous Coward on Monday June 09 2014, @02:09PM

          by Anonymous Coward on Monday June 09 2014, @02:09PM (#53224)

          But, but, but... That's not kosher!

          You should debug as told to, damnit!

      • (Score: 1) by terryk30 on Monday June 09 2014, @08:56AM

        by terryk30 (1753) on Monday June 09 2014, @08:56AM (#53165)

        ...Please show me some code that would be more clear and easier to read with something other than strict indentation within control structures.

        Not quite what you're asking for, but one... technique I've used in other languages is to put temporary debugging statements (e.g. printf's) at the start of the line, so they stand out (even though they're in code several levels deep). I missed being able to do that in Python.

    • (Score: 2) by VLM on Sunday June 08 2014, @04:07PM

      by VLM (445) on Sunday June 08 2014, @04:07PM (#52971)

      More like a 80s home computer. 192K of ram should be enough for anybody and all that.

      If you'd like a 80s era home computer on a PIC32, go google for the maximite. Its a bit more free-wheeling community than arduino so there's pretty much everyone doing their own thing under the same banner, aka nothing is compatible with anything and fads whoosh thru as fast as an IP packet. Its been around at least 3 years, lots of stuff to look at. This is self hosted, like the pi, rather than program on desktop / run on board like arduino. Be sure to google for mmbasic too, which is a pretty decent basic. Also be sure to google for CGCOLORMAX2

      If you want to program microcontrollers in a pretty nice BASIC using the edit on desktop and download to hardware model, the basic stamps have been around about 20 years now and they're still going. They do work, although very slowly. Most "foolin' around" projects don't need speed anyway.

      The problem with something like a JVM is requiring a "gig or so" that the JVM requires. Once single chip microcontrollers are out that you can develop with Clojure or whatever on them natively, then all bets are off.

      Anyway the TLDR is if you want to program MC in basic thats old stuff. This is a somewhat new idea of doing the same thing with python instead. Personally wouldn't be my first choice of language for ... anything, but it was faddy-popular at one point and it does work.

      • (Score: 2) by kaszz on Sunday June 08 2014, @06:04PM

        by kaszz (4211) on Sunday June 08 2014, @06:04PM (#52995) Journal

        Thanks for the hints! ;-)

        I found some related use for the maximite environment. I just want to avoid having to setting up a cross-development environment to just change small things. Oh and the attractiveness of having a instant-on computer with all the tools to develop right there!

    • (Score: 0) by Anonymous Coward on Sunday June 08 2014, @09:49PM

      by Anonymous Coward on Sunday June 08 2014, @09:49PM (#53041)

      I see your microperl and raise one picolisp.

      "PicoLisp uses (at least when compared to other Lisps) very little memory, on disk as well as in memory (heap space).

      For example, the installation size in the OpenWRT distribution is only 575 kB (uncompressed), where the statically linked interpreter with 296 kB takes the largest part. Yet, it includes the full runtime system with interpreter, database, HTTP server, XHTML and JavaScript application framework, watchdog, and the debugger, PostScript and XML libraries.

      PicoLisp has no compiler, everything starts up very quickly, and code dynamically loaded at runtime (e.g. GUI pages) is immediately ready. Yet, the interpreter is quite fast, usually three times a fast as Python, for example."

    • (Score: 2) by sjames on Sunday June 08 2014, @11:08PM

      by sjames (2882) on Sunday June 08 2014, @11:08PM (#53062) Journal

      If you hate indentation that much, I'm guessing any code you write is a nightmare to read.

      C and Perl use braces, but indentation is strongly encouraged for readability. Python actually won't work if you try to write a big blob of unformatted code. I consider that a feature.

      • (Score: 0) by Anonymous Coward on Sunday June 08 2014, @11:57PM

        by Anonymous Coward on Sunday June 08 2014, @11:57PM (#53070)

        One always hears about Perl one-liners that can be executed by perl -e. No one can write simple Python one-liners because of their insistence on indentation fascism. This also makes the Python REPL less useful than it could be. I find myself using Ruby and Lisp REPLs to write and test long lines of code without worrying about whether the compiler will care if I'm using spaces or tabs.

        • (Score: 2) by sjames on Monday June 09 2014, @01:34AM

          by sjames (2882) on Monday June 09 2014, @01:34AM (#53088) Journal

          Do you consider C a bad language because gcc doesn't do REPL?

          You can just run python interactively.

          • (Score: 2) by kaszz on Monday June 09 2014, @02:28AM

            by kaszz (4211) on Monday June 09 2014, @02:28AM (#53109) Journal

            Which is why Perl takes the command line and C the hard stuff.

  • (Score: 0) by Anonymous Coward on Sunday June 08 2014, @03:28PM

    by Anonymous Coward on Sunday June 08 2014, @03:28PM (#52959)

    Why someone would want to use it on a microcontroller is far beyond me. That language pissed me off the second I found out that indentation was a control structure.

    • (Score: 2) by skullz on Sunday June 08 2014, @03:33PM

      by skullz (2532) on Sunday June 08 2014, @03:33PM (#52962)

      Probably because it lowers the bar for folks wanting to get into hacking on embedded devices. If you can pick up Python faster and don't have to struggle with learning C or Java you can focus on getting your project done.

      And, it has the Python snake on the back of the board. Snakes are cool.

      • (Score: 1) by epitaxial on Sunday June 08 2014, @04:21PM

        by epitaxial (3165) on Sunday June 08 2014, @04:21PM (#52973)

        So use a variant of Basic then. I'm a hardware guy but have done several cool projects with Basic on the Microchip PIC series. Yeah yeah laugh at me but at the end of the day my project works and I didn't need a semester of C classes.

        • (Score: 2) by skullz on Sunday June 08 2014, @04:41PM

          by skullz (2532) on Sunday June 08 2014, @04:41PM (#52976)

          Haven't touched a PIC chip after college but I did find an open source compiler (I think) for them called Great Cow BASIC which looks like it is actively being maintained.

          Check out this Micro Python board video:
          https://www.youtube.com/watch?v=8V3Rpu2fpmQ [youtube.com]

          I think that is the level of ease this project is aiming for. Plug and play and remain extendable if you want to go into the deep end and bust out the soldering iron.

    • (Score: 4, Informative) by umafuckitt on Sunday June 08 2014, @03:59PM

      by umafuckitt (20) on Sunday June 08 2014, @03:59PM (#52968)

      Python with braces [pythonb.org] no more indents.

      • (Score: 0) by Anonymous Coward on Monday June 09 2014, @01:41AM

        by Anonymous Coward on Monday June 09 2014, @01:41AM (#53089)

        Wow! Thanks for that!

    • (Score: 2) by marcello_dl on Sunday June 08 2014, @09:44PM

      by marcello_dl (2685) on Sunday June 08 2014, @09:44PM (#53040)

      If I were evaluating candidates I'd ask about python's tabs and dismiss those who don't think they are irrelevant.
      How predictable is a language? how fast does it perform? what libraries, frameworks it has? interfaces to C/asm? how much is it converging to a lisp equivalent? (all high level languages are bound to reimplement lisp, poorly) these are much more important aspects.

  • (Score: 1) by moondoctor on Sunday June 08 2014, @10:01PM

    by moondoctor (2963) on Sunday June 08 2014, @10:01PM (#53043)

    If I was a python freak I suppose this would be cool, but it really leaves me scratching my head. You want tight and bulletproof code when programming those things. Assembly ftw.

    I think that one of the beauties of microcontrollers is that working with them gets back to 'real' programming. You can be aware of every single bit and what it is doing without interference from a stack/os/whatever. Makes me sad to see modern wasteful practices (i.e. python to program a uC) shoehorn their way in.

    Or am I just being grumpy?

    • (Score: 0) by Anonymous Coward on Monday June 09 2014, @01:45AM

      by Anonymous Coward on Monday June 09 2014, @01:45AM (#53091)

      Strangely enough, assembly is not hard to pick up. I learned it at age 9 from a Commodore manual. It's sometimes quite tedious, but since most "smaller" processors are relatively simple in terms of programming models, it's fairly easy to pick up after understanding something like BASIC...especially the BASIC that relies solely on GOTO and GOSUB with line numbers, which is a terrible way to have to do it but definitely makes figuring out stupid things happening in ASM far easier.