4 ms·
Lua Bash: Run Lua as a Bash loadable
- patrickg 16y agoI like seeing more and more software extensible by Lua, which is a very decent language. My very favorite is LuaTeX (luatex.org), where you can access all ugly TeX internals from Lua and even create a complete typesetting system without using the rather complicated TeX language, which is based on macro expansion. I am not so sure if I'd use Lua Bash, for bash has always been "good enough" for me.
- chalst 16y agoOh, hi Patrick. The reason Rene Rebe wrote luabash initially was to speed up certain shell scripts without drastic rewriting of existing code, efficiency being the main justification for dynamic loadables (which came from ksh) in the first place. The code here is simple, and I enjoyed reading it: it lit a few lights for me about how to use Bash loadables.
- phoyd 16y agoWhat's really cool is, that on a system with a c-compiler and swig it is now possible (and trivial) to inline some C-code in a lua script, generate a swig wrapper from lua, compile it from lua, load it as a module into the lua interpreter and then export the defined functions automatically to bash!!
- silentbicycle 16y agoNothing against Lua (it's one of my favorite languages), but unless you're dealing with complex data structures, wouldn't it be more straightforward to just write a small pipe-style C program and skip the bash-to-Lua step entirely?
- diego_moita 16y agoForget swig. Have you seen luajit new ffi library? If you think Lua's C interface is simple, you're gonna be blown out of your mind with luajit's: local ffi = require("ffi") ffi.cdef[[ int printf(const char *fmt, ...); ]] ffi.C.printf("Hello %s!", "world")
- phoyd 16y agoOw, this is cool. Here's the mouth watering announcement: http://article.gmane.org/gmane.comp.lang.lua.general/74072 http://article.gmane.org/gmane.comp.lang.lua.general/74072