Python: After more than ten years, haven't you cleared up the misunderstanding of me?

Summary:

After graduating from college, the most used programming languages ​​are C and C++. Later, I learned Python, and I feel that Python is a language that I don’t regret learning. It is especially suitable for non-programmers to learn. As the first language for teenagers to learn computers, it is also good for college students to use Python language as an introduction to learning computers. As a software engineer, I feel that the combination of C+Python+HTML5+JavaScript is acceptable. There have always been some misunderstandings about the Python language. After sorting out the online materials, it is just for the fun of my own learning, and it can be regarded as encouraging myself.

Note:

I don’t want to discuss the advantages of programming languages ​​here, because programmers are serious, and discussions about programming languages ​​will definitely become lively. . , PHP is the best language in the world and so on.

To practice martial arts, you need to practice both moves and internal skills. Don't be too serious about discussing programming languages, just choose the right language to solve your own problems.

Figure: Linus Benedict Torvalds, the father of Linux

Python is a new language:

The large-scale popularity of the Python language in China mainly started around 2014, which can also be seen from a certain girl's search index.

Figure: Search Index Trends for Several Programming Languages

As can be seen from the figure, before 2014, Python’s domestic search index was very low, and after 2014, it gradually increased, and by 2017 it surpassed the leader Java. But don't think that Python is newly popular and think that Python is a new language. In fact, anyone who knows the history of Python must know that Python was born in 1989 and released its first version in 1991, which is 4 years older than Java. A well-known early use of Python is Google's first successful web crawler in 1996. And Java is more grassroots than Python, has been practicing silently, and finally blooms late. So many people like to show that Python still has its own advantages.

Python is an interpreted language and is not compiled:

Python does not need to be compiled into executable programs like C and C++, but it is more like Java, which compiles source code into its own bytecode. Bytecode has an interpreter (what Java calls a virtual machine) to handle the execution. Python and Java are completely open source, not controlled by a big organization, and there are more interpreters, such as: CPython, PyPy, Jython/JVM, IronPython/CLR, etc.

Python is a scripting language, not an independent development language:

Python is indeed an object-oriented scripting language and one of the forerunners in this field. Because of its simple syntax, it supports cross-platform, and it is ubiquitous in Linux, Macs and other Unix machines. Especially in terms of automated operation and maintenance, the Python language is definitely the first choice. At present, automated testing has also begun to choose more Python language.

However, because of its power in this aspect, the characteristics of Python as an independent programming language cannot be ignored. In fact, Python may be one of the most flexible and powerful development languages ​​among general-purpose programming languages. Some examples are given below:

1. Telephony Infrastructure (Twilio)

2. Payment system (PayPal, Balanced Payments)

3. Neuroscience and Psychology (many examples)

4. Numerical analysis and engineering (numpy, numba and many other examples)

5. Animation (LucasArts, Disney, Dreamworks)

6. Game backend (Eve Online, Second Life, Battlefield and many other examples)

7. Email infrastructure (Mailman, Mailgun)

8. Media storage and processing (YouTube, Instagram, Dropbox)

9. Operations and systems management (Rackspace, OpenStack)

10. Natural Language Processing (NLTK)

11. Machine Learning and Computer Vision (scikit-learn, Orange, SimpleCV)

12. Security and penetration testing (DNSRecon, patator, XSSer, too many, including eBay/Paypal/)

13. Big data (Disco, Hadoop support)

14.日历(Calendar Server, which powers Apple iCal)

15. Search systems (ITA, Ultraseek, and Google)

16. Internet Infrastructure (DNS) (BIND 10)

17. Cloud computing platform (OpenStack)

18. Crawler framework (Scrapy, scrapy-redis)

19. WEB architecture (Django, Flask, Tornado)

20. Debugging and reverse engineering (many not listed here)

Other examples are numerous and can be searched through the Internet. At present, there is no problem with Python as the main development language, and it can be used as the first language for beginners.

Python is a weakly typed language:

An obvious feature of Python is that variables are dynamically typed, which does not affect Python as a strongly typed language. In a sense, Python has a stronger type system than Java. Java's primitives and objects have their own type systems, and Null exists in a kind of gray area.

On the other hand, Python has a unified strong type system, and the type None is well defined.

Regarding the type system of Python, you also need to pay attention to it in the application and handle it carefully, otherwise it will bring trouble.

Python is not safe:

Python is an interpreted language. Usually, software is released in the form of source code, so it is considered that the code confidentiality and security are not good. As I said earlier, Python supports compilation. In fact, Python can be a mixed type of compilation + interpretation.

In addition, security can not rely on the code in the compiled state, and more importantly, make the runtime environment more secure. Because essentially every language has a disassembler or can be cracked, which destroys the protection state of the program, security cannot depend on compilation alone.

A core tenet of security is to render the target as small as possible. CPython solves these problems with a simple, stable and easily auditable virtual machine. In fact, CPython received the highest quality rating in a recent analysis by Coverity Software.

Python also has a wide range of open-source, industry-standard security libraries. Combining hashlib, PyCrypto and OpenSSL, through PyOpenSSL, some processing can be used to meet various security and performance needs.

According to public information, there are many examples of security applications using Python in the application security group of PayPal (eBay):

1. Creation of security agents to facilitate key permutation and harden encryption implementations

2. Integrate industry-leading HSM technology

3. Build Transport Layer Security based wrapper proxies for incompatible stacks

4. Generate keys and certificates for our internal two-way authentication mechanism

5. Develop proactive vulnerability scanners

