Тёмный

Everything about TOML format 

Orchard Dweller
Подписаться 1,1 тыс.
Просмотров 45 тыс.
50% 1

What is this TOML?
Visualizer:
toml-to-json.orchard.blog/
Code:
github.com/orcharddweller/tom...
TOML spec:
toml.io/en/v1.0.0
#TOML #tutorial #guide #coding #learning #programming
Join the discord:
/ discord
0:00 intro
0:52 headers
2:10 values
4:17 keys
5:39 array tables
6:24 outro

Опубликовано:

 

2 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 127   
@uuu12343
@uuu12343 6 месяцев назад
Toml is like the love child of ini and yaml
@NyanCoder
@NyanCoder 6 месяцев назад
Toml is like ini with types and objects. Literally ini++
@hundvd_7
@hundvd_7 6 месяцев назад
Aside from array tables, I love everything about this
@anon_y_mousse
@anon_y_mousse 6 месяцев назад
I never bothered to read the full spec, so this is a great overview. I like some features that it provides above INI, and it's definitely better than JSON, but arrayed sections are awful. Although, I'd still use it if I need a config file format, because it's only slightly more complex than INI.
@greyshopleskin2315
@greyshopleskin2315 6 месяцев назад
Agree. It’s not perfect but easy and good enough. I like it more than yaml, ini or json. It’s less verbose.
@theherk
@theherk 6 месяцев назад
I’m fine with toml and other markups but I don’t see how it is better than JSON. They’re all the same. JSON is more clear or more simple but maybe a bit longer. They both end up representing the same data though.
@anon_y_mousse
@anon_y_mousse 6 месяцев назад
@@theherk JSON isn't what I would call a human readable format, and it's often minified which makes it even worse. Which is better, a single newline or braces around a section with no spaces at all?
@theherk
@theherk 6 месяцев назад
@@anon_y_mousse I’m not suggesting there aren’t instances in which one is more readable than the other, but sometimes I think json is more readable. I’ve dealt with some toml files with extended arrays of the same array throughout the file that in json or yaml are all grouped together. That makes logical sense in some cases but not always. And regarding one single line, surely you aren’t suggesting json requires that. One could format a toml file to be more difficult for a human to read than necessary too. But a single line of compacted json is nothing a simple pass through jq can’t fix.
@anon_y_mousse
@anon_y_mousse 6 месяцев назад
@@theherk I can agree regarding arrays, but then I don't need those in most configuration files. For data, it should just be a binary format to speed up reading and writing. If a user wants to edit data, they should use the appropriate program rather than hand editing with a text editor. As for `jq`, well, not everyone has it installed, especially if any of your users are on Windows they likely won't, and more importantly, they won't know how to use it if they're novices with a command line.
@doce3609
@doce3609 6 месяцев назад
Gotta love Tom the Genious
@vhalmd
@vhalmd 6 месяцев назад
the guy was really a genius
@eyondev
@eyondev 5 месяцев назад
Time for TDSL
@LaPingvino
@LaPingvino 6 месяцев назад
I see several reactions where people prefer JSON over this, but there are things that JSON doesn't do that TOML does that are important for configuration files. The most important one being commenting. All features are superior over JSON for readability, you can make your files readable, and less ambiguity compared to YAML. I think it's mostly very important to understand where it's useful and where it isn't.
@lhpl
@lhpl 6 месяцев назад
You do know that the absence of comments in JSON is meant as a _feature_ ?
@orcharddweller
@orcharddweller 6 месяцев назад
Yup, those are different formats, and while I don’t believe TOML is flawless, it has certain features that make it better than JSON for the job its supposed to do.
@ShadowManceri
@ShadowManceri 6 месяцев назад
Variants of JSON like JSONC and HJSON also include ability to comment. I don't think JSON is that great for config file as long it needs to be edited by a human. It's rather clunky to use the moment you go into complex structures. But if it's just simple one level object with few keys then it's a simple solution to a simple problem. Lack of comments still is kind of big negative for config files especially.
@CoolerQ
@CoolerQ 6 месяцев назад
JSON is really a pain because of the strict formatting/lack of comments, but what is the "less ambiguity compared to YAML"? I've never found YAML to be ambiguous.
@lhpl
@lhpl 6 месяцев назад
@@CoolerQ no?
@niccolobardini8905
@niccolobardini8905 6 месяцев назад
Tom's a genius
@CRAAACH
@CRAAACH 6 месяцев назад
JDSL config spec
@Lemmy4555
@Lemmy4555 7 месяцев назад
TOML is great in place of JSON that goes at most 2 levels deep. best format for configurations file, that's for sure.
@maxrinehart4177
@maxrinehart4177 5 месяцев назад
What to use in 3 (and above) level deep?
@Lemmy4555
@Lemmy4555 5 месяцев назад
@@maxrinehart4177 json or yaml have much better syntax for nested stuff
@API-Beast
@API-Beast 6 месяцев назад
cool cool, I basically implemented the same thing once, calling it "xini" but concept was very much the same, so guess it is obvious after all biggest difference is the [[notation]] for arrays, which I like quite a lot. I just treated all sections as arrays, which is quite a bit more ambigious
@ti4go
@ti4go 6 месяцев назад
You just got a new sub! Simple and objective explanation!
@jackwright517
@jackwright517 6 месяцев назад
Very underrated video! Thanks so much!
@bogdanstamenic2836
@bogdanstamenic2836 8 месяцев назад
This is really good!
@a_maxed_out_handle_of_30_chars
@a_maxed_out_handle_of_30_chars 8 месяцев назад
learned something new today, thank you :)
@knut-olaihelgesen3608
@knut-olaihelgesen3608 6 месяцев назад
Very good visualisation and explanation of dotted keys. Personally I find a bit more pace the right thing 😊
@Danielo515
@Danielo515 6 месяцев назад
Nice and entertaining video, thanks
@eu1492b
@eu1492b 8 месяцев назад
Nice!
@arlaxia
@arlaxia 5 месяцев назад
I've always been too lazy to read the specification, this video was fantastic.
@VincenzoTilotta
@VincenzoTilotta 6 месяцев назад
Thanks!
@Im_Ninooo
@Im_Ninooo 6 месяцев назад
this video made me really like TOML!
@cthutu
@cthutu 6 месяцев назад
I use the KDL (cuddle) format in my code now. Rust has a serde extension for it.
@SimonBuchanNz
@SimonBuchanNz 6 месяцев назад
I prefer the error reporting and structure binding of knuffle as a library to parse kdl, but yeah, it's currently my favorite config format. My main gripe is just that you're not allowed to have a bare symbol argument (eg "foo bar" instead of "foo "bar""), which makes some patterns a bit uglier than they need to be, though I get why.
@cd-stephen
@cd-stephen 6 месяцев назад
awesome
@juniorceccon
@juniorceccon 6 месяцев назад
Tom is a genious
@jamesfitzpatrick9607
@jamesfitzpatrick9607 6 месяцев назад
I enjoy toml as a configuration format for tools. Seen some where that it was only even meant to be machine readable and not machine writable like json. I spend alot of time in k8s using yaml and in that world toml would be a bad choice. But i still use it for tooling, where i thin it shines.
@cindrmon
@cindrmon 6 месяцев назад
i've learned toml when configuring hugo config files. after learning more about it, i love it more than yaml, and somehow learned a bit of ini. thank you tom for making this
@marloelefant7500
@marloelefant7500 6 месяцев назад
What are the advantages of toml over yaml? Like you, I'm currently starting out with toml by configuring hugo config files, but I found it very not obvious. Yaml, on the other hand, I understood immediately on the first look (with the knowledge of json).
@cindrmon
@cindrmon 6 месяцев назад
@@marloelefant7500 i guess for me is that you don't have to worry about whitespace indentation in toml (even though in hugo there are some docs that show whitespace indentation, but i choose to ignore it). also having nested selectors in which for yaml, you'd have so many indented lines to select a specific, deeply-nested key, while in toml, you just put it in dot notation making it shorter and more concise. tbh i don't toally hate yaml in general, as it is one of the morely used configuration specs besides json, and it does have its own advantages, but given the option for usage of toml, i would gladly use it.
@urisinger3412
@urisinger3412 6 месяцев назад
Toms a genius!!
@AnweshAdhikari
@AnweshAdhikari 6 месяцев назад
@manishmg3994
@manishmg3994 6 месяцев назад
good one
@nzeu725
@nzeu725 6 месяцев назад
toml is super easy, my only experience with it was like on cargo project and now i'm developing a project that involves parsing it with the tomlc99 library (the project is frogmake, it's still in early development and i'm working on it every day)
@RedStone576
@RedStone576 6 месяцев назад
trying to find any other use of toml beside of cargo.toml
@orcharddweller
@orcharddweller 6 месяцев назад
Lol, that's a great point, I've searched a bit, when making the vid and its mostly python and rust project configs, as well as some other smaller tools in those ecosystems. On the other hand its a config file format, how many config files do we need anyway
@SkMag9
@SkMag9 6 месяцев назад
If you self-host a gitlab runner you configure it in a toml file.
@diadetediotedio6918
@diadetediotedio6918 6 месяцев назад
​@@orcharddweller I use it in a server for translation of errors, it works like a charm
@greyshopleskin2315
@greyshopleskin2315 6 месяцев назад
I think traefik allows toml for config (and more formats). You can also use it for configuring your backend in those cases where your config is a but extensive and complex so that using env vars is not the best solution. I don’t like reading config from files, as you need to make sure to deploy the file, that it is in the path that your app expects it, that you don’t mess up permissions, and more. In rust you can use a macro to read a file’s content AT COMPILE TIME. And you can also do config validation at compile time. That way you can compile it in your machine or CI/CD and just deploy a single binary that will have a embedded, validated config ready to use. You can upload to git config files containing secrets using git secret which will encrypt them, so there’s no security problem in tracking them. Also, you have a history of how config and secrets changed overtime and you can see what’s the current config and compare it to the config used in the last deploy.
@rya1701
@rya1701 6 месяцев назад
a bunch of minecraft mods use toml
@hrznn
@hrznn 5 месяцев назад
you lost me at array tables, not gonna lie xd amazing quickstart video btw
@sergeikulikov4412
@sergeikulikov4412 6 месяцев назад
What is common solution for stringification, since "there are different ways to represent the same data" ?
@orcharddweller
@orcharddweller 6 месяцев назад
Its tricky, because in most cases you want to preserve the original style and comments. Poetry for example uses tomlkit, you can check out their approach here: github.com/sdispater/tomlkit In general, I’d probably avoid writing with TOML it unless you really need it.
@rahulr9539
@rahulr9539 5 месяцев назад
4:50 if you meant to use regex for bare keys you shoild escape the last hyphen with a backslash
@sm5304
@sm5304 6 месяцев назад
We have too many config languages at this point
@DaverSomethingSomething
@DaverSomethingSomething 6 месяцев назад
Still way better than it used to be when everyone invented their own thinking parsing was a trivial thing.
@ximono
@ximono 6 месяцев назад
There's a lot I like about TOML, but its sections are not very intutive. I've designed my own format (kesh-lang/na). Still haven't made a compiler for it though. But you're welcome to have a look if you're interested in data notation formats.
@makroshlyta
@makroshlyta 7 месяцев назад
Great explanation!
@D0Samp
@D0Samp 6 месяцев назад
5:20 You can write "please don't" all you want, but all I see is a convenient form to convert my Java property files into.
@khatharrmalkavian3306
@khatharrmalkavian3306 6 месяцев назад
But why?
@hrudyplayz
@hrudyplayz 6 месяцев назад
TOML is very good, i don't understand a lot of the comments. I'll take TOML over JSON any day. For once, JSON is much harder to read, heavier to write and parse, and pretty much requires an external library due to how complex it is to create a parser of...
@orcharddweller
@orcharddweller 6 месяцев назад
I think you meant YAML, JSONs parser is much simpler than TOMLs, especially for writing.
@hrudyplayz
@hrudyplayz 6 месяцев назад
@@orcharddweller Even though YAML is indeed the worse of them all, it's indeed much easier to implement a TOML parser from scratch than a JSON one. Mainly because TOML mostly separates stuff into different lines and has a less complex syntax to parse overall.
@orcharddweller
@orcharddweller 6 месяцев назад
@@hrudyplayz Hmm, I've never implement neither of them, so I might be talking out of my ass, but I've done a bit of parsing in my life and just looking at this: www.json.org/json-en.html, the grammar feels much simpler than TOML. Also TOML has inline arrays and inline tables, which are in essence a limited version of JSON. So for parsing TOML you need to be able to parse a lobotomized version of JSON, but that's not necessary the other way.
@codingjerk
@codingjerk 6 месяцев назад
Not so obvious 😅
@jamesmillerjo
@jamesmillerjo 6 месяцев назад
It is more close to INI, it would be better not call as '-ML' even it is an acronym of 'minimal language' Anyway it is further from the actual language.
@electricz3045
@electricz3045 6 месяцев назад
Coming from python, were indentation is a must, I don't really like the toml structure, I find JSON more readable because there you have indentation plus I don't need to install an additional dependency just to parse the toml into variables 😅
@cxmu0391
@cxmu0391 6 месяцев назад
A toml parser comes included with Python 3.11
@Spencer-wc6ew
@Spencer-wc6ew 6 месяцев назад
Neither json nor TOML care about indentation.
@lhpl
@lhpl 6 месяцев назад
Just use ASN.1 - it's a standard, flexible, supports a text format, as well as several binary encodings.
@D0Samp
@D0Samp 6 месяцев назад
That said, that one standardized text format is an XML transformation, if you plan for a text-first use case like a configuration file you might as well use XML directly. The most common "text" form of ASN.1 that users encounter regularly is probably Base64-encoded BER.
@lhpl
@lhpl 6 месяцев назад
@@D0Samp While XML certainly is an encodin scheme for ASN.1 defined data, I was thinking of the possibility of representing example data in ASN.1 itself. It is possible to do so, iirc. (In practice, nobody would want to do so of course, as then you'd need an ASN.1 compiler to parse configuration files.)
@scottmiller2591
@scottmiller2591 5 месяцев назад
Jason always seemed like the love child of a data structure and LISP - hard to read and too many keystrokes.
@Linuxdirk
@Linuxdirk 6 месяцев назад
Array tables are cursed ...
@henriquedante
@henriquedante 5 месяцев назад
Off topic: the stress syllable of integer is the first: ínteger
@Nanagos
@Nanagos 6 месяцев назад
So Toml is like JSON but with non obvious hierarchy and Python vibes.
@Daniel_Zhu_a6f
@Daniel_Zhu_a6f 6 месяцев назад
as they say, it's bad, but it's the best we have. somehow, nobody tried to think for a bit, when they were inventing text file formats, so .csv, .json, .yaml, .ini, .xml are all uniquely bad in many respects. if only half the ingenuity that is regularly applied to binary file formats was once applied to a text format, nobody in 10 years would probably remember what a .csv or an xml is.
@lhpl
@lhpl 6 месяцев назад
I think a guy called Charles Goldfarb did so 50+ years ago, in 1969. Called GML, it evolved into SGML which was standardised as ISO 8879 in 1986! And then of course there is also S-expressions, which is ten years older and simpler. But why use them when we can invent new buggy ones every other year?
@LukasCobblerxD
@LukasCobblerxD 6 месяцев назад
honestly, why is it bad? Everything about it is really intuitive except maybe the last part of the video
@Daniel_Zhu_a6f
@Daniel_Zhu_a6f 6 месяцев назад
​@@LukasCobblerxD well, toml is mostly ok. but i do have 2 problems with it: 1. the thing i really dislike about toml is headers vs inline tables/lists -- it is quite ambiguous. btw, yaml has exactly the same problem, only x2 because of additional features. 2. this one is much less severe, but it certainly can bit you in some cases. toml has too many data types. i'm not a hardcore optimization fan, but this is a bit much features for a "minimal config format". personally, i would do only ints, floats and strings, certainly no dates/times etc. instead they could have had an optional type annotation for a string literal, so that user would later parse it properly. with this you would have something like `my_date = @iso_date"2024-01-23"`, which is very explicit, yet minimal. although, i'd say even this is an overkill.
@Daniel_Zhu_a6f
@Daniel_Zhu_a6f 6 месяцев назад
​@@LukasCobblerxD if i had to implement a "minimal configuration language" i would probably start with something like lisp sexprs, but with string literals only, and then add ints + floats and transpose parentheses. so initially it would look something like: ``` message { chat_id { 12345 } user { John Doe } date { 2024-01-20 10:45 GMT+2 } text { "Hello, world" } status { 0 } } ``` of course, one needs a lot of testing and feedback from diverse user group to make a really good format.
@lhpl
@lhpl 6 месяцев назад
@@Daniel_Zhu_a6f If I had to implement a "minimal configuration language" I would probably start with something like lisp sexprs. And then stop right there.
@StarOnCheek
@StarOnCheek 6 месяцев назад
I knew toml was bud but I didn't think it was this bad
@ClementMasson
@ClementMasson 6 месяцев назад
Looks much less natural than yaml, especiales arrays of headers
@DaVyze
@DaVyze 6 месяцев назад
When Go 1.20 was out, a lot of CI/CD pipelines broke, because the YAML parser interpreted the 1.20 as a number (so: 1.2 instead of 1.20). To avoid this, you had to write "1.20". YAML was blamed for this. I refuted this, pointing to the parser instead. When I used a YAML parser in Go, I got the string value 1.20 instead of a numerical one. Now I tried this with your TOML Visualizer. Same result. "1.20" is interpreted as string. 1.20 as number. YAML isn't worse than TOML. In fact, I'd rather read YAML since it's more natural for me to write it.
@xdMatthewbx
@xdMatthewbx 6 месяцев назад
alright thats cool and all but I'm still using json
@totally_not_a_bot
@totally_not_a_bot 6 месяцев назад
This is basically systemd .conf files, but more complicated and python-centric.
@casraf
@casraf 6 месяцев назад
God I hate toml, using arrays/inner keys in it is absolutely terrible, and it doesn't support a lot of character escape sequences. If there's ever a way to get me to avoid updating a config file at all costs, make it in toml.
@Liamnissan22222
@Liamnissan22222 6 месяцев назад
Give me yaml any day
@Katniss218
@Katniss218 6 месяцев назад
"much more readable than json" lmao. Yeah not with that last part, definitely not.
@poisonouspotato1
@poisonouspotato1 6 месяцев назад
Watch at 1.25x speed
@harleyspeedthrust4013
@harleyspeedthrust4013 6 месяцев назад
toml doesn't need to exist. first of all, who tf is tom? and how is his language "obvious?" granted yaml isn't obvious but it's more sensible than toml. it also does pretty much anything that you might want. sure the yaml spec is huge but you don't have to implement the whole spec if you don't need to. json is also ok for simple things and is about as obvious as can be. you only need to look at an example json file to pretty much figure out how it works. anything more complicated than passing data around or dead-simple configuration though and json falls flat on its face, but that's what we have yaml for. now this tom guy decides to throw his goofy format into the mix and we have one more silly config language that we have to know.
@sacredgeometry
@sacredgeometry 6 месяцев назад
toml is just. shitty json without the outer brackets and quotations around keys
@DrewryPope
@DrewryPope 7 месяцев назад
thanks, i hate it!
@DrewryPope
@DrewryPope 7 месяцев назад
good job tho
@MonsterSmart
@MonsterSmart 6 месяцев назад
Good tutorial. But I hate what I see 🤢🤮
@69k_gold
@69k_gold 6 месяцев назад
YAML is just way better
@ShadowManceri
@ShadowManceri 6 месяцев назад
YAML is just overcomplicated. Multiple ways to do the same thing and nothing communicates what it does and whitespace management is a nightmare. I don't think you can find anything worse in all honesty. --- # lol - foo: &bar something: is something foo: *bar easy: !!str format to: !!!str read | or is it? think: > is this valid YAML file? Spoiler: it's not, it has valid structure but it won't validate because of whitespace. Spot the error, good luck. Do you know what is defined here? who: | knows: really could or could not be
@Madinko12
@Madinko12 6 месяцев назад
​@@ShadowManceriI feel like using a subset of YAML just circumvents its feature-creep and fixes some ridiculous design bugs (like the "norway problem"). For instance, you could enforce consistent indentation, force strings to be written either in doube-quotes for single line strings or multiline blocks for multi-line strings and nothing else, drop many useless features (such as anchors, though I kinda like them), drop JSON syntax compatibility, force booleans to use either the "true" or "false" token, etc… Sure YAML is bloated, but TOML gets basically unreadable and unmanagable as soon as you have some levels of nesting. It forces you to repeat many keys (when YAML prevents such repetitions by design). TOML has many more indirections by default than just a YAML document written in a consistent way without the "bad parts". TOML is just another instance of someone reinventing a whole new language that has just as many flaws as the previous one and to fix completely non-existing issues. I mean YAML was mostly fine, you just had to fix the bad parts.
@SimonBuchanNz
@SimonBuchanNz 6 месяцев назад
The Norway problem doesn't exist in a decently up to date yaml parser. They added "schemas" to define the interpretations of values and changed the default to be some simple, obvious rules like only true and false for booleans. You can still hit issues with dates with the default schemas if you don't expect them, but there's JSON and core schemas to be even simpler, and compat for earlier yaml compat. It's no longer my favorite format (that's currently kdl), but it's actually hard to point at a specific, actual problem with it now rather than "complexity" or "I don't like significant indent"
@Madinko12
@Madinko12 6 месяцев назад
@@SimonBuchanNz any YAML compliant implementation is affected by the norway problem. If it is not affected, then you're just talking about a different language, or a subset of YAML. AFAIK, most popular YAML parsers in pretty much every language I've used implement most of the YAML spec (including "NO" to false coercion) and not a strict subset of it. Having 10 different ways of declaring a simple object like a boolean was one of the many things YAML got wrong. And yeah, they added new features to an already bloated data language in order to circumvent mistakes they made in previous versions of the spec.
@SimonBuchanNz
@SimonBuchanNz 6 месяцев назад
@@Madinko12 any yaml 1.2 complaint implementation that doesn't default to the compatibility schema absolutely does not parse "no" as "Norway". This isn't a "subset of yaml" thing, it's actual yaml.
@gabrielmachado5708
@gabrielmachado5708 6 месяцев назад
I think this format is unnecessary and JSON hierarchy is much more intuitive. It only looks prettier.
@1schwererziehbar1
@1schwererziehbar1 6 месяцев назад
very bad
@yaroslavpanych2067
@yaroslavpanych2067 6 месяцев назад
Lol "more readable than EVEN yaml" Dude speaks like yaml is most readable format! Yaml is one of least readable formats ever. In fact, less readable only binary serialisation!
@kale.online
@kale.online 6 месяцев назад
Tom's language isn't all that obvious or minimal. JSON ❤
Далее
Is JSON Blazingly Fast or...?
9:57
Просмотров 189 тыс.
Using docker in unusual ways
12:58
Просмотров 426 тыс.
The Algorithm Behind Spell Checkers
13:02
Просмотров 409 тыс.
Naming Things in Code
7:25
Просмотров 2 млн
Turns out REST APIs weren't the answer (and that's OK!)
10:38
Faster than Rust and C++: the PERFECT hash table
33:52
Просмотров 529 тыс.
How principled coders outperform the competition
11:11
The size of your variables matters.
11:03
Просмотров 106 тыс.
Why do developers hate Rust?
8:20
Просмотров 107 тыс.
Dear Functional Bros
16:50
Просмотров 486 тыс.
I've been using Redis wrong this whole time...
20:53
Просмотров 346 тыс.