Data Structures

Before you say we can just make our own data structures, I would like to say that in no way will they be as efficient as if ROBLOX made them. We only have access to the most primitive arrays, meaning no pointers or anything.

I’m not sure if this is possible, but the most ideal solution would be if ROBLOX used C++ interop to make ultra efficient data structures. If this isn’t possible, (I don’t really know how it works so yea XD), then they could do something with Lua pointers. They do exist!!! Source: https://stackoverflow.com/questions/8430976/is-there-anything-like-pointers-in-lua

I would really like to see the C++ STL structures such as (most importantly in my opinion) sets, queues, stacks, and BSTs.

Ultimately I think that they should preserve the current arrays and dictionaries, but make some sort of STL for new ones. It could be something like:

local compareFunction(a,b)
     return a < b
end

local autoSort = STL.new("set",compareFunction)
autoSort.insert(5)
autoSort.insert(3)
autoSort.insert(7)

for _,v in next, autoSort do
    print(v)
end

RESULT:
> 3
> 5
> 7

Obviously this is in no way should be the exact implementation, I’m just giving an example of how it might be done without ruining the existing infrastructure.

1 Like

Roblox has been pretty pure in its implementation of Lua. Most additions to the Lua library have been in regards to the Roblox engine. I’m not entirely sure what Roblox’s philosophy would be on adding this kind of stuff, but for data structures I don’t think Roblox would want to add anything beyond what Lua itself has to offer.

Generally Lua isn’t the language to use when you’re wanting to intensely deal with data structures.

2 Likes

Hi Acreol (and anyone who may make a similar feature requests in the future),

C++ is definitely faster, but the difference is negligible if we’re not experiencing performance issues to begin with. When suggesting performance-related changes for ROBLOX, please provide use cases where you haven’t been able to do something because the default toolset you were provided was too slow. Other users may suggest better algorithms that can accomplish your goal, but if there is no good alternative and you’ve provided a repro file that demonstrates the problem, then the ROBLOX engineers will be able to look into providing more performant alternatives.

7 Likes

I guess that’s a good point. I can’t really think of anything right now, but if I do I’ll try to post a repro and exact use case.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.