A common problem in programming is moving the program data to another spot, such as a file on disk or another computer. For example, suppose a video game needs to store a saved file on the hard drive. Normally, the developer would have to write a method that takes all the game information and puts it into a format that can be placed on disk. Another method needs to be written to reverse this. The concept of serialization, used in some programming languages, bypasses this.
If a language has serialization libraries, this means that these functions are built in. You can input an object and have built-in language libraries convert the object to data. And of course, you can do the reverse. Instead of having to write code and create your own format for storing program information, you can just have the language do it. This has a wide variety of uses besides the video game save file mentioned in the intro. Suppose you want any program to store user-inputted data. You can simply put that data into a serializable object, that write it to disk. When the program starts up again, use the deserialization methods.
This can also be used for network communications. Consider the problem of writing client and server programs that can communicate with each other. Instead of having to process data, you can just serialize the object and transmit its data over the network. As long as the client and server know what class is being used, this works.
However, not all programming languages can be serialized. Generally, this is only a feature of higher-level languages. .NET has it with the Serializable attribute for a class. For Java, the java.io.Serializable interface is used. Classes that implement this interface can be serialized. Even low-level languages such as C++ have the ability, albeit not in the standard library. The popular Boost C++ library has functions that provide the serialization ability.
However, there are also problems caused by serialization. Many languages do not have backwards compatibility. So if you write a new version of the program and try to use it with existing serialized data, it can fail. Fortunately, some languages do have backwards compatibility features that avoid this drawback.
Serialization is a useful tool that all programmers should know about. It provides an easy way to store program data permanently and transmit it between multiple computers. For languages where serialization libraries are built-in, this is generally very easy.