r/ProgrammerHumor • • 2d ago

Meme tomlIsntObvious

Post image
647 Upvotes

91 comments sorted by

436

u/araujoms 2d ago

Don't you dare badmouth TOML, that's the best markup language I ever used. Simple, readable, stays out of the way.

121

u/ARKyal03 1d ago

Agree, I'm any case that should be yaml, indented awfulness.

31

u/EmperorOfAllCats 1d ago

I read this as "intended awful" first and it actually makes sense. It's like yaml specifically designed to be bad.

2

u/nhermosilla14 1d ago

Some of us actually like the mandatory use of indentation. Just like with Python, it forces others to write in a standard way, so the result is sorta guaranteed to be readable.

4

u/HungYurn 6h ago

who doesnt use a code formatter these days?
Id rather have my code formatter know what to do

0

u/nhermosilla14 4h ago

Not every config file is going to be edited in a development environment. Some of the uses for yaml involve settings files, and in some cases that can involve modifying it in production, with a very basic text editor (specially on embedded systems, usually with no network connectivity at all).

1

u/redd1ch 1h ago

Who doesn't like to count spaces when hacking on an embedded device with the barebonest editors? Especially when you only got a serial console and a limited viewport.

7

u/Meercrow 1d ago

Not needing indentation like in toml is definitely better than forcing a standard indentation

1

u/Honigbrottr 7h ago

disagree

2

u/tropicbrownthunder 5h ago

Then you get the tabs vs spaces feud

1

u/nhermosilla14 4h ago

Yeah, some things never change.

12

u/quisido 1d ago

I can't read or write it to save my life. How many square brackets do I need?!

5

u/araujoms 1d ago

Skill issue.

1

u/poughdrew 1d ago

Seriously. Read the spec, it will take 10 minutes and then you're good for life. If TOML and YAML are hard for people I really wonder what the rest of their work looks like.

17

u/prehensilemullet 1d ago

In many cases, it would be a disaster as a JSON or YAML replacement…

[Resources.SchedulerRole]
Type = "AWS::IAM::Role"

  [[Resources.SchedulerRole.Properties.Policies]]
  PolicyName = "InvokeLambdaPolicy"

    [[Resources.SchedulerRole.Properties.Policies.PolicyDocument.Statement]]
    Effect = "Allow"
    Action = ["lambda:InvokeFunction"]
    Resource = { "Fn::GetAtt" = ["MyLambda", "Arn"] }

64

u/funkdefied 1d ago

That’s not properly formatted TOML though. The whole thing would be left-justified. Plus, it’s strictly less or equally nested as JSON or YAML. Don’t like the long keys? Nest them. You’ll get YAML almost exactly. Or don’t nest them, and get something that is much more pleasant to actually review. Ever tried to read a huge YAML file? It SUCKS. Try posting this same data in YAML and tell me that it’s better. 

21

u/prehensilemullet 1d ago edited 1d ago

According to Google, some people choose to format it this way to make the nesting structure clearer. Good luck trying to edit complex nested data in TOML without it.

I'm guessing your gripe with Yaml is it can be hard to find the parent of something when scrolling up? For me this isn't a problem because VSCode keeps parent elements sticky at the top of the editor, though I know not everyone uses an IDE like that.

Which one of these alternatives do you think is better in TOML?

[Resources.SchedulerRole]
Type = "AWS::IAM::Role"

[Resources.SchedulerRole.Properties]
Policies = [
  { PolicyName = "InvokeLambdaPolicy", PolicyDocument = { Statement = [
    { Effect = "Allow", Action = ["lambda:InvokeFunction"], Resource = { "Fn::GetAtt" = ["MyLambda", "Arn"] } }
  ] } }
]
[Resources.SchedulerRole]
Type = "AWS::IAM::Role"

[[Resources.SchedulerRole.Properties.Policies]]
PolicyName = "InvokeLambdaPolicy"
PolicyDocument.Statement = [
  { Effect = "Allow", Action = ["lambda:InvokeFunction"], Resource = { "Fn::GetAtt" = ["MyLambda", "Arn"] } }
]
Resources.SchedulerRole.Type = "AWS::IAM::Role"
Resources.SchedulerRole.Properties.Policies = [
  { PolicyName = "InvokeLambdaPolicy", PolicyDocument.Statement = [
    { Effect = "Allow", Action = ["lambda:InvokeFunction"], Resource."Fn::GetAtt" = ["MyLambda", "Arn"] }
  ] }
]
[Resources]
SchedulerRole = { Type = "AWS::IAM::Role", Properties = { Policies = [ { PolicyName = "InvokeLambdaPolicy", PolicyDocument = { Statement = [ { Effect = "Allow", Action = ["lambda:InvokeFunction"], Resource = { "Fn::GetAtt" = ["MyLambda", "Arn"] } } ] } } ] } }

