DEV Community

Cover image for Why Use Python for Web Development? Pros, Cons, and Business Benefits
Adam Przewoźny for STX Next

Posted on • Originally published at stxnext.com

Why Use Python for Web Development? Pros, Cons, and Business Benefits

Originally written by Piotr Podgórski and Michał Słupski

What comes to your mind when you think of web development?

Is it a simple business website? Is it a personal blog? Is it a social media giant like Facebook? Maybe it’s all of these things?

Web development is nothing else than software on the web. It can be anything, just as long as you can reach it through a web browser (or a command-line interface).

When it comes to commercial software, web development might mean applications for CRM or ERP, sometimes a company might want a custom CMS. The most popular use case in web development has to be a business website with a blog. There are so many great technologies out there for building these things.

So, why should you choose Python for your web projects? When does it make sense to do so? You’re in the right place to find out all of these things, so keep reading.

Why choose Python for web development projects?

Here’s a list of arguments in favor of using Python for web development:

Python is mature and secure

Python has been around since the ‘90s. That’s almost 30 years of constant improvement led—until recently—by Python’s original creator Guido van Rossum.

Mature, stable technologies might be boring for some developers, but they work. An experienced Python programmer knows exactly what the strong and weak parts of the language are. There’s no need to reinvent the wheel or get creative, developers can easily find solutions to common issues.

This comes in handy especially when you need your web application to be as secure as possible. Python is often used in fintech because it’s great for dealing with large amounts of data, and it’s relatively easy (for a senior developer) to make an airtight app with military-grade security.

There’s a Python library for everything

Do you need beautiful plots on your website? Developers can employ Matplotlib to take care of generating them.

Maybe you need machine learning capabilities in your web app? There’s TensorFlow, the world’s most popular ML library.

Or, something more specific, do you need the power of SQL but with Python code? There’s SQLAlchemy, with only 25,000,000 downloads per month, no biggie. It’s a library that gives you the power of tried-and-tested enterprise development patterns for quick and simple database access using Python.

The Python Package Index has over 300,000 projects. They range from tiny libraries to large, complex tools. There’s a library for everything, including many niche web development use cases.

We need a separate point for one of these tools, Python’s secret weapon for web development: Django.

Python has Django

Django is the main web development framework for Python. It’s a very useful collection of libraries that come together to form a very flexible, powerful, comprehensive platform for building any type of web application. Oh, and it’s used by Instagram among many other major internet companies.

It does exactly what a great framework should do: it takes away the pain of building and gluing together all the parts necessary to form a web server. Developers can focus on creatively demanding tasks rather than low-impact, basic issues.

Plus, if somebody really doesn’t like Django but wants a Python web dev framework, there’s still Flask, which is kind of a polar opposite of Django. It’s a microframework, so it comes with much fewer ready-made parts than Django, but it’s more flexible.

From a business point of view, the main difference between Django and Flask is risk management—Django can cover more use cases out of the box, so it saves you time, whereas it will take more time to adapt Flask to changing requirements.

There are a lot of Python developers

It’s the second most popular general-purpose programming language, less popular than JavaScript and two other fundamental web technologies—HTML/CSS and SQL—as shown in the 2020 Stack Overflow survey.

2020 Stack Overflow Developer SurveySource: 2020 Stack Overflow Developer Survey

However, this doesn’t mean that all developers who picked Python in the survey are senior developers whose main tool of choice is Python. Building a web backend with Python is a very common use case, but a lot of developers use Python in their everyday work in other ways, for things like:

  • automating processes like web scraping or data segmentation,

  • gluing together different APIs and components built with various technologies,

  • visualizing data.

And then there’s AI and machine learning. Python truly reigns supreme in this area. It’s currently the main language used for AI and ML, while experts say it will continue to dominate.

Given that AI/ML is currently one of the hottest, if not the single hottest thing to do in computer science, it’s a big contributor to Python’s popularity.

This popularity results in a large number of Python developers with professional experience. For you, this means that it should be much easier to hire Python developers for your team than, for example, C++ developers.

