101 points · by wusspuss · 4y ago · 140 comments
It would be just as easy to write a post like this about JSON, Matrix and so on. Both have many warts.
But I really don't much care. No technology is perfect, and there will always be people who dislike choices that other people have made. What matters is what we do with the technology. XMPP has proven itself able to evolve over more than two decades, during which the internet and the way we use it has shifted dramatically, and yet it continues to be relevant as new people discover and adopt it.
It's unfair to describe things like multi-device sync as "afterthoughts" when XMPP was one of the first real-time messaging protocols to have support for multiple concurrent connections of the same account built in, at a time before the iPhone was released, and most people had a single device with wired access to the internet only.
Support for multi-device sync is part of the suite of protocol features required by modern XMPP implementations, these requirements are updated every year to account for the changing technology landscape: https://xmpp.org/about/compliance-suites/
I personally like the simple delivery model of XMPP compared to the "distributed database" model that Matrix pursues. I think there are use-cases for both approaches. Both XMPP and Matrix have bridges between each other and third-party protocols (proprietary and open ones), which makes any attempt to create false competition between them an unhelpful effort. What's important is that both provide openly-documented protocols with open-source reusable implementations, and (in my opinion) most important of all: decentralized open communication networks.
The problems facing the broader adoption of open networks for modern messaging are not protocol problems.
About the XML bloat you've mentioned: The problem isn't just the wire size, it's working with it as a developer. XML is needlessly complicated to deal with in code and super painful to read when debugging. Tooling for it seems lacking too; I even found that iOS's built in XML parser was very slow at parsing large elements, with time/mem used seemingly growing O(N^2). Found that out when the XMPP-using startup I was working for decided to send all their XMPP IQ messages as just wrapped JSON payloads.
About extensions: As cool as those XEPs are, it makes for a fragmented federated ecosystem when so many basic features are extensions. It's not awful when maybe you can't send large files on one server, but when something like auth is broken...
For messaging purposes, it is absolutely identical to JSON in this regard. Once you have many existing implementations out in the wild that need to interact with each other, you'll need namespaces or their NIH analogue. And JSONs with namespaces will be just as bloated as XML.
Understand this: xml is meant to be read by computers, not humans.
> The criticisms linked are all valid, and there are good reasons it's being abandoned
It's 2022 and there is still nothing better for federated messaging.
There's no "JSON mindset" to produce anything comparable to this crime against bandwidth and code brevity:
<stream:stream from="draugr.de" id="{ID}" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">
Being sent on every connection for no reason, thrice (!)>Once you have many existing implementations out in the wild that need to interact with each other, you'll need namespaces or their NIH analogue. And JSONs with namespaces will be just as bloated as XML.
Even XMPP, with XML, could do just fine without namespaces. The only place where namespaces are the differentiating factor in practice is <query/>'s and <x/>'s. Couldn't they just be be called <mam_query/> or whatnot? Oh, and namespaces specify the version. Like for ack's they specify the version 3 every time. But it's something that has to be (and is) clarified when enabling said acks anyway.
Online sources say it's meant to be both human and machine readable. It would be less bloated if it were just for machines. Seems like a generalization of HTML, which is meant to be hand-crafted in some cases.
Even if it were for machines only, it'd still need a human-friendly way to manipulate and debug with, and there isn't one. Protocol buffers have the text version for humans and the serialized binary for machines, plus the generated getters/setters for code. XML is a pain to deal with no matter how you abstract it.
JSON with namespaces would just mean another key-value pair in the dict or something. But I'm not sure why that's needed anyway.
> It's 2022 and there is still nothing better for federated messaging.
True, but federated messaging isn't in style anymore, and honestly I hardly even used XMPP. Was working on my own protocol 2 years ago that I truly believed was the best, and had a working reference impl, but had to abandon it. Got 2 jobs already.
That is untrue. Matrix is undoubtedly much better.
It's definitely not identical. There's one major difference, that rarely seems to get mentioned but seems to be responsible for most of the pain:
JSON maps directly to language-native data structures, but XML does not.
The reason for this is that XML distinguishes between child nodes and attributes, but in the basic data structures that most languages have, there's no way to represent this in a conflict-free manner without doing something like `{ attributes: { ... }, children: [ ... ] }`, which is an awkward structure to query.
The result is that when you're working with XML, you almost always end up with a "data API" that's designed specifically for XML (eg. classes representing nodes with getters for attributes and children), whereas with JSON you're generally working with simple nested lists and structs.
This introduces relatively much complexity in what's a "hot path" in terms of development effort - every single time you want to interact with the deserialized data (which is all the time!), you have to deal with an XML-specific data structure instead of treating it as "just another source-agnostic pile of structs/objects".
The result is tightly coupled code that requires the reader to be familiar with the specific XML API/representation being used, instead of it 1:1 mapping from the serialized data to a language-native data structure. That's not good!
While it is true that you are likely to implement a namespace-like mechanism in JSON as well, for open protocols, the difference is that the format itself does not specially define namespaces - which means that the 1:1 mapping always remains true, and it's the protocol developer's choice to eg. reserve a `children` property to contain child nodes, with the understanding that that property then cannot be used for other things anymore.
XML deserializers cannot do this; it's entirely possible for XML to exist that looks like `<tag children="yes"><subtag/></tag>`, and therefore there is no possible 1:1 mapping that a deserializer can use that's guaranteed not to make certain data inaccessible. And since child nodes are not represented as an attribute in XML's data model, you cannot expect protocol designers to avoid a specific attribute either.
Bottom line: I suspect that this seemingly small design difference has far-reaching second-order effects in how deserializers are implemented, and that that is responsible for most of the pain that people experience in working with XML.
Plus it's confusing. You have to look through feature matrices instead of just saying "Oh this is version 4, it has everything I need".
You probably have not yet written any JavaScript or CSS if you think that's how things work.
The moment you ask for reliability it stops being simple. Stream Management + Stanza Ids isn't simple, and it shows - XMPP is the only thing I use today where it occasionally happens that a message isn't delivered and I'm not even notified about it.
On a side note I don't believe that this can't be fixed. Maybe if we had end clients checking directly with each other what's been delivered and what hasn't, like actual humans end up doing anyway, I believe it'd be more reliable. Besides instead of relying on the c2s-s2s-s2c cooperation chain to work, it'd rely on just c2c cooperation, giving much fewer variations to test. Just to clarify I'm not talking about a p2p connection but rather e.g. checking the number of stanzas not with the server, but with the interlocutor's client, through the normal XMPP means, like <iq/>s maybe
The last gap I'm aware of was that if you sent a message to someone on a remote server, and the remote server couldn't be connected to, your server would generate a delivery error (i.e. not silent). But* if you went offline before this delivery error reached you, you would never see it. These days such errors are stored in the user's message archive, and available to all your clients for synchronization purposes (so all of them can see that the message failed to deliver).
So with that said, I'm very interested in hearing any details you can provide about how to silently lose messages in modern XMPP. Clients involved, steps to reproduce, etc. Then we can produce actionable bug reports.
[*]: I believe Pidgin is still a notable exception here. Notable mainly because a lot of people still use it, even though its protocol plugin development has stalled somewhat for many years (the project is still being developed, but their focus has been on core/foundation improvements rather than keeping up with changes to modern internet messaging).
Conversations, draugr.de, can't really say much on steps to reproduce - it worked reliably and then it didn't just yesterday, ironically just as I tried to send the article to a friend to check out.
If I understand the two generals' problem correctly, there always is a way to silently lose messages, with any protocol, it's just that some approaches to not doing that are more reliable than others
I guess you're not using Discord.
JSON has no namespaces, even without taking that into account it's already less verbose, it maps nicely into lists and dicts, I don't know a single JSON parser that can leak the user's IP even as an option, let alone by default (not saying there aren't any at all, just no popular ones), doing a binary version of XMPP based on JSON would take as much as switching over to bencode instead of whatever the unsupported hell EXI is. So no, you can't really write a post like this about JSON. Even if you do, it's not gonna be XML that will be proposed as a better solution.
One thing where XML beats JSON is markup. But with XMPP's unholy approach to markup, it's actually JSON that beats XML.
Causing all extensible JSON-based protocols to eventually reinvent them:
* https://www.w3.org/TR/json-ld11/#compact-iris
* "If new events are added, the event type key SHOULD follow the Java package naming convention, e.g. com.example.myapp.event." https://spec.matrix.org/v1.2/client-server-api/#types-of-roo...
* https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-22... (no aliases, so it's even more verbose)
* https://github.com/OAI/OpenAPI-Specification/issues/1362#iss...
<starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"><required/></starttls>
to specify urn:ietf:params:xml:ns:xmpp-tls other than formalism/a yearn for bloat. There would never be a name collision without this ns and it convenes no useful info.There's no reason for acks to specify urn:xmpp:sm:3 each time. Yes, here it at least specifies the version, but that's already negotiated when enabling acks anyway.
There's no reason why <query xmlns='urn:xmpp:mam:2' .../> can't be <mam_query .../>.
Namespaces are a choice, sometimes (e.g. in programming languages) reasonable, sometimes (in a serialization format for passing small texts around) not so much.
It is dictated by a mindset, the XML mindset in case of XMPP, and in the case you bring up apparently by the Java mindset, not to say there's much of a difference between the two
That's funny because it's true. To add to your list: JMAP (https://jmap.io/) has namespaces too.
I'm curious what you base this on. Without a doubt Matrix is gaining traction. It's a relatively newer project, has some new ideas, and there is a lot of buzz around it. But it has far to go before reaching XMPP's levels of achievement - millions of XMPP-connected users via Google Talk, and popular products such as WhatsApp and Zoom built on top of it. That many of these aren't, or are no longer, interested in interoperability or federation is not a protocol problem, and I don't see Matrix solving that.
XMPP continues to be widely used by individuals, organizations and governments who want more control over their communication. Across the XMPP projects and services I'm involved in, I continue to see plenty of new users and developers joining the community.
The reference client/server is definitely a pattern I agree with you on, however. It has served Matrix well, and others too. I've been a proponent of this approach for some time, and detailed my thoughts in the "Products vs Protocols" talk/post at https://snikket.org/blog/products-vs-protocols/
But these aren't the protocol's achievements either. These people have so much money they could make IRC popular.
Considering the way in which Matrix spreads unencrypted metadata (even rooms and participants in the rooms, let alone chat events) as far as possible across the network, this traction is quite insidious.
The problems is that many of these modern features were unbelievably late.
I still remember "The State of Mobile XMPP in 2016", https://gultsch.de/xmpp_2016.html
At the time, 9 years after iPhone had come on the scene, most modern features were still experimental draft proposals implemented by no one.
5 more years later there's maybe one client that implements the modern features (Conversations for Android IIRC), and that's about it.
And it's an unknown how many servers implement those features.
...and yet I'm using three different modern clients that work well with each other.
> And it's an unknown how many servers implement those features.
Enough to make me not have to care about it.
It's not: https://compliance.conversations.im/tests/
Obviously a new user is not expected to fathom what all this means before getting started, which is why there are curated lists of public XMPP services, e.g. https://providers.xmpp.net/ and https://joinjabber.org/ and for private servers there are projects like Snikket where the server software is developed in parallel with apps to ensure a consistent feature set.
* Screen sharing * File sharing * Sync across devices * Group chat without fuckery * Ability to delete and edit messages * Notifications of new messages
I know XMPP supports all of this and more. But find a cross platform client/server that implements all of it?
Then look at the clients for matrix, telegram, signal, teams, whatsapp, and others.
That is what Snikket is trying to be. https://github.com/snikket-im
Btw, iChat used to support all those features, but only when the other side was iChat too.
I think it has taken too long for the community to realise what an asset a good brand can be, and that it's hard to rally normal users around a protocol and an ecosystem rather than a product. I think that's growing to change though, with a number of user-focused projects around the ecosystem (including Snikket, the one I'm working on).
I only know about MAM which doesn't work with E2EE... and depends on the individual chatroom's server.
> Both XMPP and Matrix have bridges between each other and third-party protocols (proprietary and open ones), which makes any attempt to create false competition between them an unhelpful effort.
Bridges don't really work with E2EE anymore...
Soo first you want E2EE so nobody can tap into your conversations, and then you want to receive text of you messages from the server archive? :hmm emoji:
However, instead of arguing I think it might be better to give a short summary about the state of XMPP from a users perpective. I use XMPP every day for several years now. In my opinion the best clients are the following:
- Linux -> Gajim (also available for Windows)
- iOS -> Siskin
- Android -> Quicksy/Conversations
Especially Siskin has made great progress over the past year. While these clients can do most of the things you would expect from a modern IM client, there are still a few weak spots:
- The combination of OMEMO (End-to-end encryption) while using multiple (clients over longer periods of time) can lead to situations where some clients can't decrypt messages. This is rarely dramatic (because one of your devices can decrypt the message), but can be annoying.
- It seems video calls across different clients are work-in-progress. Conversations to Conversations works fine, but with Siskin I had some trouble.
So the bottom line is: Most things work fine, but some things don't.
- Linux -> Psi+ (also available for Windows)
- Android -> Conversations
All FOSS.
On XMPP itself — I'm looking into it as the protocol for messaging for my federated social network. I first contemplated using Matrix, but then I looked at the spec, saw the mathematical notation for the room state synchronization algorithm, and noped outta there really fast.
* https://nlnet.nl/project/Libervia/
* https://inqlab.net/2022-01-17-activitystreams-over-xmpp.html
[1] https://blog.joinmastodon.org/2018/06/how-to-implement-a-bas...
[2] https://blog.joinmastodon.org/2018/07/how-to-make-friends-an...
I do a variation of this for ActivityPub in my project already. Except I don't implement c2s ActivityPub at all.
The chat standard XMPP (IETF): https://www.freie-messenger.de/sys_xmpp (german)
Thoughts on interoperabiliy: https://www.freie-messenger.de/en/begriffe/interoperabilitae...
Quick overview of messenger systems (DE, EN, FR, ES, NL, ...): https://www.freie-messenger.de/en/systemvergleich
Because there are so many comments comparing XMPP with Matrix: https://www.freie-messenger.de/en/systemvergleich/xmpp-matri...
The author grossly misunderstands XMPP. The first letter X stands for "eXtensible", and extensible it is.
Chat history, milti-device sync, reliable message delivery is not an afterthought, it is extension (and btw they all are solved problems as of now) The protocol is by design modular, and it is a strength, not weakness.
You can't realistically expect all the world to share the same version of your monolithic messaging protocol. Different instances will support different features, some implementations will lag on with newer features, etc. The only possible answer to this is modularity and legacy fallbacks for some features that are not supported by remote party.
Sure, the protocol could develop more rapidly. I actually believe that XMPP survives despite efforts of the XSF coincils, not thanks to them. However, the core of the protocol is strong and allows to build communication products with UX not worse than Telegram or Discord. And if you lack some crucial feature like a properly working group chat, you can make your own XMPP extension - because eXtensible it is.
Also. You don't really need any of them to send messages between servers. All this stuff matters only for communication between your clients and your own server.
XML is always painful but XMPP brings it to another level by not playing nice with most parsers which expect complete documents, I ended up having to roll my own parser.
But perhaps the situation in XML land has improved since, I sincerely hope so for the people writing today's clients.
Professionally I've been involved in one project that used XMPP as a data protocol between back end services. It was eventually phased out in favor of REST because of buggy libraries which meant capturing messages in queues and replaying whenever the thing fell over.
>Today you expect a messenger to be a database.
I do? Not all of us want the levels of resource utilization this approach requires. Why would I want to be able to edit/delete old messages? I can just send new ones.
If by "push" you mean sending notifications through 3rd party servers like google's Firebase, I'd like not to use it.
I was using XMPP on mobile for years, receiving messages in background normal way almost with no battery drain.
I also run k9mail 24/7 with my personal IMAP server, receiving messages in realtime (imap idle) with almost no battery waste.
Battery is wasted more by bloated frameworks like Electron rather than by network activity itself.
These days there's also UnifiedPush which is an open standard for push on Linux and Android. FluffyChat and SchildiChat (both Matrix clients) support it. I actually switched to SchildiChat from Element because Element's notification service was using too much RAM.
Mobile push is a combination of brain damage and bizarre propaganda targeting developers.
It's not activity itself but what app does in background in reaction to incoming packets. Clients I used (Bombus and Xabber) didn't support that XEP with no problem. App may just ignore some stanzas when not needed.
A lot of effort went into Prosody 0.12, which we released recently. It's unfortunate that mod_cloud_notify didn't quite make the cut for that version, but it was better than delaying the long overdue release even further. The vast majority of work on Prosody is unpaid volunteer time, and as with most open-source work there are certain kinds of tasks which are hard to find funding for, leading to the old "it'll be done when it's done" because we (the developers) simultaneously need to pay our bills.
Also, in recognition of many desirable things being in community modules, one thing we did prioritize in 0.12 was the plugin installer, which should make it easier for people to add additional modules to their Prosody installation.