Short answer
An algorithm is a specified process that produces a prescribed result, and a framework is the surrounding structure that calls your code. NIST's glossary uses that process definition. Python's sorting howto shows your code calling sorted(), which uses Timsort. Django calls itself a web framework and says that, after a URL matches, Django calls your view.
Last verified against the sources listed below.
Key takeaways
- NIST defines an algorithm as a clearly specified mathematical process that gives a prescribed result.
- Python 3.15's sorting howto says your code calls sorted() or list.sort(), and that Timsort is the algorithm used.
- Django's site calls Django a high-level Python web framework.
- Django's overview says that when a URL pattern matches, Django calls your view function.
- React's learn page says you pass a click handler down and React calls it. That is a separate question from library versus framework.
Algorithm vs framework is a difference in who is in charge of the next step. An algorithm is a procedure you follow to get a stated result. A framework is a scaffold that calls the code you supply.
NIST’s glossary states the procedure side. Django’s own site states the scaffold side, and it uses the word framework. Both ideas show up in ordinary software development.
They also sit inside a programming paradigm only after you pick who calls whom.
How do an algorithm and a framework differ?
You call an algorithm when you want its result. A framework calls your code when a request, a click, or a match arrives.
| Question | Algorithm | Framework |
|---|---|---|
| What is it? | A clearly specified process that gives a prescribed result | A structure for an application that calls your code |
| Who is in control? | Your code invokes the procedure | The framework invokes your function |
| Example with a source | Python’s sorted(), which uses Timsort | Django, which calls your view after a URL matches |
| What you write | The inputs, and sometimes a key function | The view, the model, the URL pattern, the template |
| What you do not write | The sort procedure itself, if the standard library already has it | The loop that maps every URL to a function |
The table is the whole comparison. The rest of this guide shows the sentences those cells come from.
What does NIST call an algorithm?
NIST calls an algorithm a clearly specified mathematical process for computation, and a set of rules that gives a prescribed result if you follow them.
That wording is the CSRC glossary entry. A second entry, for a cryptographic algorithm, tightens the same idea: a well-defined computational procedure that takes variable inputs, often including a key, and produces an output.
A sort has no key. A cipher often does. Both entries are about the procedure and the result, not about application structure.
The Python sorting howto in the 3.15.2 documentation is a concrete case. sorted([5, 2, 3, 1, 4]) returns [1, 2, 3, 4, 5]. list.sort() orders a list in place.
The page says the sort routines use Timsort, and that Timsort can use ordering already present in the data. Sorts are stable, so records with the same key keep their original order. Your program calls sorted().
It does not hand control of the whole program to the sort.
You can pass a key function, and the howto says that function is called once per record. That is still your call into a procedure. The prescribed result is an ordered list.
What does Django call a framework?
Django’s homepage calls Django a high-level Python web framework, and the overview shows Django calling your view.
The sentence on djangoproject.com is the definition this guide uses: a high-level Python web framework that encourages rapid development and clean, pragmatic design. The page also says Django is free and open source. It does not say Django is an algorithm.
The overview shows the other half. You describe models in Python. You map URL patterns to callback functions in a URLconf.
When a request arrives, Django walks the patterns in order, stops at the first match, and calls the view. The view returns an HttpResponse or raises something like Http404.
A template then fills in blocks. Each piece, the overview says, is decoupled from the next, and you can skip the ORM or the template engine. The call direction remains: a matching path causes Django to call your function.
That is the scaffold. You do not write a loop that checks every route on every request. You register the route and the function, and the framework does the matching.
When should you reach for each?
Use an algorithm when the output is fixed by rules. Use a framework when the application needs a place to put requests, data, and templates.
Sorting, selecting the smallest items, and maintaining a heap are algorithm jobs in the Python howto. min() and max() make one pass. heapq.nsmallest() keeps only n items in memory.
You call them, take the result, and move on. Nothing in that howto starts a web server.
A framework earns its place when many requests must find the right function, load data, and return a document. Django’s overview is that shape: models, URLs, views, templates, and a generated admin. If you only need to order a list, adding that scaffold is extra machinery.
If you are building the application around the list, the framework is the part that calls your ordering code at the right time.
React’s learn page shows a related call pattern without answering the label. You pass handleClick to a button, and React calls it on a click. The page also mentions a build tool or a framework as something whose docs you would read for CSS.
For the library-versus-framework split, use the existing guide on frameworks, libraries, and APIs. This article does not restate it.
What goes wrong if you mix them up?
Treating a framework as if it were a single procedure, or hiding a procedure inside the scaffold, makes the control hard to see.
A URL pattern is not an algorithm just because it is precise. Django’s match is a route to your function. The prescribed result of sorted() is an ordered sequence, not an HTTP response.
If a view both parses the route and reimplements a sort the standard library already documents, two jobs are tangled. Leave the route to the framework. Call the algorithm for the result.
The same mistake runs the other way. Wrapping every small procedure in a new framework, because the framework will call you back, adds a scaffold the NIST definition never asked for. A clearly specified process can live in a function you call.
Pick the direction of the call first, then pick the tool.
Frequently asked questions
Does NIST's definition require a computer?
The glossary entry opened here does not say the process has to run on a computer. It says an algorithm is a clearly specified mathematical process for computation, and a set of rules that, if followed, will give a prescribed result. The same glossary's cryptographic-algorithm entry is narrower: a well-defined computational procedure that takes variable inputs, often including a key, and produces an output. A sort fits the first definition. A cipher fits the second. Neither entry mentions frameworks, views, or user interfaces.
Who calls whom in Django?
Your URL configuration lists patterns. Django's overview says Django walks those patterns in order and stops at the first match. It then calls the Python view you named, passing the request and the values captured from the path. The view returns an HttpResponse or raises an exception such as Http404. You write the view. The framework decides when to call it. That is the opposite direction from sorted(), which runs only when your code calls it.
Is sorted() the algorithm or a function that uses one?
In the Python howto, sorted() is the function you call, and Timsort is the algorithm the sort routines use. The page says Timsort can take advantage of ordering already present in the data, which is why a series of sorts stays efficient. It also says sorts are stable, so equal keys keep their original order. You do not reimplement Timsort to sort a list. You call sorted() or list.sort(). The algorithm is the procedure. The call is yours.
Where do libraries fit if this is about frameworks?
This comparison stops at the control difference: you call an algorithm, and a framework calls your code. A library is a third shape, and the live guide on frameworks, libraries, and APIs is the place that splits those three. React's learn page is easy to misread here. It tells you not to call the click handler yourself, because React calls that handler when the user clicks. That sentence shows a tool invoking your function. It does not, on the page that was opened, define the word framework.
Can one project contain both?
Yes. A Django project is the framework, and a view inside it can call sorted() on a list of rows before rendering a template. The framework still owns the URL match and the call into the view. The algorithm still owns the ordering rules and the result. Putting business rules in the framework's URL list, or rewriting Timsort inside a view for a ten-item list, mixes the jobs. Use the framework for the scaffold and call an algorithm when you need a prescribed result.
Sources
- Algorithm · NIST CSRC, 2026
- Cryptographic algorithm · NIST CSRC, 2026
- Django · Django Software Foundation, 2026
- Django at a glance · Django Software Foundation, 2026
- Sorting HOW TO · Python Software Foundation, 2026
- React quick start · React, 2026