Python Still Rules After 30 Years

By Stephen Cassar

CTO / Chief System Architect

Mouser Electronics

March 08, 2021

Story

Python Still Rules After 30 Years
(metamorworks/Shutterstock.com)

Initially created to program simple tasks, writing automation scripts, and rapidly prototyping apps, Python is a 30-year-old language growing in popularity. Here, we’ll explore Python’s strengths and weaknesses, how to get started, and the resources available to Python developers.

Python turns 30-years-old this year, but you wouldn’t know it. According to a 2019 Stack Overflow Survey, the high-level dynamic programming language is still the fastest-growing major programming language, edging out Java, and is the most-wanted language of artificial-intelligence developers. In January 2021, Python won TIOBE’s most popular programming language of the year award for a record fourth time. The award goes to the programming language that has gained the most popularity in one year.

That begs the question: Why do so many developers prefer to use an ancient language when they can choose from more than 500, with more being written each year? The answer might lie in Python’s simplicity.

Many languages promise a short, flat learning curve, but developers today demand more flexibility. As they experiment with different stacks and technologies, they quickly realize that Python does almost everything they need with less effort. This is partly because of how easy it is to use compared to other languages. A fledgling developer can build and run a simple Hello World Python application in minutes. But what typically seals the deal is the language’s built-in flexibility that supports multiple programming paradigms and enables development using considerably less effort.

From humble beginnings as a tool to facilitate programming of simple tasks, automating scripts, and rapid app-prototyping, Python has risen to the status of first-class language. For example, Instagram recently doubled down on the language, choosing to upgrade its core stack to Python 3 in three phases over 10 months, even though parent company Facebook relies heavily on PHP: Hypertext Preprocessor (PHP) for its core architecture. After analysis, Instagram simply determined that PHP did not offer significant advantages in performance, especially as each new version of the language continues to get faster. It could also be that Python’s AI and machine-learning prowess was a consideration.

Microsoft also seems to recognize the importance of Python. On Nov. 12, 2020, Guido Van Rossum, the Dutch programmer who created Python, announced that he was coming out of retirement to join the Developer Division at Microsoft. Other companies that rely on Python include Amazon, Industrial Light and Magic, Netflix, Reddit, Google, and Spotify. With heavy-hitters such as these fueling demand for Python developers globally, it’s not going away anytime soon, so it makes sense for every developer to consider adding Python to the arsenal.

A Simple Solution for a Complex World

It’s not unheard of for development teams to attempt to build complex systems with the latest technology only to abandon their efforts midway and return to simpler programming languages such as C++ or Python. Sometimes, what is called for is a big diesel engine instead of a dual-turbo 4-cylinder with all the bells and whistles, and if you can figure this out in the planning stages, it can save everyone involved a lot of heartache, time, and money.

The rise in AI has seen developers harnessing Python’s potential for data science, data analysis, and more. Python’s subsets, machine learning and deep learning (DL), are great examples of how the simplest of languages can solve problems that did not exist when the program was first created.

The smart developer finds the simplest solution to each problem, regardless of how complex it might first seem.

(Figure 1: Programming Example. (Source: MIKHAIL GRACHIKOV/Shutterstock.com))

Amazon took this approach and placed its bet on Python’s ML prowess, choosing it for the core of its DeepLens device library. Python saw a genuine need to simplify ML tasks that typically require the implementation of high-dimensional data and manual processes.

Python’s power has greatly simplified tasks such as image recognition, feature extraction, and object detection. This enabled the AWS DeepLens project to use neural networks to learn and make predictions through computer vision projects, tutorials, and hands-on exploration using physical devices developers can touch and feel, such as the AWS DeepLens Camera.

The device library for AWS DeepLens consists of a diverse set of Python modules that expose objects and various device operations methods. The result is that deep-learning models can be run locally on a camera to analyze and take action on what it sees. Pick up one of these cameras and explore the modules even if you never plan to use the platform in production. Experimenting with tools such as this is what helps developers hone their craft.

