5 ms·
I generally very much dislike dynamic languages but for some reason I've always really liked Lua. I'm not exactly sure why to be honest. Maybe because you can
by PacificSpecific 6mo ago
I generally very much dislike dynamic languages but for some reason I've always really liked Lua. I'm not exactly sure why to be honest.
Maybe because you can fit the whole language spec on a single sheet of paper and adding more advanced features is pretty easy.
Love looks really cool. I never got into it personally but I still might
- turtledragonfly 6mo agoThe Lua source code is also a masterclass in C, I recommend it to anyone learning that language. It's big enough to be an involved implementation, but small and focused and well-organized enough to (at least roughly) understand what's going on at the various layers. It's a very solidly-written mass of portable C, with only minor exceptions.
- PacificSpecific 6mo agoOh I hadn't considered looking at the source but considering how minimal and clean Lua is I should have assumed so :) Thanks for the tip. That should make for a fun weekend
- Kaliboy 6mo agoLua will forever hold a special place in my heart. It was the first programming language that I actually managed to learn, instead of just attempting to learn it. It was chosen around 2008 or so to be the scripting language in Multi Theft Auto: San Andreas. We build entire worlds in Lua, there were many gamemodes, but my favorite was Roleplay. Good old carefree times.
- Iridescent_ 6mo agoIt has a very lego-like feeling, with simple, orthogonal design that lets you build the language and constructs you need. Very elegant.
- dgb23 6mo agoLua is a scripting language done right. It doesn’t pretend to be more than it is. Anyone can learn it a couple of sessions. It has all the stuff you need to write a program. Imagine if we had Lua instead of JS in the browser. In fact the latter was once closer to Lua, but didn’t have the same philosophy of wanting to stay minimal.
- linzhangrun 6mo ago[flagged]
- sph 6mo agoI know it’s bikeshedding and leads to pointless discussions, but in my opinion Lua would be the perfect scripting language if it had 0-based indexing. “It makes more sense this way” is not a good enough reason to break convention.
- rigonkulous 6mo agoThere is nothing stopping you from doing someArray[0] = "the first item", you know. For me, the table is extremely powerful. I like it that it can be used as a sparse array, a hash, a vector, whatever. Of course one must know, at heart, the difference between pairs() and ipairs() and what it means for your data, though ..
- HiPhish 6mo ago> There is nothing stopping you from doing someArray[0] = "the first item", you know. Yes, there is: local l = {[0] = 'a', [1] = 'b', [2] = 'c'} for i, c in ipairs(l) do print(i, c) end This will only print the last two pairs. Lua is 1-indexed, end of story. You can store values at index zero, but it's no different than storing values at index -1 or index 'lolrofl'. It does not exist in the array-part of the table as far as Lua is concerned.
- 0x3444ac53 6mo agoI've always assumed that there is some technical reason for Lua being 1 indexed, rather than it being a design choice. Either way, I think it's a nitpick to complain about. I've written a decent amount of Lua and there's only been a handful of times where 1-indexing was even relevant to me.
- ModernMech 6mo agoIt's a design choice. Lua was first intended to be a configuration language for engineers to enter data at an oil company. They were used to the 1st thing being number 1, the 2nd thing being number 2, and so forth. It's just a very natural way of counting. You don't change something like that because it eventually got picked up by game programmers (never the intent of Lua, something that just happened after it was used by the Grim Fandango team, then it took off in the gaming world).
- functional_dev 6mo agoexactly, the simplicity is its beauty! A single data structure (tables), no built in OOP (you build it with metatables). Coroutines instead of threads. I was curious and explored it in detail here - https://vectree.io/c/lua-language-design-metatables-coroutines-the-minimal-core-philosophy https://vectree.io/c/lua-language-design-metatables-coroutin...