Beehaw
  • Communities
  • Create Post
  • search
    Search
  • Login
  • Sign Up
Like A Duck ( likeaduck@programming.dev )  to Technology@lemmy.ml · 3 years ago

What is the best file format for configuration file?

message-square
message-square
26
link
fedilink
29
message-square

What is the best file format for configuration file?

Like A Duck ( likeaduck@programming.dev )  to Technology@lemmy.ml · 3 years ago
message-square
26
link
fedilink

cross-posted from: https://programming.dev/post/1743099

.yaml, .toml, etc?

alert-triangle
You must log in or # to comment.
  • glibg10b ( glibg10b@lemmy.ml ) 
    link
    fedilink
    arrow-up
    25
    ·
    3 years ago

    There is no best. It depends on the application

    • doomkernel ( doomkernel@sopuli.xyz ) 
      link
      fedilink
      arrow-up
      4
      ·
      3 years ago

      Agree 100%

    • balls_expert ( balls_expert@lemmy.blahaj.zone ) 
      link
      fedilink
      arrow-up
      1
      ·
      3 years ago

      How would it depend?

      • glibg10b ( glibg10b@lemmy.ml ) 
        link
        fedilink
        arrow-up
        4
        ·
        3 years ago

        Some applications don’t have enough config entries to warrant support for nested entries

        Some applications need variable-length data, and some even variable-length lists

        Some applications don’t care about having fast read/write times or a small memory footprint and can do with more complex formats that require the use of third-party libraries

        Some embedded applications (e.g. AVR) don’t have access to a whole lot of libraries

  • silent_squirrel ( silent_squirrel@feddit.de ) 
    link
    fedilink
    arrow-up
    22
    ·
    3 years ago

    Not xml

  • argv_minus_one ( argv_minus_one@beehaw.org ) Banned
    link
    fedilink
    arrow-up
    14
    ·
    3 years ago

    JSON is overly verbose and doesn’t allow comments. Please do not use it for anything that humans frequently need to read or write.

    YAML is a syntactic minefield. Please do not use it for anything ever.

    • Sir_Simon_Spamalot ( Sir_Simon_Spamalot@lemmy.my.id ) 
      link
      fedilink
      arrow-up
      1
      ·
      3 years ago

      How is it syntatic minefield? I find it at least more reasonable than XML. The comment feature is nice to have.

      • nubbucket ( nubbucket@beehaw.org ) 
        link
        fedilink
        arrow-up
        3
        ·
        3 years ago

        yaml is susceptible to things like the Norway problem: https://www.bram.us/2022/01/11/yaml-the-norway-problem/

        There’s also a lot of stuff that can go wrong with deserialisation that make it a tricky dependency for security purposes. I like how yaml looks and it’s obviously much better than XML, but it had those potential problems

  • JackbyDev ( JackbyDev@programming.dev ) 
    link
    fedilink
    English
    arrow-up
    13
    ·
    3 years ago

    The one already being used by the project.

  • SorteKanin ( SorteKanin@feddit.dk ) 
    link
    fedilink
    arrow-up
    7
    ·
    3 years ago

    Definitely not yaml. It’s spec is horrible.

    Toml is pretty nice though.

    • richieadler ( richieadler@lemmy.myserv.one ) 
      link
      fedilink
      English
      arrow-up
      8
      ·
      3 years ago

      I hate table definitions in TOML with a passion.

      I like YAML. I guess that’s because I don’t need to build parsers for it. What’s your worst complain about it?

      • SorteKanin ( SorteKanin@feddit.dk ) 
        link
        fedilink
        arrow-up
        9
        ·
        3 years ago

        Just read this https://ruudvanasseldonk.com/2023/01/11/the-yaml-document-from-hell

        • richieadler ( richieadler@lemmy.myserv.one ) 
          link
          fedilink
          English
          arrow-up
          4
          ·
          3 years ago

          Very educational.

  • Lanthanae ( Lanthanae@lemmy.blahaj.zone ) 
    link
    fedilink
    arrow-up
    5
    ·
    3 years ago

    nix

    This post was sponsored by NixOS gang

    (jokes aside, json is king. Yaml is a pain in the ass)

  • Lettuce eat lettuce ( Lettuceeatlettuce@lemmy.ml ) 
    link
    fedilink
    arrow-up
    5
    ·
    3 years ago

    .ini has never let me down.

  • Papamousse ( Frederic@beehaw.org ) 
    link
    fedilink
    English
    arrow-up
    5
    ·
    3 years ago

    I’d say a file that you can open with a simple text editor is convenient, so it can be a simple .conf/.ini, more complex are .xml/.yaml that you can still edit in vim/nano but can be cumbersome.

    But as others say, it all depends on your app…

    • notthebees ( notthebees@reddthat.com ) 
      link
      fedilink
      arrow-up
      2
      ·
      3 years ago

      Toml is about the same as ini files at least with what I’ve worked with

  • The Doctor ( drwho@beehaw.org ) 
    link
    fedilink
    arrow-up
    4
    ·
    3 years ago

    Not XML. Not binary-only (looking at you, Solaris).

    Personally, I like .ini-style config files, but I’m weird that way.

    • GissaMittJobb ( GissaMittJobb@lemmy.ml ) 
      link
      fedilink
      arrow-up
      3
      ·
      3 years ago

      Toml is kind of ini++, though, isn’t it.

      • The Doctor ( drwho@beehaw.org ) 
        link
        fedilink
        arrow-up
        1
        ·
        3 years ago

        I don’t know. Never really thought about TOML.

        • GissaMittJobb ( GissaMittJobb@lemmy.ml ) 
          link
          fedilink
          arrow-up
          2
          ·
          3 years ago

          Check out the spec sometime. It’s basically ini with some stuff added on top.

          It’s quite nice when you need something that parses into some kind of map, while being human readable.

  • hellishharlot ( hellishharlot@programming.dev ) 
    link
    fedilink
    arrow-up
    2
    ·
    3 years ago

    Json

  • static_caster ( static_caster@programming.dev ) 
    link
    fedilink
    English
    arrow-up
    1
    ·
    3 years ago

    If you use protobuf/gRPC anywhere in your application, text format protobuf. Writes like JSON, but with a clear schema, a parser that already exists in most languages, and has comments.

  • jollyrogue ( jollyrogue@lemmy.ml ) 
    link
    fedilink
    arrow-up
    1
    ·
    3 years ago

    UCL and HCL are interesting, but YAML is more widely supported.

  • dmoonfire ( dmoonfire@kbin.social ) 
    link
    fedilink
    arrow-up
    1
    ·
    3 years ago

    Overall, JSON5 (having comments and end-of-line commas is a big reason I got into YAML).

    I suffer with YAML, but use it pretty heavily. It also has the * and & operators which I use fairly heavily, and it fits well with the Markdown + YAML I use, but I hate that whitespace indenting with a passion.

    Occasionally, I look at Nickle (https://github.com/tweag/nickel) and KDL (https://kdl.dev/) and I get really tempted, just haven’t made that jump.

  • Andy ( Andy@programming.dev ) 
    link
    fedilink
    arrow-up
    1
    ·
    3 years ago

    https://nestedtext.org/

    It’s like yaml but simple, consistent, untyped, and you never need to escape any characters, ever.

    Types and validation aren’t going to be great unless they’re in the actual code anyway.

Technology@lemmy.ml

technology@lemmy.ml

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !technology@lemmy.ml

This is the official technology community of Lemmy.ml for all news related to creation and use of technology, and to facilitate civil, meaningful discussion around it.


Ask in DM before posting product reviews or ads. All such posts otherwise are subject to removal.


Rules:

1: All Lemmy rules apply

2: Do not post low effort posts

3: NEVER post naziped*gore stuff

4: Always post article URLs or their archived version URLs as sources, NOT screenshots. Help the blind users.

5: personal rants of Big Tech CEOs like Elon Musk are unwelcome (does not include posts about their companies affecting wide range of people)

6: no advertisement posts unless verified as legitimate and non-exploitative/non-consumerist

7: crypto related posts, unless essential, are disallowed

Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 2 users / day
  • 27 users / week
  • 553 users / month
  • 3K users / 6 months
  • 1.1K local subscribers
  • 43.4K subscribers
  • 4.7K Posts
  • 26.7K Comments
  • Modlog
  • mods:
  • MinutePhrase ( MinutePhrase@lemmy.ml ) 
  • BE: 0.19.15
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code