What gives Smalltalk the ability to do image persistence, and why can't languages like Ruby/Python serialize themselves?

后端 未结 4 1223
青春惊慌失措
青春惊慌失措 2021-02-07 05:13

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 p

4条回答
  •  不要未来只要你来
    2021-02-07 05:43

    It's much simpler than "serializing". A Smalltalk image is simply a snapshot of the object memory. It takes the whole RAM contents (after garbage collecting) and dumps it into a file. On startup, it loads that snapshot from disk into RAM and continues processing where it left off. There are some hooks to perform special actions on snapshot and when resuming, but basically this is how it works.

    (added: see Lukas Renggli's comment below for a crucial design choice that makes it so simple compared to other environments)

提交回复
热议问题