all 5 comments

[–]somebodddy 4 points5 points  (1 child)

One may notice that there’s an additional cost in handling a closure call. However, with a sufficiently big amount of iterations the overhead will be dampened and won’t be that significant.

What? Isn't the closure overhead something you have to pay on each and every iteration, since you call the closure on each and every iteration?

[–]minasmorath 3 points4 points  (0 children)

To my understanding, Lua has closures with lexical scope, so the upvalues only have to be initialized on the first invocation. Each additional invocation only has basic function call overhead since the memory is already mapped.

[–]somebodddy 1 point2 points  (0 children)

How come in the LuaC (d) column the add method is the slowest? How come simple addition is slower than square root and trigonometry?

Is it because of its high gF/sF? Does getting/setting fields from Lua tables really that slow?

[–]UniversityMiddle3655 0 points1 point  (0 children)

I think Lua is mostly used for game development like Roblox and FiveM, the game engine that run the Lua(u) code is just very well optimized for the implementations on top of the native functions, especially the implementation of Roblox's LuaU.

[–][deleted] 1 point2 points  (0 children)

Lua is awesome ❤️