Friday 26 May 2017

Python in Embedded

C/C++ are compiled languages, while Python is an interpreted language.

Python might be at its strongest when used as a communication middleman between the user and the embedded system they're working with. Sending messages through Python to or from an embedded system allows the user to automate testing.

Python is an object oriented script language while C++ is an object oriented compiling language.

Here are some of differences.

  • Memory management: C++ doesn't have garbage collection, and encourages use of raw pointers to manage and access memory. It differentiates between heap and stack, and it requires you to attend to values versus references. C++ requires much more attention to bookkeeping and storage details, and while it allows you very fine control, it's often just not necessary.
  • Types: C++ types are explicitly declared, bound to names, checked at compile time, and strict until they're not. Python's types are bound to values, checked at run time, and are not so easily subverted. Python's types are also an order of magnitude simpler. The safety and the simplicity and the lack of declarations help a lot of people move faster. Speaking of...           Python:
        bob = 6
        bob = 6.5
        bob = "My name is Bob"
     
  • Language complexity: C++ is a beast of a language. I've known can be caught up short by unintended consequences in complex (or not so complex) code. Python is much simpler, which leads to faster development and less mental overhead.
  • Interpreted vs compiled (implementation): C++ is almost always explicitly compiled. Python is not (generally). It's common practice to develop in the interpreter in Python, which is great for rapid testing and exploration.  
If a problem can be solved in Python, then it can also be solved in C/C++; the reverse is not always true.
 However, if the problem can be solved in Python:

-- The solution (source code) will be simpler than the corresponding C code.
-- It will be more "readable."
-- Perhaps more importantly, it will be more "writeable" (this is an oft-overlooked quality!).

Due to the qualities noted above, the solution will have fewer bugs and be much faster to develop, and these are the real reasons to opt for Python over C/C++ for many tasks.



 

No comments:

Post a Comment