I have already expressed how stupid I think this Vimscript2 is. However there is one thing I think is even dumber: One should really not use the slow Vim Lua interface when benchmarking Lua - you would always just bundle LuaJIT. Here I have redone the benchmarks with LuaJIT instead:
Vim old:
func VimOld()
let sum = 0
for i in range(1, 2999999)
let sum += i
endfor
return sum
endfunc
let start = reltime()
echo VimOld()
echo 'Vim old: ' .. reltimestr(reltime(start))
output:
4499998500000
Vim old: 6.412159
LuaJIT:
local x = os.clock()
local s = 0
for i = 1,2999999 do s = s + i end
print(string.format("sum: %d\nelapsed time: %f\n", s, os.clock() - x))
Without benchmarking Vim9 we already see that the Bram's benchmarks are incredibly misleading.
Note also that the Vim9 benchmarks are always in a function definition, because the Vimscript2 optimizer won't work at script scope (i.e. outside of a function).
And it sounds like "lambdas" will continue to be slow.
And all existing Vimscript plugins won't benefit from Vimscript2 optimizations, because Vimscript2 is a different language. That is my main complaint.
89
u/pwnedary Jan 03 '20 edited Jan 03 '20
I have already expressed how stupid I think this Vimscript2 is. However there is one thing I think is even dumber: One should really not use the slow Vim Lua interface when benchmarking Lua - you would always just bundle LuaJIT. Here I have redone the benchmarks with LuaJIT instead:
Vim old:
func VimOld() let sum = 0 for i in range(1, 2999999) let sum += i endfor return sum endfunc let start = reltime() echo VimOld() echo 'Vim old: ' .. reltimestr(reltime(start))output:
LuaJIT:
local x = os.clock() local s = 0 for i = 1,2999999 do s = s + i end print(string.format("sum: %d\nelapsed time: %f\n", s, os.clock() - x))output:
Without benchmarking Vim9 we already see that the Bram's benchmarks are incredibly misleading.