20 votes

Why Pyramid?

Tags: ask

This is mostly a question for @Deimos, just out of curiosity: is there are particular reason for the choice of Pyramid as the framework for TIldes? Is it familiarity, or clear advantages over sth. like Django or Flask?

(Edit: actually I'd welcome comparisons favouring one or another from anyone too, related or not to Tildes itself.)

3 comments

  1. Deimos
    Link
    Other people have mostly covered it, but overall I chose Pyramid because it has a lot of useful aspects for a larger/more-complex site, but is also very flexible and allows me to choose my own...
    • Exemplary

    Other people have mostly covered it, but overall I chose Pyramid because it has a lot of useful aspects for a larger/more-complex site, but is also very flexible and allows me to choose my own libraries and easily modify how it behaves if I need to.

    Django is great, as long as you're doing something that fits into "the Django model", where all the pieces it includes work well. If you need to get outside of that, it can start getting ugly really fast, and you might have to start wrestling with the framework to try to convince it to let you do things that you need.

    Flask is almost the opposite—it includes almost nothing. This is part of what's great about it, and it's always what I use when I'm building a small, straightforward site where I don't need much in terms of complicated functionality. I'd never use it for a larger site though, it's just not very easy to organize larger projects with it, and you can end up having to manage (or write) a lot of dependencies for even pretty basic functions.

    Pyramid is more complex to get set up, but it's really well-designed overall and has a lot of great features when you need the flexibility. I've run into quite a few cases with it where I was expecting something to be difficult, and then it turned out that Pyramid already had a way to easily hook into it or override to get the behavior far more easily than I was expecting.

    15 votes
  2. [2]
    cfabbro
    (edited )
    Link
    I remember asking Deimos about this ages and ages ago but can't specifically remember his response. However I do remember an article I found around that time comparing the frameworks (since I...

    I remember asking Deimos about this ages and ages ago but can't specifically remember his response. However I do remember an article I found around that time comparing the frameworks (since I bookmarked it for myself) written a few years ago by Ryan Brown, a Senior Software Engineer at Red Hat:
    https://www.airpair.com/python/posts/django-flask-pyramid

    2 About the Frameworks

    Django's "batteries included" approach makes it easy for developers who know Python already to dive in to web applications quickly without needing to make a lot of decisions about their application's infrastructure ahead of time. Django has for templating, forms, routing, authentication, basic database administration, and more built in. In contrast, Pyramid includes routing and authentication, but templating and database administration require external libraries.

    The extra work up front to choose components for Flask and Pyramid apps yields more flexibility for developers whose use case doesn't fit a standard ORM, or who need to interoperate with different workflows or templating systems.

    Flask, the youngest of the three frameworks, started in mid-2010. The Pyramid framework began life in the Pylons project and got the name Pyramid in late 2010, though the first release was in 2005. Django had its first release in 2006, shortly after the Pylons (eventually Pyramid) project began. Pyramid and Django are extremely mature frameworks, and have accumulated plugins and extensions to meet an incredibly large range of needs.

    Though Flask has a shorter history, it has been able to learn from frameworks that have come before and has set its sights firmly on small projects. It is clearly used most often in smaller projects with just one or two functions. One such project is httpbin, a simple (but extremely powerful) helper for debugging and testing HTTP libraries.

    7 Summary

    Pyramid is the most flexible of the three. It can be used for small apps as we've seen here, but it also powers big-name sites like Dropbox. Open Source communities like Fedora choose it for applications like their community badges system, which receives information about events from many of the project's tools to award achievement-style badges to users. One of the most common complaints about Pyramid is that it presents so many options it can be intimidating to start a new project.

    By far the most popular framework is Django, and the list of sites that use it is impressive. Bitbucket, Pinterest, Instagram, and The Onion use Django for all or part of their sites. For sites that have common requirements, Django chooses very sane defaults and because of this it has become a popular choice for mid- to large-sized web applications.

    Flask is great for developers working on small projects that need a fast way to make a simple, Python-powered web site. It powers loads of small one-off tools, or simple web interfaces built over existing APIs. Backend projects that need a simple web interface that is fast to develop and will require little configuration often benefit from Flask on the frontend, like jitviewer which provides a web interface for inspecting PyPy just-in-time compiler logs.

    All three frameworks came up with a solution to our small list of requirements, and we've been able to see where they differ. Those differences aren't just cosmetic, and they will change how you design your product and how fast you ship new features and fixes. Since our example was small, we've seen where Flask shines and how Django can feel clunky on a small scale. Pyramid's flexibility didn't become a factor because our requirements stayed the same, but in the real world new requirements are thrown in constantly.

    p.s. And even though it doesn't specifically address your question, the technical goals section of the Tildes docs is probably worth reading if you haven't already since it delves in to Deimos' overall philosophy regarding the technical side of the site.

    15 votes
    1. unknown user
      Link Parent
      Thanks a lot, that was very informative!

      Thanks a lot, that was very informative!

      5 votes