(Figure 2: Python-based AWS DeepLens allows developers to prototype machine-learning applications using a special camera quickly. (Source: metamorworks/Shutterstock.com))

Why Does Python Excel?

Python is ideal for data analysis and numbers crunching, which explains why most libraries involved in ML, and data science have a Python interface. But Python is far more than a great way to get started in these disciplines. Developers can choose to adopt the paradigm that best suits their needs: functional, imperative, object-oriented, structured, or reflective. Python supports all five.

Python is at its best when simplifying complexities. For example, when crunching numbers, Python is adept at extremely fast and can use complex math. It also has simple syntax to implement such basic computations as the addition of two strings, all the way to building an ML model with its inherent complexities.

Simple also means users write less code. Python supports predefined packages, practically eliminating algorithm coding. For the code that is needed, understanding, changing, copying, and sharing is greatly simplified. This has helped the Python community of developers thrive with a free and efficient exchange of algorithms, ideas, and tools amongst them.

Python is flexible. Python offers an option to choose either object-oriented programming (OOP) or scripting, and it runs on multiple platforms, including Windows, macOS, Linux, and Unix. Porting code from one platform to another is accomplished with PyInstaller.

Python has a vast number of communities, groups, and forums where programmers help solve issues. Many resources are available for beginners and pros alike, so you’re never alone. Hundreds of prebuilt libraries are also available to implement ML and DL algorithms. And installing packages usually takes just a single command.

Free, easy, and open source, Python has made its way into some of the most complex technologies and is used by industry giants, developers, data scientists, ML engineers, and beginners alike.

Popular Python Libraries

A great language requires a great choice of libraries to thrive, which is one of the main reasons Python is the most popular programming language used for AI. Python library modules contain base-level items, eliminating the need to code them each time.

For example, NumPy helps manage multi-dimensional arrays efficiently and has a great random function. It also contains tools for integrating C/C++ and Fortran code. Pandas helps handle two-dimensional data tables in Python. Although SQL also does this, Pandas is a lot easier to execute in code. These two libraries alone will save developers hours.

Matplotlib, although not the easiest to use, will save developers approximately six code blocks for basic line charts and scatter plots that can be used repeatedly. The creation of charts, histograms, and plots for better data comprehension, effective presentation, and visualization can be done very quickly using Matplotlib.

Scikit-Learn is the first library any Python programmer should use for AI /ML. It handles regression methods, classification methods, and clustering, model validation, and model selection and makes dimensionality reduction and feature extraction a snap. Moving to the more advanced, Scipy (not to be confused with the Scipy stack) provides core mathematical methods for such complex machine-learning processes as integration, interpolation, and optimization. Scikit-Learn relies heavily on the Scipy Library, so move it to the top of the list.

Creating Quick, Clean Prototypes with Python

Creating prototypes typically involves hours of compiling, debugging, editing, recompiling, debugging ... You get the picture. Python is ideal for prototyping because it allows for writing and testing just a few lines of code without compiling or using Makefiles. It is high level, so low-level details such as memory management or garbage collection aren’t a concern.

Get started with a module and build from there. Many easy and well-documented Python modules exist. The language is so popular and users so plentiful that several people within a group can likely read your code and helps you get it to the finish line. Because your Python projects will also run on most platforms, developers won’t need to branch off code or maintain separate repos.

Python Tools Worth Exploring

Using libraries can help speed up development dramatically. Chances are, someone has already written the needed function. Developers can leverage Python’s inbuilt imaging library or the MayaVi and VTK 3D visualization toolkits for scientific and numeric applications. Or developers can consider ScientificPython and Numeric Python for numeric and scientific applications.

Chances are, a library is available to help developers fast track a project. Here is a list of five community favorites worth exploring.

  1. Selenium forms the core technology in countless browser automation tools, application programming interfaces (APIs), and frameworks. It automates web applications for testing. Selenium makes data-scraping projects easier and often reduces complex routines to just a handful of lines of code.

  2. Gooey enables turning Python command-line programs into full-fledged apps with graphical user interfaces using just a few lines of code making sharing tools much easier, regardless of skill level. Gooey also provides easy date and time input.

  3. Pyinstaller creates small, efficient, stand-alone executables using transport compression. It is multi-platform and greatly simplifies executable creation.

  4. PYNQ (Python Productivity for Zynq) exploits benefits of Xilinx devices in applications and eliminates the need to use ASIC-style design tools to design programmable logic circuits.

  5. Intel Distribution for Python accelerates Python and speeds up computational packages. It lets developers create and accelerate applications and services that scale, unlocking the power of modern hardware, and easily implement algorithms.

The Limitations of Python

To quote a system architect friend: “The perfect language for the project is the perfect language for the project.”

We’ve discussed Python’s many strengths, especially for number-crunching in the fields of data science and scripting. But no language is perfect for every application, and Python is no exception. Understanding Python’s limitations will help developers better determine whether it’s a good fit for their project. Python suffers in performance, app packaging, and project management to summarize its limitations. Other downsides include:

  • Python is a high-level language. Because it is further away from hardware than a lower-level language, it’s slower.

  • Python is not ideal for mobile development.

  • Python uses flexible data types, precluding its use for memory-intensive tasks.

  • High memory consumption.

  • Python’s database access layer is primitive. It is not a good choice for enterprises requiring smooth interaction of complex legacy data.

  • Because Python is dynamically typed, it requires more testing and has errors that only show up at runtime.

Although elegant workarounds are possible for each of these, Python is not usually the right choice for mobile development or enterprises that rely on reading and manipulating legacy data for mission-critical applications.

Getting Started with Your First Python Project

Getting started with any language takes time, and although Python is quite easy to pick up, it is recommended that beginners reference as many resources as possible. One learning resource to join is PythonistaCafe, a peer-to-peer learning community. This invite-only group offers a plethora of exercises, events, and meetups specifically for Python, all in one of the best-run environments to be found anywhere.

Be sure to check out projects trying to solve specific problems, too. Here is a short list of open-source projects to check out:

  • OpenCog is creating the Artificial General Intelligence (AGI) project with human capacities. It is used at the SingularityNET project and the Hanson Robotics project, delivering intelligence to Sophia and other robots.

  • Institute for Artificial Intelligence (part of the Faculty of Computer Science at the University of Bremen) researches AI and conducts workshops and events designed to advance AI technologies. They are committed to supporting existing AI-powered projects and education.

  • Zulip is dubbed the “world’s most productive team chat,” allowing for the processing of thousands of real-time messages daily. Zulip offers clear organization, asynchronous communication, and other great advantages for teams.

  • Magenta is a Python library and research project. Its goal is to enable the creation of music and art using AI. It can create images, songs, and even generate drawings, enabling artists to explore new ways of creating.

  • MailPile is an innovative email client focusing on safe and private communication. It’s fast, has no ads, and comes with a powerful search function, privacy, and encryption.

Summary

Developers learn new languages for three primary reasons:

  1. Because they have to: Perhaps a dev team you are working with has decided to build something in Python, or a job you are applying for needs Python-experienced devs.

  2. For fun: If you are bored or simply looking to experiment with AI, ML, or DL, Python will call your name.

  3. To solve a problem: Perhaps you have hit a brick wall with the language you are using for a project. Python might be something to try.

Whatever the reason, efforts in learning Python could pay off in either a new job, a new solution to a problem that has been taunting you, or the satisfaction of knowing you are one step closer to becoming a true polyglot.

Featured Companies

Mouser Electronics

1000 N Main Street
Mansfield, TX 76063

Stephen is often invited to advise Fortune 100 companies in overall Product Strategies and Architecture Design especially as it pertains to Workflow Management, eCommerce, Artificial Intelligence and Machine Learning, bringing with him an objective view of current processes and recommending small shifts in strategy that yield big long term results and immediate ROI. As CTO / Chief System Architect, Stephen brings an in-depth knowledge of successful Software-as-a-Service platforms.

More from Stephen