Domestic BATJ companies also use Python extensively for development. In addition, many operation-oriented systems built with Python contain security features, such as firewalls and connection management.

Python lacks good concurrency support:

When it comes to Python, you will definitely mention Python's GIL (Global Interpreter Lock), and you will definitely question "Python's lack of concurrency". This is really hard to say. Just look at it simply.

Python has a large number of concurrency primitives, including generators, greenlets, Deferreds and futures. Python has a lot of concurrency frameworks, including eventlet, gevent, pulsar, toro, offset and Twisted.

A lot of work has gone into customizing runtimes for concurrency, including Stackless and PyPy. All of these, and many more cases show that concurrent programming can be done effectively with Python. These enterprise-level products are officially supported and used.

The global interpreter lock GIL is a performance optimization in most use cases of Python and an ease-of-use optimization for CPython code in development. The GIL makes it easier to use the operating system's threads or green threads without affecting the use of multiple processes.

A large amount of server-side software is currently developed in Python, and we also see Python servers have millions of requests per machine per day, but they can all be handled with ease. So it cannot be said that Python lacks concurrent distribution support.

Python is not suitable for big projects:

One of the main features of Python is its extremely high development efficiency, and the Python project team can complete larger projects with a small number of developers. Instagram hits billions of hits per day and billions of dollars, and the entire company is still just a team of dozens of people. Dropbox had only 70 engineers in 2011, and other Python teams are similarly small. At the same time, it also brings a question, Python can't do big projects, and can't form a team. Are Instagram, Dropbox considered small projects?

Looking at a few examples, Bank of America actually has over 5,000 Python developers, and a single Python project has over 10 million lines of Python code. JPMorgan has gone through a similar transition. YouTube also has thousands of engineers and millions of lines of code. Big products and big teams use Python every day, and they have excellent modularity and encapsulation characteristics, beyond a certain point, the general development scale remains largely unchanged. Tools, strong conventions, and code reviews make large projects manageable.

Any language will encounter problems when writing large projects, and you can't rely on language constraints alone. Reasonable and strict specifications should be followed to develop good programming literacy. For example, it can support the PEP8 specification. Before submitting the code, we use PyFlakes and other tools to perform static analysis of Python code, etc.

In fact, Python not only has high development efficiency, but also makes it easier to develop efficient and stable software.

Python does not scale:

This is not vague, the Python language itself is extensible, and Python can also develop extensible software. Developed in Python, YouTube is an extensible website. There are more than 1 billion unique visitors every month, more than 100 hours of video uploads per minute, occupying 20% ​​of the peak Internet bandwidth, all of which use Python as the core technology. Dropbox, Disqus, Eventbrite, RedTwilio, Instagram, Yelp, EVEOnline, Second Life, eBay, and PayPal are examples of how Python scales well.

Simplicity and consistency are the keys to success. CPython, the basic Python virtual machine, maximizes these features while also making runtime predictable. It's hard to see Python programmers paying attention to garbage collection aborts or application startup time. With strong platform and network support, Python naturally adapts to intelligent horizontal scalability, mainly manifested in systems like BitTorrent.

Two more questions:

These two cannot be regarded as misunderstandings, they can be said to be facts.

1. Python runs slowly

As an interpreted language, Python is usually understood that it is not as fast as compiled languages ​​such as C and C++. However, the Python language is slower than Java, which is open to question. This problem can be viewed from the following aspects. Language is only a factor, and it is sometimes not appropriate to evaluate the speed and slowness of a language alone. An application should be evaluated, preferably for a specific use case. For example, in Java, Python also implements a software for evaluation. Since Python can call each other well with C and C++, C and C++ can be used for extensions where performance is really needed, and Python is used where coding efficiency needs to be improved. The overall software written in this way may be faster than Java. There are also some optimized Python interpreters, such as: PyPy's JIT compiler achieves faster performance than C language. There are also many Python applications on the server side, and the running speed is also a bottleneck compared to the network throughput. From the perspective of existing software, the running speed of Python is not the biggest problem. The number of users of Disqus has increased from 250 million to 500 million, and they have always used the same of 100 servers. Increasing the software iteration speed is also a factor to consider. Python has put developers' development efficiency first from the beginning of its design. As a rule of thumb, Python projects will have more iterations than C++ or Java projects in the same amount of time.

2. Python programmers are scarce

Python became popular relatively late, and before Python was usually used as a second language for an engineer, it is a fact that the number of Python development engineers is small.

Python doesn't have as many web developers as PHP and Java. This may be due to the linkage between industry demand and education, but education trends suggest that this is likely to change.

The high efficiency of Python development enables a small team to complete an efficient and powerful software development project using Python development. This is also a factor.

From another point of view, the small number of Python practitioners is also relative, and the absolute number of Python practitioners is also quite large. There are millions of Python developers worldwide, dozens of Python conferences, tens of thousands of Python-related questions on StackOveflow, and companies such as YouTube, Bank of America, and LucasArts/Dreamworks employ thousands of Python developers personnel.

A new project or startup prefers to choose Python for the following reasons:

Python is very easy to learn and is the programming language of choice for kids, college students, and working professionals. For a new Python programmer, it only takes a week to see first results, often 2 to 3 months, and the Internet is rich in interactive tutorials, books, documentation and open source code bases , making this possible.

The number of Python development engineer jobs has surged in recent years. The salary of the employees is not bad, so there must be a large number of beginners entering the market, and it is inevitable that the average salary will be lowered. There are risks in the business, and you need to be cautious when entering the industry.

Figure: Bruce Eckel's original words are "Life is short, you need Python"

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325205267&siteId=291194637