Recent

Author Topic: Best data structure to use?  (Read 13022 times)

rwebb616

  • Full Member
  • ***
  • Posts: 133
Re: Best data structure to use?
« Reply #60 on: March 23, 2021, 03:26:13 pm »
I have to admit that I'm ignorant of the bitbucket interface. I don't know what capabilities it has.

It's very similar to github - it works with git.

Quote
It also would be private, hence only visible to us both and not to this community at large, but in the end it is your code and U da boss :)

There is a way to make the repo public but I'm not sure I would want to host that on my meager 3Mbps internet connection :) 

Quote
At the moment I think the peeps behind GitHub have a very nice UI and, I can be biased here, it's a very good UX (while @wp may disagree :) ) and I would prefer it. And it does have private repos for free!!
But again, ultimately it's your code, so U da boss'man :)

So are you saying that if you want a public repo on GitHub you have to pay for an account?  I will have to read more about it. I still think it's a great idea to put this up somewhere - and I think you're right a team account for non-profit is free .. up to 2 developers based on what I read last night.

rwebb616

  • Full Member
  • ***
  • Posts: 133
Re: Best data structure to use?
« Reply #61 on: March 23, 2021, 03:28:07 pm »

This might come as a surprise, since I've been so vocal on the JSON thing I made, but I just hit me after I had a look, again, at the OP's first post: Why did SQLite get the boot??

@Rich: To be quite honest, SQLite would conform to all 5 of your initial needs, so why did SQLite get the boot?
I hope it wasn't me being a pestering loud mouth, that would shame me to death!!!

No - just didn't want to have to install a client library or make someone using the program do so.. I suppose one could build an installer that takes care of it but anyway that was the rationale behind it.


Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1119
  • Professional amateur ;-P
Re: Best data structure to use?
« Reply #62 on: March 23, 2021, 10:41:06 pm »
Hey Rich,

I was wanting to keep it into a single "portable" executable so nothing needs to be installed on the pc.

Let me clarify things in regards to SQLite. When you choose a SQLite implementation there are, at least, 3 scenarios:
  • Include the *.dll with the distribution package.
    In this case you bundle your binary with the correct architecture of the *.dll, so a 32b binary with the 32 bit library, etc all inside a nice *.zip / *.tar.gz
  • At least in Linux, I'm not sure in Windows, you can always engorge the binary a bit and add the library statically.
  • Here on the forum I've seen mentioned native ObjectPascal code that suppresses the need for any library.
    I think it's TSQLite2Connection, but I'm lazy and I haven't search for it on either the SVN source or OPM, or even Google for that matter.

So, as you can see, in none of those options is there any need to install anything, since SQLite is a local database(in a single file) with no server.

Cheers,
Gus
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

MarkMLl

  • Hero Member
  • *****
  • Posts: 6682
Re: Best data structure to use?
« Reply #63 on: March 23, 2021, 10:45:02 pm »
No - just didn't want to have to install a client library or make someone using the program do so.. I suppose one could build an installer that takes care of it but anyway that was the rationale behind it.

But you're going to need to install an access library for any database.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1119
  • Professional amateur ;-P
Re: Best data structure to use?
« Reply #64 on: March 23, 2021, 10:47:01 pm »
Hey Rich,

It's very similar to github - it works with git.

You know what? I just went to bitbucket and realized I already have an account there, MAAAAN is my memory shot to all hell!!

There is a way to make the repo public but I'm not sure I would want to host that on my meager 3Mbps internet connection :) 

Yeah, you're right, this should never be an option.

So are you saying that if you want a public repo on GitHub you have to pay for an account?  I will have to read more about it. I still think it's a great idea to put this up somewhere - and I think you're right a team account for non-profit is free .. up to 2 developers based on what I read last night.

Absolutely not, GitHub is free to sign in and when I mention that now you have free private repos, is because when they started, free accounts did not have private repos.
Since GitLab, their direct competition, added private repos to their free accounts, they kinda had to get along :)

So, since you did have a gander at GitHub's free Organization offer, whet do you think we make it official?
You have my GitHub Profile link on my sig ;)

Cheers,
Gus
« Last Edit: March 23, 2021, 10:50:10 pm by gcarreno »
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1119
  • Professional amateur ;-P
Re: Best data structure to use?
« Reply #65 on: March 23, 2021, 10:51:48 pm »
Hey Rich,

No - just didn't want to have to install a client library or make someone using the program do so.. I suppose one could build an installer that takes care of it but anyway that was the rationale behind it.

I think I've answered your concerns on this post.

Cheers,
Gus
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1119
  • Professional amateur ;-P
Re: Best data structure to use?
« Reply #66 on: March 23, 2021, 11:05:56 pm »
Hey avk,

I don't understand why you don't want to use database.
With SQLite you need one file along your executable.
I guess it's just @gcarreno hasn't gotten to the DB components yet.

