Prev: Reading files
Next: Reading files
From: Ian on 13 Aug 2010 15:19 Most major programming languages have a way to serialize their objects to allow safe passage across many different interfaces (the network, stored in a database, read aloud by robot slaves, you get the idea). I've found no way other than kludges so far to serialize matlab data robustly. I've seen some user submissions to get only certain data structures into XML, but no way for example to do the same for class instances and the like. But no JSON/BSON, protocol buffers or other known formats at all. Do any Matlab Central gurus know how to serialize matlab objects -- is there some magic sauce that Java could add to use its serialization functions on matlab objects? Shouldn't the Mathworks implement serialization as a core part of Matlab?
From: Walter Roberson on 13 Aug 2010 15:35 Ian wrote: > Most major programming languages have a way to serialize their objects > to allow safe passage across many different interfaces (the network, > stored in a database, read aloud by robot slaves, you get the idea). Ah? Could you name a few of those "most" ? I'm drawing blanks for the several dozen programming languages I've worked with. > I've found no way other than kludges so far to serialize matlab data > robustly. I've seen some user submissions to get only certain data > structures into XML, but no way for example to do the same for class > instances and the like. But no JSON/BSON, protocol buffers or other > known formats at all. JSON is useless for serializing anything at all complex. BSON I would have to look at further, but I do not see at the moment how one would encode, say, behaviour for variables in such a way that when the remote system changed the variable, the update was propagated back to all interested parties -- and if you cannot do that then you have not serialized objects _robustly_ .
From: Ian on 13 Aug 2010 17:50 Walter Roberson <roberson(a)hushmail.com> wrote in message <i446rf$mrt$1(a)canopus.cc.umanitoba.ca>... > Ah? Could you name a few of those "most" ? I'm drawing blanks for the several > dozen programming languages I've worked with. OK, that probably shows I'm a neurobiologist and not a computer engineer (and with a bias to newer dynamic languages like matlab to boot) sorry to have have offended :-) -- Java, Objective-C, Perl, Python, Javascript, Ruby, PHP and several others as I know, but your experience is probably much larger than mine, I only use Matlab, PHP (for the web), Objective-C, Ruby and a smattering of javascript. > JSON is useless for serializing anything at all complex. but good at serializing many types of standard data and a lot of dynamic languages and network frameworks have robust support for it. > BSON I would have to look at further, but I do not see at the moment how one > would encode, say, behaviour for variables in such a way that when the remote > system changed the variable, the update was propagated back to all interested > parties -- and if you cannot do that then you have not serialized objects > _robustly_ . I suppose so, but many use cases would not require one->many support. In concrete terms, I have two matlab machines running on a network, and i want to send an a couple of objects (class instances) which generated a stimulus to another machine to read their values (not write back or round-trip). I can save them to files, zip them and send over the network somehow, unzip them to file and open. But surely there has to be a more elegant way of serializing the data between these two? Or how about sending an object to be stored in a SQLite database?
From: Walter Roberson on 13 Aug 2010 18:06 Ian wrote: > I suppose so, but many use cases would not require one->many support. > In concrete terms, I have two matlab machines running on a network, and > i want to send an a couple of objects (class instances) which generated > a stimulus to another machine to read their values (not write back or > round-trip). I can save them to files, zip them and send over the > network somehow, unzip them to file and open. But surely there has to be > a more elegant way of serializing the data between these two? Or how > about sending an object to be stored in a SQLite database? Perhaps http://www.mathworks.com/matlabcentral/fileexchange/12063-serialize Keep in mind though that the action of reading an object can trigger a method, and indexing an object (subsref, subsassign) very likely requires triggering a method. Those methods might trigger actions that have to be done on the original machine, or might involve variables in a workspace on the original machine (e.g., a class that counts the number of times the object was read, perhaps because the class implements MRU caching.) Your proposed methods are not _robust_ for objects, which was the exact complaint you had originally about existing serialization methods. If you don't mind greatly restricting the object behaviour you support (e.g., if to your "objects" are really just structure arrays of basic numeric types, characters, cells, and structure arrays) then the possibilities expand a fair bit.
|
Pages: 1 Prev: Reading files Next: Reading files |