2195 views|0 replies

1w

Posts

25

Resources
The OP
 

Python is terrible? Developers summarize 8 reasons [Copy link]

 A developer has published an article expressing the eight reasons why he thinks Python is not good. The author analyzes each "shortcoming" and the whole article is very lengthy. In summary, the eight reasons are: 1. Version incompatibility Python 3 is not fully compatible with Python 2. The author uses the Perl language and Commodore, which created the world's early personal computers, as examples to analyze how the lack of backward compatibility and separate versions led to failure. 2. Installation issues Running tools such as apt, yum, and rpm can obtain and install the latest code for most software packages, but when you use apt-get install python or pip install python to install Python, you don't know which version is actually installed, and this may be incompatible with the code you need. You need to specify the Python version during installation. 3. Indentation rules At first glance, Python code seems very readable, but this is not the case in large code bases. Python's four-grid indentation allows deep nesting, but too many layers of nesting will cause the code to wrap in the text editor and become messy. Long functions and long conditional operations may make it difficult to match the beginning and end of the syntax. This brings great difficulties to debugging. 4. Code import method Python's import method import allows the introduction of an entire module, part of a module, or a specific function in a module. The author believes that Python's import rules make it unintuitive to find an importable list. In C, you can directly view the .h header file, but Python needs to use python -v to list the location of the reference, and then search every file in each directory and subdirectory in the list. In addition, Python's import mechanism also allows users to rename imported code. The author believes that renaming modules is very suitable for small scripts, but it is really bad for long programs because it affects the readability and long-term support of the code. What's worse is that for most languages, importing code is just importing code. If there is a global object with a constructor, some languages will execute the code, but this is generally considered a bad practice. Many Python modules run initialization functions during import, which makes it unclear what is running and what it is doing, and it takes a lot of time to track. 5. Nomenclature The author believes that Python does not use common and professional terms to describe the language itself. For example, in all other languages, arrays are called arrays, but in Python, they are called lists; associative arrays are sometimes called hashes (Perl), but Python calls them dictionaries. The same is true for the naming of code libraries. Libraries like PyPy, PyPi, NumPy, SciPy, SymPy, PyGtk, Pyglet and PyGame sometimes put the "Py" at the beginning and sometimes at the end of their names. Some common libraries like matplotlib, nose, Pillow and SQLAlchemy even directly abandon the naming convention of "Py". The author describes Python as "a collection of libraries with terrible and inconsistent naming conventions." 6. Quirks Every language has its own quirks, but Python has more than any other language. Take string operations as an example. In Python, there is no difference between single quotes and double quotes. However, if you want the string to span lines, you need to use triple quotes """string""" or ```string```; if you want to use binary files, you need to use b'binary' or r'raw'; sometimes you need to convert the string to a string using str(string) or convert it to utf8 using string.encode('utf-8'). 7. Pass variables by object reference Most programming languages pass function parameters by value, but Python executes functions using pass-by-object-reference parameters by default, which means that changing the source variable may change the reference value. This is one of the major differences between procedures, functions, and object-oriented programming languages. If each variable is passed by object reference, and any change to the variable changes the reference everywhere, then global variables can be used directly to handle all variables. But the disadvantages of global variables are obvious to all. 8. Local name gcc -o screencapture.exe screencapture.c -lscreencapture If you are testing a screen capture program using a C library called "libscreencapture.so", you can call your own program "screencapture.c" and compile it into "screencapture.exe". But this is not possible in Python. Python assumes that you are importing local code first, so if you have a program called "screencapture.py" that uses "import screencapture", it will import itself instead of the system library. The author finally said that he usually comments on something dialectically. He thinks Python does have some good libraries, such as BeautifulSoup, NumPy, and TensorFlow, but he really can't list other good aspects about Python because he really thinks Python is terrible. Original text: https://www.hackerfactor.com/blog/index.php?/archives/825-8-Reasons-Python-Sucks.html
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list