• CreamyJalapenoSauce@piefed.social
    link
    fedilink
    English
    arrow-up
    21
    ·
    24 hours ago

    Not-so-fun fact: if you’re transferring a yaml or toml file and the transfer is incomplete, the receiving app may not even know! Yaml and toml both have a good chance of being apparently valid when cut off randomly. This doesn’t impact JSON because of the enclosing {} or [].

    • Ephera@lemmy.ml
      link
      fedilink
      English
      arrow-up
      28
      ·
      edit-2
      22 hours ago

      Counterpoints:

      • TOML is intended for configuration, not for data serialization, so you shouldn’t be sending it over the wire in all too crazy ways anyways.
      • Most protocols will have a built-in way of knowing when the whole content has been transferred, typically by putting a content length into the header.
      • Having to wait until the closing } or ] can also be a disadvantage of JSON, since you cannot stream it, i.e. start processing the fields/elements before the whole thing has arrived. (You probably still don’t want to use TOML for that, though. JSONL, CSV or such are a better idea.)
      • CreamyJalapenoSauce@piefed.social
        link
        fedilink
        English
        arrow-up
        1
        ·
        edit-2
        3 minutes ago

        I’m only being pedantic. Toml is not bad. Yaml I personally don’t like because I don’t approve of semantically required whitespace but I know I’m in the minority there.

        • It’s not the norm in smaller companies, but big companies can use config servers where an app will retrieve its config on startup over the network. To be fair, I think they fall back to a platform specific encoding though.
        • Better hope it’s built in. I don’t remember the last time I verified a Content-Length was accurate. Also this generally applies to networking; disk writes don’t get this same verification especially if a process is killed mid-write.
        • True point, no real notes. I’ve recently been dealing with streaming JSON for AI, it’s SOO verbose for the few tokens that come across in each message. I don’t know how gRPC wasn’t chosen, or at least made an option, but oh well.

        You make good, valid points and I know I’m talking about edge cases that require the stars to align to break. It reminds me of an old, not-quite-relevant-but-oh-well saying “a ‘one in a million’ chance at 1GHz happens every millisecond.” The law of large numbers isn’t always on our side.

  • thebestaquaman@lemmy.world
    link
    fedilink
    arrow-up
    22
    ·
    1 day ago

    I’ve never gotten to be good friends with toml. I’ve never liked that the properties of some thing can be defined all over the place, and I’ve definitely never liked that it’s so hard to read nested properties. JSON is my friend.

    • Ephera@lemmy.ml
      link
      fedilink
      English
      arrow-up
      6
      ·
      23 hours ago

      They serve largely different use-cases. JSON is good for serializing data. TOML is good for configuration.

      • thebestaquaman@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        edit-2
        8 hours ago

        .vscode would like a word.

        But besides that, I just can’t understand why even someone that hates JSON would choose TOML over YAML for a config file.

        • Faux@lemmy.ml
          link
          fedilink
          arrow-up
          1
          ·
          32 minutes ago

          Most of production failures in my company in last few years come from people making mistakes in yaml indentation.

        • ell1e@leminal.space
          link
          fedilink
          English
          arrow-up
          3
          ·
          edit-2
          19 hours ago

          INI can be nicer for non-techies due to its flat structure. However, TOML seems to be in an awkward spot: either I want flat approachable (I’ll pick INI) or not (I’ll pick JSONC). Why would I want a mix?

          • Ephera@lemmy.ml
            link
            fedilink
            English
            arrow-up
            4
            ·
            15 hours ago

            Well, you can still decide how much of the TOML features you actually use in your specific application. For example, I’m currently involved in two projects at $DAYJOB where we read TOML configurations and we don’t make use of the inline tables that OP memes about in either of them.

            Ultimately, the big advantage of TOML over INI is that it standardizes all kinds of small INI extensions that folks have come up with over the decades. As such, it has a formal specification and in particular only one specification.
            You can assume that you can read the same TOML file from two different programming languages, which you cannot just assume for INI.

            • ell1e@leminal.space
              link
              fedilink
              English
              arrow-up
              2
              ·
              edit-2
              14 hours ago

              I can’t really decide what extensions my users will face, once they are supported. Therefore too many extensions seems bad to me.

              • Ephera@lemmy.ml
                link
                fedilink
                English
                arrow-up
                2
                ·
                edit-2
                11 hours ago

                We just document that this is how you write the config file:

                [network]
                bind.host = "127.0.0.1"
                bind.port = 1234
                
                # etc.
                

                And that seems straightforward enough. Yeah, technically users can opt to use inline tables or raw strings or whatever, but they don’t have to.

    • Ephera@lemmy.ml
      link
      fedilink
      English
      arrow-up
      4
      ·
      23 hours ago

      Well, TOML is essentially just an extension of the INI format (which helped its adoption quite a bit, since you could just fork INI parsers for all kinds of programming languages).

      And then, yeah, flattening everything is kind of baked into INI, where it arguably made more sense.
      Although, I do also feel like non-techies fare better with flat files, since they don’t have to understand where into the structure they have to insert the value. They just need find the right “heading” to put the line under, which is something they’re familiar with.