A Persistent Save State

Hi

I was having one of those “this OS was great, because…” type of drunken chats with a colleague recently. He was banging on about how great the Newton was. As I’m a BeOS fan, we both have a healthy laugh at each others’ nostalgias, while sharing an even healthier dislike of Windows and Linux. Anyway, he was telling me about something in Newton which I though was flatout a damn good idea.

Whenever the machine was switched off, struck by lightning, etc, it would always remember what the machine was up to at the time of it losing power. In effect, it was constantly saving your session. Would such a thing be possible with BeOS, and if it was, would it be desirable. I like the idea of not having to worry about saving anymore, and should the power suddenly flip out, you can laugh and say, “no worries, I’ll just resume once I’ve powered up again”, however, I’m not sure of the technicalities of making such a thing happen. I’m presuming, that it would eat up resources. The thing that made me wonder about it with Haiku/BeOS is that my mate said that the Newton worked on a database principle. I wondered if such a similar thing could be acheived with Haiku’s own database model?

As you can guess, I’m not a programmer, far from it, so the above may seem like lunacy.

expensivelesbian wrote:
Hi

I was having one of those “this OS was great, because…” type of drunken chats with a colleague recently. He was banging on about how great the Newton was. As I’m a BeOS fan, we both have a healthy laugh at each others’ nostalgias, while sharing an even healthier dislike of Windows and Linux. Anyway, he was telling me about something in Newton which I though was flatout a d___ good idea.

Whenever the machine was switched off, struck by lightning, etc, it would always remember what the machine was up to at the time of it losing power. In effect, it was constantly saving your session. Would such a thing be possible with BeOS, and if it was, would it be desirable. I like the idea of not having to worry about saving anymore, and should the power suddenly flip out, you can laugh and say, “no worries, I’ll just resume once I’ve powered up again”, however, I’m not sure of the technicalities of making such a thing happen. I’m presuming, that it would eat up resources. The thing that made me wonder about it with Haiku/BeOS is that my mate said that the Newton worked on a database principle. I wondered if such a similar thing could be acheived with Haiku’s own database model?

As you can guess, I’m not a programmer, far from it, so the above may seem like lunacy.

While I know very little about Newton’s - I’d have to assume that either it was doing the same thing as a Palm (battery-backed memory) - or was using some type of non-volatile memory (Flash memory) instead. The problem with the former is that it can only go without a main power source for a certain amount of time (usually an internal rechargeable battery is supplying the power when the main power source is removed)… the problem with the latter is that flash memory tends to “wear out” after so many writes… and I believe it’s quite a bit slower than standard RAM.

Saving a state constantly requires dumping RAM to some type of non-volatile storage (hard drive) – this is extremely time-consuming… Have you ever done a “hibernate” in Windows XP? – that’s exactly what it’s doing - saving RAM state to hard drive. It takes longer depending on how much RAM is in use - you’re stuck while it’s doing it - and it requires as much free HD space as you have RAM.

There is also “standby” mode on most APM-supported computers which is basically the first option from above. The machine is pretty much shut-down, except the RAM state is kept by supplying power to it… it takes a lot less power to keep RAM state than it does to keep HDs spinning, processors processing, fans fanning, etc - so Standy mode is primarily for power-savings.

Well, I’ll grill him further about it, but he seemed to be suggesting that this persistent save state was achieved with the database system that the Newton was built on. It was this that made me wonder about it with BeOS.

I agree with you that dumping an image of the machine from RAM would not be the way to go.

expensivelesbian wrote:
Well, I'll grill him further about it, but he seemed to be suggesting that this persistent save state was achieved with the database system that the Newton was built on. It was this that made me wonder about it with BeOS.

I agree with you that dumping an image of the machine from RAM would not be the way to go.

I guess I would need more context to understand what it did… remembering what apps/windows were open is one thing - remembering exactly what state the entire machine was in is very different…

A similar feature would be to have all applications implement some type of “auto-save” of their documents… this would be the responsibility of each application to save it’s open documents on a regular basis so that they can be “recovered” after a system failure (similar to Microsoft’s Office products… which admittedly suck at this)

So, I’m the friend with whom the expensivelesbian was having a chat the other day…

On a Newton it was indeed vary rare for you to loose data in the case of a power failure. You wouldn’t actually end up exactly where you left of when/if you lost power (or reset) though, instead your Newt would reboot and start up the app it was configured to start. In general though you wouldn’t have lost any data - well, maybe a few words, and possibly as much as a whole sentence.

There were two factors at play here. Firstly there’s the storage model, and secondly general application design.

Newton used a persistent dynamic object oriented database system for storage, rather than a traditional filing system. The basic object in Newton OS is called a frame, which is a slightly different concept to a class, and the databases were called soups. (NewtonScript, the language you used to write Newton apps, has more in common with Self than C++.) There were a few things to be careful about when writing frames into your applications soup (or soups), but essentially you could store frames of any format into soups. There was a concept of “folders” in the storage which provided some structure, however this was implemented using standardly named slot in your stored frame. Soup storage was tightly tied to the language and object model, which made coding for it very simple.

