MicroPython has become popular in the domestic programming community recently. What is the reason why it is so popular? Is it because it has powerful functions and is open source under the Mit license?
The origin of Micropython is due to Damien George, a great computer engineer. Damien George uses Python for work every day. One day he came up with a bold idea: Can Python be used to control a microcontroller? What about operating robots?
So is micropython suitable for development?
The Python language itself is an easy-to-use scripting language. Some non-computer major enthusiasts choose Python language as their introductory language. , but it has a fly in the ointment (why China and the United States do not participate in the World Cup), it cannot implement some low-level operations, and is inconspicuous in the hardware field. Therefore, Damien George spent 6 months to build MicroPython. This is the origin of MicroPyhton.
MicroPython is based on ANSIC, and its syntax is basically the same as Python3. It has an independent parser, compiler, virtual machine and class library. Currently it supports 32-bit based ARM processors, such as STM32F401, STM32F405, and STM32F407.
The following comparisons were made using the three languages of assembly, C, and MicroPython to illustrate whether micropython is suitable for development?
1. Compilation environment
Before writing programs in C language and assembly language, you need to download the compilation environment. However, Micropython does not require any compilation environment. You only need to insert the U port of the development board into the computer. A drive letter can appear on the computer, just like inserting a U disk. Then open the U disk and edit main.py directly with Notepad. The comfort of it is that MicroPython does not require any tools and environments. Any text tool can be used with just one development board. It can be developed and compiled, and you can give it a nickname - pocket programming computer. . . The best one in China is the TPYBoard v102 development board. If you are interested, you can learn more about it. It has complete information and video learning materials, which is quite good. That’s how I got into it.
2. Operation difficulty
The basic operation of assembly language is simple, but it is relatively difficult to achieve complex project goals. The code is lengthy and debugging is difficult; C language has statements and a large number of libraries Functions are simpler than assembly; MicroPython has more library functions than C, and the code format is not only simpler. With the support of the library, many functions and methods do not need to be written by yourself. You can just import xx directly. The class library import is ok. In the past, it took five or six lines of code to light a lamp, but now it only takes one line of code to light up the LED, so easy.
3. Program structure
Assembly language generally uses a jump structure. Whether it is a subroutine call, a loop or a random jump, in theory, the jump method is used to interrupt the operation or force an exit. The operation of the program segment requires precise control of the stack push, and the requirements are very strict; the C language generally uses a loop structure or a sequential structure, and there is no need to jump around to execute the program. The interrupt operation will automatically push the stack without human intervention. When timing requirements are high, assembly can be embedded to improve efficiency; MciroPython can use the C program structure or the thread structure. The thread structure requires strict and reasonable allocation of thread working time without conflicts, and good control of resources. , resources cannot be wasted by idle threads. In theory, multi-threads can run more efficiently. Although a single core can only run a single thread at the same time, it is synchronized from a macro perspective. It can effectively reduce the program when time requirements are not strict. difficulty of writing.
4. Writing method
When assembly does not use macros, the instructions usually directly operate the unit, which requires memorizing a large number of data unit uses, and due to the large number of program lines (possibly (will reach one or two thousand lines), you need to look back and forth through the program code, and the entire writing process is relatively cumbersome. And because they are all 8-bit units, complex data operations need to be completed by nesting C language; any variables used in C language need to be defined first. Compared with not having to memorize variable names, the overall structure is clear and most programming software has jumps. The subroutine function makes it very convenient to find program blocks. There are a large number of finished header files containing various commonly used functions, which reduces the writing of complex program codes; MicroPython inherits the writing advantages of C and does not require pre-definition or any end symbols. You only need to change the line to continue writing. But pay attention to the use of the Tab key in some special circumstances.
5. Readability
The assembly itself is difficult to read because there are few marks and the units are directly manipulated. The visual structure is not only two columns of code but also requires constant jumps, so it is difficult to read. It’s very difficult; the simple operation codes in C language are relatively clear, but for complex ones, you have to find methods within methods. Many complex codes have to be found by yourself, which makes people feel very headache; MicroPython has better readability than C , and because many special symbols have been cancelled, the overall feeling is relatively clear. Many methods are written separately in separate libraries and can be called directly. Each function has a separate class library, which seems extremely convenient and clear at a glance.
The above is the detailed content of Is micropython suitable for development?. For more information, please follow other related articles on the PHP Chinese website!

Python and C each have their own advantages, and the choice should be based on project requirements. 1) Python is suitable for rapid development and data processing due to its concise syntax and dynamic typing. 2)C is suitable for high performance and system programming due to its static typing and manual memory management.

Choosing Python or C depends on project requirements: 1) If you need rapid development, data processing and prototype design, choose Python; 2) If you need high performance, low latency and close hardware control, choose C.

By investing 2 hours of Python learning every day, you can effectively improve your programming skills. 1. Learn new knowledge: read documents or watch tutorials. 2. Practice: Write code and complete exercises. 3. Review: Consolidate the content you have learned. 4. Project practice: Apply what you have learned in actual projects. Such a structured learning plan can help you systematically master Python and achieve career goals.

Methods to learn Python efficiently within two hours include: 1. Review the basic knowledge and ensure that you are familiar with Python installation and basic syntax; 2. Understand the core concepts of Python, such as variables, lists, functions, etc.; 3. Master basic and advanced usage by using examples; 4. Learn common errors and debugging techniques; 5. Apply performance optimization and best practices, such as using list comprehensions and following the PEP8 style guide.

Python is suitable for beginners and data science, and C is suitable for system programming and game development. 1. Python is simple and easy to use, suitable for data science and web development. 2.C provides high performance and control, suitable for game development and system programming. The choice should be based on project needs and personal interests.

Python is more suitable for data science and rapid development, while C is more suitable for high performance and system programming. 1. Python syntax is concise and easy to learn, suitable for data processing and scientific computing. 2.C has complex syntax but excellent performance and is often used in game development and system programming.

It is feasible to invest two hours a day to learn Python. 1. Learn new knowledge: Learn new concepts in one hour, such as lists and dictionaries. 2. Practice and exercises: Use one hour to perform programming exercises, such as writing small programs. Through reasonable planning and perseverance, you can master the core concepts of Python in a short time.

Python is easier to learn and use, while C is more powerful but complex. 1. Python syntax is concise and suitable for beginners. Dynamic typing and automatic memory management make it easy to use, but may cause runtime errors. 2.C provides low-level control and advanced features, suitable for high-performance applications, but has a high learning threshold and requires manual memory and type safety management.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

Dreamweaver Mac version
Visual web development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function