Atom is better than RSS, in ways that matter

Atom is better than RSS, in ways that matter

Atom 在关键方面优于 RSS

My feeds are Atom feeds. Everyone with knowledge agrees that Atom is technically superior to RSS. Everything should have switched to it twenty years ago. All feed readers support Atom just fine (except in podcasts, for no good reason). 我的订阅源都是 Atom 格式的。所有业内人士都认同 Atom 在技术上优于 RSS。二十年前,一切就应该全面转向 Atom。所有的订阅阅读器都能很好地支持 Atom(除了播客领域,且毫无正当理由)。

Unfortunately, many people continued to write and choose RSS, whether from ignorance of Atom (please stop calling feeds “RSS”!), or from figuring it doesn’t really matter in the end. Most of the differences are surface-level, or in practice not a problem: RSS uses a stupid date format? Doesn’t really affect people much. RSS doesn’t specify content encoding, so it’s ambiguous as to whether <description> is text or HTML? Used to be a problem, but these days everyone emits and assumes HTML. 遗憾的是,许多人仍然在编写和选择 RSS,要么是因为不了解 Atom(请停止把所有订阅源都称为“RSS”!),要么是觉得最终结果都一样。大多数差异仅停留在表面,或者在实践中构不成问题:RSS 使用了愚蠢的日期格式?这其实对人们影响不大。RSS 没有指定内容编码,导致 <description> 到底是纯文本还是 HTML 存在歧义?这曾经是个问题,但如今大家都默认输出并解析为 HTML。

In fact, RSS 2.0 specs settled on it being HTML, though people often use the unreasonably-popular, wonkily-versioned, horribly-named content:encoded to mean that, even though that’s not what it was supposed to mean. RSS is a travesty and the name refers to nine mutually-incompatible formats, published by a variety of different and competing organisations sometimes even using the same version numbers? Meh, just ignore the XML namespaces, be sloppy, the feeds you want to cope with will be worse. Resign yourself, it’ll be easier in the long run. Seriously, you may even be able to get away with forgetting that RSS is supposed to be XML. 事实上,RSS 2.0 规范最终将其定为 HTML,尽管人们经常使用那个极其流行、版本混乱、命名糟糕的 content:encoded 来表示内容,尽管这并非其本意。RSS 简直是一场闹剧,这个名字指代了九种互不兼容的格式,由各种不同且相互竞争的组织发布,有时甚至使用相同的版本号?算了,忽略那些 XML 命名空间吧,随意一点,反正你要处理的那些订阅源只会更糟。认命吧,从长远来看这样更容易。说真的,你甚至可以假装忘了 RSS 本应是 XML。

But what few realise is that some of the differences matter. That due to inconsistent treatment and usage, some reasonable content cannot reliably be expressed in RSS, whereas it’s unambiguous in Atom and should always work fine (and if it doesn’t, it’s unambiguously a bug). So let’s talk about the cases that matter. I would like to convince people to prefer Atom for useful reasons, rather than merely ideological purity. I want RSS dead. 但很少有人意识到,其中一些差异确实至关重要。由于处理和使用方式的不一致,一些合理的内容无法在 RSS 中可靠地表达,而在 Atom 中却是明确无误的,且总是能正常工作(如果不行,那显然就是 Bug)。所以,让我们谈谈那些关键的情况。我希望说服人们出于实际原因而非仅仅是意识形态的纯粹性来选择 Atom。我希望 RSS 消亡。

Title encoding semantics

标题编码语义

Précis: you can’t reliably use characters like < or & in RSS titles. Don’t even try mentioning HTML tags in titles. Content management systems normally allow headings to contain markup; but they seldom allow titles to contain markup. This is a tragedy. Many an article calls for <code> or <em>. I do it often, and I’ve seen a few others do it, but not many. 摘要:你无法在 RSS 标题中可靠地使用 <& 等字符。甚至不要尝试在标题中提及 HTML 标签。内容管理系统通常允许标题包含标记,但很少允许标题包含标记。这真是一场悲剧。许多文章需要用到 <code><em>。我经常这样做,也见过少数人这样做,但并不多。

