The beauty of using Python for your back-end
Tags: webdev, python, flask, fastapi
Published: 2023-05-01 08:15:36

Python is a versatile, high-level programming language that is widely used in web development, scientific computing, artificial intelligence, and data analysis. One of its strengths is its ability to serve as a backend language for web applications. In this article, we'll explore some of the reasons why Python should be your backend language of choice, then I will talk about my little expriences with Flask & FastApi.

## Why Python should be your backend language of choice
### Simplistic  

Python is a language that is known for its simplistic, readable and easy-to-use syntax. Developers can write less code than in many other languages, which can speed up development times and boost productivity. Aside from SQL supreme similar english syntax, Python comes in second place easily and this what makes it the ideal language for young developers (of course after learning C like real men).
### Mature Ecosystem  

Python has a rich ecosystem of libraries and frameworks that make backend development faster and more accessible. Popular frameworks like Flask and FastApi (which we will talk about them in a while) provide powerful tools for web application development, while libraries like NumPy and Pandas are essential for scientific computing and data analysis.
### Scalable  

Python is a scalable language that can handle large volumes of data and traffic, making it a popular choice for high-traffic websites and applications.

### Performance

Python is referred to as both CPU and memory unfriendly but with a huge number of libraries, Python performs efficiently all the basic development tasks. Golang comes with inbuilt features and is more suitable for microservices software architectures.
### Active Community  

Python has a vast and active community of developers who contribute to open-source projects and offer support through forums and online resources. This community support can be invaluable when facing complex development challenges.
### Integrable  

Python can integrate with many other languages and platforms, making it an excellent choice for building complex systems that require integration with multiple technologies.
### Machine Learning and AI  

Since everyone is talking about the magic of AI we shoudl mention Python's popularity in machine learning and AI. It makes it an excellent choice for building backend systems that require machine learning algorithms. Libraries like TensorFlow and PyTorch are powerful tools for building deep learning models.

## My experience with Flask
Flask is a well-known and best Python framework that comes under the Microframework category and comes with the BSD license. It is inspired by the Sinatra Ruby framework, so developers can utilize Flask as a web framework for both frontend and backend.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zey6wz36u0i1oqt3zg5r.png)


Thanks to the functionality, restful request dispatching, request handling, modular, and lightweight frontend design of Flask, it is more adaptable than Django.

ORMs deliver an advanced abstraction on an interactive database that lets a developer transcribe code in place of SQL to read, create, delete, and update tools and data in the database.

Flask is a framework of Python language that allows the users to build a genuine web app foundation and database tables from where they can use any source of extensions needed.

The other benefit of using this framework is that it is compatible with Google App Engine and offers a request dispatching way. For instance, 21% of Facebook Infrastructure has Python codebase.

## My experience with FastApi
Before saying anything about this experience I just want to say that ma man [Sebastián Ramírez](https://dev.to/tiangolo) didn't just make a framework, he made a weapon. The future of this framework is absolutely bright.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ta4xy7aqnvpchlzaqvnt.png)

FastAPI is a Python web framework that is similar to Flask in its minimalistic design, but it offers many powerful features that make it stand out.
It uses Python +3.6 type declarations, allowing for excellent editor support and extensive validation of standard and custom data types.

FastAPI also provides built-in support for API documentation, security and authentication, and asynchronous endpoints, all of which can simplify and speed up development.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cpgftt87kv55wio8cmv5.png)

<center>Score chart from Techempower</center>  



FastAPI is known for its excellent performance (It's in the name, of course it will be fast), being built over ASGI instead of WSGI, making it a great choice for building APIs.

All points above are great on their own, but the most important part is that they are leading (if not forcing) to clean code habits. All points above are great on their own, but the most important part is that they are leading (if not forcing) to clean code habits.
FastAPI makes it mandatory to write type hints, declare dependencies, and follow OOP design patterns which help to create great code structure and keep code clean. This is the reason why it’s so popular now and I feel it’s here to stay.

## Conclusion
Whether you're building a web application or a complex system, Python is a language that can handle the challenge.
Flask and FastAPI can put up Python web servers and data science programs rapidly. FastAPI is superior for speed and performance. 
Flask is better for simple microservices with a few API endpoints.

Sources:
[Why Choose Python As Backend Development?
](https://micropyramid.com/blog/why-choose-python-as-backend-development)
[Python for backend development
](https://sonali-saikia.medium.com/python-for-backend-development-bbdd4c0cf041)
[List of 7 Best Python Frameworks to Consider For Your Web Project](https://www.monocubed.com/blog/top-python-frameworks/)
[Why FastAPI?](https://medium.com/featurepreneur/why-fastapi-69fb172756b7)
[Why FastAPI is a Future of Python Web Development](https://levelup.gitconnected.com/why-fastapi-is-a-future-of-python-web-development-181bed9d46f4)
[FastAPI – The Good, the Bad and the Ugly](https://www.infolytx.com/fast-api-gbu/)