And I won't get there. My knowledge of Lazarus is not that extensive that I can dive into the Connection/Dataset/Field web.
I honestly can say that I know some stuff about Lazarus/FPC but not to the point I can dish out database components.
I also have to admit that I did, once, try to look at the database realm of code and had to step out due to a head ache. Sorry, I was a coward!!

I'll try to explain why I liked @gcarreno's idea of ​​using JSON.

You like it? Awww, thanks man, quite appreciate it!!

Code: Javascript  [Select][+][-]
  1. {
  2.   "categories":
  3.   {
  4.     "category1":
  5.     {
  6.       "word1": {"played": false, "play date": <UnixTime>},
  7.       "word2": {"played": false, "play date": <UnixTime>},
  8.       ...
  9.     }
  10.     "category2":
  11.     {
  12.       .....
  13.     }
  14.     ...
  15.   }
  16. }
  17.  


I see you're still insisting on having Category names as object names. I still agree that's a good unique index thing, but....
What if the OP needs to attach some fields to the Category object? Major rewrite, non? N'est-ce pas?

The resulting file is ~ 43MB in size, TJSONObject parses it in about 2 seconds on my old machine. If necessary, you can find a faster parser.

So I think the idea is quite good.

Amazing, only 43MB!! My math was a bit off then, I'm glad!!

Cheers,
Gus
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

rwebb616

  • Full Member
  • ***
  • Posts: 133
Re: Best data structure to use?
« Reply #67 on: March 24, 2021, 03:24:15 am »
But you're going to need to install an access library for any database.

Not if I store it with JSON as Gus has described (and programmed - thanks Gus!) .  I originally started sniffing down the path of statically linking in the client library for SQLite but that seemed like too much hunting to figure that out and so with there being so many ways to skin a cat I decided to post on the forum to see what everyone else thought. 

So far I like Gus's solution and also I want to check into TBufDataset and TCSVDataset.  I read a little on TBUFDataset and it sounds very good. 

Rich

rwebb616

  • Full Member
  • ***
  • Posts: 133
Re: Best data structure to use?
« Reply #68 on: March 24, 2021, 03:27:28 am »
Quote
So, since you did have a gander at GitHub's free Organization offer, whet do you think we make it official?
You have my GitHub Profile link on my sig ;)

I want to talk with you a little bit about this off the forums - I sent you an email - just fire back when you get it and we can start a conversation there. 
Rich

avk

  • Hero Member
  • *****
  • Posts: 752
Re: Best data structure to use?
« Reply #69 on: March 24, 2021, 05:52:04 am »
...
What if the OP needs to attach some fields to the Category object? Major rewrite, non? N'est-ce pas?
...

It's just JSON, N'est-ce pas?

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1119
  • Professional amateur ;-P
Re: Best data structure to use?
« Reply #70 on: March 24, 2021, 06:17:48 am »
Hi avk,

It's just JSON, N'est-ce pas?

Oui, oui ç'est vrais mais... I'm discarding all the TJSONData structure and un-marshalling it to my own objects, hence me saying that it would be a major rewrite of my object structure.

But yeah, if you're only messing about with the TJSONData structure, then yeah, ç'est vraiment jusque du JSON!

Cheers,
Gus

PS: I'm sorry if I seem to be bragging with my French, but I spent 4.5 year (6.5 yo to 11 yo) in Canada/Quebec and I picked up 2 more languages apart from my native Portuguese: English and French.
It's was a "right place, right time" kinda thing :)
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

dbannon

  • Hero Member
  • *****
  • Posts: 2791
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Best data structure to use?
« Reply #71 on: March 24, 2021, 10:18:39 am »
While I understand that this thread has moved on (to J stuff !)  I took on board rwebb's comment about reading how TList works from my code.  So, far, far more readable, I have added a page to the wiki https://wiki.freepascal.org/TList
(quite surprised there was not one there already )


https://github.com/tomboy-notes/tomboy-ng/blob/master/source/note_lister.pas

I will need to read up on pointers - I understand how a pointer works as in passing a variable by reference but the ^ and @ syntax is new to me.  I must say I got a little overwhelmed with the 1500 lines of code in your note lister.....


Is that entire notes application written in Pascal?  Seems that I saw a version that had .cs files (c#?)
100% pascal (apart from some build scripts), the origional Tomboy was C#, very difficult to build theses days ....

Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

avk

  • Hero Member
  • *****
  • Posts: 752
Re: Best data structure to use?
« Reply #72 on: March 24, 2021, 11:42:37 am »
While I understand that this thread has moved on (to J stuff !)... 

Although the name "JSON" contains "js", it is nevertheless just a language independent text format for exchanging and storing hierarchical data. Something like XML, only simpler.

dbannon

  • Hero Member
  • *****
  • Posts: 2791
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Best data structure to use?
« Reply #73 on: March 24, 2021, 12:29:47 pm »
Although the name "JSON" contains "js", it is nevertheless just a language independent text format for exchanging and storing hierarchical data. Something like XML, only simpler.

Err, sure, I use JSON myself for comms on the Interweb thing. And the FPC json object is nice to steam, its all cool ! I don't have a problem with it ....

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018