Newton storage would either be battery backed ram, or flash memory. Both were supported. There was even rudimentary support for ATA built into late versions of Newton OS, which has since been completed by inventive third party hackers.

More important is general application design. The Newton UI paradigm was based around the notepad, rather than the desktop…

Newton apps don’t have a “File” menu (since there’s no filing system as such), and no “Save” option. After all, if you scribble something into a notepad you don’t have to “save” it. You would design your application to save its data in response to edits. If you planned on dealing with a lot of data at once it was sensible to design ways in which this data could be split up into smaller frames and stored separately in order to get better storage performance. (Newton devices had limited memory, so this kind of thing was normal practice.) Tapping the “overview” button, located between the up and down scroll arrows, would generally give you a list of all “documents” applicable to the application you were using filtered by the folder you were viewing.

Doing stuff with “documents”, such as duplicating them, printing, sending them as a fax, was done using a standard “routing” menu, signified with an envelope icon. This was actually extensible - new output methods could be added to all apps that supported standard routing options.

It is of course perfectly possible to design desktop apps in a similar manner. From what I understand Apple has done something like this in Aperture, their new high-end photo software - it doesn’t have a save option either, yet all edits are persistent.

The key is to make it easy for the developer to write applications that don’t need a “save” option. It must be trivial to regularly write out updates to persistent storage. Mac OS X 10.4’s CoreData, essentially an SQL database engine, helps Aperture do its stuff. From what I understand you guys have a bit of a head-start on that kind of thing with your storage model.

So, to summarise, this kind of behaviour in apps is essentially down to application design. The only other thing that would help a lot is a hefty chunk of sample code that simply demonstrates how to build applications that don’t have a save option.

xan wrote:
So, to summarise, this kind of behaviour in apps is essentially down to application design. The only other thing that would help a lot is a hefty chunk of sample code that simply demonstrates how to build applications that don't have a save option.

Thanks for the (long winded) explanation :smiley:

So I can see that pretty much the entire device and all applications were designed to retain their state via this object/storage paradigm (which does make sense on a small handheld device with limited power supply).

I’m curious - are there any projects already out there to re-create this type of system? It seems like it would be a good fit for ANY PDA or pocket computer…

In any case, I would think this would make a good “office suite” style project initially… once a developer had evolved a system to a good object design, they could then extend their object model beyond the “office suite” product into other applications where it made sense.

TUNES or Slate or most dynamic programming languages (Squeak, LISP, etc.) will be able to do this. We see the limits of C++ and static programming, here. Orthogonal persistence should be done correctly and with the right language. IMHO, in future, Haiku should switch to a more modern programming (but still efficient) language or at least use the more effective one where appropriate.

I think the People app would be a classic way to start off this persistant save state in earnest. It drives me round the bend that I have to save a person when I’ve entered their details in. Why on Earth not save it as you move from data cell to data cell? Surely People is small enough an app to get away with the disk I/O cost?

expensivelesbian wrote:
I think the People app would be a classic way to start off this persistant save state in earnest. It drives me round the bend that I have to save a person when I've entered their details in. Why on Earth not save it as you move from data cell to data cell? Surely People is small enough an app to get away with the disk I/O cost?

Maybe DW will hear you :wink:

Edit: Oh…maybe he’s already ahead of you:

http://darkwyrm.beemulated.net/apps.htm

“Autosave” – I’m guessing that’s similar to what you’re after

Yeah, I can go on a bit sometimes. Sorry about that. :slight_smile:

There was at least one project with the aim of recreating a Newton-like environment, but that died off quite a while ago. There is also a Newton emulator (called Einstein), but that frustratingly requires access to a Newton to download the ROM image. All my Newtons are in storage so I haven’t got to play with it yet.

Whilst it’s true that dynamic object oriented languages and environments tend to have better object persistence, this is so much a demonstration of the limits of C++, but rather the APIs that get used with it. (There are IMHO many other reasons to use something other than C++.) The way we design desktop applications as well as the file formats we insist our applications are compatible with are also major factors here.

It is perfectly possible to have APIs that facilitate persistent data in C++ and other static languages.

Newton applications save small amounts of data frequently, which is exactly what you need to do for such apps. If you edit a cell in a spreadsheet then the spreadsheet app would only save that single cell.

There are two key things needed to make this work. Firstly the data model of the application needs to be broken down into lots of relatively small objects. Secondly you need to use a fast database for your application’s native storage to store those objects.

To get compatibility with other file formats you need to import and export in those file formats.

It is possible to make just about any kind of application work in this way - it often takes some imagination though to work out quite how to break down your data model.