This post originated from an RSS feed registered with Agile Buzz
by James Robertson.
Original Post: Persisting the Joys of the REPL
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Dumb question - you are happily programming in the environment, and the lights go out. Have you lost your state? How do you save “source” code? I'm interested from the angle of irb, as I like ruby. I still think in the mode of writing the source in an editor, checking it in, etc. I can't seem to imagine this environment in terms of day to day work, esp with a development group.
The answer goes over the typical "save your files" response, and then gets to images:
Don't despair, there are better ways. Most CL implementations and several Schemes (MIT/GNU Scheme and, again, scheme48 come to mind) allow you to save your complete state, at any time, in what is called and image file . This image contains a binary snapshot of the interpreter's state, and you can reload it at any later time. Being a binary representation, it will come to life blazingly fast. Besides Lisp, Smalltalk is the paradigmatic (and possibly pioneer, but i'm not 100% sure on this) image-based language: for instance, in Squeak , the only way to launch the environment is loading a previously saved image, which contains detailed information of your previous state (including the graphical environment). In this sense (and many others), Smalltalk is a dynamic programmer's dream come true.
Images makes things even better, but not perfect: you still need to save your state every now and then. In an ideal world, persistence should be automatic, managed behind the scenes by the system, even by the operating system.
Well, in Smalltalk - certainly in VisualWorks and Squeak - even a power outage isn't going to end up losing you any work (unless your HD dies simultaneously, of course). As it happens, each change you make to your image is saved off in a transaction log called the change file. When you restart the image, you can load the change file into a tool, and replay all (or a set of specific) actions so as to restore your state.
So if you are working on a large set of changes, and *poof* - off go the lights - when power comes back, you can roll it all back in. I think I'll do a screencast on that next week - it's a very cool, but under-publicized, feature of Smalltalk.