remix logo

Hacker Remix

Show HN: Lux – A luxurious package manager for Lua

267 points by mrcjkb 1 week ago | 134 comments

nerflad 1 week ago

Execution env is the achille's heel of scripting languages. Personally I don't use Neovim, but had a feeling its adoption would spur development in this area for Lua. Bryan Cantrill called Javascript "LISP in C's clothes". In some ways I feel like Lua is the opposite, and love it for those reasons (disclaimer: never had to use it at work).

jmercouris 1 week ago

Javascript is Lisp in C's clothes? On what basis? Also what does Lua have to do with Lisp? It has no Lisp syntax whatsoever.

0x3444ac53 1 week ago

Fennel has actually convinced me that Lua and lisp have more in common than one might think. I don't know what the above comment was referencing, but I've always found beauty in lisp languages for having a primary datastructure that all others can be abstracted to. Lisp, classically, has list, clojure has sequences, and Lua/fennel has tables.

https://fennel-lang.org/

creata 1 week ago

And Tcl has strings.

Fennel is more popular than I expected! It's in the official repositories of Arch, Fedora and Debian.

cmdrk 1 week ago

as a Lisp-curious person, Fennel was a gateway drug for me

0x3444ac53 1 week ago

Fennel is phenomenal, and is the reason I switched from chicken scheme to clojure/babashka despite hating the JVM. Neovim config, Wezterm Config, and various scripts to do things are all now written in fennel. I've also used it for game dev using Love2D.

It's a great great language, and fixes a LOT of the issues I have with Lua.

Barrin92 1 week ago

> Javascript is Lisp in C's clothes? On what basis?

On a lot of bases. Javascript has real lambdas, a sort of homoiconicity of code and data (hence JSON as a data format), also has the same dynamic take as lisps on "types belong to data". Rather than variables types belong to values. Brendan Eich's original idea was literally to "put scheme in the browser" and you can in fact pretty easily convert the Little Schemer to JS.

Saying two languages don't have much in common because they don't have the same syntax is a bit like saying we don't have much in common because we don't have the same hair color.

alex-robbins 1 week ago

> a sort of homoiconicity of code and data (hence JSON as a data format)

I get that "sort of" was an attempt to hedge, but really, this isn't even close. Homoiconicity here would be if all javascript source files were valid JSON documents. A weaker version would be if it were common to use JSON to represent an arbitrary javascript program, but I've never heard of that, either. (For a good explanation of this weaker sense of homoiconicity, this stackoverflow page [1] is pretty good.)

[1]: https://stackoverflow.com/questions/31733766/in-what-sense-a...

To use Clojure as an example of a language that is homoiconic, you can take any Clojure source file, send it to an EDN parser (EDN being Clojure's equivalent of JSON), and not only will parsing succeed, but the result will be a complete representation of the program (you could execute it if you wanted to). In contrast, if you try to send JS to a JSON parser, you'll get an error as soon as it hits a function definition, or a for loop, or an operator, or whatever.

kazinator 1 week ago

But MacCarthy's original LISP 1 and LISP 1.5 do not have real lambdas. The lambda feature parametrizes a piece of code as a function literal, but doesn't capture anything.

What they have is code parsed to a data structure, which is then susceptible to manipulation by the program before being executed. JS has some dumb textual eval, like the Bourne shell.

They also have the concept of a symbol.

And only one value that is false.

galaxyLogic 1 week ago

JavaScript is not Lisp but it is more like Lisp than like C, even though syntactically it much resembles C.

ES6 JS has nice syntax for calculating with lists:

   let [car, ...cdr] = [1,2,3]
After the above 'car' has value 1 and 'cdr' has value [2,3].

behnamoh 1 week ago

in that case Python is also a Lisp because it has:

    car, *cdr = [1, 2, 3, 4]

tcfhgj 1 week ago

hmm Rust as well:

    let [car, cdr @ ..] = [1,2,3];

nateglims 1 week ago

Javascript hotloading development setups are about the closest you can get to the REPL development loop outside of lisp. I'd imagine lua is similar if the embedding is set up for it.

sundarurfriend 1 week ago

Revise.jl in Julia (https://docs.julialang.org/en/v1/manual/workflow-tips/#Revis...) also gives a really neat REPL development experience. It allows tracking changes to any source code file, module, even standard libraries or the Julia compiler itself!

soapdog 1 week ago

I hate to be that guy but a ton of languages have REPLs. The whole collection of smalltalks out there are basically an interactive environment. All of them forth languages do it too. Factor, Racket, LiveCode, there are so many. And for most of them, watching files and hotreloading is not how they do it.

johnisgood 1 week ago

Pretty sure they are just filesystem watchers. Correct me if I am wrong. Filesystem watching is NOT hot loading.

johnisgood 1 week ago

To whoever down-voted me, please do explain how HMRs are comparable to Erlang's true hot code swapping or even Lisp's live redefinition.

HMR is limited to modules (almost or always UI components), and there is no native VM support (module boundaries, side effects, and global state complicates it further) for it, and there is no multi-version coexistence either, and it is absolutely not suitable for production.

To call "hot module replacement" hot loading is very generous, and quite an overstatement.

It is only very superficially similar to hot code swapping. It is a developer tool, not a foundation for live, fault-tolerant systems.

It is absurd to call hot module replacement (HMR) "hot reloading". It might sound fancier, but it is nowhere close to true hot code swapping.

Peak redefinition of terminology. Call it what it is: hot module replacement, at best.

braebo 1 week ago

Hot module reloading is common in JS land and does things like trying to preserve running state as opposed to just watching a dir and restarting everything.

gavmor 1 week ago

Have you used `bun --hot`?

jjtech 1 week ago

I know some projects like Koreader[1] use Lua as their primary application language. If you could convince one of them to switch, it would provide some assurances about the maturity and popularity of the idea.

[1]: https://github.com/koreader/koreader

mrcjkb 1 week ago

That's a neat suggestion, thanks. Lux will need some time to become mature, but building a large multi-platform project like koreader would definitely be a nice goal.

MyOutfitIsVague 1 week ago

This sounds amazing. I use Lua a lot, and luarocks has been nearly useless for anything I need it to do because it's so heavily opinionated. For anything more than "install a library specifically for direct execution on the local system" or anything around that, it's a non starter. Have an embedded scripting environment that works with Lua packages and you want to package scripts with dependencies for use there? Give up.

I don't know if this is better for that use case, but even if not, luarocks is clunky and annoying to use at best.

shortrounddev2 1 week ago

the lua community is also incredibly dependent on C libraries, and nearly every luarocks package tries to build libs, which makes it basically useless on Windows

giraffe_lady 1 week ago

Useless if you need to run it in a scripting environment where you don't have control over runtime too. The thing lua was designed and is still prominently used for.

droelf 1 week ago

Interesting project. We'd love to work together for better Lua support in Pixi (through the conda-forge ecosystem). We already package lua and a few C extensions. C extensions are the bread and butter for Pixi, so I think it could be a good fit!

- pixi.sh (docs) - lua package on the registry: https://prefix.dev/channels/conda-forge/packages/lua

mrcjkb 1 week ago

That sounds like a great idea! I've opened [an issue](https://github.com/nvim-neorocks/lux/issues/550) in our repo. Feel free to ping us there :)