Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pharo 3.0 - Is persistence automatic?

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?

like image 987
MrDuk Avatar asked Jul 02 '13 18:07

MrDuk


2 Answers

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.

like image 63
camillobruni Avatar answered Nov 11 '22 10:11

camillobruni


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/

like image 2
Stephane Ducasse Avatar answered Nov 11 '22 10:11

Stephane Ducasse