

Why can't modern languages (like ruby) serialize themselves like smalltalk? - endlessvoid94

In smalltalk, you're able to save the state of the world into an image file. I assume this has to do with Smalltalk's ability to "serialize" itself -- that is, objects can produce their own source code.<p>1) Is this an accurate understanding?<p>2) What is the challenge in adding this ability to modern languages (non-lisp, obviously)?<p>3) Is "serialization" the right word? What's the correct jargon?
======
MarcusDenker
1) No. The object-as-sources ("storeString") is very slow an has many negative
effects. E.g. the result is a large string, you need the compiler for de-
serialization... all in all, if you look at current Smalltalks, this feature
is not used too much.

Saving the whole state of the world to an image is not implemented by using
#storeString. Instead it saves the whole heap of the vm to a file. Very fast,
but of course this means that the resulting file is specific for 32bit vs.
64bit, endianess... and, very important, object layout (Object Headers are
saved as they are in memory). So it is not really serialisation in the classic
meaning of the word.

2) Implementing storeString like in Smalltalk needs some reflective features,
e.g. enumerating instance variables, setting instance variables after creating
new objects when recreating. And the compiler needs to be part of the
language, as the string is one huge Smalltalk expression.

3) For image snapshotting serialization is not really the correct term. The
memory is just written from RAM to Disk. For #storeString, yes, this is
serialization.

For more infos about a modern binary serializer for Smalltalk, see Fuel:
<http://rmod.lille.inria.fr/web/pier/software/Fuel>

------
seiji
Explained briefly at [http://en.wikipedia.org/wiki/Smalltalk#Image-
based_persisten...](http://en.wikipedia.org/wiki/Smalltalk#Image-
based_persistence)

