Live data from Hacker News

JSON vs. XML

corecursive.com

201–210 of 252 posts

Re: JSON vs. XML

#201
post #23

Earlier quoted context omitted.

Scala had XML literals as part of the language! Apparently Philip Wadler was the person who told them needed it, because the future was XML. ( Walder is big Haskell/PL person)

Was it far from JSX?

It was almost literally JSX (except with Scala syntax instead of Javascript, of course).

An XML literal in Scala would have been:

  // XML literals (to be dropped)
  val mails1 = for (from, to, heading, body) 
      {from}{to}
      {heading}{body}
    
  println(mails1)
This was replaced with "XML string interpolation", which

  // XML string interpolation
  val mails2 = for (from, to, heading, body) 
      ${from}${to}
      ${heading}${body}
    """
  println(mails2)

Re: JSON vs. XML

#202
"So Netscape thought they could do a similar thing for their navigator browser that, if they could get people programming in the same way that they did on HyperCard, on the browser, but now they can have photographs and color and maybe sound effects, it could be a lot more interesting, and you can’t do that in Java."

It's like the man never tried. Try a Java enabled browser: https://www.wikihow.com/Enable-Java-in-Firefox

Just as a reminder Minecraft (the most sold game in history) started out as an Applet.

Applets where not horrible because of the underlying technology, they where horrible because people made bad things with it, just like J2EE was a bad thing people made with J2SE.

But sometimes, rarely, people would make beautiful things with J2SE and J2ME and those are now removed from history forever under the banner of security like everything else that is good in life.

Re: JSON vs. XML

#203
post #171

Earlier quoted context omitted.

Don't you also have to escape stuff in XML? Like &gt, which is even worse.

Yes, though many languages have lenient parsers. Most browser parsers, for example, will probably only be lenient if parsing "HTML." new XMLSerializer().serializeToString(new DOMParser().parseFromString(" hello ", "text/html")) The above in my console does as expected there. And again, entities are a very dangerous part of XML and friends. You are correct that if you tell it that that is xml, the browser will throw i…

per specifications, json parsing is not lenient, html parsing is lenient

Re: JSON vs. XML

#204
post #196

Earlier quoted context omitted.

JSON vs XML isn't going to make or break your project. But why would you use XML for data interchange. It makes sense for things like HTML where you're writing a document, but otherwise, it's usually just a needless burden. Like, if I were there when XMPP was created, yes I would have insisted on JSON. XML was a plainly bad choice. Edit: Oh, JSON didn't exist until a little later. Maybe something similar did.

I mostly agree. I do think Jupyter choose wrong by picking JSON for their documents. They are literally marked up source documents. XML does have the "benefit" of being a bit more extensible than JSON. Specifically, being able to have namespaced elements in there does make some sense on paper. For example, you could have two extensions both add in data using the same keys, but different namespace. Can't really do tha…

Yes, XML is probably a good fit for something like Jupyter. Basically if you want to reuse a lot of "objects" throughout a structure and have the mean the same thing in different nested parts of it. Like how in HTML means a hyperlink whether it's under or some nested .

Re: JSON vs. XML

#205

Earlier quoted context omitted.

Every key is written twice, for opening and closing. Keys can be duplicated, and in fact that's what you have to do if you want a simple list. There aren't numeric types, so you have to parse strings. It also looks horrible. Led Zeppelin II Led Zeppelin 999 La Brise Arax 999 or Led Zeppelin II Led Zeppelin 999 La Brise Arax 999 vs something like [ {"title": "Led Zeppelin II", "artist": "Led Zeppelin", "price": 999},…

Thanks. I get your point about the close element including the tag name - but that's the kind of detail I leave to the serialisation library, in the same way that the close scope token in json is different to the start scope token. As for "looks horrible"... well yeah, I always feel that xml looks "spikey" somehow. But I've been programming in curly-brace languages for 30+ years and I still find json harder to read t…

> At least we're not stuck using ASN1.

Prepare for trouble, and make it double: http://xml.coverpages.org/dstc-xer2.html

Re: JSON vs. XML

#206

I worked on a customized ejabberd at a company for years, drinking all the XMPP kool-aid and becoming very familiar with XML along the way. Slowly we all began to realize how bad XML was. We eventually put our custom extensions' data into JSON just embedded inside the XML. Says a lot that such a hack was actually an improvement. The other two premier XML use cases I can think of are 1. RSS: Last time I did this, iron…

3. HTML-like things where XML actually makes sense cause you're defining some sort of document with reusable objects that gets rendered at the end.

Re: JSON vs. XML

#207
post #171

Earlier quoted context omitted.

Yes, though many languages have lenient parsers. Most browser parsers, for example, will probably only be lenient if parsing "HTML." new XMLSerializer().serializeToString(new DOMParser().parseFromString(" hello ", "text/html")) The above in my console does as expected there. And again, entities are a very dangerous part of XML and friends. You are correct that if you tell it that that is xml, the browser will throw i…

per specifications, json parsing is not lenient, html parsing is lenient

Right, and amusingly, more than a few json parsers are very lenient in this. That or folks abandon ship fairly quickly and go for another spec that is far more friendly.

Re: JSON vs. XML

#208
post #196

Earlier quoted context omitted.

I mostly agree. I do think Jupyter choose wrong by picking JSON for their documents. They are literally marked up source documents. XML does have the "benefit" of being a bit more extensible than JSON. Specifically, being able to have namespaced elements in there does make some sense on paper. For example, you could have two extensions both add in data using the same keys, but different namespace. Can't really do tha…

Yes, XML is probably a good fit for something like Jupyter. Basically if you want to reuse a lot of "objects" throughout a structure and have the mean the same thing in different nested parts of it. Like how in HTML means a hyperlink whether it's under or some nested .

I'd phrase it more that there is a document with mixed use items marked up throughout it. Some items in the document are code, in which case you probably want to fence the code with a marker on what language is used. Other items are just prose, in which case you'd like to just write the prose as much as you can.

Some items can even be other forms of xml that have their own schemas dictating what is valid. (Thinking SVG here.)

I'll also note that even there, I can see why HTML went with the odd parsing they do. XHMTL tried going with "well formed" documents, but that falls flat for the authors. Is why "sections" of a document are essentially just collecting all of the "h" tags and making an implied tree out of that. As opposed to making the tree directly. To that end, my markup language of choice for Jupyter style things is org-mode in emacs. Yes, it has some warts; but again, all formats that I have ever seen have warts.

Edit: I want to add that I don't intend this as a "correction." I should say that I agree with your post. Complicated field where I doubt I'd have done better than most others. :)

Re: JSON vs. XML

#209

If it's not obvious, the issue is that standardizing a data format is going to have trade offs. Interoperability, leveraging tooling universally so all effort is going in the same direction, awesome. The problem is that some uses cases for the format are going to be insanely complex, which will make the standard and tools unnecessarily complex for the simple cases. JSON is simpler and easier for many cases, but then…

> you're going to end up translating JSON XML which isn't fun. Not fun? It's not even possible in the general sense. If you have XML that looks like: cheese How would you convert that to JSON without knowing how the JSON consuming application expects it to be formatted? Where do you put the "breakfast" and "count" attributes? You'd need to manually write a translator for each potential translation.

> You'd need to manually write a translator

Yep, therein lies the “not fun”. You write a bunch of super complex, brittle code.

Unfortunately because XML is entrenched in certain domains, you have to decide between writing these converters or doing everything in XML which also sucks, especially if you’re trying to write a modern app with a modern stack.

Re: JSON vs. XML

#210
post #207

Earlier quoted context omitted.

per specifications, json parsing is not lenient, html parsing is lenient

Right, and amusingly, more than a few json parsers are very lenient in this. That or folks abandon ship fairly quickly and go for another spec that is far more friendly.

well json definitely does not accept `{'test':'value'}` as valid input

any parser that behaves otherwise is pretty clearly buggy

json has many problems but parsing ambiguity is not really one of them

Post reply on HN