Should I look into using linked lists?

Hey guys I have a data structures question kinda. I am building an offline electron app that's using SQLite as the database. I am going to have 3 tables in my database. Each of these tables will hold 1000 items each at max. right now as things are I'm just fetching all the items and storing them in a typical array and printing them in a table. I'm working with TypeScript. My question is that should I look into implementing linked lists for speed and such? Sorry if this is a stupid question or if it doesn't make sense. I'm going to be learning linked lists and data structures in general soon so not fully sure of the advantages and such just yet.
8 Replies
cje
cje2y ago
JavaScript’s arrays ARE linked lists What is your specific performance problem? In TypeScript the only other data structures you really have access to are Objects, Maps, and Sets. If you want to build your own data structure that is more performant than these, you should probably consider a different language. But 1000 items isn’t a big deal most of the time as long as you’re not spreading a lot etc
maghfoor
maghfoor2y ago
Thanks for answering! I don't have a performance problem yet but the app I'm building is gonna be used by someone else in an event. I just didn't want the app to crash or something bad to happen because of having thousands of items in an array. Also I didn't know how arrays fundamentally are in JS. Thank you. Sounds like I have a lot of learning to do
cje
cje2y ago
Other data structures generally require MORE memory than an array. Their advantages are in searching, sorting, inserting, etc. If you’re worried about the amount of data, figure out a way to not need all of it at once, for example pagination. Or maybe you can cache something. There’s many different things you can do, depends on the situation.
maghfoor
maghfoor2y ago
Thanks that's very useful, I hadn't thought of any of that. Right now I was just fetching all the items from the database and displaying them in a table. Can I also ask how you knew how arrays fundamentally work in JS? Where can I read up on this is there any resource you recommend about learning stuff like this in general
cje
cje2y ago
I’m the wrong person to ask about this tbh. I’ve never read a programming book, I just Google around when I hit a wall
Kev
Kev2y ago
I'd look around at a JS engine like V8. The backing data type for arrays actually becomes a hashmap at certain sizes which blows my mind.
Kev
Kev2y ago
GitHub
v8/js-array.h at master · v8/v8
The official mirror of the V8 Git repository. Contribute to v8/v8 development by creating an account on GitHub.
maghfoor
maghfoor2y ago
still sounds like you know a lot haha thank you very much, this is gonna be a very useful read!
Want results from more Discord servers?
Add your server