Would global variables and global scripts be supported in the new VM, I’m not sure what is meant by “the optimization aren’t really present yet”
Please explain what you mean. Global variables should be fine but what do you mean by global scripts? When he says the optimizations aren’t present yet he means they aren’t implemented.
Will it be implemented or is that unknown currently?
Yes it will be eventually but most likely not until the release
Type annotations, what exactly is this suppose to mean?
It’s referring to the future release of statically typed Lua. You can read about what statically typed means here but the TL;DR is that it’ll let you specify a type that variables can hold and that functions will return. This helps debug large projects.
The interesting part is that they always said they didn’t want to change Lua’s specification to keep it compatible with other IDEs. I guess that isn’t the case anymore?
Looks to be that way. I’m excited because it may mean more flexibility in the future with regards to additions and changes.
True, and I hope they keep making updates regarding that. Lua on its own is a great language for development, but it is very limited in features on its own so the critical parts should always be done in C or whatever it was implemented in.
Would also be nice if we had a JIT (I know iOS doesn’t support it, but that’s not a reason not to speed up PCs and Androids).
So if they did the type annotations update would that mean we’d have to change up our scripts to make it compatible or would it all work as it does now?
The type annotations is a feature already in the works, and it is designated for release this quarter according to the Roblox roadmap. In short, everything will work as it does now.
Type annotations simply allow developers to specify the type of variables and function parameters. These annotations are designed to help developers avoid errors when dealing with data types. It also makes readability and future maintenance by other developers much easier. However, using type annotations is not mandatory which is why your current scripts will work fine.
Ariggt i just got confused when @nooneisback said, “The interesting part is that they always said they didn’t want to change Lua’s specification to keep it compatible with other IDEs. I guess that isn’t the case anymore?“ then again I could be misunderstanding.
Special VM instructions are generated for for i, v in pairs(t) do
and for i, v in ipairs(t) do
syntax that perform the iteration directly in the VM and remove the overhead of executing a function every iteration. Would explain the performance increase
It’d also be nice if iterating through vector components was optimized (or maybe more aggressive for loop unrolling):
local vec=Vector3.new(math.random()*math.random(),math.random()*math.random(),math.random()*math.random())
local s=tick()
for _=1,1e5 do
for i=1,3 do
local axis=i==1 and vec.X or i==2 and vec.Y or vec.Z
end
end
print(tick()-s)
local s=tick()
for _=1,1e5 do
do
local axis=vec.X
end
do
local axis=vec.Y
end
do
local axis=vec.Z
end
end
print(tick()-s)
I get:
0.010617256164551
0.0067298412322998
Call me old fashioned but I consider being able to index a userdata 300,000 times in 6ms to be sufficiently optimized.
Well I guess I am asking to make the first one (300,000 indexes in 10ms) as fast as the second (300,000 in 6ms)
But for some reason now that I think about it I can’t help feeling even the second is slow hmm
You’re doing several extra operations in the first one. I don’t know you would expect it to be as fast as the second, and I don’t really know what could be done to optimize it on Roblox’s end.
I was hoping it’d be unrolled into something similar to the second
This seems very niche and the code/behavior of the loops wouldn’t even be similar if they were unrolled. In the first you have 1 variable vs 3 in the second. What would happen if you then did something like print(axis)
? By your example it should print just one of them, but looking at the unrolled version you made it looks like you want to print all 3.
It should print each axis 100,000 times (the first example has a nested for loop)
The example I gave was bad, but I think for loop unrolling (not when solely iterating through vector components e.e, I shouldn’t have said that) would be cool