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

后端 未结 4 748
情深已故
情深已故 2021-02-07 04:55

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:48

    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)

提交回复
热议问题