Page 1 of 1
TOML
Posted: Sat Dec 24, 2022 4:24 pm
by Joubarbe
https://toml.io/en/
As it seems to become a big player, PB should have its own implementation!

Re: TOML
Posted: Sun Dec 25, 2022 11:36 am
by infratec
I just read over the toml page.
Why I should use it?
I was not able to detect any advantage compared to JSON.
The dot stuff in keys makes it more complicated (in my opionion), bcause you can not see dirctly the dependencies.
Also the """ ''' and mixed stuff of them makes it more complicated.
Orginally I wanted to start an implementation, but that string, dot and the whitepace stuff makes it to complicated for a
few hour project and I don't see a real advantage.
Can you tell me one? Maybe I oversee something.
Re: TOML
Posted: Sun Dec 25, 2022 12:37 pm
by Cyllceaux
Well... its exact the same like the "Preference"-Lib from PB.
There is only a Multiline-String Feature and Arrays. Nothing more.
It's also same like the "INI" File Format, Microsoft uses since the beginning:
https://en.wikipedia.org/wiki/INI_file
PB-Code
Code: Select all
CreatePreferences("C:\temp\test.txt",#PB_Preference_GroupSeparator)
PreferenceGroup("test")
PreferenceComment("Simple comment for an empty group")
PreferenceGroup("test.string")
WritePreferenceString("array","[100,200,300]")
WritePreferenceString("text","Hello World")
PreferenceGroup("test.number")
WritePreferenceDouble("double",2.33)
WritePreferenceFloat("float",4.55)
WritePreferenceQuad("quad",99999999999999)
WritePreferenceInteger("int",32000)
WritePreferenceLong("long",32000000)
ClosePreferences()
Result:
Code: Select all
[test]
; Simple comment for an empty group
[test.string]
array = [100,200,300]
text = Hello World
[test.number]
double = 2.3300000000000001
float = 4.550000
quad = 99999999999999
int = 32000
long = 32000000
Re: TOML
Posted: Sun Dec 25, 2022 1:42 pm
by Joubarbe
To me it's more clear and... more obvious at one glance (and it has comments), and no, it's not "exactly the same" as INI. It's is a nice mix of INI and JSON, and you should therefore be able to parse it to a structure for it to be a complete valid library. I recommend searching for "TOML vs JSON".
The most important thing might be the usage. I see TOML files here and there now, and would be a nice addition. But then you also have YAML

Re: TOML
Posted: Sun Dec 25, 2022 7:12 pm
by infratec
On my search toml vs. json vs. yaml I found also this:
https://hitchdev.com/strictyaml/why-not/toml/
And many of the comparissons say that it is good that the order is not fixed.
But exactly this is
discouraged
by the author.
Re: TOML
Posted: Sun Dec 25, 2022 8:07 pm
by plouf
i also dont see any obvious advantage.
Since we already have Preference/XML/Json , there no need for further fragmentation is such a small issue (prefs files).
Re: TOML
Posted: Mon Dec 26, 2022 12:03 am
by infratec
Ups..
Tom totally forgot macOS:
Newline means LF (0x0A) or CRLF (0x0D 0x0A)
So if you edit a toml file with a native macOS Editor, you run into big problems.
Because there is still CR (0x0D) a NewLine.
Re: TOML
Posted: Mon Dec 26, 2022 10:57 am
by Joubarbe
Hmm... Ok, you've convinced me infratec

Re: TOML
Posted: Mon Dec 26, 2022 2:43 pm
by skywalk
To be honest, the availability of comments was the only interesting feature for me.
I have steadily dropped ini, prefs files from my apps and stuff everything into a sqlite.db. Way more flexible except human must use data browser to view/edit.
SQLite Browsers are many.
Re: TOML
Posted: Mon Dec 26, 2022 8:56 pm
by mk-soft
I have switched from INI files to XML files.