Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

NodeBB

  1. Home
  2. General Discussion
  3. I have deeply mixed feelings about #ActivityPub's adoption of JSON-LD, as someone who's spent way too long dealing with it while building #Fedify.

I have deeply mixed feelings about #ActivityPub's adoption of JSON-LD, as someone who's spent way too long dealing with it while building #Fedify.

Scheduled Pinned Locked Moved General Discussion
fedifyjsonldfedidevactivitypub
65 Posts 19 Posters 1 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • kopper@not-brain.d.on-t.workK This user is from outside of this forum
    kopper@not-brain.d.on-t.workK This user is from outside of this forum
    kopper@not-brain.d.on-t.work
    wrote last edited by
    #8
    @hongminhee take this part with a grain of salt because my benchmarks for it are with dotNetRdf which is the slowest C# implementation i know of (hence my replacement library), but JSON-LD is slower than RSA validation, which is one of the pain points around authorized fetch scalability

    wetdry.world/@kopper/114678924693500011
    kopper@not-brain.d.on-t.workK 2 Replies Last reply
    0
    • kopper@not-brain.d.on-t.workK kopper@not-brain.d.on-t.work
      @hongminhee take this part with a grain of salt because my benchmarks for it are with dotNetRdf which is the slowest C# implementation i know of (hence my replacement library), but JSON-LD is slower than RSA validation, which is one of the pain points around authorized fetch scalability

      wetdry.world/@kopper/114678924693500011
      kopper@not-brain.d.on-t.workK This user is from outside of this forum
      kopper@not-brain.d.on-t.workK This user is from outside of this forum
      kopper@not-brain.d.on-t.work
      wrote last edited by
      #9
      @hongminhee if i can give one piece of advice to devs who want to process JSON-LD: dont bother compacting. you already know the schema you output (or you're just passing through what the user gives and it doesn't matter to you), serialize directly to the compacted representation, and only run expansion on incoming data

      expansion is the cheapest JSON-LD operation (since all other operations depend on it and run it internally anyhow), and this will get you all the compatibility benefits of JSON-LD with little downsides (beyond more annoying deserialization code, as you have to map the expanded representation to your internal structure which will likely be modeled after the compacted one)
      natty@astolfo.socialN 1 Reply Last reply
      0
      • kopper@not-brain.d.on-t.workK kopper@not-brain.d.on-t.work
        @hongminhee if i can give one piece of advice to devs who want to process JSON-LD: dont bother compacting. you already know the schema you output (or you're just passing through what the user gives and it doesn't matter to you), serialize directly to the compacted representation, and only run expansion on incoming data

        expansion is the cheapest JSON-LD operation (since all other operations depend on it and run it internally anyhow), and this will get you all the compatibility benefits of JSON-LD with little downsides (beyond more annoying deserialization code, as you have to map the expanded representation to your internal structure which will likely be modeled after the compacted one)
        natty@astolfo.socialN This user is from outside of this forum
        natty@astolfo.socialN This user is from outside of this forum
        natty@astolfo.social
        wrote last edited by
        #10

        @kopper@not-brain.d.on-t.work @hongminhee@hollo.social expansion is actually really annoying because the resulting JSON has annoyingly similar keys to lookup in a hashmap, wasting cache lines, and CPU time

        1 Reply Last reply
        0
        • kopper@not-brain.d.on-t.workK kopper@not-brain.d.on-t.work
          @hongminhee take this part with a grain of salt because my benchmarks for it are with dotNetRdf which is the slowest C# implementation i know of (hence my replacement library), but JSON-LD is slower than RSA validation, which is one of the pain points around authorized fetch scalability

          wetdry.world/@kopper/114678924693500011
          kopper@not-brain.d.on-t.workK This user is from outside of this forum
          kopper@not-brain.d.on-t.workK This user is from outside of this forum
          kopper@not-brain.d.on-t.work
          wrote last edited by
          #11
          @hongminhee i put this in a quote but people reading the thread may also be interested: json-ld compaction does not really save that much bandwidth over having all the namespaces explicitly written in property names if you're gzipping (and you are gzipping, right? this is json. make sure your nginx gzip_types includes ld+json and activity+json)

          RE:
          not-brain.d.on-t.work/notes/aihftmbjpxdyb9k7
          1 Reply Last reply
          0
          • cwebber@social.coopC This user is from outside of this forum
            cwebber@social.coopC This user is from outside of this forum
            cwebber@social.coop
            wrote last edited by
            #12

            @kopper @hongminhee As the person probably most responsible for making sure json-ld stayed in the spec (two reasons: because it was the only extensibility answer we had, and because we were trying hard to retain interoperability with the linked data people, which ultimately did not matter), I agree with you. I do ultimately regret not having a simpler solution than json-ld, especially because it greatly hurt our ability to sign messages, which has considerable effect on the ecosystem.

            Mea culpa 😕

            I do think it's fixable. I'd be interested in joining a conversation about how to fix it.

            evan@cosocial.caE 1 Reply Last reply
            0
            • cwebber@social.coopC cwebber@social.coop

              @kopper @hongminhee As the person probably most responsible for making sure json-ld stayed in the spec (two reasons: because it was the only extensibility answer we had, and because we were trying hard to retain interoperability with the linked data people, which ultimately did not matter), I agree with you. I do ultimately regret not having a simpler solution than json-ld, especially because it greatly hurt our ability to sign messages, which has considerable effect on the ecosystem.

              Mea culpa 😕

              I do think it's fixable. I'd be interested in joining a conversation about how to fix it.

              evan@cosocial.caE This user is from outside of this forum
              evan@cosocial.caE This user is from outside of this forum
              evan@cosocial.ca
              wrote last edited by
              #13

              @cwebber @kopper @hongminhee

              I don't remember it that way.

              We started the WG off with AS2 being based on JSON-LD, and I don't think we ever considered removing it.

              I don't think it was a decision you made on your own. I'm not sure how you would, since you edited AP and not AS2 Core or Vocabulary.

              evan@cosocial.caE 1 Reply Last reply
              0
              • evan@cosocial.caE evan@cosocial.ca

                @cwebber @kopper @hongminhee

                I don't remember it that way.

                We started the WG off with AS2 being based on JSON-LD, and I don't think we ever considered removing it.

                I don't think it was a decision you made on your own. I'm not sure how you would, since you edited AP and not AS2 Core or Vocabulary.

                evan@cosocial.caE This user is from outside of this forum
                evan@cosocial.caE This user is from outside of this forum
                evan@cosocial.ca
                wrote last edited by
                #14

                @cwebber @kopper @hongminhee

                I would be strongly opposed to any effort to remove JSON-LD from AS2. We use it for a lot of extensions. Every AP server uses the Security vocabulary for public keys.

                evan@cosocial.caE cwebber@social.coopC 2 Replies Last reply
                0
                • evan@cosocial.caE evan@cosocial.ca

                  @cwebber @kopper @hongminhee

                  I would be strongly opposed to any effort to remove JSON-LD from AS2. We use it for a lot of extensions. Every AP server uses the Security vocabulary for public keys.

                  evan@cosocial.caE This user is from outside of this forum
                  evan@cosocial.caE This user is from outside of this forum
                  evan@cosocial.ca
                  wrote last edited by
                  #15

                  @cwebber @kopper @hongminhee It would be a huge backwards-incompatible change for almost zero benefit. People would still make mistakes in their ActivityPub implementations (sorry, Minhee, but that's life on an open network). We'd need to adopt another mechanism for defining extensions, and guess what? People are going to make mistakes with that, too.

                  evan@cosocial.caE kopper@not-brain.d.on-t.workK ianh@mastodon.socialI 3 Replies Last reply
                  0
                  • evan@cosocial.caE evan@cosocial.ca

                    @cwebber @kopper @hongminhee It would be a huge backwards-incompatible change for almost zero benefit. People would still make mistakes in their ActivityPub implementations (sorry, Minhee, but that's life on an open network). We'd need to adopt another mechanism for defining extensions, and guess what? People are going to make mistakes with that, too.

                    evan@cosocial.caE This user is from outside of this forum
                    evan@cosocial.caE This user is from outside of this forum
                    evan@cosocial.ca
                    wrote last edited by
                    #16

                    @cwebber @kopper @hongminhee The biggest downside to JSON-LD, it seems, is that it lets most developers treat AS2 as if it's plain old JSON. That was by design. People sometimes mess it up, but most JSON-LD parsers are pretty tolerant.

                    1 Reply Last reply
                    0
                    • evan@cosocial.caE evan@cosocial.ca

                      @cwebber @kopper @hongminhee It would be a huge backwards-incompatible change for almost zero benefit. People would still make mistakes in their ActivityPub implementations (sorry, Minhee, but that's life on an open network). We'd need to adopt another mechanism for defining extensions, and guess what? People are going to make mistakes with that, too.

                      kopper@not-brain.d.on-t.workK This user is from outside of this forum
                      kopper@not-brain.d.on-t.workK This user is from outside of this forum
                      kopper@not-brain.d.on-t.work
                      wrote last edited by
                      #17
                      @evan @hongminhee @cwebber my argument is that json-ld is way more prone to mistakes. in iceshrimp.net, for example, we ship and preload several modified contexts in order to correct some mistakes on our end, and even then we encounter a lot of software that do not, for example, include the security context in their actors

                      if, as per my suggestion, property names were always written in expanded form, the only mistakes you could really do would be typos, and that would fail pretty loudly compared to the current status quo where most software accept it and some software silently fail. how are those developers meant to even be aware that this is a problem?
                      1 Reply Last reply
                      0
                      • kopper@not-brain.d.on-t.workK This user is from outside of this forum
                        kopper@not-brain.d.on-t.workK This user is from outside of this forum
                        kopper@not-brain.d.on-t.work
                        wrote last edited by
                        #18
                        @gugurumbe @hongminhee @evan @cwebber

                        from my brief tests, compacting with no context (which is basically expanded json-ld, with very minor differences) compresses better, but standardizing on expanded ld would still be better than the status quo. yes backwards compatibility would be broken, but pretty much any other solution to this problem beyond not solving it would end up breaking it anyway

                        i'm still unsure about certain aspects of json-ld such as everything having the capability for multiple values, but without any context defined it's at least explicit and implementations can take that into account where it's actually helpful (
                        sec:publicKey comes to mind) and ignore it where it isn't

                        (
                        edit: ignore the last part, i just re-checked and compact-with-no-context collapses arrays with single values, expanded would be clearer here)

                        RE:
                        not-brain.d.on-t.work/notes/aihftmbjpxdyb9k7
                        1 Reply Last reply
                        0
                        • evan@cosocial.caE This user is from outside of this forum
                          evan@cosocial.caE This user is from outside of this forum
                          evan@cosocial.ca
                          wrote last edited by
                          #19

                          @gugurumbe @cwebber @kopper @hongminhee AS2 requires compacted JSON-LD.

                          evan@cosocial.caE trwnh@mastodon.socialT 2 Replies Last reply
                          0
                          • evan@cosocial.caE evan@cosocial.ca

                            @gugurumbe @cwebber @kopper @hongminhee AS2 requires compacted JSON-LD.

                            evan@cosocial.caE This user is from outside of this forum
                            evan@cosocial.caE This user is from outside of this forum
                            evan@cosocial.ca
                            wrote last edited by
                            #20

                            There is no data format we can choose to eliminate programmer errors in online protocols. That's a quixotic aim.

                            @gugurumbe @cwebber @kopper @hongminhee

                            1 Reply Last reply
                            0
                            • evan@cosocial.caE evan@cosocial.ca

                              @cwebber @kopper @hongminhee It would be a huge backwards-incompatible change for almost zero benefit. People would still make mistakes in their ActivityPub implementations (sorry, Minhee, but that's life on an open network). We'd need to adopt another mechanism for defining extensions, and guess what? People are going to make mistakes with that, too.

                              ianh@mastodon.socialI This user is from outside of this forum
                              ianh@mastodon.socialI This user is from outside of this forum
                              ianh@mastodon.social
                              wrote last edited by
                              #21

                              @evan @cwebber @kopper @hongminhee maybe a compromise approach could be to specify a simpler “json-ld as it is used in practice”, similar to what HTML5 was, that remains backward compatible while simplifying the spec to the point that it is actually feasible to implement

                              1 Reply Last reply
                              0
                              • evan@cosocial.caE This user is from outside of this forum
                                evan@cosocial.caE This user is from outside of this forum
                                evan@cosocial.ca
                                wrote last edited by
                                #22

                                @gugurumbe @kopper I don't think that's the model of ActivityPub. It's made to allow reading remote objects.

                                Most implementations pre-load or compile in the external contexts. I agree, it's a big performance hit to load context URLs at runtime.

                                1 Reply Last reply
                                0
                                • evan@cosocial.caE evan@cosocial.ca

                                  @cwebber @kopper @hongminhee

                                  I would be strongly opposed to any effort to remove JSON-LD from AS2. We use it for a lot of extensions. Every AP server uses the Security vocabulary for public keys.

                                  cwebber@social.coopC This user is from outside of this forum
                                  cwebber@social.coopC This user is from outside of this forum
                                  cwebber@social.coop
                                  wrote last edited by
                                  #23

                                  @evan @kopper @hongminhee The problem is that signing json-ld is extremely hard, because effectively you have to turn to the RDF graph normalization algorithm, which has extremely expensive compute times. The lack of signatures means that when I boost peoples' posts, it takes down their instance, since effectively *every* distributed post on the network doesn't actually get accepted as-is, users dial-back to check its contents.

                                  Which, at that point, we might as well not distribute the contents at all when we post to inboxes! We could just publish with the object of the activity being the object's id uri

                                  evan@cosocial.caE smallcircles@social.coopS 2 Replies Last reply
                                  0
                                  • cwebber@social.coopC This user is from outside of this forum
                                    cwebber@social.coopC This user is from outside of this forum
                                    cwebber@social.coop
                                    wrote last edited by
                                    #24

                                    @kopper @hongminhee @evan Interesting... I guess it means you can't re-compact with a new outer context, but maybe that's fine

                                    1 Reply Last reply
                                    0
                                    • cwebber@social.coopC cwebber@social.coop

                                      @evan @kopper @hongminhee The problem is that signing json-ld is extremely hard, because effectively you have to turn to the RDF graph normalization algorithm, which has extremely expensive compute times. The lack of signatures means that when I boost peoples' posts, it takes down their instance, since effectively *every* distributed post on the network doesn't actually get accepted as-is, users dial-back to check its contents.

                                      Which, at that point, we might as well not distribute the contents at all when we post to inboxes! We could just publish with the object of the activity being the object's id uri

                                      evan@cosocial.caE This user is from outside of this forum
                                      evan@cosocial.caE This user is from outside of this forum
                                      evan@cosocial.ca
                                      wrote last edited by
                                      #25

                                      @cwebber @kopper @hongminhee I talk about this in my book. Unless the receiving user is online at the time the server receives the Announce, it's ridiculous to fetch the content immediately. Receiving servers should pause a random number of minutes and then fetch the content. It avoids the thundering herd problem.

                                      patmikemid@sfba.socialP julia@eepy.moeJ cwebber@social.coopC 3 Replies Last reply
                                      0
                                      • evan@cosocial.caE evan@cosocial.ca

                                        @cwebber @kopper @hongminhee I talk about this in my book. Unless the receiving user is online at the time the server receives the Announce, it's ridiculous to fetch the content immediately. Receiving servers should pause a random number of minutes and then fetch the content. It avoids the thundering herd problem.

                                        patmikemid@sfba.socialP This user is from outside of this forum
                                        patmikemid@sfba.socialP This user is from outside of this forum
                                        patmikemid@sfba.social
                                        wrote last edited by
                                        #26

                                        @evan @cwebber @kopper @hongminhee I think that is a better algorithm than a brain dead exponential back off. Perhaps put the two together.

                                        evan@cosocial.caE 1 Reply Last reply
                                        0
                                        • gugurumbe@mastouille.frG This user is from outside of this forum
                                          gugurumbe@mastouille.frG This user is from outside of this forum
                                          gugurumbe@mastouille.fr
                                          wrote last edited by
                                          #27

                                          @kopper It does not; if a malicious context redefines the security properties then the JSON-LD processor will understand the data differently than the unaware processor.

                                          1 Reply Last reply
                                          0

                                          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                          With your input, this post could be even better 💗

                                          Register Login
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          Powered by NodeBB Contributors
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups