4 ms·
Lua's designers purposefully try to keep the language's standard library vanishingly small to reduce portability issues and the footprint for embedded targets.
by ANTSANTS 12y ago
Lua's designers purposefully try to keep the language's standard library vanishingly small to reduce portability issues and the footprint for embedded targets. So for Lua, if no one makes user libraries, you don't have any libraries.
- jzwinck 12y agoLua's standard library is so small, in fact, that until 2012 there was popen() but no pclose(), a bizarre situation that persists today for people still using Lua 5.1 (which is probably the most popular version deployed). So you can spawn a shell to run an external program, but you cannot retrieve its return code to know if it succeeded or failed. Now that's minimalism!
- acqq 12y agoThe minimalistic core language is OK if the authors don't want to maintain more. What I miss is some incarnation of the language that would still be more convenient than Perl or Python (by being a single executable) but have enough "basic libraries" inside. The last time I investigated I failed to find something like that. Once you have Lua with the tons of the packages in different files with the package managers and stuff you lose the benefit of having a small-size-of-the-executable language. I understand that the language author doesn't want to be a part of that.
- darkFunction 12y agoHave you tried http://luapower.com/ http://luapower.com/
- acqq 12y agoThanks! If it would allow that the modules locally exist inside of a single ZIP file instead of the single directory, it would be almost exactly what I want. Then the "getting started" would be "download luajit choose/download wanted packages along with their listed dependencies unzip all over the same directory (optional) rebuild binaries (optional) zip all modules to modules.zip. <== new run a demo: luajit ..._demo.lua This will give you an instantly portable luajit distro with only a few small files!" Java also has JAR files which are actually ZIPs.
- ANTSANTS 12y agoI don't like luapower's approach to package management. Basically it stuffs the contents of packages in the base of a single directory: luapower/lib.lua luapower/additional-files-for-lib/stuff.lua Instead of completely encapsulating each package in its own directory: luapower/lib/lib.lua luapower/lib/stuff.lua So instead of being able to just cd to luapower and git clone repo, you need to use a silly wrapper script that overlays the repos with each other. All of this presumably because the author wanted to type `require "lib.lua"' instead of `require "lib/lib.lua"'
- acqq 12y agoI like it, I'd like even one step more, of making a ZIP of all of the packages. I never modified in place any Perl or Python module, and I don't expect I'd do it with Lua, so having a small portable file set of just a few self sufficient files I could copy to the another machine is my real wish.
- ANTSANTS 12y agoBut it's arguably easier to package the other way I described, just stick all of the relevant directories into a zip file, instead of needing to manually pick out the "lib.lua" files from the base directory. Literally the only benefit of this approach is saving a few characters on require statements. For anyone interested in creating a new language, make your equivalent of `require "lib_directory"' do the equivalent of `require "lib_directory/init.lua"' or `require "libname_directory/libname.lua"' so we don't have this issue.
- acqq 12y agoDo you actually do that manually? Why isn't there a script for that? It should be a part of the automated process. Much better doing it once as an automatic step than writing everywhere in your sources: somethingbig/somethingbig every time you use somethingbig. And that step should also zip the modules, I believe. The behavior of require, as I'd like it: require X first looks in the directory X, for module X. If there is no such, it opens modules.zip and reads module X from there. If internally in the ZIP there were a subdir for every module, I don't care, as long as I don't have to type that fact every time. modules.zip would be constructed automatically. Whoever wants to tweak some specific module can unpack it in the separate directory.