News for hackers. Stuff that matters.
Re:The Rise of Python for Embedded Systems by nikofeyn on Thursday July 20, 2017 @10:51AM (#14812972)
whhhhhhyyyyyyy?

i just can't understand why someone would want python for embedded applications. i primarily use labview for systems development, and there is not a single thing that would be gained by moving to python while many things would be lost. and no one can convince me that using python over labview would generate more robust code. i have used python before, and it was slower to develop in and more error prone than labview for system development.

personally, i want to see more lisps/schemes and ML-based languages on embedded systems. i know there are some, but they aren't quite there. that's the direction i think we should move. python isn't the best at any one thing other than having lots of libraries. there are far more productive dynamic languages (lisps/schemes) and far better languages for developing safe code (ML-based). i am currently learning idris, which seems like it could be amazing for embedded code development. having provable state machines would be a huge plus.

Re:The Rise of Python for Embedded Systems by keenerd on Thursday July 20, 2017 @11:39AM (#14813420)
> i have used python before, and it was slower to develop in and more error prone than labview for system development.

Exact opposite in my experience. I've been there, tried that. Re-wrote it in python for a more than 50x productivity gain.

At my first job out of school, I inherited maintenance for a couple of projects. All were extremely expensive custom test equipment, written in Labview. One was the central project, the whole point of this group's existence. It had been in development for more than two years. It routinely destroyed thousands of dollars worth of hand-made sensors during its power-on self-test. It was a far cry from being finished. It couldn't even be considered a prototype.

In a two-week period, I taught myself python, quickly cloned the existing calibration procedures, and finished the entire thing. My boss thought I was a genius rockstar, but no, I'm not. I just had the sense to evaluate every available tool and came to the conclusion that Python (mostly due to the ctypes module and a robust Windows ecosystem), was the best option.

Personally I'll use C whenever possible for embedded work. (And later I did port the entire project to a DSP running C, because Labview & an AD DAcq board was too expensive.) But if latency doesn't matter, Python is fine.

edit: Side note, I was already conversational in Labview. Admittedly only for school projects, but at that point I knew more Labview than Python.

Re:The Rise of Python for Embedded Systems by zwieback on Thursday July 20, 2017 @11:47AM (#14813497)
Agreed, at my job I'm now actively campaigning against LabView (and Matlab) for application development. These projects turn out productive at first and invariably turn into unsupportable messes.

What's the right platform for "embedded systems" is debatable. A true bare-metal app has different requirements from something running on RPi or Beagleboard.

Re:The Rise of Python for Embedded Systems by nikofeyn on Thursday July 20, 2017 @12:31PM (#14813916)
see my other reply.

but in general, without proper architecture, any project will become a mess in any language. this isn't special to labview. all of my systems and code in labview are extremely extensible and maintenance. why? i pay attention to design and architecture and use labview's OOP functionality. people regular comment how great it is that i can add full features in mere minutes, including UI behavior, and they are regularly surprised by the end result i have with labview. is that possible in other languages? yes. but labview's dataflow makes it very easy to reason about local changes.

Re:The Rise of Python for Embedded Systems by lvoudour on Thursday July 20, 2017 @04:05PM (#14815807)
I strongly disagree. I've used both LV and matlab for many years and they are tremendously good for specific tasks.

Labview is great for data acquisition and GUIs to visualize this data. Drop a ready made UART/TCP/VISA block, some array manipulation in a loop, connect a waveform block with zoom/cursors/etc. and you have a working real-time app in a couple of hours.

Matlab is perfect for heavy matrix operations on large datasets, fantastic for plotting your data and it's very good for prototyping algorithms.

I tried python as an alternative for both. Tons of boilerplate code, a pain for GUIs and don't get me started on matplotlib/scipy/numpy...

The biggest drawback of both LV/matlab is their proprietary nature and the expensive licenses which make them unsuitable for hobbyists (at least there's octave as a matlab alternative). But they're great tools for the appropriate tasks

Re:The Rise of Python for Embedded Systems by snovv_crash on Thursday July 20, 2017 @04:56PM (#14816225)
The problem with both LV and MATLAB is that once you've done the basics, and now you want to turn it into something that you can maintain and sell.

With LabVIEW you can compile and redistribute, but good luck writing an efficient binary search tree when your data gets bigger than what can be searched for with brute force. Also, at least last time I used it, the version control was horrendous.

For MATLAB, just forget redistribution in general. Nobody is going to buy a MATLAB licence to run your code.

Re:The Rise of Python for Embedded Systems by lvoudour on Thursday July 20, 2017 @05:29PM (#14816451)
>The problem with both LV and MATLAB is that once you've done the basics, and now you want to turn it into something that you can maintain and sell.

That's true, but it's not their strong selling point. There's tons of problems to solve at the r&d stage when dealing with custom hardware, a dozen different instruments and algorithm exploration. That's where these tools shine and the reason they're ubiquitous in industrial/military/aerospace environments.

For a full product with drivers, libraries and fast, customer friendly UI sure there are better solutions, but there's no law that dictates to use the same tools at the development stage

Re:The Rise of Python for Embedded Systems by thethirdone on Thursday July 20, 2017 @05:07PM (#14816310)
I know very little about the current state of Labview; I used it a bit 6 years ago so this may be a silly idea.

Do you know of any Labview -> Python conversion tools?

I would think that would be a pretty ideal solution for the right problem domains. You could get a quick first version up, and then when you need more maintainability or flexibility, convert to Python.

Obviously, this would require some kind of Labview library in Python, but that seems like it should be relatively easy to make as a wrapper around the Labview included library.

Re:The Rise of Python for Embedded Systems by stinos on Friday July 21, 2017 @02:43AM (#14818542)
For MATLAB, just forget redistribution in general. Nobody is going to buy a MATLAB licence to run your code.

That's a bit far fetched. People already having a Matlab license (and it's not like there aren't many of those) already made that cost, so buying your Matlab product is not really different. Alternatively you could compile your code into a C API and distribute that instead: the Matlab runtime itself is free of charge.

Re:The Rise of Python for Embedded Systems by kongolongo on Friday July 21, 2017 @04:21AM (#14818922)
You don't need a Matlab license to run compiled Matlab code. Matlab provides free runtime libraries.
Re:The Rise of Python for Embedded Systems by nikofeyn on Thursday July 20, 2017 @12:26PM (#14813856)
that sounds like the software design itself was at fault. labview is a programming language. if one writes poor code, then labview can't magically fix that.

since labview is dataflow and has static typing, it shares a lot in common with functional languages. this means you can trace your data and execution in a very deterministic manner. i often write code that just works. there are almost always no bugs in the final software. that's almost impossible in python.

labview also has OOP, which any respectable labview developer uses heavily on any project. for larger projects and systems with concurrent processing needs, it's multithreaded features and actor framework are necessary.

labview makes it easy to code simple projects, and so people don't treat it with respect. labview code is often written by non-software engineers, who will write poor code in ANY language. people seem to forget that. if one treats labview as any other language and with respect from the perspective of a software engineer, then it has a lot of functionality that is very difficult to replicate in other languages. for example, async is all the rage these days, including in python. labview has had that functionality for many years now. and the dataflow paradigm pays off big time.

labview is different and people don't respect it. that's okay, because i do which makes me pretty valuable and quite efficient.

and i do think labview could be improved. it's just i wouldn't put any effort into python, especially for real embedded systems. many, many languages out perform it in many vectors.

Re:The Rise of Python for Embedded Systems by adrianN on Thursday July 20, 2017 @12:29PM (#14813898)
One important point is that Labview is proprietary and expensive and Python is free both as in beer as well as in freedom. Many people already know Python, so supporting Python on embedded systems opens up a whole new field for tinkerers.

I feel that more options for embedded development are always better than fewer options. Personally I'd prefer Rust or Ada over Python, but other people like dynamic languages better.

Re:The Rise of Python for Embedded Systems by nikofeyn on Thursday July 20, 2017 @12:39PM (#14814032)
part of my comment was also advocating other languages. i am actively researching options for replacing labview, but the choices are just not great. python is the last language i would consider moving towards.

in general, i am looking for a lisp, scheme, or ML-derived language. there are places where these can be ran on embedded controllers, but they aren't complete systems. it's great that people are putting together these alternatives, but it just feels python is being force fed in places it doesn't belong. i don't see how this article can say python is better for safe code.

Re:The Rise of Python for Embedded Systems by throwaway7645 on Thursday July 20, 2017 @01:19PM (#14814450)
Python has a lot of good runtime checks and doesn't allow implicit castes in most cases. It is #4 on TIOBE, and used all over industry, so probably not all that bad. If you're looking for something to run embedded: Rust, Nim (maybe if you tune the GC or turn it off), Forth, and Ada come to mind besides the obvious C/C++/Assembly. I'd keep an eye out on Red although it still has a ways to 1.0 it will be much nicer than Python in this space and much easier to use than most of the above. Red should run fairly fast when compiled and will yield a tiny native executable.
Re:The Rise of Python for Embedded Systems by nimmer on Friday July 21, 2017 @09:25AM (#14820299)
Nim runs even on microcontrollers and produces tiny executables (few kilobytes).
Re:The Rise of Python for Embedded Systems by elago on Thursday July 20, 2017 @11:48AM (#14813502)
Admittedly I'm not extremely advanced in embedded design, and work more on prototype r&d than production applications with really high stakes (life safety, expensive equipment failure)

I've always been really repulsed by labview for a few reasons: expensive, proprietary, vendor lock in to national instruments. Also prefer text only rather than graphical click and drag programming.

For these reasons I'd choose python over labview in a hypothetical project where the hardware could be chosen to support either

Re:The Rise of Python for Embedded Systems by verall on Thursday July 20, 2017 @12:45PM (#14814088)
Because old C/C++ programmers can use python just like C/C++, and it's easy.

I work on an embedded soc, and it's seriously easy for an experienced systems guy to make a python interface to the huge C++ high level driver, without knowing very much python (let alone some kind of "productive" language).

On the other hand, my experience using labview was like amputating my fingers with a spoon. So I probably didn't spend enough time with it to 'get' it. But it did crash a lot. A friend of mine uses it in the research lab he works in, and he hates it with a passion, and complains about buggy closed source modules and hidden accrual of state.

Re:The Rise of Python for Embedded Systems by stinos on Thursday July 20, 2017 @02:45PM (#14815221)
Like other comments: I have quite a different experience. I don't think you are wrong, nor that I am wrong, but rather that it depends heavily on the type of application.

Need to quickly have a basic graph for some signals in 'real' time? I'll pick LV over anything else: it will be faster to develop, more robust, and just work (until you want to customize the graph). In Python I'd first have to go look for the appropriate libraries to use, start fiddling with gui layouts, etc. And after a couple of hours it probably still wouldn't even look remotely as good as LV and still lack basic zoom/cursor functionality.

But for even basic if-then-else and loop programming (not even talking 'true' algorithms) I'm, after about 10 years of Labview experience, pretty sick of using Labview for it. You see in Python I can just do [func(x) for x in someRange if x > 0 and x in someOtherRange]. In the time I typed that, in Labview I would have maybe managed to draw the outer loop and drag the func block into it. Then I'd still have to the conditional logic, all the wriring, etc. So even though you say for some cases Python might be slower, there is no way you can do this real life example faster in LV. And that actually goes for a major part of the program logic.

edit Also a note on Python vs C for embedded and the likes: we're currently running an application where the whole backend is C++ and does things like signal processing, but the frontend is written in MicroPython and with usability in mind. As such, I can just give it to very inexperienced programmers and they can actually build something useful with it. Yet they don't even have to touch a fiddly build system or learn how to shoot yourself in the foot a million times and the backend still happily runs speedy code. So again: heavily depends on the application.

Re:The Rise of Python for Embedded Systems by throwaway7645 on Thursday July 20, 2017 @01:09PM (#14814343)
You're the first person I've met that would take labview over python. I suppose if you're heavily using all the block diagrams for signal processing or control systems it probably makes sense, but as a general purpose & beginner friendly language, python is king.
Re:The Rise of Python for Embedded Systems by Too on Friday July 21, 2017 @01:05AM (#14818190)
Labview is only simple if your problem domain is simple, eg: only scalar values, only cyclically updated values, no text handling, no lists, no event systems, very few conditionals, whole program fits on a single page, no distributed development.
Re:The Rise of Python for Embedded Systems by nikofeyn on Friday July 21, 2017 @10:59PM (#14825152)
that's really not true. i build systems using full on OOP, actor framework, custom OOP UI controls, many user interfaces, distributed, etc. all in labview

labview has some great libraries for developing complex systems. thiugh i a, the first to say it isn't close to end game.

Re:The Rise of Python for Embedded Systems by sametmax on Thursday July 20, 2017 @02:51PM (#14815266)
It's just easier. It's an open source power yet simple to learn language. There are many materials about it and many libs. Python has great productivity, and hzs priven great for protyting which is an asset in getting lower costs.

It's not a silver bullet but it's nice to have it as a solution.

Re:The Rise of Python for Embedded Systems by christophilus on Thursday July 20, 2017 @12:32PM (#14813935)
What would it take for a scheme/lisp to meet your criteria for embeddability?
Re:The Rise of Python for Embedded Systems by nikofeyn on Thursday July 20, 2017 @11:59PM (#14817963)
that's a great question. given that i use the labview ecosystem, having another language that allows me to program desktop, real-time, and fpga applications all with the same lanhuage would be the eventual goal. so being bale to target any high-level cpu like x86 or arm but also targets like xilinx zynq would be great. in addition, libraries for signal and image processing in additional to libraries for serial and other instrument communication would be best. i realize i am describing more of a systems development rather than just embedded systems, but those are my needs. basically i want something that can replace labview to give me access to more advanced abstractions.