In this video, I'd like to explain a little bit
Pharo's different packaging ways, in order for
not to get lost in the future.
When you install Pharo, you will normally click on a link
given, but if you go on Pharo,
the release at the moment of this video
is version 4, but version 5 will be exactly the same.
When I downloaded Mac OSX version, I get this zip.
If I unzip this zip, I get what I call Pharo4 app.
When I launch Pharo 4 app, I get Pharo.
Let's imagine we write
"Hello". When I save, it will save the environment.
I click on Save.
If I click on Quit now, I will launch it again,
and I will have exactly "Hello", because saving the Pharo
image is making a memory copy with all the
objects included Bytecode objects and compiled methods.
What is there in
this application?
On Mac, we can what is inside.
If I click on Show Contents, what will I see?
I'm going ti find a Pharo virtual machine and resources.
And here, I will find a changes file and an
image file.
The image file is the one that really contains
the objects representing the memory, and the changes file
is a file comprising all the incremental changes
done. If I double-click
on the image file,
normally, depending on the OS, I will launch it on
a Pharo virtual machine that I have installed, it
will launch again my image file.
This image file, what happens with it?
Let's imagine I define a classe.
I'm going to define a package,
"Add package" "ATest".
In this package,
I'm going to define "MyStrangeClass".
I define it and here, I put "foooo" which returns
42.
If I save this image with another name, I'm going
to save it with the name
Pharo40Stef.
What did it do?
I quit. It created another pair
image and change. In this changes file, we won't open it
because it is not readable by a human, there is
the methods code I have just created.
And if I launch again Pharo 4, I'm gonna
launch it using the virtual machine, I get
once more the snapshot, what we call the system
copy that I had done at a certain moment
before.
Now, if I execute again PharoStef image, what will it
do?
It will show me the system with my new class.
The Pharo 4 application, it is what we call a Mac
bundle which contains the Pharo VM plus an image plus a change.
If I double-click on it, I don't have any choice, it
will always choose Pharo image because it is a script
that has coded: "Here it is, this is THAT image."
In general, it is useful at the beginning of the use of
Pharo, but we do not use it.
In general, either we use an instruction of the command
line which is something like
Pharo-ui with MyPharoImage.image
and this will
send the thing. Or if we use command line and we
don't want to have the ui, we will do that kind of things.
It means that Pharo is installed somewhere in
your system as a standard Unix application.
Now, you see on this page
that you can download a Pharo
pair, you can download a virtual machine.
We are gonna download the virtual machine and
download an image pair and also source.
I'm gonna explain what it is, this way we will have the
3 at hand, we will play together.
Now if I unzip the file corresponding to
Pharo Image and Changes, I get this one.
When I unzip, what do I get in Pharo in this file?
I get an image.
We will do it in a mode where you can
see what is inside.
It means that this file, it is again an image pair
corresponding to a certain state of the snapshot or of the
Pharo image, of the virtualised system. Here, I can execute it
on the Pharo image.
I get a message, what is this message?
The system can work since I can execute anything.
I can run it.
Now, I can do exactly what I did before.
I can define MyPackage, and in MyPackage
I will say MyStrangeClass.
So we start to be used to it.
I define a method:
fooo 42. It asks for my login.
I can do as usual "MyStrangeClass new foo"
and I get 42.
So, very good. I can save.
I save it for example with another name,
Stef, I name it PharoStrange.
OK.
What does it say?
It says “I can’t find the source file
Pharo 4. 0." Why does it say this?
When I open the browser, if I can see for instance the
AST code, this is not your code, so we go at the top.
The reason why the system
doesn’t find the comments
is that it is decompiling.
So, we don’t see it because the methods are
too simple, but it decompiles the code.
Let’s go on something more concrete.
Here it decompiled the code, the Bytecode represents an
an argument and it knows very well that this is an argument.
But we lost the source.
In general, the sytem source, when Pharo
is implemented, is stored in a file called Pharo 4 source
that you can find here.
In general Pharo 4
source will be installed once on the system because
this file is on read only, and all your
applications can use it.
I have it here, I’m gonna unzipp it.
Here I have Pharo4.source.
If I quit without saving
and I relaunch the application, here anyway you see
that it does exactly the same as previously, it is to say
that when I save a snapshot giving it
another name, I have once more a system with 2 things:
the image and its changes.
Here if I take my old image, there
is no more error because it has found the code and it
knows that it corresponds to the state there was
when we launched the first image.
Now if I use the second one,
if I consider the file AST-Core, first
my classes have comments.
Here these are really the names people gave.
If we look at this architecture, what do we have?
We have the source file containing the system sources,
in general, once the system is compiled, the compiler
doesn’t need the sources,
the virtual machine and image and change pairs.
Image contains all the objects that have been defined plus
the system objects, with the changes files which
contains the deltas of what you’ve done compared to the changes file.
Each time you save you system, it is
as if you save a virtualised image of your OS.
This is exactly the same principle.
If you look inside the Pharo 4 application,
you will find those ressources.
I have the Pharo 4 sources, I have the image file,
the changes file and somewhere here the virtual
machine with its plugins.