Trends in technology come and go, and webDev is no different. The past two decades have been marked by a number of trends in web app development, not all of which have stood the test of time, including (in roughly chronological order):
- Java servlets
- ActiveX controls
- Ajax
- HTML5
In this article, we’ll focus on ten of the most current trends for modern Python webDev. Also included are a number of Python resources to help you get started understanding and implementing these trends.
Before you start: Install WebDev Trends Python Environment
To follow along, you can install the WebDev Trends Python environment for Windows or Linux, which contains Python 3.8 and all the packages you need.
In order to download this ready-to-use Python environment, you will need to create an ActiveState Platform account. Just use your GitHub credentials or your email address to register. Signing up is easy and it unlocks the ActiveState Platform’s many benefits for you!
Or you could also use our State tool to install this runtime environment.
For Windows users, run the following at a CMD prompt to automatically download and install our CLI, the State Tool along with the WebDev Trends runtime into a virtual environment:
powershell -Command "& $([scriptblock]::Create((New-Object Net.WebClient).DownloadString('https://platform.www.activestate.com/dl/cli/install.ps1'))) -activate-default Pizza-Team/WebAppTrends"
For Linux users, run the following to automatically download and install our CLI, the State Tool along with the WebDev Trends runtime into a virtual environment:
sh <(curl -q https://platform.www.activestate.com/dl/cli/install.sh) --activate-default Pizza-Team/WebAppTrends
1. Single Page Apps
The Single Page App, or SPA is currently gaining attention in 2021 since it allows you to create a browser-based application that doesn’t require page loads. This gets around the often frustrating delays users experience when navigating a web app. Some notable SPA applications include Google Maps, Facebook and GitHub.
As a Python developer, the quickest way to get started creating your own SPA is with Flask, which is a self-contained, micro webDev framework. With the help of Flask you can place static files produced by your frontend framework in a subfolder inside of your project. Then all you need to do is create a catch-all endpoint that routes all requests to your SPA.
The following example demonstrates how to serve a SPA along with an API:
from flask import Flask, jsonify app = Flask(__name__, static_folder='app', static_url_path="/app") @app.route("/heartbeat") def heartbeat(): return jsonify({"status": "healthy"}) @app.route('/', defaults={'path': ''}) @app.route('/<path:path>') def catch_all(path): return app.send_static_file("index.html")
2. Progressive Web Apps
Progressive Web Apps (PWA) were first introduced by Google back in 2016, and after some hesitancy are now supported by Microsoft, as well. That hesitancy has delayed adoption, but PWAs are set to trend in 2021.
PWA is all about smooth web apps that enhance the user experience. They are built using APIs that serve to abstract away the underlying technology so users can work with the app on any device. As such, PWAs come closest to the “code once, deploy anywhere” mantra that kickstarted the web app revolution, featuring a single code base and offering cross-device compatibility. This is very welcome in a world where users appreciate the ability to seamlessly continue working as they move from their desktops to their mobile devices. And it even enables users to work offline.
The easiest way to build a PWA with Python is by using the Django web framework together with React. Django is used for the backend logic, while the React JavaScript framework lets you build out the frontend. Read more about Django and other webdev frameworks here.
3. Artificial Intelligence for Web Applications
Implementations of Artificial Intelligence (AI) on the web are booming. E-commerce is just one of the areas where it’s used widely since it can help predict customer choices with the help of Machine Learning (ML), effectively allowing you to make product recommendations. Other well-known implementations include chatbots, virtual reality and augmented reality.
TensorFlow is the Python open source library of choice for all your ML challenges. It can be installed with pip, or via numerous TensorFlow Docker images. It can be used with Keras to create neural networks that can perform predictions (such as which products to recommend to your customers), or used with JavaScript to create apps for mobile or embedded devices (IoT).
Machine Learning skills are some of the most sought-after talents in the 21st century. You can improve yours by trying your hand at some of our ML projects:
- How to use machine learning to determine Titanic survivors
- How to build a lyrics generator with Python & necurrent neural networks
- Fantasy march madness: How to predict winners
- How to predict NFL Winners with Python
- How to build a generative adversarial network (GAN) to identify deepfakes
- Can an AI classification model detect AI-generated content?
4. WebAssembly
The main risk a web developer has when building a web app is poor performance. Slow web apps mean poor user experiences, hampering adoption. Unfortunately, highly performant web apps are a rarity, mainly due to the inclusion of JavaScript code, which can slow things down considerably.
If you’re worried about performance, WebAssembly can be a good solution. WebAssembly is an open standard that defines a portable binary-code format for executable programs, combined with a corresponding text-based assembly language. It also offers interfaces for facilitating interactions between such programs and their host environment.
WebAssembly offers plenty of advantages:
- It’s independent of the programming language used to code the web app, as well as the platform the app is deployed on
- It’s independent of the underlying hardware of the device the web app is run on
- It executes code fast
- It offers a high level of security
In other words, code in any programming language and compile into bytecode that can be run in any browser.
As a Python programmer you can use Pyodide. Pyodide delivers the Python 3.8 runtime to the browser via WebAssembly together with the Python scientific computing stack, including Pandas, NumPy, Matplotlib, SciPy, and scikit-learn.
If you recall our previous trend, AI for web apps, Pyodide offers you the ability to do AI in the browser. With this quickstart guide, you can be up and running in no time with Pyodide. You can even try it out directly using their terminal emulator:
5. Voice Search for Web Applications
Voice search and voice navigation are going to be one of the most dominant web development trends in 2021. As a matter of fact, they’re probably already a part of your daily routine if you use Siri, Alexa or Cortana to help you find information, create notes, dial your phone, etc.
A good way to get started working with voice in Python is to check out everything you wanted to know about Speech Recognition from RealPython. But working with audio files is very easy, so you can also just jump and give it a try for yourself. We recommend starting with our simple “how to build a digital virtual assistant in Python” project to get your feet wet with voice recognition and processing.
6. Native Apps vs Web Applications
Web apps have one huge drawback: if your users have no internet connection, your application is useless. Even if their network connection temporarily goes down, they may lose all their work. So is it possible to work offline with a web app? Yes, via native apps.
A native mobile app installed on a smartphone works both online and offline. Native apps represent a growing market for mobile platforms like iOS and Android, but unfortunately, Python doesn’t have native mobile development capabilities. Luckily, there are several popular packages that can help you bridge the gap when it comes to creating web apps for mobile devices, such as BeeWare and Kivy.
Kivy is an open source Python library designed for the rapid development of apps with complex user interfaces, such as multi-touch apps. Kivy is famous for its widgets, which can help shortcut the creation of your app. The following script shows how to display an image in your app:
from kivy.app import App from kivy.uix.image import Image class MainApp(App): def build(self): img = Image(source='/path/to/real_python.png', size_hint=(1, .5), pos_hint={'center_x':.5, 'center_y':.5}) return img if __name__ == '__main__': app = MainApp() app.run()
With Kivy, you can have a native app built in no time. To learn more about developing mobile applications with other frameworks like BeeWare, read ‘the best Python frameworks for mobile development and how to use them’.
7. Motion Design UI for Web Applications
You heard it here first: motion design is going to be one of the biggest trends in web development this year. It’s not only about animations, but rather making motion design an integral part of the entire UI/UX design. Check out some cool examples.
A great Python package to use for motion design is Tkinter. Tkinter combines both the TK and Python standard GUI frameworks, and is one of the best graphic packages for Python.
Simply put, Tkinter works with widgets, which include graphical elements like buttons and text boxes. It gives you control over your application’s UI layout with geometry managers, and lets you make your application interactive by associating button clicks to Python functions, such as in the following Python code snippet:
greeting = tk.Label(text="Hello")
Learn how to work with Tkinter by reading ‘how to position widgets in Tkinter’.
8. Serverless Architecture for Web Applications
With a serverless architecture you still run your web apps on a server, but the advantage is the server is managed remotely by a 3rd party provider. For example, Amazon Web Services (AWS) offers AWS Lambda which you can use together with Python to create a serverless web app.
For more information on working with serverless architectures and AWS Lambda, read ‘how to create a serverless REST API with Python and AWS Lambda.’
9. Optimizing CI/CD for Web Applications
Rather than conducting a majority of their testing manually, organizations implement Continuous Integration and Continuous Delivery (CI/CD) of their software using a “pipeline” that automates the execution of various tests against their web application. In this way, organizations can implement more frequent changes with greater confidence.
However, because most CI/CD implementations build every environment from scratch, they’re subject to:
- Poor Environment Reproducibility – when dev environments differ from CI/CD environments developers waste time reproducing the CI/CD environment in which a bug has been found.
- Supply Chain Attacks – pulling dependencies from their public repositories in order to build CI/CD environments can lead to inadvertently incorporating typosquatted or otherwise compromised binaries.
- Slow Execution – while caching can help cut down on environment creation times for repeated runs, it won’t help when you’re doing rapid development and changing your dependencies.
See how you can avoid these common CI/CD issues by using prebuilt runtimes. Read ‘optimizing CI/CD implementations in your organization.
10. Cloud Monitoring
If you run your web application in the cloud, you’ll want to monitor it. Python offers numerous packages that give you a headstart when it comes to building just about any monitoring tool you’ll need, including the ability to incorporate AI and dashboards.
Additionally, Python can be used on different cloud computing platforms from Amazon AWS, to Microsoft Azure to Google Cloud Platform, and more, making it a good choice for cross-cloud monitoring. You can check out Python Monitoring resources for more information no matter whether you’re intending to build your own monitoring application, or deploy a prebuilt one.
WebDev Trends in 2021: Conclusions
Web applications have been the way we build and interact with software for the majority of the past 20 years. While browser-based web applications haven’t quite got the same cachet on mobile devices where users prefer native applications, there’s no reason to think web applications are going away anytime soon.
In this article, we discussed some of the top trends affecting web application development in 2021. In every case, Python, as a versatile scripting language with a wide range of third party packages and almost infinite flexibility, offers a great way to incorporate these trends in your daily web development.
- Download our WebDev Trends Python environment and try out some of the technologies mentioned in this post.
With the ActiveState Platform, you can create your Python environment in minutes, just like the one we built for this project. Try it out for yourself or learn more about how it helps Python developers be more productive.
Related Reads