I don't think I would find any of the above as clear, readable or maintainable as the yaml that AWS CloudFormation supports:

Resources:
  SchedulerRole:
    Type: AWS::IAM::Role
    Properties:
      Policies:
        - PolicyName: InvokeLambdaPolicy
          PolicyDocument:
            Statement:
              - Effect: Allow
                Action:
                  - lambda:InvokeFunction
                Resource: !GetAtt MyLambda.Arn

I'm guessing what you use TOML for usually doesn't have many levels of nesting. It's fine enough simple configs. But for structured data that's unavoidably nested, you have half a dozen ways of expressing that structure in TOML, and they're all kind of awkward. And because it's awkward, people don't use TOML for those use cases, so you don't get much firsthand experience with what it's unsuited for

2

u/razies 1d ago
[resources.SchedulerRole]
type = "AWS::IAM::Role"

[[resources.SchedulerRole.policies.InvokeLambdaPolicy.statements]]
effect = "Allow"
actions = ["lambda:InvokeFunction"]
resource = { get_att = "MyLambda.Arn" }

Or:

[resources.SchedulerRole]
type = "AWS::IAM::Role"

[resources.SchedulerRole.policies]
InvokeLambdaPolicy = {
    effect = "Allow"
    actions = ["lambda:InvokeFunction"]
    resource = { get_att = "MyLambda.Arn" }
}

1

u/prehensilemullet 1d ago

According to what I’ve read, an object with { } has to stay on one line in TOML 1.0.0, and support for newer versions isn’t widespread yet

Also, these examples are missing PolicyName.  

2

u/Alternative-Tie-4970 1d ago

It isn't markup though?

233

u/gabedamien 2d ago edited 1d ago

YAML is awful though. Massively over complicated, horrifying grammar, tons of edge cases and exceptions, ambiguities, etc. TOML isn't perfect but from a parsing / formal design perspective it puts YAML to shame.

35

u/ACoderGirl 1d ago

