Assuming you're going to use couchdb, is it realistic to try to just use couchapp in place of django, rails, or asp.net mvc? What would be the benefits and drawbacks?
-
I think this is a very valid question. I'd like to hear from folks who have used CouchDB with traditional frameworks and Couchapp to hear about pros/cons. – Barry Wark May 02 '11 at 14:38
2 Answers
Yes, normally a CouchApp would use AJAX for the whole application, though that's not a requirement. It's possible to create a CouchApp that will provide a fallback and render the core content for browsers without JS (and search engines).
This is normally a little complicated and involes writing your rendering functions twice. Once in the design doc as a show or list function, then again for your client-side code. However, I've been working on a CouchApp framework called Kanso, which allows you to write code once and have it run on the client-side when possible and fall-back to CouchDB when that's not.
Another problem I've found with CouchApps is that the validation and permissions code can get very complicated quickly with a bigger app. So Kanso also provides Type definitions similar to other Model systems you might have used in Django or Rails.
Just to be clear: You will not achieve the same experience for browsers without JS, but what you can do is render the basic content of the page and then progressively enhance it with JavaScript.
This is what Kanso was designed for :)
As it stands, a CouchApp essentially require you to use AJAX for the entire application. Generally speaking, that's poor for user experience, as you are downloading the skeleton markup, running JS, usually hitting the server again, and then adding more markup dynamically. (as opposed to just downloading the finished markup up front) In addition, caching data is a different beast on the browser than it is on a server. Also, SEO is much more difficult when you have AJAX-only content.
Basically, all of the reasons you see people going against AJAX-only (ie. obtrusive JavaScript) web applications, will all hold up in this context.
On the other hand, you would be able to replicate the entire application (as well as all the relevent data) to any node that is running CouchDB. I could see mobile versions of your application running only the CouchApp while offline, since a full web server stack wouldn't necessarily be available to you. In addition, it's easy to get up and running with a CouchApp, as opposed to learning a framework like Rails, Django or Express.js.
I have high-hopes for CouchApps becoming a complete web application solution eventually, as I am a huge fan of CouchDB as a database. However, right now it just isn't feasible for me because of the heavy reliance upon obtrusive JavaScript.

- 28,083
- 8
- 65
- 90
-
1AJAX and "obtrusive Javascript" are completely different issues. It's perfectly reasonable to write an AJAX-based application with unobtrusive Javascript. In fact, it's recommended. Your assertions about performance are also questionable: sending out the framework fast, and the data within one second, often gives the user that "something is happening" and encourages them to wait for the result. Doing the processing on the client reduces the load on the server, which is also A Good Thing. – Elf Sternberg Jun 21 '11 at 20:53
-
"a CouchApp essentially require you to use AJAX for the entire application". You dont have to use Ajax at all if you don't want to. – ajsie Jul 20 '11 at 01:24
-
No, you don't *need* to use AJAX. But you are very limited if you don't. In particular, you can only deal with one data-set at a time. – Dominic Barnes Jul 20 '11 at 03:36
-
1I know it's 4 years later, but I read this post as a list of reasons *to* use CouchApps, not against it. – Jonathan Hall Aug 27 '15 at 22:23