Re:MoonScript, a programmer friendly language that compiles ...
by rweichler on Tuesday May 30, 2017 @06:28AM
(#14444215)
Idk. Still not sold. You can do list comprehensions in regular Lua with something like this:
And then, your Lua code would be like:
Which would be the equivalent to this in MoonScript:
I dunno. Just seems like a wash to me. And then you think about the extra compile step to run MoonScript, and the potential performance hits, and I'm just turned off completely from it.
[ Parent
| on HN ]
Re:MoonScript, a programmer friendly language that compiles ...
by shalabhc on Tuesday May 30, 2017 @06:48AM
(#14444303)
There are no potential performance hits. In particular the code generated for list comprehensions would be faster than your example because there is no extra function call per item.
Re:MoonScript, a programmer friendly language that compiles ...
by anonymoushn on Tuesday May 30, 2017 @06:47AM
(#14444298)
Over here it generated
local b
do
local _accum_0 = { }
local _len_0 = 1
for k, v in pairs({
1,
2,
3,
4
}) do
_accum_0[_len_0] = v * 2
_len_0 = _len_0 + 1
end
b = _accum_0
end
It did a pretty good job. Unlike your code, it doesn't have any function calls, and unlike the code I would probably write, it doesn't use the # operator.