27 ms·
My question is, how portable is the lua code written for redbean to a GNU/Systemd environment running something like LuaJIT or whichever interpreter would be mo
by tepitoperrito 4y ago
My question is, how portable is the lua code written for redbean to a GNU/Systemd environment running something like LuaJIT or whichever interpreter would be more compatible. Forgive my lack of knowledge of the lua ecosystem, and not checking out more of the redbean docs.
- giraffe_lady 4y agoI may not be understanding the concern correctly so forgive me if not. Lua code pretty much always ends up tightly coupled to the embedding environment and the API exposed by it. Running a bare lua script against an unmodified interpreter supplied by the OS is just not the normal use case, though certainly possible. So it's as portable as all lua code, which is up to you but there's rarely a reason to prioritize that too highly. For example the two kinds of lua I've done professionally are web servers and industrial automation. What does it even mean for code to be "portable" between those two? A web server doesn't have a motor and so doesn't expose functions to control one. A conveyor belt doesn't handle http requests so has no functions to send one. You can definitely come up with library code-type functionality that you'd want in both, and if you write it carefully not to depend on anything outside of the core lua implementation it will run on both. Nothing special about redbean here among the many many other niche uses of lua.
- jart 4y agoRedbean embraces and extends Lua. That's good since Lua by itself is the most austere language. For instance, here's Lua's standard library as shown by redbean auto-completion: https://redbean.dev/img/lua-stdlib.png https://redbean.dev/img/lua-stdlib.png It only covers stdio functionality, since that's traditionally the only thing that's been portable across platforms. What we did with Cosmopolitan Libc was make POSIX as a whole portable to things like Windows. Redbean uses it to offer you a much larger breadth of system functionality across platforms https://redbean.dev/img/redbean-unixlib.png https://redbean.dev/img/redbean-unixlib.png so you can benefit from the modern features of your operating system. We've also added language features to Lua that we borrowed from C and Python. https://redbean.dev/#enhancements https://redbean.dev/#enhancements If you want to move your code to a different Lua environment, then you can take our APIs with you. For instance, our enhancements to Lua are all open source and built on standardized interfaces. We even offer a 420kb build of just the lua command + our unix module, in the event you ever need just Lua but not the web server too. https://redbean.dev/lua.com https://redbean.dev/lua.com
- tepitoperrito 4y agoThanks a trillion. I'm basically hoping to use the code I write targeting redbean + lua + sqlite in an OpenResty (nginx + their set of lua modules) environment without too much mental overhead or god forbid, a parallel implementation. This confirms I'll be good to go!
- jart 4y agoYou will! Please note not all our APIs are present on OpenResty at the moment. However we'd be happy to see them be included. Most of our modules e.g. unix https://github.com/jart/cosmopolitan/blob/master/third_party/lua/lunix.c https://github.com/jart/cosmopolitan/blob/master/third_party... only really depend on Lua and POSIX which is available everywhere. You can build our modules in different environments. Obviously only the Cosmopolitan Libc environment is going to let the code run on six operating systems. But since our Lua contributions are based on standardized interfaces and libraries, if you use a different platform to build our code, then it will work there.