Pharo 3.0 - Is persistence automatic?
Asked Answered
J

2

5

I noticed that after running into an issue last night, relaunching Pharo 3.0 didn't "undo" my working set - everything appeared to be as it was when I closed it. I saw where Fuel is included with Pharo now - does it automatically persist your session? I was under the impression that you had to do some tricks to make it actually work with your application.

Am I wrong?

Jasmine answered 2/7, 2013 at 18:5 Comment(0)
U
8

Pharo uses an Image. The image basically is the snapshot of your memory contents when you use Pharo.

Upon startup this image is loaded from the image-file into memory and Pharo starts to run. The inverse happens when you save (snapshot) your session: the current state/memory is saved to the .image file. That includes all tools opened in the current session, all running processes and all live objects.

This has nothing to do with Fuel, which is a separate object serialization library.

Update answered 2/7, 2013 at 19:8 Comment(1)
for serializing single object graphs, for instance to persist a certain object or send over the internet. That is a very different from persisting the whole image. Saving the whole image is much less efficient.Update
T
2

There are two mechanisms in Pharo:

  • The image. The image is a memory snapshot containing all the objects (and in particular the compiled methods and classes as objects). When you save the image, you are saving the complete state of the system to disk. You can open an image (it loads the memory back and the execution continues where it stopped). In fact there is also another file that is called the change file. This file contains the textual representation of the classes and methods you edited. The tools are using this file to show you method code for example.

  • Now in addition to the concept of image (memory snapshot). The system records in permanence your code edition. After each compilation phase, the change is committed to the changes file. You can see what you did using the changeSorter or version browser (note that if you do not save your image, your changes will not be browsable using a changesorter because it is a simple tools). Now even if you did not save your image, your changes are logged in the changes file. There is a way to recover your changes using the "Recovery lost changes..." menu item under the Tools menu. With this tools you can browse all the changes that have been recorded automatically and replay them. We are working on new tools for the future.

Now in general you should not rely on such tools. Using the Pharo distributed version management system (monticello) to create packages and publish them on forges such as SmalltalkHub.

Finally Fuel is an object serializer that is not used for saving Pharo snapshot. Fuel is a fast serializers that people used when they want to select what they serialize - usually graphs of objects.

All this information is also available in the free Pharo books: http://pharobyexample.org and http://rmod.lille.inria.fr/pbe2/

Trueman answered 4/7, 2013 at 8:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.