Author Topic: Database Code Challenge(s)  (Read 837 times)

Offline AIR

  • BASIC Developer
  • Posts: 504
Re: Database Code Challenge(s)
« Reply #60 on: November 22, 2018, 10:06:19 AM »
I'm curious to see what you mean.  I've attached a json version of the yaml data file I used....

Here is some demo code to read JSON file into map and display the content on screen...


Thanks, jalih, that's real interesting.

Does 8th support maintaining the order of the data when you output it?


Offline jalih

  • Contributor
  • Posts: 14
Re: Database Code Challenge(s)
« Reply #61 on: November 22, 2018, 11:01:40 AM »
Does 8th support maintaining the order of the data when you output it?

8th seems to store the data in different order, so iterating map directly changes order of the data outputted. I guess I would need to iterate the map keys in correct order myself.

Offline John

  • Forum Support / SB Dev
  • Posts: 2339
    • ScriptBasic Open Source Project
Re: Database Code Challenge(s)
« Reply #62 on: November 22, 2018, 11:18:14 AM »
Maybe a future code challenge could be a JSON parser.

Offline AIR

  • BASIC Developer
  • Posts: 504
Re: Database Code Challenge(s)
« Reply #63 on: November 22, 2018, 12:20:15 PM »
Does 8th support maintaining the order of the data when you output it?

8th seems to store the data in different order, so iterating map directly changes order of the data outputted. I guess I would need to iterate the map keys in correct order myself.

Most hash/map implementations don't maintain order, for efficiency.  In Python, for example, the Dict object doesn't maintain order. But the OrderedDict does while being less efficient. Other languages offer this option, but not all.

Offline John

  • Forum Support / SB Dev
  • Posts: 2339
    • ScriptBasic Open Source Project
Re: Database Code Challenge(s)
« Reply #64 on: November 22, 2018, 12:27:35 PM »
Associative arrays seems the only way I know of taming these hash lists.

Offline AIR

  • BASIC Developer
  • Posts: 504
Re: Database Code Challenge(s)
« Reply #65 on: November 22, 2018, 01:28:10 PM »
Associative arrays seems the only way I know of taming these hash lists.

Same thing, different names.  The question is does it maintain order, or do you have to handle that programatically?

Offline John

  • Forum Support / SB Dev
  • Posts: 2339
    • ScriptBasic Open Source Project
Re: Database Code Challenge(s)
« Reply #66 on: November 22, 2018, 01:48:51 PM »
In SB it's about creating freeform structures that can contain any of the data types SB supports. LBOUND/UBOUND are key functions to keep it all together.

No matter how complex your array structure gets, you can iterate though it using standard indexing methods.

Arrays in ScriptBasic

« Last Edit: November 22, 2018, 02:55:23 PM by John »

Offline AIR

  • BASIC Developer
  • Posts: 504
Re: Database Code Challenge(s)
« Reply #67 on: November 22, 2018, 02:59:31 PM »
In SB it's about creating freeform structures that can contain any of the data types SB supports. LBOUND/UBOUND are key functions to keep it all together.

No matter how complex your array structure gets, you can iterate though it using standard indexing methods.


So....you have to handle maintaining the original structure programmatically.  There's nothing bad about that, why not just say that instead of the marketing pitch?

Anyway, we've derailed the original topic enough...


Offline John

  • Forum Support / SB Dev
  • Posts: 2339
    • ScriptBasic Open Source Project
Re: Database Code Challenge(s)
« Reply #68 on: November 22, 2018, 03:07:06 PM »
Quote
Anyway, we've derailed the original topic enough

Just chatting at the water cooler waiting for Alysson to return. I see this challenge as extended. How about you getting us going on something else to keep things moving?

There are no sales pitching with open source. It's called advocating for the project.
« Last Edit: November 22, 2018, 04:05:09 PM by John »

Offline AIR

  • BASIC Developer
  • Posts: 504
Re: Database Code Challenge(s)
« Reply #69 on: November 22, 2018, 05:33:54 PM »
How about you getting us going on something else to keep things moving?


I think your json suggestion could work.  With the stipulation that it be done in native code (meaning no external libs, AND if the language you use already has support for it you don't that capability and instead roll your own).  Otherwise it's not much of a challenge.

Offline John

  • Forum Support / SB Dev
  • Posts: 2339
    • ScriptBasic Open Source Project
Re: Database Code Challenge(s)
« Reply #70 on: November 22, 2018, 06:16:14 PM »
Sounds great!

I didn't use SB LIKE for the challenge EXTRACT. SB needs an easy to use JSON function.

http://www.json.org

Would rewriting the jsmn library in C BASIC count?  :)

Please kick off the new challenge thread when you have time.
« Last Edit: November 22, 2018, 06:31:59 PM by John »

Offline AlyssonR

  • Advocate
  • Posts: 126
Re: Database Code Challenge(s)
« Reply #71 on: December 23, 2018, 01:14:26 AM »
Hi all,

I've taken a quick peek at the thread - and it looks like everyone's been having fun with it.

I've been on extended domestic maintenance (i.e. fixing stuff around the house AND fixing myself), and will likely only look in on occasion for a while more :( The trouble is that I have far too much on the go right now with harware, software AND hard/software projects simmering as well as trying to keep abreast of everything that needs fixing around the house.

Offline John

  • Forum Support / SB Dev
  • Posts: 2339
    • ScriptBasic Open Source Project
Re: Database Code Challenge(s)
« Reply #72 on: December 23, 2018, 12:22:48 PM »
You sound busier than Santa's elves.  :)