The Flask framework, which we looked at the beginning of the course, belongs to the class of so-called microframeworks. All of them, in one way or another, are clones of the Ruby framework Sinatra, which set the trend for microframeworks. See how similar the code structure is:
Ruby:
# Ruby
require 'sinatra'
get '/frank-says' do
'Put this in your pipe & smoke it!'
end
Java:
// Java
import static spark.Spark.*;
public class HelloWorld {
public static void main(String[] args) {
get("/hello", (req, res) -> "Hello World");
}
}
JavaScript:
// JavaScript
import Express from 'express';
const app = new Express();
app.get('/', (req, res) => res.send('Hello World!'));
Python:
# Python
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
They're all like twin brothers in defining routes and setting handlers. Apart from basic functionality, there's nothing in microframeworks. We install everything else separately.
Moving away from microframeworks, consider full-fledged frameworks — large packages of code. It comes with everything you might need out of the box. They're usually easy to extend because of the many add-ons available on GitHub. The history of web frameworks dates back to 2004, when the first version of Ruby On Rails, a Ruby language framework, was released. Rails was ahead of its time and set the tone for many years. Many modern web frameworks are clones of Rails in one way or another.
In Ruby, you could say there is nothing else except Rails, and it positively affects development because everyone is running in the same direction. The situation is similar in Python: Django is the default framework, although there have been other comparable frameworks at different times (Zope, Plone, WebRu, and others).
Here is a summary of the features that modern frameworks have:
- Code generation. Any complete framework will contain a utility that allows you to generate code from the command line, such as for tests or migrations
- Built-in mechanisms for testing. In other words, the framework allows you to start writing tests with almost no need to install or configure anything else
- ORM. Either their own or one that's popular for the language as a whole
- Templating engine and helpers (which are functions) for repetitive output tasks
- Abstractions for working with letters
- Internationalization and localization tool (we should integrate all other framework parts with i18n)
- Security mechanisms, such as CQRS
- Caching
Are there any more questions? Ask them in the Discussion section.
The Hexlet support team or other students will answer you.
For full access to the course you need a professional subscription.
A professional subscription will give you full access to all Hexlet courses, projects and lifetime access to the theory of lessons learned. You can cancel your subscription at any time.