5 ms·
I love how the context is embedded systems, yet python is used to demonstrate the technique. Are people really that bad at reading C or C++?
by mempko 11y ago
I love how the context is embedded systems, yet python is used to demonstrate the technique. Are people really that bad at reading C or C++?
- jacobolus 11y agoI think the key part you’re missing is “Here's a quick Python function that uses numpy and matplotlib to plot the results:” Doing the same in C is going to be a lot more effort.
- jason_s 11y agoThe author (me) frankly hates C and C++. Haven't touched it for use on a PC since 2009. However I use it every day for my job working on dsPIC motor control, because I have no better options. When I am trying to teach someone about algorithms, I turn to Python because it is more readable, quicker for me to write, it's platform-independent, and I can incorporate it into an IPython (now Jupyter) Notebook and postprocess that into my blog articles with a minimum of hiccups.
- 3pt14159 11y agoHave you checked out Nim? I've been using it in production for a couple small programs and I've had no issue. I've also been able to bind it to higher level languages using the FFI: http://nim.community/answers/create_a_shared_library/ http://nim.community/answers/create_a_shared_library/ Although I haven't figured out the garbage collection bit for the shared object bit. It is a lovely language and it's reaching 1.0 sometime this year.
- jason_s 11y agoI've heard of it. Rust is probably the most promising to me. Unfortunately just because a language exists, doesn't mean it is usable on a particular embedded system architecture. The processor core and system libraries need support.
- mindslight 11y agoRust works fine with Cortex-M3/M4 (a bit larger than dsPIC, and their documentation isn't as nice as Microchip's). Library support isn't great though - try zinc.rs or roll your own. An STM32F4 Discovery board is $15. Just in case you didn't have enough to play with...
- jason_s 11y agowell, I work for Microchip, so I won't be writing code for other manufacturers' processors, at least not for my day job :-)
- mindslight 11y agoWell then go lobby for creating dsPIC support in LLVM! Selling 10M chips at a time is great and all, but designs start with a single engineer. The 16F84 was the hobbyist darling until gcc-avr ate its lunch.
- jason_s 11y ago>Well then go lobby for creating dsPIC support in LLVM! Um. Been there, done that. Well, you see, [: discussion of internal politics deleted :]
- makomk 11y agoPIC is not an open-source-friendly company. They literally wrapped a license manager around gcc and used it as their C compiler on several platforms, and their libraries come with a license forbidding you from using them with a compiled-from-source version of gcc. If they did switch to LLVM, it'd probably be so they could closed-source their compilers completely.
- mindslight 11y agoSheesh. I worked with their 8-bit chips in an era when using a C compiler was essentially just a nicer syntax for ASM (and you really didn't want to deal with code written by someone who thought differently). In that environment, their easily available good documentation is about as close as you can get to Free. Software complexity was of course on the rise and I figured it was only a matter of time until they "got it" with regards to a Free C compiler etc. It's sad to hear that they've dug their heels in even further and are now one of the few examples of bad-faith attacking the GPL through contracts. Especially because recently reading their ENC28J60 documentation was a nice break after wading through STM/ARM's stuff. If I'm ever again in a position where I'm choosing chips for a production design, I'll be verifying what you said for myself (diligence) and then steering clear to less risky alternatives.
- sp332 11y agoC code would use twice as much room on the page for function & variable declarations and brackets.
- sophacles 11y agoI think it comes down to the same reason algorithm papers use psuedo code rather than a particular language - the point is to represent the main idea clearly, rather than bog down the reader in all the accounting and syntax of a particular language. Details about a particular variable's type, or a languages semantics don't tell me anything about (in this case) chebyshev or taylor functions, but to follow the code I'd have to internalize the interactions of those things, along with the actual math for it all to make sense. Consider it an abstraction layer for learning. Just like when dealing with files on disk I use open(), read(), etc rather than work in my fs + hdd controller.
- monochromatic 11y agoPython is easier to read. Somebody with almost no programming experience at all can read (simple) Python and understand what's going on.