Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
LuaX – Lua interpreter, REPL, and useful packages (github.com/cdsoft)
62 points by adius on May 26, 2024 | hide | past | favorite | 14 comments


> The script bootstrap.sh installs ninja, zig and compiles LuaX

I think we're going to see more build instructions like this as time goes on. Zig installs are simple, self-contained, don't require root to install, and automatically handle C/C++ cross-compilation like magic. I suspect long term these benefits will put Zig in a position to become the best build tool for C/C++ projects. If you're already using it for your compiler, you might as well use it to write your build scripts.


And if you're already using zig cc to compile your C project, you might as well write the next module in Zig. I know of no other language which makes it quite so easy to produce C-compatible object code. Some of that is the design of the language itself, but a great portion of it is providing native C and C++ compilation, with a good build system and an excellent cross-compilation experience.

Projects which rely heavily on this feature are a bit nervous about the plans to break the LLVM dependency, but using the Zig toolchain this way is too important to the goals of the language to screw that part up.


If you want it to interact well with a couple of really popular languages there's this:

https://github.com/mlua-rs/mlua

Rust and through Deno, JavaScript.

It also supports Luau which has sandboxing. https://luau-lang.org/sandbox


So this lets you essentially run Lua standalone, and then compile those scripts into executables. Seems like a mix of Cython and bash. In going to give it a try, it might fill a niche of some dev tool scripts I make for the team.


Look at what Justine Tunny did with Redbean.

https://justine.lol/redbean2/

Lua plus lots of "Unix" support in a exe/zip that runs on 6 different OS setups.


> Lua interpreter and REPL based on Lua 5.4

Lua already is this. I don't understand.

> augmented with some useful packages

How is this better than using LuaRocks?


> How is this better than using LuaRocks?

Batteries included. If everything you need is included, you can pass around scripts to other users / computers without having to install anything


Dumb question: really compiled code , non plain readable anymore ?


luac can compile lua code,how different is luaX?


This is probably compiling to bytecode (like luac) and bundling the result with the lua interpreter as an executable. Doing the latter by hand involves writing a very small C program that passes a static char array to the lua entry point - I think this is nicely packaging that process.

It might be compiling to native code instead but the readme doesn't look like it.


Janet puts together “executables” like this as well, which is a pretty slick setup.


Janet has nothing to do with Lua though, am I missing something


Right, sorry — to be clear, I brought it up because it's a pretty nice way to make executables easily from an embeddable scripting language and the approach is fairly unique among interpreted languages.


I think mate is just saying that Janet works the same way.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: