Python’s Comeback is no Mistake

Since the advent of nodeJS, you may have experienced something called *Javascript-fatigue*: the natural exhaustion one feels in response to the influx of new Javascript modules and developers putting Javascript everywhere – your phone, your car, your toaster – instead of just the web. For a while, it seemed that Javascript would eat the world.

However, over the past few years, an underdog has silently established itself as a cogent solution in both mainstream and niche spaces. Not only has it proved its mettle seemingly overnight, developers are adopting it *fast*.

Enter Python. A dynamic, strongly-typed programming language with a well-deserved reputation of having a beautifully concise, yet expressive, syntax. One might even say that Python code *is* executable pseudocode.

Python’s popularity has exploded in a relatively short timespan. A myriad of reasons exist that can easily explain this upsurge in adoption, all of which go far beyond the simple fact that snakes are cool.

Ease of Use

Rapid prototyping and development are arguably Python’s mainstay. Boilerplate and cruft that are all too familiar in Java development Need Not Apply: Python doesn’t want or need it. This is a language that aids, and doesn’t hinder, a developer’s ability to actualize their billion dollar ideas in code.

Like many other dynamic scripting languages, Python takes care of low-level details that a developer might handle on their own in another language.

Python manages memory automatically and includes a garbage collector to that end. No more having to be mindful of the call-stack, heap, or issuing malloc() and free() appropriately when writing code! Forget worrying about buffer overflows, Python shields the developer from the mindless minutiae that enable this class of exploits.

The language doesn’t require explicit typing, yet it maintains a strongly-typed runtime which ensures that this won’t happen in your Python project:

Whoa there! Behind the scenes Javascript coerced a numeric type into a string so that it could be concatenated with another string.

Let’s see what happens in PHP.

Strange. In this case, the string "1" was type-coerced into an int so that it could be added to the trailing numerical 1.

Truthfully, unexpected results are scary. I would hope that the runtime would catch such a programmer error so that it doesn’t go unnoticed.

Ease of development is further aided by Python’s rich ecosystem of modules split between its standard library and 3rd party add-ons. That means you won’t have to *roll your own* implementation of commonly used code.

Take a look at this example, where we print a string to stdout in Java.

There’s an absurd amount of boilerplate for what is a simple task.

Now, look at how easy it is to accomplish the same thing in Python.

It’s exceedingly clear why a developer, novice or expert, might favor Python over more verbose languages.

The Numbers Guys and Academics are Getting Their Hands Dirty with Python, Too

Python’s lavish ecosystem can almost ensure that [*there’s a module for that*](https://xkcd.com/353/). This rich repository of Python libraries has proven to be invaluable in finance, bioinformatics, data science and analytics, machine learning and academia.

Libraries like pandas, NumPy, sciKit.learn, TensorFlow and matplotlib are worthy competition to former industry staples, such as MatLab and R. Combined with Python’s easy to learn (and to love!) syntax, these modules have enabled an era of rapid data processing for researchers, quants and other analysts.

As an interpreted language with a Global Interpreter Lock (GIL), Python can be slow at times. Brilliant mitigation solutions exist to address this problem: both a C extension interface and a C foreign function interface are provided in the Python standard distribution.

If code *must* run close to the metal for performance reasons, the C extension interface can be used to write importable Python modules in C/C++. For existing software written in C/C++, Python allows developers to load foreign libraries and call them within Python code. If you have a masochistic streak, C extensions allow you to sidestep the GIL (but why do that when multiprocessing exists in the standard library?).

The C extension interface enables powerful scientific computing packages like NumPy to crunch data so quickly that it leaves native Python code in the dust.

Python Rules the Web

While Python dominates at data analysis, it’s also a great choice for building web applications. Frameworks like Django and Flask are battle-hardened competitors to Ruby on Rails or Laravel in PHP-land. Instagram, Pinterest and The Washington Times wield the power of Python frameworks to run their massively popular web applications.

With cloud computing, running and scaling Python web applications is easier than ever. Today, you can automatically throw more memory, processing power or nodes at a resource-intensive Python application in a cost-effective manner.

Python Responds to Developer Demand

Single-threaded, asynchronous programming has made a comeback with the popularity of nodeJS and its impressive speed benchmarks. Due to the flexibility Python provides, it too, can take advantage of node’s tight event loop, libuv. Even using Python’s native event loop, asynchronous web servers [are pretty darn fast](https://klen.github.io/py-frameworks-bench/).

Remember the Global Interpreter Lock? While threading in Python might be constrained by the GIL, the asynchronous programming model in Python works with it through cooperative multitasking. Within the async model, there’s no need to sidestep the GIL and no need to worry about [common multithreading pitfalls](https://austingwalters.com/multithreading-common-pitfalls/).

In Python 3.5, [a new syntax for async programming was implemented](https://www.python.org/dev/peps/pep-0492/) in yet another step towards prioritizing developer convenience.

Python is Ubiquitous

Python code doesn’t just run in the cloud. Not only is Python portable and extensible, it is embeddable. Python powers Internet of Things (IoT) hubs and devices. MicroPython has even found its way onto low-powered microcontrollers.

Conclusion

Data intensive fields have exploded recently, and with it, so has Python adoption. Python’s portable, extensible and embeddable qualities make it a great choice for almost all development platforms. The language’s ecosystem and ease of use attract developers from all walks of life. Finally, Python’s developers make sure the 20+ year old language stays relevant and continues to meet developer needs.