Fields vs Dictionary vs JSON

232 views
Skip to first unread message

Ed Heil

unread,
Jun 10, 2021, 1:10:53 PM6/10/21
to TiddlyWiki
Right now I'm working on a project where a number of tiddlers are just little chunks of key-value data.  I'm putting them in JSONTiddlers, because that seems to be what tiddlers turn into naturally when I start setting data on their indices. 

I just noticed that there's a nice thing available for tiddlers which are collections of *fields* as opposed to using indices, and that's:

[field:foo<bar>] which gives you all the tiddlers whose foo field is equal to the value of the variable "bar".  There's not a simple equivalent with indices as far as I know, you have to cobble together a filter with [filter[]] or the new :filter prefix.

Obviously with fields you're more limited in the names of keys -- keys can be any string in data tiddlers, but only lowercase, "-", "_", and "." for fields. And obviously there are reserved names for fields, like "text", that are not reserved for data tiddlers. 

I *think* I made the right choice going with a data tiddler for my little blobs of data, but that nice [field[]] filter operator made me wonder.

Just wanted to throw the question open to the community:  If you've used tiddlers as blobs of key-value data, and made the choice between using the fields in a normal tiddler, and using a data tiddler, what considerations factored into your decision?  Do you have any rules of thumb?

I'm not asking because of a particular decision I need to make, I'm more curious about the general question.

(Oh, secondarily: any reason to choose one or the other of Dictionary vs JSON?  They seem to do pretty much the same job to me.)

Thanks!

Mohammad Rahmani

unread,
Jun 10, 2021, 3:22:45 PM6/10/21
to tiddl...@googlegroups.com
Ed,
 I myself love JSON and dictionary tiddlers as they are very handy, compact and encapsulate things in one pack!
On the other hand, it seems Jeremy supports using fields as first class citizens in Tiddlywiki!
Also, it seems TW  5.2.0 is coming  soon and it supports field names with almost all characters! So the restrictions on field names will be lifted!


This is my 2 cents! But, let the developers come and advise!



Best wishes
Mohammad


--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/d7c6875b-8edd-40e8-9a3a-e07dea33c4f1n%40googlegroups.com.

TiddlyTweeter

unread,
Jun 10, 2021, 5:25:10 PM6/10/21
to TiddlyWiki
Ciao Ed. 

VERY interesting post. In fact I stopped watching a movie on the phone to go to Desktop to reply since Goggle Groups on phone is the Pits.

Briefly. IF your data need is merely BINARY (just index: value) then data dictionaries ARE really ACE. 
IF you need anything more than that then, yes, there would be no benefit in a dictionary. 
(and FYI JSON structures are actually more difficult to manually edit than simple flat plain text dictionaries).

The POINT is: ARE you BINARY in need? 
IF SO then simple dictionaries will work well. 
IF NOT, you need  more fields than one under one index, regular tiddlers will work MUCH better.

Just an opinion
My 7 Cents
TT

PMario

unread,
Jun 11, 2021, 2:42:12 AM6/11/21
to TiddlyWiki
Hi Ed,

There are some usecases for data-tiddlers. Eg:

 - If you want to log some actions. So if you have "timeline-like" data
 - Configuration tiddlers
 - Functions, where it is important to keep values together

The biggest disadvantage for data-tiddlers is, that if you add / change or remove a value from a data-tiddler all visible tiddlers that have a connection to this tiddler need to be updated, even if the index, that is changed doesn't correspond to those tiddlers. .. So there is a potential for a performance hit, if it's done wrong.

This said. I did create a plugin https://wikilabs.github.io/editions/keyvalues/ that may allow you a more flexible access of keys and values at the same time.
Using it myself, I did realize, that there is still some room for improvement. So feedback is very welcome here _or_ at: https://github.com/wikilabs/plugins/issues

have fun!

-mario

Ed Heil

unread,
Jun 11, 2021, 8:56:15 AM6/11/21
to TiddlyWiki
This has been a very informative thread, folks -- always enjoy hearing about big picture decisions in TW.

On Friday, June 11, 2021 at 2:42:12 AM UTC-4 PMario wrote:

The biggest disadvantage for data-tiddlers is, that if you add / change or remove a value from a data-tiddler all visible tiddlers that have a connection to this tiddler need to be updated, even if the index, that is changed doesn't correspond to those tiddlers. .. So there is a potential for a performance hit, if it's done wrong.


Ok, this is potentially huge.  I've got a very large template which displays and manipulates the data from a data tiddler in complex ways, and I'm running this on Bob, so responsiveness is a big deal.  If I can get a speed bonus by going with fields...  that means a lot.

TiddlyTweeter

unread,
Jun 11, 2021, 12:39:10 PM6/11/21
to TiddlyWiki
Your tool looks interesting ... https://wikilabs.github.io/editions/keyvalues/

I have no idea whether it MIGHT cope with ,.,.

      MY INDEX ; value field one : value field two : value field three

COULD it?

Just asking for a friend with databaseitis

tt

PMario

unread,
Jun 11, 2021, 2:30:37 PM6/11/21
to TiddlyWiki
On Friday, June 11, 2021 at 2:56:15 PM UTC+2 Ed Heil wrote:
...
Ok, this is potentially huge.  I've got a very large template which displays and manipulates the data from a data tiddler in complex ways, and I'm running this on Bob, so responsiveness is a big deal.  If I can get a speed bonus by going with fields...  that means a lot.

If it's only 1 template with 1 open tiddler, there won't be a big difference. .. BUT if there are a lot of visible elements that depend on data from the data-tiddler it does matter. .. So as long as it is only a view visible elements you are good.

-mario

PMario

unread,
Jun 11, 2021, 2:34:58 PM6/11/21
to TiddlyWiki
On Friday, June 11, 2021 at 6:39:10 PM UTC+2 TiddlyTweeter wrote:
Your tool looks interesting ... https://wikilabs.github.io/editions/keyvalues/

I have no idea whether it MIGHT cope with ,.,.

      MY INDEX ; value field one : value field two : value field three

COULD it?

I think that's not possible with data tidders. You always have exactly 1 index (key) and 1 value.
So you'd have to "print" the index and then you can print the values, BUT only if the index is a counter.

Otherwise there will be a relation between the key and the value. So a list as you describe it doesn't make too much sense, if you loose the "relation".

Hope that helps. I'm not 100% sure if I do understand the question right.

-mario

Ed Heil

unread,
Jun 11, 2021, 5:15:30 PM6/11/21
to TiddlyWiki

It's a template that does a lot of calculation based on the elements of that data tiddler... and which has edit fields for parts of the data tiddler.  I've observed that using the data tiddler *with bob* there seem to be issues with the back end "keeping up with" people typing in edit fields, keystroke by keystroke.  Switching to regular fields in a regular tiddler as a data store seems like it may have fixed this (fingers crossed!)
Reply all
Reply to author
Forward
0 new messages