All the hubbub about the hashbang URL system got me thinking about sharing client/server javascript just this morning, and then lo and behold, a post about it pops up a few hours later.
Instead, though, I was thinking that perhaps controllers and views could be re-used across the server and client. When a request comes in to the server, it renders a page just like a typical MVC framework would, but also directs the client to download the view/controller javascript. Any links the user follows could then be rendered client-side. When the framework is running server-side, the model layer talks directly to the database - when it's running client-side, it talks to the server through JSON.
It could give you the best of both worlds - an initial request returns a quick, fully-formed HTML page, so it's speedy on the first load and crawlers will know what to do with it. Later requests use AJAX, so things are responsive and the server isn't weighed down with HTML rendering.
Take a look at liftweb. http://liftweb.net/ Its Scala which I don't know, but I've got some very intelligent friends trying to get me to back it at our company. (Scala is a lisp that runs in the JVM. - Someone's going to hang me for confusing what lisp is.) Its a framework that can leverage websockets/comet/longpoll to extend your classes to work client side.
Think message passing between client objects (in js) and server objects (in scala). You can do jqueryish things server side to the client side pages. (That blew me away when I saw it in action.) Your submit even can pass params to the server object. It's really simple and strait forward. I'm looking for lift for NodeJS.
Quora seems to be taking this approach. Except, after the initial request, mutations make the server send rendered HTML fragments instead of raw JSON back to the client. I believe this is due to the fact that their view templates are coded in Python so they can't be easily reused on the client side.
Instead, though, I was thinking that perhaps controllers and views could be re-used across the server and client. When a request comes in to the server, it renders a page just like a typical MVC framework would, but also directs the client to download the view/controller javascript. Any links the user follows could then be rendered client-side. When the framework is running server-side, the model layer talks directly to the database - when it's running client-side, it talks to the server through JSON.
It could give you the best of both worlds - an initial request returns a quick, fully-formed HTML page, so it's speedy on the first load and crawlers will know what to do with it. Later requests use AJAX, so things are responsive and the server isn't weighed down with HTML rendering.