Atom defines something called text construct, where you can specify whether the value is text, entity-encoded HTML, or XML-encoded HTML. Titles are text constructs. In RSS… well, not even content gets encoding semantics, which used to be a real problem, but over time everyone settled on “it’s always HTML”. So titles definitely don’t get encoding semantics. And different implementations do different things. Atom 定义了一种称为“文本结构”(text construct)的东西,你可以指定值是纯文本、实体编码的 HTML 还是 XML 编码的 HTML。标题就是文本结构。而在 RSS 中……好吧,连内容都没有编码语义,这曾经是个大问题,但随着时间推移,大家都默认“它总是 HTML”。所以标题肯定没有编码语义。不同的实现方式处理起来也各不相同。

Suppose you want to encode this title: All about the <xmp> element. How are you going to do it? In Atom, you have three clear choices: 假设你想编码这个标题:All about the <xmp> element。你该怎么做?在 Atom 中,你有三个明确的选择:

  1. Discard the markup, and encode the text as text. 丢弃标记,并将文本编码为纯文本。 <title type="text"> All about the &lt;xmp> element </title>

  2. Keep the markup, and entity-encode the HTML. 保留标记,并对 HTML 进行实体编码。 <title type="html"> All about the &lt;code>&amp;lt;xmp>&lt;/code> element </title>

  3. Keep the markup, and represent the HTML as XML. 保留标记,并将 HTML 表示为 XML。 <title type="xhtml"> <div xmlns="http://www.w3.org/1999/xhtml"> All about the <code>&lt;xmp></code> element </div> </title>

TODO: survey RSS readers to find out how they handle all of these cases. (This is the biggest reason I haven’t published this previously. Probably should have by 2020 or so.) Hard mode challenge: <_>::v::<_>, a real title I used. 待办:调查 RSS 阅读器,看看它们如何处理所有这些情况。(这是我之前没发布这篇文章的最大原因。大概 2020 年左右就该发了。)地狱难度挑战:<_>::v::<_>,这是我用过的一个真实标题。

The fly in the ointment: podcasts

瑕疵:播客

I must, in good faith, mention podcasts. Although approximately every single feed reader and open-source feed-reading library from the last twenty years supports both RSS and Atom, most of the largest podcast feed readers or syndicators only support RSS. 我必须诚实地提到播客。尽管过去二十年里几乎每一个订阅阅读器和开源订阅阅读库都同时支持 RSS 和 Atom,但大多数大型播客订阅阅读器或聚合平台只支持 RSS。

Since this stuff is largely from 20–25 years ago, and I wasn’t paying attention to the space at the time (few twelve-year-olds would), details are hazy. Rough timeline: Podcasting started to be a thing. RSS 2.0 added enclosures for it. Atom was designed, to fix most of the problems with RSS. It stabilised. Apple released iTunes podcasting stuff only supporting RSS. The iTunes client got Atom support, but the iTunes Music Store did not. Atom was published as RFC 4287. I have found no clear evidence that the iTunes Music Store (later the Apple Podcasts catalogue) ever supported Atom. And whatever iTunes/Apple Podcasts ever did have, was removed in 2023. 由于这些内容大多源于 20-25 年前,而我当时并没有关注这个领域(很少有 12 岁的孩子会关注),细节有些模糊。大致的时间线是:播客开始兴起。RSS 2.0 为此增加了附件(enclosures)功能。Atom 被设计出来,旨在解决 RSS 的大部分问题。它趋于稳定。苹果发布了仅支持 RSS 的 iTunes 播客功能。iTunes 客户端后来获得了 Atom 支持,但 iTunes Music Store 没有。Atom 作为 RFC 4287 发布。我没有找到任何明确证据表明 iTunes Music Store(后来的 Apple Podcasts 目录)曾经支持过 Atom。而且无论 iTunes/Apple Podcasts 曾经拥有过什么,都在 2023 年被移除了。

So I want to blame Apple. They controlled the space in the critical early days, and they ruined it. Some podcast readers or syndicators support Atom. Some claim to but don’t. Some (probably the most important ones) just don’t. RSS is a mess. Podcast RSS is even more of a mess. Frozen in time, hack is piled upon hack to work around RSS’s shortcomings. Ugh. 所以我得怪苹果。他们在关键的早期阶段控制了这个领域,并毁了它。一些播客阅读器或聚合平台支持 Atom。有些声称支持但实际上并不支持。有些(可能是最重要的那些)干脆不支持。RSS 是一团糟。播客 RSS 更是乱上加乱。它被冻结在过去,为了绕过 RSS 的缺陷,各种补丁堆叠在补丁之上。唉。