Author Topic: Serialization / Deserialization  (Read 11477 times)

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Re: Serialization / Deserialization
« Reply #25 on: September 27, 2016, 02:21:19 AM »
Quote
One extra negative that isn't being mentioned about JSON is the requirement of needing JavaScript to use.

JSON in no way requires JavaScript. It's just a text based data format, like any other. Any language that can parse text files (i.e. all of them), can parse JSON files. Pretty much every language out there now already has a JSON library to parse these files. Even if you didn't have a library, it's a simple format, and easy to write a custom parser to handle it.

For a list of JSON parsers in other languages, see the bottom of the JSON homepage. I count about 45 languages, some of which have over 10 libraries to choose from for parsing JSON. (Java has 25 libraries listed).

The name, JavaScript Object Notation simply derives from the fact that the data format closely matches the subset of the JavaScript language for defining literals. This subset is quite simple, and in no way requires parsing of the full JavaScript language to process. Also worth noting, if you examine the literal section of any programming language, they don't usually differ all that much. In regards to JavaScript however, JSON has some differences. It is possible to have a valid JSON file, which is not valid JavaScript. The difference is largely to do with escaping requirements for special Unicode characters for line termination, line separation, and paragraph separation.

The popularity of JSON comes from use in web programming, where JavaScript is the only universally supported client side language. Due to the high similarity between JSON and JavaScript, it was possible to parse a JSON response from the server by simply calling eval on the string returned from the server. This is of course unsafe for untrusted sources, since it would execute any JavaScript code, not just parse JSON objects. As such, this use of eval has fallen into disuse. Instead, even JavaScript itself now has standard JSON parsing code (JSON.parse). No matter what language you use, JSON still gets parsed, not interpreted.

Quote
Yes JavaScript is a scripting language, but all scripting languages REQUIRE an interpreter of some kind on the system to use it. If you don't have the interpreter you can't use JavaScript. When people don't install JavaScript on their machine, they are purposefully trying to avoid auto-activating scripts and the only surefire way to avoid them is to not have a JavaScript interpreter or any of the runtimes installed. Hope I've made things clear enough.

Your web browser comes with a JavaScript interpreter. It doesn't need any special installation. It can't be unbundled from the browser. Every OS out there today comes with a packaged Web Browser. Internet Explorer, Firefox, Chome, Safari, Netscape Navigator, they all have a JavaScript interpreter.

It sounds a bit like you're confusing JavaScript with Java. Java does need to have a separate runtime installed. Java also has extensions for use on the web, such as Java applets. Java can be used for desktop only apps which have nothing to do with the web. You can use Java on a server. You can also use JavaScript outside of a web browser, using something like Node.js, which is often used for a server side JavaScript environment used in web apps.

Quote
Also wonder which came first, Java or JavaScript.
Both languages appeared May 23, 1995. The similarity in name is largely due to marketing reasons. The languages themselves are quite distinct. They both had strong early ties to web browsers.
« Last Edit: September 27, 2016, 11:41:48 PM by Hooman »

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2350
  • OPHD Lead Developer
    • LairWorks Entertainment
Re: Serialization / Deserialization
« Reply #26 on: September 27, 2016, 09:59:57 AM »
I think Hooman nailed it. Don't think I can add much more to this.