Hacker News new | comments | show | ask | jobs | submit login
Why can't modern languages (like ruby) serialize themselves like smalltalk?
6 points by endlessvoid94 1774 days ago | hide | past | web | 2 comments | favorite
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.

1) Is this an accurate understanding?

2) What is the challenge in adding this ability to modern languages (non-lisp, obviously)?

3) Is "serialization" the right word? What's the correct jargon?




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





Applications are open for YC Winter 2018

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: