TOML

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Joubarbe
Enthusiast
Enthusiast
Posts: 703
Joined: Wed Sep 18, 2013 11:54 am
Location: France

TOML

Post by Joubarbe »

https://toml.io/en/

As it seems to become a big player, PB should have its own implementation! :)
infratec
Always Here
Always Here
Posts: 7587
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: TOML

Post 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.
Last edited by infratec on Sun Dec 25, 2022 12:49 pm, edited 1 time in total.
Cyllceaux
Enthusiast
Enthusiast
Posts: 510
Joined: Mon Jun 23, 2014 1:18 pm

Re: TOML

Post 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
Joubarbe
Enthusiast
Enthusiast
Posts: 703
Joined: Wed Sep 18, 2013 11:54 am
Location: France

Re: TOML

Post 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 :D
infratec
Always Here
Always Here
Posts: 7587
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: TOML

Post 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.
plouf
Enthusiast
Enthusiast
Posts: 281
Joined: Fri Apr 25, 2003 6:35 pm
Location: Athens,Greece

Re: TOML

Post 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).
Christos
infratec
Always Here
Always Here
Posts: 7587
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: TOML

Post 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.
Joubarbe
Enthusiast
Enthusiast
Posts: 703
Joined: Wed Sep 18, 2013 11:54 am
Location: France

Re: TOML

Post by Joubarbe »

Hmm... Ok, you've convinced me infratec :)
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: TOML

Post 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.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
mk-soft
Always Here
Always Here
Posts: 6209
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: TOML

Post by mk-soft »

I have switched from INI files to XML files.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply