The article indirectly nods to that history by linking here: https://www.lua.org/history.html#:~:text=All%20this%20config...
So every time I want to embed Lua in a project I bring in the Fennel compiler as well which is a single Lua file and end up with a very nice embedded lisp running on top of LuaJIT. There's also Janet which has the same spirit of being small and easily embeddable and even has the same creator as Fennel but I haven't played around with it as much.
Which is to say, Lua is used practically everywhere.
I recently added Lua bindings to the BlenderUI library, and it was just so easy and fun - and immediately made nice UI development so productive. Coding up a BlenderUI with a Lua REPL is a very rewarding thing to do indeed.. so much so that I added Lua bindings to CUI, also!
m = Menagerie {
Dog { tail, ears, snout=long },
Cat { you, get, the=idea },
table.unpack(ark),
}There are a couple of snippets here that refer to it (search for @track):
If you need to access the data from a different language, you just load Lua in the other language.
[1] https://github.com/CorsixTH/CorsixTH/blob/master/CorsixTH/Lu...
[2] https://github.com/CorsixTH/CorsixTH/blob/master/CorsixTH/Lu...
[3] https://github.com/CorsixTH/CorsixTH/blob/gh-pages/check-for...
It was their answer to the old VFX industry default, RIB (or custom scene description) files (i.e. data) manipulated with "filters" or inline-expanded Python inside the "pipeline".
Didn't get traction but it was the right idea and they never discontinued support for it.
If you watch movies/series containing VFX you have seen CGI rendered with 3Delight. But most of it will have been intermediate .nsi files, not .lua.
No thanks
"if you want to see "hello, world" printed 5 million times, run it in lua. lua's parser is designed to handle massive files with stride, which is fairly unique and quite necessary if lua is to be used for this purpose."
OK
[dead]
In BlenderUI repo, it mentions Lua bindings, but there aren't any docs about it.
In CUI repo, I didn't find any reference for Lua bindings.
Thanks in advance!
https://github.com/ppmpreetham/BUI.git
Merged, a bit behind because of massive leaps in Blender UI progress this week, but if you're a Lua person keep an eye on things because I will bring the Lua bindings forward over the weekend to catch up with this weeks mad Blender UI progress.
Check the examples/lua directory, lots of examples and code, see also bindings/lua/README.md, etc.
I've already done a few small apps with this, and use the REPL for prototyping pretty successfully now .. but Blender UI has had some stonkin' pushes forward in the past week, I have to catch up a bit ..
CUI:
My PR hasn't been accepted, but you can nevertheless access it here:
https://github.com/yappologistic/CUI/pull/22
.. I have to fight with the bot protecting upstreams' intake process a bit, its a little frustrating but I'm on it - because CUI is really pretty slick, to be honest.
I'll be working on pushing both forward - if you have suggestions/contributions also, I'm all ears ..
(But it really does excel at the tacked-on job.)
foo = {}
foo[0] = "Zero index in Lua!"
No actual array:1) Lua has optimizations when a table only has numeric keys
2) This keeps Lua small. AWK, another tiny language, has the same behavior.
No bitwise operators:
Lua 5.2 and higher have bitwise operations,[1] and pretty much every modern Lua 5.1 fork (LuaJIT, the version of Lua Wikipedia uses for scripting, luau, my personal “lunacy” fork of Lua 5.1, etc.) has added bitwise operations.
The only case where a real-world Lua implementation doesn’t have bitwise operations is Adobe Lightroom Classic,[2] and even there is is possible to implement them with a polyfill.
[1] https://lua.org/manual/5.2/manual.html#6.7
[2] Alpine Linux has a lua5.1-bitop package which adds bit ops to their port of Lua 5.1
The other bit was "Why do Lua indexes start at one? The FIRST reason is..."
The 1-based indexing, in my usage, has never been a problem. A lot of people run into this, and I feel that it is because they are trying to make something using only Lua. In fact, I would suggest that if you're trying to use Lua with a shebang that you might not like the language very much.
Where it truly shines is when it is embedded into another runtime. Find something that you already have and extend it so that functionality can be added through Lua scripts. You might even be surprised at how little you actually use indexing.
I would argue that if you don't need to do manual memory management 1 based indexing should be default and all other language are doing things badly on this front.
And the current version of LuaJIT includes bitwise operators.
[dead]
Let’s see, no native json support. This day and age it should be built in. No array support: is {} an empty json object or empty json array? Just add the dang arrays already.
LuaJIT is very awesome! Amazingly fast. Does it support the latest Lua? Nope it doesn’t. Lua is at 5.5 or something, LuaJIT at 5.2 maybe.
Default global vars? Nope. More awkward than cute. Maybe introduce some profile / pragma to invert that. Everything should be local by default not global.
Speaking of Roblox, they liked Lua so much they forked it and created a new language altogether! Luau which is only fully compatible with 5.1
I mean it’s still a nice language for a configuration format but otherwise I think that summarizes why people might not be reaching for it as much, in other cases.
https://luarocks.org/modules/luarocks/json4lua - https://luarocks.org/modules/winterstream/wjson - https://luarocks.org/modules/xpol/rapidjson - etc.
Lua supports arrays; it has optimizations when all of a table’s keys are integers. Keep in mind that AWK is the same way: There’s no numeric array in AWK per se either, just AWK’s version of a “table”, but it works just fine when all of the keys are integers.
Keep in mind that I have a fork of Lua which is 116,224 bytes in size (security hardened Lua 5.1 with `lfs` support); Lua is tiny and that’s why it does not have a built in JSON library nor will it wash the dishes for you.
Versions of Lua after Lua 5.1 introduced changes which broke backward compatibility. Lua 5.1 is smaller than newer versions of Lua, runs great, and is incredibly fast. I see Lua 5.5 as a different language than Lua 5.1, even though one can make a polyglot program which can run in both. Lua 5.1 is also the point from which a bunch of offshoots were made: luau (Roblox Lua), LuaJIT, etc.
I guess my point is that why it's not picked as large of a support. I can see that being a good reason for Lua in 2006 when JSON was still not as popular but for better or worser, it's taken over so having built in JSON support would help, especially for a language geared for configuration and data representation.
> Keep in mind that I have a fork of Lua which is 116,224 bytes in size (security hardened Lua 5.1 with `lfs` support); Lua is tiny and that’s why it does not have a built in JSON library nor will it wash the dishes for you.
Agree, that's where it really shines, it's small and embeddable.
> Lua 5.1 is also the point from which a bunch of offshoots were made: luau (Roblox Lua), LuaJIT, etc.
But you see how the official site doesn't seem to issue bug fixes for anything lower than 5.4 yet everyone says 5.1 is the version to stick with. And there is luau and LuaJIT as well, that I think explains a bit why people are embracing it as eagerly any longer.
All the Lua 5.x versions that I have seen have small compatibility issues, and that's why many projects stick with what it's compatible with 5.1 only.
C++ doesn't have any "native json support" either, and that's fine. I don't think JSON is that critical. You can use a library for the kind of serialization that you want. Neovim uses JSON and Lua extensively, and it just uses a C library inside.
It's true that `{}` doubles down as an empty array or an empty map. It is not a problem that often, IME. You also can't signal that a certain key in a map is `nil`, but you can use a sentinel for it. You can do the same to disambiguate between these two.
Different features hit differently to different people. I agree that global by default seems so wrong, but I just go used to it, and I don't care anymore. To me, the main deal is not that Lua doesn't have this features by default, is more that, when I want them, there is no generally agreed library/framework that can plug all the features in a unified, coherent way. Penlight should be that, but I don't like it that much.
This is something that personally hits me the most, because I'm used to Qt. With Qt, I have tons and tons of functionality and a well established community and practices.
Lua has many quirks (global by default etc.) but with a language server like https://luals.github.io/, you can detect most of them easily plus optional type annotations.
function declare(name)
rawset(_G,name,false)
end
function exists(name)
if rawget(_G,name) ~= nil then
return true
else return false end
end
setmetatable(_G, {
__newindex = function(self,x) error("Undeclared global " .. x) end,
__index = function(self,x) error("Undeclared global " .. x) end
})
And now declare("foo")
foo = 1
-- Create name if it hasn’t
-- been declared yet
if not exists("name") then
declare("name")
name = 1
end
More discussion: https://lua.org/pil/14.2.html pos = Point(2.5, 8.9)
size = Size(4, 5)
opacity = 0.5
color = Color(0.5, 0.2, 0.1)Even ls has 60 flags.
The reason I like Lua is because I use it like a tiny Perl, but, unlike Perl, I already include the entire language with my open source project (it’s embedded in another program I wrote) so my Lua scripts in said project will run on any POSIX compliant system: The Lua fork I use and include also compiles as a standalone scripting language.
But you see how "why isn't Lua more popular" is answered with that? Do I start with 5.5? 5.3 and below seems is EoL already per the official site, they only have 5.4 bug fixes. It's a bit like C++ I guess, use only a small subset of features perhaps?
> C++ doesn't have any "native json support" either, and that's fine.
Unlike C++ Lua posits itself as an easy data representation and configuration language but it doesn't have a built-in way to load one of the most popular serialization formats out there these day.
> Different features hit differently to different people.
Definitely, I am just explaining why it doesn't appeal to me and the reason I heard other people didn't start or continue using it.
If it had a few changes and perhaps some optional additions (while keeping a "classic" or "standalone" version), it would probably be more popular.
> Unlike C++ Lua posits itself as an easy data representation and configuration language but it doesn't have a built-in way to load one of the most popular serialization formats out there these day.
But that's the thing: if you want to represent data or configure something, wouldn't you prefer to do it in Lua? Seems the history of the language was using Lua syntax for the data representation, which is a bit more convenient than JSON for a few schemas. JSON is useful for interoperability, but it's far from my favorite for making a configuration file. The next project I'm working on is a small Lua script that will let the user configure itself via Lua, because that's more convenient than a static config format.
I would love to see a POSIX standard for Lua (probably based on Lua 5.1); it’s widely enough deployed that a standard for it would make sense. Right now the standard is either PUC Lua 5.1 or whatever the latest release of PUA Lua is at a given time.
I prefer Lua over Perl/Python/Ruby because I know I can get a Lua runtime going in whatever environment I’m in—e.g. when writing my Lua book, I used my personal fork of Lua 5.1, but the person I was writing the book with was using Moonsharp (Lua in C#) since they were a C# developer. We could easily share code with each other.