Sunday, March 23, 2014

Comparing Three Python Web Frameworks

I have been spending a lot of time noodling around with different Python web frameworks.  Specifically, I have played with Django, Bottle, and Pyramid.  Here are my thoughts on them.  Since the first MVC framework I learned is Rails, I will be comparing some of them to Rails.

1. Django

Basically Python's answer to Rails (or vice versa?).  Django is a powerful, fully developed, and very structured framework that can be used to make professional web apps.  If you want a job, this is the one to learn.  One significant difference between Rails and Django is that you work on Django project, which can include multiple apps, where in Rails you just work on one app.  This promotes code reuse because if you are clever you can use one Django app in several projects.

Models are called models in both Django and Rails.  What are called controllers in Rails are called views in Django, and views in Rails are called templates.  Django does not have a concept of scaffolding to speed up setting up routes like Rails does.  You have to write all of the routes out.

2. Bottle

Bottle interests me because I like the idea of carrying an app in my pocket.  Seriously, the code for the Bottle framework is contained in one file!  One way to install Bottle is to just download the bottle.py file.  My guess is that the Ruby equivalent is Sinatra.

Bottle is very minimal, and you have to build everything from the ground up, which can be liberating or frustrating depending on your personality, unlike Django, which gives you a lot of bells and whistles out of the box.

3. Pyramid

Pyramid wants you to have your cake and eat it too.  You can write a very minimal web app (like the "Hello World" app you write in one of Pyramid's tutorials), or you can write a larger app using a directory structure similar to Django.  Flexibility seems to be the trademark of this framework.

No comments:

Post a Comment