this post was submitted on 15 Aug 2023
32 points (94.4% liked)

Technology

34832 readers
1 users here now

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

founded 6 years ago
MODERATORS
 

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

.yaml, .toml, etc?

top 38 comments
sorted by: hot top controversial new old
[–] silent_squirrel@feddit.de 29 points 2 years ago
[–] glibg10b@lemmy.ml 25 points 2 years ago (2 children)

There is no best. It depends on the application

[–] doomkernel@sopuli.xyz 3 points 2 years ago
[–] balls_expert@lemmy.blahaj.zone 2 points 2 years ago (1 children)
[–] glibg10b@lemmy.ml 6 points 2 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

[–] JackbyDev@programming.dev 15 points 2 years ago

The one already being used by the project.

[–] igorlogius@lemmy.world 11 points 2 years ago* (last edited 2 years ago) (1 children)
[–] csolisr@communities.azkware.net 4 points 2 years ago (1 children)

Agreed. YAML is a pain to edit manually, to ensure that all the tabulation is correct and the parser does not choke. JSON is passable, but you must be mindful about the brackets. XML is too verbose and duplicative. INI files are just good enough.

[–] exu@feditown.com 3 points 2 years ago

YAML is fine if you use a formatter. JSON's ok to read but a pain to write imo. INI if it's simple.

[–] sylver_dragon@lemmy.world 11 points 2 years ago

A well documented one.

[–] argv_minus_one@beehaw.org 11 points 2 years ago (1 children)

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@lemmy.my.id 1 points 2 years ago (1 children)

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

[–] nubbucket@beehaw.org 3 points 2 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

[–] SorteKanin@feddit.dk 7 points 2 years ago (1 children)

Definitely not yaml. It's spec is horrible.

Toml is pretty nice though.

[–] richieadler@lemmy.myserv.one 9 points 2 years ago (1 children)

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@feddit.dk 11 points 2 years ago (2 children)
[–] JonnyRobbie@lemmy.world 4 points 2 years ago (1 children)

Thie essentially boikls down to "quote yur shit". Yes, it can be frustrating if a language superficially allows you to use unqoted strings with the promise that it will inteligently interprets that. It's like parentheses in arithmetics. If you are not sure or if you are not competent in a language enough to predict the order of operations, use parentheses. The same with strings and quotes in yaml.

[–] SorteKanin@feddit.dk -2 points 2 years ago (1 children)

... or just use another tool where you don't even have to think about this problem.

[–] richieadler@lemmy.myserv.one 1 points 2 years ago

I get that JSON is intuitive and a huge improvement over XML, but I still find it verbose.

[–] richieadler@lemmy.myserv.one 4 points 2 years ago

Very educational.

[–] Lettuceeatlettuce@lemmy.ml 6 points 2 years ago

.ini has never let me down.

[–] Frederic@beehaw.org 5 points 2 years ago (1 children)

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@reddthat.com 2 points 2 years ago

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

[–] drwho@beehaw.org 4 points 2 years ago (1 children)

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

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

[–] GissaMittJobb@lemmy.ml 3 points 2 years ago (1 children)

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

[–] drwho@beehaw.org 1 points 2 years ago (1 children)

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

[–] GissaMittJobb@lemmy.ml 2 points 2 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.

[–] Lanthanae@lemmy.blahaj.zone 3 points 2 years ago

nix

This post was sponsored by NixOS gang

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

[–] ksynwa@lemmygrad.ml 3 points 2 years ago

I really dislike when indentation is a part of the syntax (like in YAML). Apart from that it depends on the requirements of the project.

[–] hellishharlot@programming.dev 2 points 2 years ago
[–] AntiOutsideAktion@hexbear.net 1 points 2 years ago
[–] jollyrogue@lemmy.ml 1 points 2 years ago

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

[–] dmoonfire@kbin.social 1 points 2 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.

[–] static_caster@programming.dev 1 points 2 years ago* (last edited 2 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.

[–] Andy@programming.dev 1 points 2 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.

[–] BitSound@lemmy.world 0 points 2 years ago (1 children)
[–] JonnyRobbie@lemmy.world 2 points 2 years ago (1 children)

Meh, at that point, you may as well use python.

[–] BitSound@lemmy.world 1 points 2 years ago

I like Python and use it a lot, but Dhall has several guarantees that Python doesn't. If you hand someone clever a Python interpreter, they can and will find a way to run rm -rf / or what-have-you, no matter what safeguards you put in place. Dhall also guarantees that it will terminate, which is pretty useful if you're embedding it in something else. In Python you could pretty easily accidentally or purposefully get into a while True loop.