easy ≠ simple easy ≠ simplePerhaps the road block that you've run into is because you've been treating it as just a scripting language.
There's also the venerable MoonScript: https://moonscript.org/
And YueScript, a personal fave: https://yuescript.org/doc/
A whole list: https://github.com/hengestone/lua-languages
When you're doing stuff in nvim or HammerSpoon, you're dealing with someone else's interface and the decisions that they've made.
> I find Lua simple
The comment you've replied to is correct: "easy ≠ simple". Lua is indeed simple, but it chooses simplicity over ease-of-use. For example, even printing the contents of a table requires explicit logic.
OTOH Python, for example, prioritises ease-of-use: `l = [1, 2, 3]; print(l)` does what you'd expect. But Python only achieves this ease at the expense of simplicity: not only does the implementation of `print` need to be more complex, its output can be complex and unpredictable as well - for example, in the case where `l` refers to itself.
Of course it has its warts, but given the topic, almost everything is better than a vimscript imho.
0-indexing makes sense in the context of C where the index operator is syntactic sugar for pointer arithmetic. In higher-level languages like C# and Python and others, it's pretty much just a leftover habit from C devs that we all got used to.
Global by default is a perpetual issue, agreed.
for i=1,#arr do
foo(arr[i])
end
I don't feel that strongly for or against either way of indexing though, they both have their pros and cons. for (0..$#arr) {
foo(arr[$_])
}
Whatever you're feeling is not in starting at one.The left handed scissors are only a difference from what you're used to.
> Lua was made by mathematicians
The default value is nil and using nil as an index on a table returns nil. Yet nil + number is not valid and results in a runtime error.
> it's pretty much just a leftover habit from C devs
It's reflective of the fact that these languages are either intended to work with C APIs or are implemented in C itself. This makes writing FFI and extensions _far_ easier than it would be otherwise.
In fact, at least for this application I've come to enjoy its practicality!
https://andregarzia.com/2021/01/lua-a-misunderstood-language...
I like 1 based indexes and the globals don't hurt me on my projects. It is like JS, it has its own bits that are different than other languages, once you learn them you see that it is mostly fine.