I recently read a blog post demanding wider support for JSON feeds because RSS and Atom are old standards and she finds XML painful to work with.
I see where melanie kat is coming from, but in my experience a developer’s convenience is only of concern to other developers, and even that is not necessarily the case. Otherwise Microsoft Windows would provide SSH by default.
However, I don’t merely operate this website and build it using shell scripts, UNIX tools, and a makefile. I’m also a full-stack developer at my day job. That means working JavaScript and modern front-end development frameworks and libraries. As such, I don’t see the problem with using JavaScript to process XML when HTML5 is a subset of XML and both can be manipulated using a Document Object Model. It’s not like we’re dealing with SGML or — Crom help us — an undocumented fixed-field format generated by a COBOL application that hasn’t seen any maintenance since the Y2K panic.
For my part, I provide both RSS and JSON feeds on my website because I get paid the same whether I provide one format, the other, or neither: nothing at all. Text is text to me, and every format sucks in its own special way. However, if I wasn’t already providing JSON feeds for my own reasons, and somebody demanded I do so because JSON support is built into JavaScript but supporting XML requires importing an external library and writing more code to work with it, the most likely response would be to ask how JavaScript’s relative lack of support for XML vs JSON is my problem.
JSON feeds as future-proofing
What I’m seeing here is a developer demanding that others cater to her, because she think working with XML provides an inferior developer experience. However, I can’t help but suspect that part of @@zicklepop’s problem is self-inflicted. Here’s how she’s fetching a feed:
import { XMLParser } from 'fast-xml-parser'
const parser = new XMLParser({
ignoreAttributes: false,
})
const parsedXML = parser.parse(xmlAsString, {})
if (parsedXML?.feed?.entry) {
// If the feed is Atom
console.log(parsedXML.feed.entry0)
} else if (parsedXML?.rss?.channel?.item) {
// If the feed is RSS
console.log(parsedXML.rss.channel.item0)
}
However, there are other ways to go about this.
Here’s a 2020 CSS Tricks tutorial for Fetching and Parsing RSS Feeds in JavaScript.
What Chris Coyier is doing here doesn’t appear to require any third-party libraries.
They’re using JavaScript’s built-in fetch() API to grab a feed by its URL.
Then they’re fetching the text of the HTTP response and running it through DOMParser.parseFromString() as if it were HTML, but passing in text/xml instead of text/html.
They then work on the output using the same JS functions one might use to manipulate a DOM generated from a web page.
Admittedly you can’t target the same elements in all feeds since some websites might provide RSS and others Atom, but this is not insurmountable.
This seems to me the sort of task one might do twice (once for RSS and once for Atom) to create code for one’s personal library.
Better yet, encapsulate the logic into GetRSS(url, itemCount) and GetAtom(url, itemCount) functions.
Import them as needed, and you’re still only writing one new line of code every time you need to fetch a feed.
Regardless, it is hard enough to persuade people to provide feeds at all, especially since the most likely audience for a feed is OpenAI, who will use it to train a LLM. Developers should be grateful that website operators still provide feeds at all. They certainly shouldn’t be picky about formats; most operators aren’t doing DIY feeds but providing whatever a CMS like WordPress generates.
Perhaps developers who are picky about data formats should direct their complaints to CMS developers instead of website operators? Just a thought.
Perhaps I’m being unreasonable, but a developer’s convenience is irrelevant outside of personal projects that require no interoperability. After all, there is no way I’d get away with not using JavaScript and React, Angular, or Vue at my day job. Management would have shit hemorrhages if I even suggested it, their apoplexy more befitting a Baptist church congregation confronted with the suggestion that Sodom got nuked for its inhabitants’ lack of hospitality instead of their licentiousness.
A professional developer trying to earn a living must work with the data provided using the tools available. Complaining about bad tools or formats won’t get us any sympathy, because nobody cares. If we’re not making it easier for other people to do their jobs, then we’re just an expensive obstacle becaue they don’t value us as human beings. In any case, time spent arguing over programming languages and data formats would be better spent unionizing our trade.