TL;DR: Which one has better performance? Lua or JavaScript? (test scripts I used can be seen below)
====================================================
So, I am scripting in Lua, but someone suggested that Lua runs slower than JavaScript.
Now, obviously I wanted to make some research about this, but I found nothing on the internet / forums, so I created two scripts, one in Lua, one in JavaScript and I made them identical (as much as the languages allowed it), but both scripts achieve the same results.
After running both codes after each other, the results were interesting.
Picture of the results:
As you can see, JavaScript was significantly slower.
.js script:
RegisterCommand("jsC", () => {
let counter = 0;
let startTime = GetNetworkTimeAccurate();
console.log(`startTime: ${startTime}`);
for (let j = 0; j <= 100; j++) {
for (let i = 0; i <= 10000; i++) {
let playerPed = PlayerPedId();
let [playerX, playerY, playerZ] = GetEntityCoords(playerPed);
let vdist = Vdist(playerX, playerY, playerZ, 0, 0, 0);
if (!playerPed)
counter = 0;
if (vdist > 0)
counter++;
}
}
console.log(`counter: ${counter}`);
let endTime = GetNetworkTimeAccurate();
console.log(`endTime: ${endTime}`);
console.log(`runTime: ${endTime - startTime} ms.`);
})
.lua script:
RegisterCommand("luaC", function()
local counter = 0
local startTime = GetNetworkTimeAccurate()
print("startTime: " .. startTime)
for j = 0, 100 do
for i = 0, 10000 do
local playerPed = PlayerPedId()
local pos = GetEntityCoords(playerPed)
local vdist = Vdist(pos, vector3(0, 0, 0))
if not playerPed then
counter = 0
end
if vdist > 1 then
counter = counter + 1
end
end
end
print("counter: " .. counter)
local endTime = GetNetworkTimeAccurate()
print("endTime: " .. endTime)
print("runtime: " .. (endTime - startTime) .. " ms.")
end)
I ran these commands multiple times, after each other, the same command 10 times, but the results were the same.
Is there anything I did wrong, or my results are correct? (So JavaScript is that much slower?)

