Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

2 dynamic language myths

Name: Anonymous 2012-06-03 18:07

the 2 biggest myths I see all the timethat get spouted by noobs are that:
1) JIT makes huge speed gains in VM languages
2) a VM language will run as fast as C if its compiled to machine language

This is simply not true, Lua's JIT does not make any significant speed gains. Python's compile-to-platform implementations are not much faster than fast VM languages like Lua

Name: Anonymous 2012-06-03 18:53

>>1
fagburst@x:~/Desktop$ cat prop.lua
local data = { properties = { test = { } } }
function data.properties.test.get (value) return value * 8 end
function data.properties.test.set (newvalue) return newvalue / 3 end

local objectmt = { }
function objectmt:__index (key)
    local prop = data.properties[key]
    if prop then
        return prop.get(data[key])
    end
    error("idk what `" .. tostring(key) .. "' is", 2)
end
function objectmt:__newindex (key, value)
    local prop = data.properties[key]
    if prop then
        data[key] = prop.set(value)
        return
    end
    error("idk what `" .. tostring(key) .. "' is or why i should set it to: " .. tostring(value), 2)
end

local object = setmetatable({ }, objectmt)

-----
local b = 0
for i = 1, tonumber(arg[1]) or 60 do
    object.test = i
    b = b + object.test
end
print(b)

fagburst@x:~/Desktop$ time lua prop.lua 1e7
1.3333334666667e+14

real    0m4.104s
user    0m4.092s
sys    0m0.008s
fagburst@x:~/Desktop$ time luajit prop.lua 1e7
1.3333334666667e+14

real    0m0.099s
user    0m0.092s
sys    0m0.004s

nigger i don't care if this is slower than C but i think it's slightly faster at least

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List