flutter / website

Flutter documentation web site
https://docs.flutter.dev
Other
2.82k stars 3.22k forks source link

Clarify differences between serialization and encoding on 'JSON and serialization' page #5182

Open richardhaven opened 3 years ago

richardhaven commented 3 years ago

Page URL: https://docs.flutter.dev/data-and-backend/json Page source: https://github.com/flutter/website/tree/master/src/docs/development/data-and-backend/json.md

Description of issue: "Encoding and serialization are the same thing—turning a data structure into a string"

I understand some simplification and generalization, but this is flat-out WRONG. Please make the context of this specific example clear

sfshaza2 commented 3 years ago

@johnpryan, @domesticmouse, can we clarify this?

domesticmouse commented 3 years ago

Apologies for going all citation required, but can you please explain why you believe that Encoding and serialization are different concepts?

According to Wikipedia's Code page: The process of encoding converts information from a source into symbols for communication or storage.

Likewise, the Wikipedia page on Serialization states: In computing, serialization (US spelling) or serialisation (UK spelling) is the process of translating a data structure or object state into a format that can be stored (for example, in a file or memory data buffer) or transmitted (for example, across a computer network) and reconstructed later (possibly in a different computer environment).

I'm having trouble figuring the difference between the two definitions. Please enlighten me?

richardhaven commented 3 years ago

One can encode something (e.g. UTF-16, xor) without creating something to be transmitted and received

I grant that the difference is small in practice, but the two terms have different intents, and perhaps that difference deserves two different words

Cheers

domesticmouse commented 3 years ago

I totally agree it would be good to have two different words for these closely related concepts, but we have to deal with words as they are currently used in practice. However, given the currently accepted definitions for the words, I'd argue the statement "Encoding and serialization are the same thing—turning a data structure into a string" is more true than false, as much as we might like it to be otherwise.

richardhaven commented 3 years ago

One can encode a string into a non-string (e.g. zip files)

Cheers