Do you have real-world (real-roblox?) data on how big of a performance gain this instantiates?
There are too many benefits to count, ranging from readability to performance to memory usage.
- It makes my code more difficult to configure if someone manages to steal a copy
- I can implement ifdefs, and remove debug-only code before publishing
- Simplified Lua results in less bytecode/debug data, and thus faster load times
- I can focus on writing readable code, instead of micro-optimizing every single one of my 1000 modulescripts
The magnitude of these benefits depend entirely on the Lua code being simplified.
Here’s a simple performance example:
Lua makes zero assumptions about your scripts environment. “math.pi” literally gets the “math” global, then the “pi” index. Hardcoding math.pi can be 10x more efficient:
local tick = tick
local t0, t1 = 0, 0
do
local v = 0
t0 = tick()
for i = 1, 1000000 do
v = v + math.pi
end
t1 = tick()
print("Performance1", (t1 - t0)*1000, "ms")
end
do
local v = 0
t0 = tick()
for i = 1, 1000000 do
v = v + 3.1415926535897932384626433832795
end
t1 = tick()
print("Performance2", (t1 - t0)*1000, "ms")
end
Just a few math.pi’s is insignificant, but when my game is over 100,000 lines of code, optimizing is worth it. My simplifier can make assumptions about a script’s environment, where lua can’t.
Here’s a simple memory usage example:
local collectgarbage = collectgarbage
local function GetMemoryUsage()
local kilobytes = collectgarbage("count")
local bytes = kilobytes * 1024
return bytes
end
local dataCount = 65536
do
local data = {}
for i = 1, dataCount do
data[i] = false
end
local someConstant = 123
local usage0, usage1 = 0, 0
usage0 = GetMemoryUsage()
for i = 1, dataCount do
data[i] = function()
return someConstant
end
end
usage1 = GetMemoryUsage()
print("Memory1", (usage1 - usage0)/dataCount, "bytes")
end
do
local data = {}
for i = 1, dataCount do
data[i] = false
end
local usage0, usage1 = 0, 0
usage0 = GetMemoryUsage()
for i = 1, dataCount do
data[i] = function()
return 123
end
end
usage1 = GetMemoryUsage()
print("Memory2", (usage1 - usage0)/dataCount, "bytes")
end
The hardcoded version results in 4 less bytes per closure (20 instead of 24). This is insignificant for a few functions, but these benefits definitely add up for large games.
Is this an attempt to redo Stravant’s Minify & Beautify Plugin?
If you need a potential tester/user, I do plan to use something for my plane system when I do sell it.
It’s an attempt to make my game more efficient and easy to develop long-term. It’s configurable and can make assumptions about all of the global utility stuff I put in _G, not just lua’s libraries. I also try to keep errors meaningful by not messing with line numbers or variable names too much. I might even add a way to describe variables using comments.
I’m too lazy to implement stuff I don’t use, so this:
print{}
results in: “Unexpected statement token {, line 1”
I’ve been working on this for a long time, so I think I’ll keep it to myself for now. If you want to see what it does to one of your scripts, feel free to send it to me.
fwiw, anything past 15 decimals doesn’t increase accuracy
I know, I just pasted it from the windows calculator.
Although that’s technically false in the case of: 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000049
Actually something that really bothers me is that none of lua’s tostring functions always return an equivalent string:
local v = 2.99999999999999
print(v, v == 3)
> 3 false
That’s insane. Will you release this in any shape or form?
Probably will once I’m satisfied with it .
Why the hell do you have 120,000 lines of code
See for yourself
That doesn’t answer my question
More screenshots from Holiday’s World!
Wheel of Fortune! (Coming Soon)
@Locard’s House!
You can try it out today, here! 🌎Holiday's World - Roblox
Checked the game out, is it influenced by Maplestory?
The game is influenced by many games such as MapleStory, MeepCity, Legend of Zelda, Poptropica, Wizard 101, and many other games. It’s putting a lot of my childhood games and favorite games into a fun-packed adventure!
I’ve been working on a Tapu Lele model today!
yes, this is all CSG
Better than moonwalking imo
Anyways the game is really cool but I didn’t see how it was anywhere near 120k lines. Sounds like a headache.
The style and animations are neat but I left after a bit since there wasn’t enough to keep me there, wasn’t too sure what the big objective was. Is it just a roleplay/social game?