Remix.run Logo
sunshine-o 2 days ago

I never coded in Lua but I found out recently that Lua is now in FreeBSD base [0] This is huge for Lua and FreeBSD.

Now something that worry me is whenever you need to make an HTTP request or parse some JSON you need to go on a quest for a "library" on the Internet. It doesn't seems to have a (semi-)official "Extended Standard Library" I can quickly trust.

- [0] https://man.freebsd.org/cgi/man.cgi?query=flua&apropos=0&sek...

Fwirt a day ago | parent | next [-]

The Lua ecosystem is more like the Lisp ecosystem than Python. The language is small enough that there’s a lot of stuff out there that’s just… finished. Hasn’t been updated in 10 years but still works. The LunarModules org tries to gather it up and keep it compatible.

For an extended standard lib, the closest thing is probably Penlight. https://github.com/lunarmodules/Penlight If you want async IO, sockets, etc, check out Luvit. https://luvit.io

Lua is really designed as an extension language but it’s such a nifty little language that sometimes you really wish you could use it in place of Python or Perl, which is why LuaJIT is so popular. But LuaJIT is really just one guy’s project. Its metaprogramming features are really nice and let you build some Lisp-style DSLs, and if you want full Lisp syntax you can drop in Fennel. If you’re just writing extension code you often don’t need a standard lib because it’s easier just to roll your own function to fill the gap.

Personally, I found it easier and quicker to just read the reference manual to learn the language. It’s small and simple enough that you shouldn’t have trouble getting up to speed if you have a couple other imperative languages under your belt. IMO metatables are much easier to work with than JavaScript’s prototype inheritance.

catwell 16 hours ago | parent | prev | next [-]

Most people don't use the standard library to make a HTTP request in Python either...

I agree with the sentiment though, I even gave a talk about this at Lua Workshop 2013 (https://www.lua.org/wshop13/Chapuis.pdf) around that issue. There are good reasons why several important but OS-specific features are not included in the core language. Discussion around a "blessed" extended standard library module arise from time to time but never lead anywhere.

The Lua community - at least the one around PUC Lua - is reasonably small and you can typically look at what active popular projects use to figure out the best libraries. The LuaRocks download count can be an indicator as well. But I agree this is still a problem.

nmz a day ago | parent | prev [-]

You kind of always have to go on a quest for a library on the internet, why would lua be any different? For lua, luarocks is its module registry and you can sort by most downloads, which sometimes leads you to buggy modules, but what can you do.

deanishe 20 hours ago | parent [-]

> You kind of always have to go on a quest for a library on the internet

Plenty of languages come with standard libraries that are more than sufficient for handling plenty of tasks.

nmz 6 hours ago | parent [-]

There's nothing stopping anybody from making a batteries included lua, and plenty have done so (emilua, luapower, luaforwindows, luart and etc), of course, pure lua still exists and their changes are usually backported into lua since its so small and portable.

FWIW you can do a lot with pure lua and unless you're importing json there's no reason to include a library for it given that lua itself can be used as the data exchange format.