A few examples for people unaware:

  • YAML allows unquoted strings, which is confusing when a string happens to have a value that looks like another type (like the string "true").
  • It's rarely used, but YAML actually has variables, which let you store objects in a variable and reuse later to reduce repetition.
  • YAML 1.1 allowed unusual boolean representations like "yes". I've personally experienced this breaking things because a config file meant for 1.2 was parsed as 1.1.
  • While I personally think that people complaining about indentation are not being very serious (it's no different from Python and only students are confused by it), it still does have some dangers. I've seen vulnerabilities come from naive attempts at tenplating YAML due to this (people will remember to escape quotes but forget that indentation has a similar effect). And it is arguably less clear what the exact resulting string will be.

6

u/Alternative-Tie-4970 1d ago

The unquoted strings was a massive headache for past me when I was dealing with numbers in yaml

55

u/TerminalVector 1d ago

I feel like yaml is okay if you just don't use any of the fancy crap and quote your strings. For short 20-30 line config files it's fine.

43

u/PlanetJourneys 1d ago

Cries in GitHub actions workflow file yaml

20

u/TerminalVector 1d ago

Okay yeah that's a solid point, that shit is a nightmare.

4

u/mrnosyparker 1d ago edited 1d ago

I just posted a comment about this the other day. It seems like a lot of people here might be just dumping every piece of a large/complex workflow into a single manifest?

If your workflows are properly abstracted and follow best practices, you really shouldn’t end up with insane levels of indentation or a manifest that’s difficult to read or maintain.

Just to illustrate, here's an example ci.yaml

on: [push, pull_request]

jobs:
  checks:
    uses: ./.github/workflows/checks.yaml

  deploy:
    needs: checks
    if: github.ref == 'refs/heads/main' && github.event_name == 'push'
    uses: ./.github/workflows/deploy.yaml
    secrets: inherit

... and then example checks.yaml

on: workflow_call

jobs:
  test:
    strategy:
      matrix:
        node: [20, 22]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: ${{ matrix.node }}
      - run: npm ci && npm test

  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: ./scripts/lint.sh

3

u/quisido 1d ago

Even simpler imo to use custom actions instead of callable workflows.

2

u/mrnosyparker 1d ago

If you’re re-using a workflow across multiple repositories or want to encapsulate more sophisticated functionality with well-defined inputs and outputs then for sure, custom actions are the way to go 👍.

But if all you need to do is break up an unwieldy repo-specific workflow to avoid the yaml-hellscape issue people are commenting about lately, then an example like what I gave is probably sufficient.

6

u/MegaIng 1d ago

Oh. So TOML?

6

u/prehensilemullet 1d ago

But all of TOML’s ways of expressing nesting are way less convenient.  For a few levels of nesting it’s fine, but for something like an AWS CloudFormation template, using TOML would be a nightmare.  Even CI workflow configs require too much nesting.  That’s probably the main reason no CI providers support workflow config in TOML as far as I know.

4

u/metaltyphoon 1d ago

Said the cracked C++ programmer 

-6

u/Fidel___Castro 1d ago

agreed but it's perfect for AI, I can just read it and not struggle with actually writing it 

26

u/naveenda 1d ago

TOML: Tom's Obvious Minimal Language

155

u/FoodBorn2284 2d ago • Bravo

YAML and TOML should trade places.

4

u/WindowlessBasement 2d ago

Why?

YAML is just whitespace JSON. It's a superset so even just dumping JSON into a YAML file is valid YAML

53

u/latkde 1d ago

I have yet to see two YAML parsers that can fully handle each other's output. Common incompatibilities include multiple documents in the same file, parsing scalars beyond the JSON profile (e.g. parsing datetimes, or the Norway problem), support for explicit tags, cyclic data structures, the << merge pseudo-operator, templating on top of or inside YAML. Most of these problems are semantic, not syntactic.

In contrast, TOML has reasonably clear syntax and semantics. There are a few interesting edge cases in the syntax, but there's no opportunity for YAML-style type confusion problems. However, TOML doesn't have a JSON-compatible data model: the top level must be a table (mapping), nulls don't exist, and expressing lists of items that may be scalars or large tables is awkward (in TOML 1.0, inline tables cannot contain line breaks).

46

u/ArtOfWarfare 1d ago

You’ve never seen the YAML spec. It’s hundreds of pages long and has a horrifying number of features.

It’s comparable to XML or HTML… maybe worse.

24

u/Rafert 1d ago

YAML is the only one with the Norway problem.

4

u/flamingspew 1d ago

Thats when Australians say “Nor way!” And people think they are referring to the country. That’s why they sell koala and kangaroo stuffies in Austria as a joke.

8

u/TerminalVector 1d ago

Yes, but not always. Which is basically what you could say about most aspects of yaml.

Yaml is okay if you always quote your strings and only use it for lists, k-v pairs, numbers and strings. Any usage of advanced yaml features is heresy.

1

u/ydieb 1d ago

Yeah that does not make it better, but worse imo. It is ambiguous and messy because it tries to do too much stuff, unclearly.

42

u/Lord_Of_Millipedes 1d ago

y'all forgot the holy texts, yaml is a creation by the devil himself

https://ruuda.nl/2023/the-yaml-document-from-hell

19

u/araujoms 1d ago

As it turns out, numbers from 0 to 59 separated by colons are sexagesimal (base 60) number literals.

Ok, that settles it, YAML is just trolling.

26

u/PresidentOfSwag 2d ago

pyproject though

7

u/radarvan07 1d ago

Respectfully, Norway

12

u/Alternative-Tie-4970 1d ago

json's only real problem is the lack of comment support, but it has something both of the other two don't have.

Or rather, it doesn't have something that both of the other two have.

It doesn't have something that really bothers me - multiple ways to do the exact same thing.

json is dead simple: curly brackets are mappings/dictionaries and angle brackets are arrays. There is not much else really to it.

Compare it with the other two, both of which have two completely valid ways to define an array.

I will praise toml's desing on the human-readability front tho, it's definitely a good choice for anything humans will read, and especially write.

4

u/YourMJK 1d ago

Let me introduce you to JSON5:
https://json5.org

Has comments and no need for quoting of keys.

Basically comparable to YAML but not whitespace sensitive (apart from single-line comments I guess) and syntax definition is as simple as JSON

5

u/NegativeGrocery8684 1d ago

Why would anyone want to use JSON as a config file in the first place, but even so much that they'd sacrifice core functionality to do that? We have TOML for that exact reason.

2

u/-Redstoneboi- 1d ago

meanwhile, env files

1

u/Alternative-Tie-4970 1d ago

toml absolutely wins for configs by far. That's why I praised it for human readability. But in general, and where being machine-readable is the priority, json's simplicity tends to win, not that you would often need to write your own parser. Though as far as being human readable is concerned, json isn't all that far off from toml, it's fairly readable for something that's machine-first.

2

u/NegativeGrocery8684 1d ago edited 1d ago

JSON5 explicitly strips the machine interoperability from JSON and turns it into a config format, which is baffling to me, and was the purpose of my comment. JSON has always been a comfortable middleground for when I want a machine to store and parse data, but I don't care about performance and would rather it be quick enough to manually read and/or manipulate. From what I can tell, JSON5 takes an already decently human-unfriendly format and tries to polish the manure, resulting in some very shiny manure that doesn't fertilize soil.

2

u/gcstr 1d ago

Yaml is already a superset of json. Also, last release 4 years ago?

6

u/Random_182f2565 1d ago

Jason, Yamal and Tom

:D

4

u/27_myths 1d ago

Eh, I'll just stick with Lisp. I don't need any of this bs!

6

u/fugogugo 1d ago

json wont get destroyed if you remove the whitespace

3

u/funny_xor_die 1d ago

You forgot to duplicate the head of JSON 10 million times

5

u/Ok_Solid6442 1d ago

hating on toml while being a yaml lover is... an opinion

14

u/SpacewaIker 1d ago

Toml is great, json is the worst (for humans)

33

u/Batman_AoD 1d ago

Yaml is the worst, because of all the weird edge-cases. 

4

u/Alternative-Tie-4970 1d ago

For humans specifically yaml is pretty good. For machines, it's a nightmare.

5

u/Sibula97 1d ago

TOML and KDL are nice, and JSON has it's place.

YAML fucking sucks.

2

u/theQuandary 1d ago

All three are just worst S-expressions.

2

u/reallokiscarlet 1d ago

But... JSON is the odd one out.

2

u/riisen 1d ago

I actually like all 3, they are all simple.

I usually try to make deserialisation/serialization for all 3.

Toml is my goto, since that the standard for most conf files in linux so thats what i learned first.

Json is used everywhere often mandatory

Yaml is great for configurations just like toml is.

2

u/Prior-Perspective-61 1d ago

How the hell are these in one row? TOML is a config language, JSON is an object notation language, they can be interchangeable, but are usually used for different stuff

2

u/miller_99 1d ago

Toml is great

2

u/fwhite01 1d ago

Xaml - Not even worth to mention

2

u/pjank85 1d ago

JSON is by far worst format of these 3 for the simple reason that it has no support for comments. Also it was never supposed to be a serialization nor configuration format. I was just something made up that worked out of the box in JavaScript.

2

u/parnmatt 1d ago

May or may not be a hot take… but I prefer TOML to YAML any day. I wish RON was more commonly used outside of rust as well. JSON but better typed 😅

2

u/DiegoG2004 1d ago

After having been forced against my will to do a yaml, give it the silly dragon too.

2

u/stumpychubbins 15h ago

I’m sorry but yaml is the one that’s deeply unserious. I have my problems with toml but at least the syntax and semantics are standardised

Also json is a serialisation format not a markup language and I will die on that hill

2

u/SmellThePheromones 2h ago

YAML is a fucking abomination. Whoever designed it should be forever laughed at, whoever pushed it to a current level of adoption should burn in hell.

4

u/canihelpyoubreakthat 1d ago

🤡 take YAML is the devil

2

u/SweetBabyAlaska 1d ago

YAML is utter dog shit.

2

u/boxxy_morningwood 1d ago

Anything is better than writing raw json. Listen, if my agents are doing all the editing, who cares, but if I need to maintain it give me something with clear formatting now not 100000 quotes and curlies

1

u/marcodave 1d ago

What about the TOON format?

1

u/an-italian-shotgun 1d ago

Where is XML?

1

u/pintu236 1d ago

Someon ahould make that swimming pool meme with hocon and properties as well

1

u/zeukid 1d ago

yo yo, hear me out:

toon

1

u/enigma_0Z 22h ago

TOML is a just the next evolution from INI files

1

u/aceluby 22h ago

We use Hocon, like yaml but without the awfulness

1

u/Tysonzero 21h ago

Smh everyone forgetting Dhall

1

u/DerZappes 1d ago

All of them are jokes to anybody who had a chance to experience the power of XML.

-10

u/No-Magazine-2739 1d ago

TOML, YAML, INI, TCL(Cmake), Lua (used as JSON), Sqlite, registry, parsed markdowns, OMFG could we please stop inventing new ways to write down config data with the BS of telling this time its better then ever before?! Everybody not using JSON or XML straight to jail. And an extra shower rape for everybody who comes with the „… but comments“ justification.

-7

u/rover_G 2d ago

Tom’s unObvious Markup Language