preface

I’ve been learning Python and machine learning and deep learning. But why on earth Python is chosen as the preferred language for artificial intelligence among so many programming languages is unknown to me. Today, LET’s comb through it with my understanding. First of all, I will not go into the past and present of Python, but the relationship between Python and artificial intelligence.

First, start with artificial intelligence

First of all, the rise of the topic of ARTIFICIAL intelligence started with a science and technology news that triggered a national frenzy. From 2016 to 2017, AlphaGo, the GO AI program developed by Google, beat Fan Hui, the European champion, Lee Se-dol, the South Korean nine-dan go player, and Ke Jie, the world go champion, to reach the top of the earth. It was exactly 20 years since Deep Blue had swept human players in chess. A few months later, AlphaGo Zero, an upgraded version of AlphaGo, came back and defeated AlphaGo Lee, who had beaten Ke Sedol, after only 3 days of self-training. After 40 days of training, AlphaGo Master, who had beaten Ke Jie, was not prepared. Go, which is considered to be the FIG leaf of human wisdom, was pressed to the ground by the machine and rubbed hard, which completely triggered the carnival of public opinion. At this time, many people say the age of artificial intelligence is coming again…

In what is said above is a application in the field of artificial intelligence in the game, but the application of artificial intelligence and there are many, such as computer vision, speech recognition, unmanned, natural language processing, recommendation system, etc., in the following, we focus on something about our core topic of this article: why Python become the preferred language of artificial intelligence.

Is Python the programming language of choice for AI?

First of all, we need to understand that ai relies on C or C++ for all of its core algorithms. These algorithms are very complex and computation-intensive tasks that need to squeeze every ounce of performance out of hardware. Python’s performance is a pity. Java’s performance has always been criticized. Python is even worse than Java. Python plays more of a tool role in artificial intelligence, deep learning and other fields, which is to play a front-end or “vase” role. Although Python is not fast, it is easy to learn, easy to use and easy to tear down. You only need to use Python to do visualization, call the Api interface, and write the logic of the presentation layer. Ai is still in the artificial retardation stage, and building a prototype that can be called and iterated quickly is more important than anything else. For those who specialize in research and algorithms and don’t have a programming language to work with, Python is a quick way to get started with the lowest learning cost.

Why not learn another low-cost programming language?

  1. Python’s early advantages, especially in the field of data analysis related to artificial intelligence (AI), were significant. Some popular data analysis frameworks, such as Numpy and Pandas, were written by Python.

  2. Big Internet companies like Google and FaceBook are also big fans of Python, both of which are pioneers in ARTIFICIAL intelligence. Google has released its deep learning framework TensorFlow, FaceBook’s machine learning library PyTorch, Both have Python on the shoulder;

  3. The penetration of Python academic circle and scientific research circle is far from that of other languages. If you don’t learn Python, which is easy to learn, why should you learn C++? Doctor is also a human being, and persimsiman will also pick soft ones.

  4. In the United States, the Trump and Obama administrations also spent a lot of money to promote computer education;

  5. Hammering requires hard work, and Python has its own unique advantages:

  1. Python is designed to be “elegant,” “unambiguous,” and “simple.” So Python programs always look simple and easy to understand.
  2. Development efficiency is very high, Python has a very powerful third-party library, basically you want to achieve any function through the computer, Python official library has the corresponding module for support, directly download and call, on the basis of the basic library to develop, greatly reduce the development cycle, avoid repeating the wheel.
  3. High level languages ———— When you write programs in Python, you don’t have to worry about low-level details like how to manage the memory your programs use
  4. Portability ———— Due to its open source nature, Python has been ported to many platforms (with modifications to make it work on different platforms). If you are careful to avoid using system-dependent features, all of your Python programs will run without modification on almost any system platform on the market
  5. Extensibility ———— If you need a key piece of your code to run faster or want some algorithms to remain private, you can write parts of your program in C or C++ and use them in your Python program.
  6. Embeddability ———— You can embed Python in your C/C++ programs to provide scripting functionality to users of your programs.

Other supplements

Python in some companies:

  • Google: Projects like Google App Engine, code.google.com, Google Earth, Google Crawlers, Google Ads, and more are all heavily developed in Python
  • CIA: The CIA website was developed in Python
  • NASA: NASA makes extensive use of Python for data analysis and computation
  • YouTube: YouTube, the world’s largest video site, was developed in Python
  • Dropbox handles 1 billion file uploads and downloads a day
  • Instagram is the largest photo-sharing social network in the US. Over 30 million photos are shared every day, all developed in Python
  • Facebook: A lot of the base libraries are implemented in Python
  • Redhat: The YUM package management tool in the world’s most popular Linux distributions is developed in Python
  • Douban: Almost all of our business is developed in Python
  • Zhihu: The largest Q&A community in China, developed by Python (Quora abroad)
  • Chunyu Doctor: The famous online medical website in China is developed with Python

In addition to the above, there are sohu, Kingsoft, Tencent, Shanda, netease, Baidu, Ali, Taobao, Tudou, Sina, Guoku and other companies using Python to complete a variety of tasks.

Disadvantages of Python:

  1. Slow, Python’s running speed is much slower than C, compared to the JAVA also slower, so this is also a lot of the so-called Daniel above the main reason for using the Python, but here refers to the speed slow, in most cases, the user is not directly perceived, must use testing tools to reflect, For example, if you run a program in C, it takes 0.1 seconds, but in Python it takes 0.01 seconds. So C is 10 seconds faster than Python. For the most part, Python will do the job you want, unless you’re writing a search engine that requires a lot of speed, in which case C is recommended.
  2. The code can’t be encrypted because PYTHON is an interpreted language and its source code is stored in nominal form, but I don’t think this is a disadvantage. If your project requires the source code to be encrypted, you shouldn’t do it in PYTHON in the first place.
  3. One of Python’s most criticized shortcomings is that threads cannot take advantage of multiple cpus. The Global Interpreter Lock is a tool used by computer programming language interpreters to synchronize threads so that only one thread is executing at any one time. Python threads are native to the operating system. Pthread on Linux and Win Thread on Windows. The operating system schedules the execution of threads. A Python interpreter process has one main thread and multiple threads of execution for user programs. Even on multi-core CPU platforms, parallel execution of multiple threads is prohibited due to the presence of a GIL. A compromise solution to this problem will be explored in more detail in the threads and processes section.