From: Richard Conroy Date: 2011-03-15T21:24:08+09:00 Subject: Re: Understanding YAML and this practice in general --001636d33c961e9e96049e848179 Content-Type: text/plain; charset=ISO-8859-1 On Tue, Mar 15, 2011 at 11:48 AM, Fily Salas wrote: > Thank you for your reply! I now have a better idea as to what YAML does > and its big plus, it basically makes the store objects human readable, > even though I still don't know have a clear picture as to where or how > this will be used later, but I guess the answer will come later when I > gain more experience. > > Again I don't have too much experience with high level languages other > than Actionscript 3.0 and JavaScript. > > Hi Fily, it is often very useful to save the state of your program (or just a piece of it to the hard disk). You usually do this for the following reasons: - you need to restore the state of the program after you have switched it off and restarted it - you need to save user operations and work in a manner that you can easily load Using traditional means (databases, export formats etc.) this process is actually technically challenging to do. It usually involves writing a lot of code yourself to make the transformations, and dealing with any corruption. YAML on the other hand, saves your Ruby objects themselves. Its representation is standardised, so saving the state of your Ruby objects is simply a manner of passing the object to the appropriate function. Restoring is the reverse. It is an extremely simple procedure that is useful in a lot of contexts (it is not suitable for large sets of data, or heavy use). For instance, the YAML file can be moved between machines and used to replicate the data on another instance of the running program, either by manually transferring the file, or sending it over the network between the computers themselves. Also YAML files are human readable and human editable, which is also an advantage - especially if you are using them for compiling test data, or exporting the state of a running program (could be handy for debugging crashes). YAML is not the only technique for dumping the state of a program in Ruby (and these techniques are not Ruby specific either). In the JavaScript world, JSON fulfills almost exactly the same purpose. I believe that measures have been taken to make JSON and YAML grammatically compatible. regards, Richard -- http://richardconroy.blogspot.com | http://twitter.com/RichardConroy --001636d33c961e9e96049e848179--