Serialization, marshalling, etc.: Difference between revisions
Jump to navigation
Jump to search
(Created page with " <!-- Serialization seems to originate from "that your programming language lets you think of it purely functionally is great and all, but when you want to write whatever you have to a sequence of bytes on disk, how do you do that?" (which, note, relates to the concept of reification) https://en.wikipedia.org/wiki/Marshalling_(computer_science) https://en.wikipedia.org/wiki/Serialization -->") |
mNo edit summary |
||
Line 11: | Line 11: | ||
--> | |||
<!-- | |||
Marshalling - "talking a memory format and put it in a format that can be stored or transmitted." ([https://en.wikipedia.org/wiki/Marshalling_(computer_science) wikipedia]) | |||
You'll note that the sense of "creating a byte representation" is already covered by serialization, so apparently it means something else. | |||
That 'something else' is exactly depends a lot on context. | |||
That context is almost invariably a very specific OO thing. | |||
Concepts I've seen referred to as marshaling | |||
* the general concept of getting an object from program/computer A to B. that is | |||
:: where serialization has the connotation of storing for later use | |||
:: marshalling has having the connotation of moving structures around between running programs, using [[RPC]]. | |||
* specific implementations of such, e.g. in COM | |||
* serialization to do that | |||
* marshalling sometimes means 'standard format' instead, like a word document | |||
* marshalling tends to suggest shorter timespan, temporary transport only | |||
: whereas serialization is often about equivalent storage on disk so can be permanent | |||
: marshalling is frequently more about parts of a running system | |||
* marshalling can be serialization plus telling loading code what class (that is already defined by the codebase) to create | |||
:: sensitive to abuse | |||
* marshall''er'' can refer to the code that does the serialization, but otherwise serialization=marhalling | |||
* marshalling can be serialization that also transports code | |||
:: sensitive to abuse | |||
* marshalling by reference - where what you communicate is the ''location'' of the data needed to (re)create the object | |||
* Scriptable runtimes, e.g. spidermonkey, where there is a C++ and a JS representation of the same DOM elements | |||
It can be context-specific. | |||
* For example, .NET | |||
** uses serialization for 'storing/transporting objects'[https://docs.microsoft.com/en-us/dotnet/standard/serialization/] | |||
** and marshalling for other things, like type marshaling in C# - amounts to "yeah so native and managed code may have different ABI, so we need you to tell us" [https://docs.microsoft.com/en-us/dotnet/standard/native-interop/type-marshaling] | |||
::: not necessary for [https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-1.1/75dwhxf7(v=vs.71)?redirectedfrom=MSDN blittable types]. | |||
* Java | |||
:: sometimes just serializing things [https://docs.oracle.com/javase/7/docs/api/javax/xml/bind/Marshaller.html] | |||
:: sometimes object specific (e.g. JAXB) | |||
Also, | |||
: marhsalling seems preferred over serialization when describing conversion for something by some other sub-system (e.g. APIs or IPC), particularly those not controlled by us. | |||
: marshalling seems preferred when it's not a byte format - e.g. formats that go via XML or SOAP | |||
: marshalling is more OO-geared in that it focuses on the call parameters that need to happen | |||
:: apparently a COM definition? | |||
: marshalling may refer more to | |||
: in some contexts, serialization may imply just public fields, while marshalling is also private data{{verify}} | |||
: in this context, serialization is taken to mean by"" | |||
Serialization is a subset of marshaling where the representation is defined to be a stream of bits/bytes | |||
When you look for "what is the difference between serialization and marshalling", it's surprising | |||
how many people do not actually explain the difference, or use the wrong definition. | |||
Serialization is more specifically concerned with a bytestream representation, and for anything you care to represent. | |||
Marshalling just cares about getting a single object from point A to B. | |||
When throwing parameters at remote procedure calls, there isn't really much difference. | |||
In C#, serializing seems to care only about the public fields, whereas marshalling (when it doesn't mean something else) means | |||
In other contexts, we are usually talking about Java or C# or perhaps Ruby (you'll get few hits for all of the other OO languages). | |||
Marshalling will often store the | |||
Meaning that it stores which class it's recreating. Basically so that you can do: | |||
Player p = Marshal.load(stored_object) | |||
instead of | |||
Player p = Player() | |||
p.load(stored_object) | |||
or | |||
Player p = Player(load_from=stored_object) | |||
Those reasons are that this hides more trouble than | |||
Marshalling also often means not writing a representation, but full object state, so that you can transport the entire thing and use it as an object on the other side. | |||
Downsides: | |||
* you basically need to write custom marshalling, always | |||
* it can be security sensitive | |||
* good luck figuring out what to do with objects referencing other objects | |||
Unsorted | |||
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dcom/d325327c-4b2c-4096-964e-c596feffd929 | |||
--> | |||
<!-- | |||
https://en.wikipedia.org/wiki/Marshalling_(computer_science) | https://en.wikipedia.org/wiki/Marshalling_(computer_science) | ||
https://en.wikipedia.org/wiki/Serialization | https://en.wikipedia.org/wiki/Serialization | ||
--> | --> |
Latest revision as of 10:53, 23 May 2024