Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How limiting are web frameworks

This is a general question about how limiting are web development frameworks such as Django and ruby-on-rails.

I am planning on building a RESTful web service which will have a purely JSON/XML interface, no GUI. The service will rely on a database however for a few of the more important operations there is no clear way of persisting a "model" object directly into a database table. In addition I require full control over when and how the data is being written to the database. I will need to maintain multiple database connections in order to use some connections only for reads and others only for writes.

I've looked at the "full" MVC frameworks such as Django and more basic ones such web.py and pylons. The impression I currently have is that if I go with the full framework initially things will go faster but eventually I will get stuck because I will be limited by the framework in what I can do. If I go with a more basic framework it will take much longer to get everything running but I will be free to do what I need.

This is what it seems like but I suspect that it might be an incorrect impression given how many sites are written in Django and Rails. Could you please provide your opinion. Am I totally wrong and there is a way to easily do anything with a framework like Django or Rails or given my requirements I should go with something like web.py?

Thank you!

like image 278
Alex Avatar asked Jan 24 '10 03:01

Alex


People also ask

Are web frameworks necessary?

Web frameworks help us achieve structure in our applications, and they give us additional features we can add to them without too much extra work. Frameworks give us a place to start so that we can focus on features rather than configuration details.

When should you not use a framework?

If you're working on something simple and small, then a framework is going to be overkill. In fact, if you're working on a smaller project, a framework will only complicate matters, so you're better off doing without.

What is web framework and its advantages?

A web framework (WF) or web application framework (WAF) is a software framework that is designed to support the development of web applications including web services, web resources, and web APIs. Web frameworks provide a standard way to build and deploy web applications on the World Wide Web.


1 Answers

Web frameworks tend to optimize around building websites, making most normal use cases simpler to accomplish. Once you start to do more "out of the box" stuff with a framework, you might find that you spend more time working around it then you save using it in the first place.

It's hard to generalize here (especially since I've really only worked in-depth with Django), so I'll offer some advice based on my own experiences developing a JSON API using Django:

Simple put, I don't recommend using Django to write a REST API. In my own experience, I really didn't find anything worth writing home about. I didn't need Django's templating system, so all that I really made use of was the URL dispatching and ORM. Even then, I had to do some hacks to get the URL dispatcher to do what I wanted -- had I not used other features it would've been faster to use a different URL system, in fact. In your case, Django's ORM wouldn't even be suitable since it doesn't support multiple databases (unless you're using 1.2 alphas...). Compound that with Django's lack of a good startup signal, and Django starts to look pretty bad for the job.

If I were in your shoes, I'd dig around for specific libraries that did what I needed (ORM, WSGI, etc) and just use them, rather than trying to bend and hammer Django into something that suits my needs.

On a totally different note, you might want to take a look at Tornado as a possible HTTP frontend. It's both simple and fast.

like image 77
ShZ Avatar answered Sep 20 '22 11:09

ShZ