10 ms·
Do we really need this? Atom is fine for feeds. Avoiding XML just for the sake of avoiding XML, because it isn't "cool" anymore is just dump groupthink. If t
by mindcrime 10y ago
Do we really need this? Atom is fine for feeds. Avoiding XML just for the sake of avoiding XML, because it isn't "cool" anymore is just dump groupthink.
If this industry has a problem, it's FDD - Fad Driven Development and IIICIS (If It Isn't Cool, It Sucks) thinking.
- metheus 10y agoWe don't prefer JSON to XML for any reason other than that XML is terrible by comparison.
- bdr 10y agoThat's not a reason.
- dangerlibrary 10y agoIt's funny to me that at the same time people are flocking to languages with strong, flexible type systems (often with compile-time checks), we are fleeing from a strongly typed data interchange format in favor of a dynamic bag of objects and arrays.
- pg_is_a_butt 10y agoit's funny to me that you think those are "people"
- algesten 10y agoI think that's because even if the data interchange format is strongly typed, as a consumer you often still must expect _anything_. I've yet to work on a project that handles XML where we have a XSD prevalidation step that makes the reading of some deeply nested XML tag feel safe. Unless we count XML <-> data object binding back in the java days. Not sure that felt any better...
- eropple 10y agoOn the flip side, I've only ever not had an XSD when I was building something myself and actively didn't care. The truth, I tend to suspect, lies somewhere in between. =)
- armandososa 10y agoIt is very likely than I am an idiot, but I've always found parsing XML too hard, specially compared to JSON which is almost too easy.
- mstade 10y agoIf there was an `XML.parse` just like there's `JSON.parse`, I doubt you'd say the same. As it stands, the added complexity in JS-land is to import a library that provides this functionality for you. Fortunately there are many, but I agree a built-in would be nice. It's a bit of a shame that E4X never landed in JS.
- moduspol 10y agoIt's more than JUST library support. It's also that JSON deserializes into common native data types naturally (dictionary, list, string, number, null). You can deserialize XML into the same data types, but it's not anywhere near as clean because of how extensible XML is. That's a big part of what's made JSON successful.
- dangerlibrary 10y agoThis is really only true in dynamically typed languages. From personal experience: parsing json in Java or Go without just treating everything as a bag of Object or an interface{} requires a ton of menial boilerplate work. Super nice in python/ruby/javascript, though.
- moduspol 10y agoSure--it's kind of a pain in Swift, too. Wouldn't it just be worse with XML, though? I get that people don't realistically parse it themselves and libraries are smart enough to use schemas to deserialize, but there's nothing inherent about JSON that makes it unable to conform to a schema or be parsable by libraries into native strongly-typed objects the same way.
- 10y ago
- chc 10y agoYou're basically saying that this isn't technically better, just more socially acceptable right now. I think you're right, but it seems to me that Atom's problem is primarily a social one. So even if this doesn't carry any technical advantages, a format with a strong social "in" is precisely what we need to make feeds a thing again.
- matthewaveryusa 10y agoOnce you've peeked at the complexity of some of the xml parsers (like xerces, oh god xerces) undoubtedly you'll want to avoid it like the plague. xml can get crazy-bananas very quickly. I fundamentally don't understand xml (just like I don't understand asn1) for anything beyond historical purposes.
- aloisdg 10y agoThe Atom spec is really easy to grasp. Your platform may even include a way to deal with it ([.NET](https://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationfeed(v=vs.110).aspx https://msdn.microsoft.com/en-us/library/system.servicemodel... for example)
- mindcrime 10y agoThere are definitely complexities in the XML ecosystem, like XLink, schemas, namespaces, etc. But in practice, not every application needs all that stuff, and when using the "common" parts of XML, I don't find it difficult to understand or work with. But that's just me.
- djur 10y agoXML parsers have a pretty bad track record for security vulnerabilities. If I was writing code to distribute that was going to be parsing arbitrary data from third parties (which is the RSS/Atom use case), I would be more comfortable trusting the average JSON parser than the average XML parser. Otherwise, I agree with the "if it ain't broke" principle. There's also cases where so much ad hoc complexity is built on top of JSON that you end up with the same problems XML has, except with less battle-tested implementations.
- tetrep 10y agoAs terrible as XML parsers can be, they've never been as bad as "XMLdoc = eval(XMLString)". I'd be more likely to trust a JSON parser not written in JavaScript than an arbitrary XML parser, but that's only because of the XML specification itself, which includes such features as including arbitrary content as specified by URLs (including local (to the parser) files!). Great ideas when you can trust your XML document, not so great otherwise.
- philsnow 10y agomodern browsers don't internally call eval(). See e.g. the definition of JSON.parse in v8: https://chromium.googlesource.com/v8/v8/+/4.3.65/src/json.js?autodive=0%2F%2F https://chromium.googlesource.com/v8/v8/+/4.3.65/src/json.js...
- vsl 10y agoAnd modern XML parsers aren't full of vulnerabilities anymore. You're missing the point.
- pfranz 10y agoPart of me is with you. But even in established languages I've had trouble finding an appropriate xml parser and had to tweak them way more than I thought necessary. I haven't (yet) had that problem with JSON. I think with something like feeds there's the possible benefit of becoming a 'hello world' for frameworks. Many frameworks have you write a simple blogging engine or twitter copycat. I don't think I've ever seen that for a feed reader/publisher. People have said that Twitter clients were an interesting playground for new UI concepts and paradigms because the basics were so simple (back when their API keys were less restrictive). Maybe this could be that?
- deleted 10y ago[deleted]
- mindcrime 10y agoBut even in established languages I've had trouble finding an appropriate xml parser and had to tweak them way more than I thought necessary. I haven't (yet) had that problem with JSON. Maybe it's just that I work mostly with JVM languages (Java, Groovy, etc.) but I haven't had any problems with handling XML - including Atom - in years. But I admit that other platforms might not have the same degree of support.
- pfranz 10y agoMost of my experience is from Python. Each time I use it I have to look at the docs for etree (a library that ships with Python). We would hit performance and feature support issues with etree and tried lxml but had binary compatibility issues between our environments. The Hitchhiker's Guide to Python[1] (a popular reference for Python) recommends untangle[2] and xmltodict[3], neither of which I've used. I feel like in other languages I've used had similar brittleness when dealing with xml. I might be biased because working with xml in an editor it's difficult to validate visually or grok in general when used in practice. [1] http://python-guide-pt-br.readthedocs.io/en/latest/scenarios/xml/ http://python-guide-pt-br.readthedocs.io/en/latest/scenarios... [2] https://untangle.readthedocs.io/en/latest/ https://untangle.readthedocs.io/en/latest/ [3] https://github.com/martinblech/xmltodict https://github.com/martinblech/xmltodict
- oefrha 10y agoYep, we don't really need another syndication format that no reader is going to support or support well for years. All I see missing in RFC 4287 is the lack of a per-entry cover image/thumbnail, which you can solve with an extension (which no one supports, and that's kind of the point) anyway.
- oxguy3 10y agoTo be honest, I'm really excited about the prospect of JSON based feeds. Right now, there's no easy way to work with Atom/RSS feeds on the command-line (that I know of anyway), which is something I often wish I could do. With a JSON feed, I can just throw the data at jq (https://stedolan.github.io/jq/ https://stedolan.github.io/jq/) and have a bash script hacked together in 10 minutes to do whatever I want with the feed.
- sillysaurus3 10y agoSurely there's an xml->json converter somewhere.
- duskwuff 10y agoIt's kind of tough to convert XML directly to other formats (including, but not limited to, JSON), because there are a lot of XML features that don't map cleanly onto JSON, such as: • Text nodes (especially whitespace text nodes) • Comments • Attributes vs. child nodes • Ordering of child nodes
- eponeponepon 10y agoAs it happens, XSLT 3.0 and XPath 3.0 both have well documented and stable features for doing exactly this. Roundtripping XML to JSON and back is a solved problem - check it out some time; it may surprise you.
- ajanuary 10y agoAre you talking about json-to-xml and xml-to-json? From the XSLT spec [0]: "Converts an XML tree, whose format corresponds to the XML representation of JSON defined in this specification, into a string conforming to the JSON grammar" It can't take an arbitrary XML document and turn it into JSON, it can only take XML documents that conform to a specific format. You can safely round-trip from JSON to XML and back to JSON. That's trivial because JSONs feature set is a subset of XMLs. What you can't safely do is round-trip from arbitrary XML to JSON and back to XML. That's because, as the parent said, there are features in XML that don't exist in JSON. That means you are forced to find a way to encode it using the features you do have, but then you can't tell your encoding apart from valid values. [0] https://www.w3.org/TR/xslt-30/#func-xml-to-json https://www.w3.org/TR/xslt-30/#func-xml-to-json
- weberc2 10y agoYikes, you didn't even make it to the second sentence. > JSON is simpler to read and write, and it’s less prone to bugs.
- jwilk 10y agoFrom the HN guidelines: Please don't insinuate that someone hasn't read an article.
- weberc2 10y agoMy mistake for phrasing my point in a manner that violates HN guidelines. I tried to edit, but I missed the window. At any rate, my point stands.
- mindcrime 10y agoJSON is simpler to read and write, and it’s less prone to bugs. I don't actually find either of those things to be true.
- jack9 10y agoI simply think you're lying to yourself. It's both literally and theoretically simpler to write and digest let's start with the simplest case, {}. Prone to bugs is a matter of debate, depending on a number of factors.
- weberc2 10y agoThat's a fine opinion to have, but that doesn't mean that people (the authors or devs generally) use JSON out of vanity. As an aside, you're the first person I've heard suggest people put their identity in serialization format, which gave me a good laugh.
- wcummings 10y agoNo, we don't. This doesn't do anything except break compatibility.
- hyperpallium 10y agoIn practice, json is much easier to work with on the command line because of jq.
- robgibbons 10y agoJSON, given the same schema, will always be more efficient byte-for-byte than XML. In addition, JSON as a format is native to JavaScript, which itself is ubiquitous. That's not even mentioning raw readability/writability. Basically, XML is to JSON as SOAP is to REST. It had it's day, though it's obviously still useful, but we have better tools now. Frankly, I'm surprised we haven't seen a proposal like this sooner.
- stephenr 10y ago> XML is to JSON as SOAP is to REST That's true. Both XML and SOAP are well defined, and well structured. JSON and REST are both marginally defined, and thus we see constant incompatible/incomplete implementations, or weird hacks to overcome the shortcomings. > we have better tools now I think "the cool kids are cargo-culting something newer now" is probably more accurate.
- icebraining 10y agoNitpick: REST is very well defined. It's not just a protocol, like some people insist. Other than that, fully in agreement.
- stephenr 10y agoRest is effectively a concept, and its up to developers to follow the rules it sets. You can't take your codebase, add some glue code to a REST module, and know that it will be usable by any other REST consumer/client, because no one follows the guidelines exactly the same way.
- liuyanghejerry 10y agoPart of me is also with you - JSON is indeed smaller than XML , but we do have gzip almost everywhere around the web, and with gzip, they don't have that much difference on space. Also, if people really care about this, why don't they use binary format, such as something like protobuf? And the other part of me is not with you - manipulating XML is not as easy as JSON in most of my development time, and sometimes I even need to write something by my bare hands, which JSON is much more handy. Tons of other formats are more human-friendly than JSON, for example TOML, but they don't have the status JSON has. So I guess JSON is kinda choice under the current state of "web development times".
- revelation 10y agoYeah this is great, now instead of properly machine-readable and verifiable XSD files we have pseudo-RFC text on some shitty GitHub page.