Sunday, October 26, 2008

Persistence in applications or why screen is so cool

I use the tool screen day in and day out. If you work on some form of linux and don't know about screen, I'd highly recommend you take the time to learn it. Screen allows me to set up a number of virtual terminals and then each day when I log in, I simply re-attach to screen and I'm exactly back where I was. Terminal services or citrix on windows provides very similar functionality for a gui environment on windows. I don't tend to use gui's very much in linux, but I've used vnc in a similar fashion. All of them have this same feature, I can disconnect and come back tomorrow and reconnect and pick back up exactly where I left off.

This is incredibly useful because it saves me from having to set up my environment each day. I can just get back to work exactly where I left off. But, i don't have to be at the same computer to do it, I just reconnect, login and voila, I'm back where I was. You get the same effect by simply locking your workstation and signing back in when you get in the next day. It's why most of us hate rebooting. It's because of the time it takes to get things back to where you can concentrate on real work again. (Have to open email, web browser with 6 tabs, sign into each page, load up editor, etc).

It struck me the other day that this would be a really neat behavior for complex applications as well. Even web apps. What if when you logged in the next day, you were taken back to the same "place" you were the previous day with all the history and context restored. What if web apps did this so that if I log in from home, I'm exactly at the same point I was when I closed my browser at work.

Then I realized that there is a limited form of this already and actually it's one of those things that makes web apps so much more powerful then desktop apps. Two applications which exhibit some of these behaviors are mail and rss readers. In both cases, I can read, process, respond to items at work, and when I get home and log back in, I see the same state of the environment as it was at work. If I have a few minutes to kill, I can even pull them up on my cell phone and get some reading done on the road and when I log in at home anything I've done on my cellphone shows up there as well. This really is the killer promise of web applications. My environment is no longer tied to a desktop or even a laptop. I can use someone else s machine, or even a public machine to log in, do work and log off. We trade freedom for some loss of control. We no longer have as much control of our own environments, but now have the freedom to access them from anywhere.

So, does persistence of session make sense in applications? That's a good question. We have simple versions of this today as I showed above. But those don't actually store a full persistent state like you'd see in a citrix or screen session. The exact windows and dialog boxes you were seeing aren't there when you log in from home though the core items (email and rss feeds) are kept up to date.

I expect that this is a hard enough problem that it will be unlikely that we will see web based applications with this kind of state storage anytime soon. But theoretically it should be possible if the state is kept on the server and something like a continuation is used to return a user to an exact point in the application. But is this useful enough to even spend the time to get working. I don't know, but it's interesting to think about. With html applications, you could actually get pretty close if you store sessions in a persistent data store and then record the last url requested in that session. Then when the user returns the next day, you just restore their session and take them back to that url in the application. Sort of like auto-bookmarking. Hopefully whatever they've been working on hasn't been moved or deleted.

Hmmm, maybe we aren't as far off as I thought. Something to play around with.

8 comments:

dibblego said...

Persistence, with an 'e'.

Tom said...

Dreamhost's panel actually does this.

Lunatic Programmer said...

@dibblego - Thanks for catching that.

@tom - Hmm, haven't had access to dreamhosts panel. I'm curious if you find being returned to the same state a useful feature in their application, or an annoyance.

non_stop_pain said...

viola != voila

Blaxter said...

I'm totally agree.

The Firefox's feature of restoring you tabs from the last session is, without any doubt, my favourite.

jpdaigle said...

I think the big problem with implementing this in web apps is that you might use some web app from multiple locations simultaneously.

As soon as your app allows you to be logged in from multiple browsers at once, you have a sync problem with storing context. GMail, Google Reader, etc solve this by being just a view on a data model (that can change from under you) and not persisting your context, only the state of that model.

kaykay said...

A framework which does that is already built : http://seaside.st/

Lunatic Programmer said...

@non_stop_pain - Thanks, fixed misspelling.

@jpdaigle - You have a very good point. Multiple browser windows do pose an interesting challenge.

@kaykay - Yes, seaside would provide some ability to handle this, though I think you'd still have some challenges in implementing screen like functionality generically.