When does it make sense to use Python for web development?

You might say, “That’s all great, but you still haven’t told me if Python is the right fit for my project.”

For starters, it’s impossible to say for sure without taking a close look at your project. However, there are a few general facts about Python that will give you an idea if it’s the right choice for your tech stack:

You need great development and/or execution speed

As it usually happens, some developers will tell you that Python is great for performance, others will give you 10 reasons why it isn’t. Our Solutions Architect, Piotr Podgórski, is here to tell you not to worry too much about performance:

“Selecting tech for speed of execution, rather than speed of development, is a rookie mistake. Python is a very good language to build and iterate quickly. Performance is important, but responding to changing needs even more so. Plus, with good architecture, you can always find and optimize bottlenecks.”

—Piotr Podgórski, Solutions Architect

That’s not all. The opinion that Python makes it hard to achieve fast performance is simply not true.

The myth comes from CPython, the default implementation of Python. By itself, CPython is indeed slow and eats up resources like every day is cheat day—but this is a solvable problem! We can optimize it, employ a special architecture, or use tools like asyncio, PyPy, and Cython to improve performance.

What’s more, after a failed attempt to retire, Guido van Rossum (Python’s original creator) is working on Python again—this time at Microsoft. His main goal is to turbocharge CPython to make it faster than ever, so the performance will only keep getting better.

You want to find developers quickly

Junior Python programmers can do web development with great results. You don’t have to be worried about junior Pythonistas building your next web app, even if there’s money on the line—there are projects in our portfolio that are proof of this.

Which is great, because finding junior Python developers is relatively easy compared to most programming languages. As a matter of fact, Python seniors are a little easier to find, too—although remember that, in this industry, “a little easier” doesn’t mean it’s simple. There’s just a wider talent pool available than with less popular languages.

If you need to build a team quickly, start development as fast as possible, and make sure you reach the MVP stage quickly—Python is a great choice.

Complex data is the core of your business

Fintech and medtech come to mind as the most prominent examples of industries that are perfect for Python.

Large amounts of data, visualizations, analyses, the need to predict things, the need for AI because the problems are too complex for humans to do efficiently, the often devastating consequences of bad decisions—finance and healthcare have it all.

Of course, they’re not the only industries with huge amounts of data and a lot of risks. If you’re wondering whether Python is right for your project, consider the data at the core of your business model.

If it’s as complex as in finance or healthcare, then Python might be a great choice either as the main technology or in a supportive role.

Summary: Python and web development have a complicated relationship, but they’re a great fit at the end of the day

The simple truth is this: Python wasn’t built only with web development in mind. But this coin has two sides, as Piotr can tell us:

“It’s true that Python wasn’t built specifically for web development, but that’s a good thing. This is exactly what makes Python so nice to program with and so versatile. It has its flaws, but it was designed to be a general-purpose, pleasant-to-use language. Web-first technologies, like PHP and JavaScript, started their lives as hacks and while their design has improved, there are remnants of that history.”

—Piotr Podgórski, Solutions Architect

Python is a simple, powerful, and well-designed language. It’s mature and actively developed in a sensible direction, as it has been for decades. The choice of frameworks isn’t overwhelming (as it is in case of JavaScript, where they were necessary for cross-browser support at one time) and you can create a sensible, reliable toolbox without worrying you’re not using the latest tech.

So, ultimately, Python is a great choice for web development.

Final thoughts on using Python for web development

We gladly use Python for web development at STX Next. It’s versatile, and in the hands of our team, Python code can be molded into almost any type of web application.

In the world of software development, there are a lot of opinions and stereotypes. If you ask 10 different developers or CTOs, they’ll each paint a unique picture of how Python does or doesn’t work for web development.

However, the consensus seems clear. While JavaScript is here to stay due to its monopoly in the browser and promising technologies emerge every day, Python has only been gaining momentum. In 2005, we decided to build our future on Python, and we believe you can build yours on it, too.

If you wish to learn more about Python, head over here:

Top comments (0)