Earlier quoted context omitted.
Roberto Ierusalimschy makes an interesting point on this in an interview[1] last year. > When we started Lua, the world was different, not everything was C-like. Java and JavaScript did not exist, Python was in an infancy and had a lower than 1.0 version. So there was not this thing when all the languages are supposed to be C-like. C was just one of many syntaxes around. > And the arrays were exactly the same. It’s v…
I'm confused. Lisp does 0-based indexing. Lisp predates C and C-like languages by decades.
I open sourced my game along with a tutorial on how to make it using Lua
61–70 of 96 posts
Re: I open sourced my game along with a tutorial on how to make it using Lua
#62Earlier quoted context omitted.
1-index kept throwing me off though
It’s unfortunate that Lua makes some strange decisions, but the powerful functionality totally outweighs the weirdness (metatables are especially cool). I really like Lua, especially for game programming with LÖVE.
Lua is a language for both hardcore C programmers and complete n00bs wanting to configure their C programs. In that context, position-based indexing makes much more sense, as it's how most non-programmers think.
Re: I open sourced my game along with a tutorial on how to make it using Lua
#63The author has some relevant blog posts (in GitHub issues) too: https://github.com/a327ex/blog/issues/35 - BYTEPATH Postmortem (2018) https://github.com/a327ex/blog/issues/44 - One Year Sales Data for BYTEPATH (2019)
Re: I open sourced my game along with a tutorial on how to make it using Lua
#64Earlier quoted context omitted.
Once you get used to it, it does help prevent a whole bunch of off by one errors though, as you don't need math when grabbing a range. Like a string will always be: s:sub(1, #s) And a sequence table will always be: for i = 1, #t do t[i] end
I disagree. Particularly when parsing strings, it's useful if the upper bound of one substring is the lower bound of a nonoverlapping substring immediately after. For example, here's a routine to split a string into the part before the first dot and the part after: function split_dot(s) local idx = s:find(".", 1, true) if not idx then return s end return s:sub(1,idx-1), s:sub(idx+1) end It may come as a surprise that…
On the contrary; unless you're very used to offset-indexing, it seems more natural to start at the next element for the next substring, or the 2nd next element when skipping one.
Re: I open sourced my game along with a tutorial on how to make it using Lua
#65Earlier quoted context omitted.
I disagree. Particularly when parsing strings, it's useful if the upper bound of one substring is the lower bound of a nonoverlapping substring immediately after. For example, here's a routine to split a string into the part before the first dot and the part after: function split_dot(s) local idx = s:find(".", 1, true) if not idx then return s end return s:sub(1,idx-1), s:sub(idx+1) end It may come as a surprise that…
You wouldn't end up with this: s:sub(0, #s) You would end up with: s:sub(0, #s - 1) Which demonstrates the off-by-one error.
Re: I open sourced my game along with a tutorial on how to make it using Lua
#66Earlier quoted context omitted.
I'm confused. Lisp does 0-based indexing. Lisp predates C and C-like languages by decades.
They don't say that C was the first. The claim is that C's influence was responsible for the proliferation. (Bit of a tangent: Lisp predates C by at most 2 years if you count McCarthy's original 1960 paper, but afaict their respective implementations both got their first public distribution in 1962. Of course, Lisp was set to gain momentum from that time until the AI winter, while C was practically confined to UNIX u…
Re: I open sourced my game along with a tutorial on how to make it using Lua
#67Earlier quoted context omitted.
It’s unfortunate that Lua makes some strange decisions, but the powerful functionality totally outweighs the weirdness (metatables are especially cool). I really like Lua, especially for game programming with LÖVE.
"strange" in the sense of different from other languages in 2020, yes, but not strange from the perspective of its developers. Lua is a language for both hardcore C programmers and complete n00bs wanting to configure their C programs. In that context, position-based indexing makes much more sense, as it's how most non-programmers think.
Re: I open sourced my game along with a tutorial on how to make it using Lua
#68I've never heard of Lua, but now that I am looking at it, it seems very friendly. Love how they call things what they are, for example `local` is just a local variable, or `repeat X until Y` for a loop. It's a joy to see, to be honest.
The Defold game engine (recently spun back out of King) uses Lua as the main language [0] [0] https://defold.com/manuals/lua/
Of the three I thought Defold was the best and was supported by a company of commercial game developers. If I were going to start today it would be my top one to consider.
Re: I open sourced my game along with a tutorial on how to make it using Lua
#69Earlier quoted context omitted.
The Defold game engine (recently spun back out of King) uses Lua as the main language [0] [0] https://defold.com/manuals/lua/
They also open sourced it and created a new organization, the Defold Foundation, to own it. I have built commercial games but only some incomplete side projects with Defold, Corona, and Love2D. Of the three I thought Defold was the best and was supported by a company of commercial game developers. If I were going to start today it would be my top one to consider.
Don't let that stop you using the software of course, as long as you have knowledge of the actual license being used.
Re: I open sourced my game along with a tutorial on how to make it using Lua
#70Earlier quoted context omitted.
A decade ago, I thought Lua would be where JS is today. But JS won... A new text editor in Lua, why not: https://github.com/rxi/lite (Rxi is awesome, see https://rxi.itch.io/ )
rxi indeed is awesome! Do you know in what language/engine his (her?) tools on itch.io are written? They all have an awesome pixelart look to them and I wonder if (s)he uses lua for them too.