Standard Libraries

lua-users home
wiki

stdlib is a library of modules for common programming tasks, including list, table and functional operations, regexps, objects, pretty-printing and getopt.

Description

This is a project to make a standard set of Lua libraries that are not included in the core distribution but are widely useful.

Download

https://github.com/rrthomas/lua-stdlib

Snapshots are made available as zip files (these are fairly carefully timed so as to contain stable code).

Rationale

Why bother having standard Lua libraries when Lua code is so easy to write? And anyway, isn't Lua mostly used just to script C and C++ programs? The answer is simply that as in any language (especially in one as small and flexible as Lua) there are a lot of useful wheels that there is no point reinventing. Whether it's support for functional programming (map, curry), string manipulation (split, join) or object orientation (constructors and inheritance), high quality and well-documented code takes time to write and is easy to get wrong. By putting this sort of thing in libraries, a lot of programming tasks can be eased.

Also, Lua isn't just used for scripting. Some people use it to write command-line utilities (hmm, fancy a getopt implementation?). And "scripting" doesn't just mean a few lines of code, anyway. Many scripted applications will have thousands of lines of Lua. Here, not only the libraries themselves, but their structure can be useful in guiding the development of large projects.

Aims

The idea is to take the rag-tag bags of personal utilities we each have, and combine them into a coherent standard library.

Here are some properties the library should have:

Library structure

The libraries can be loaded all at once (require "std"), or a module at a time, e.g. require "std.object". They have a hierarchical structure, divided into areas such as code, data and text. ReubenThomas is currently in the process of structuring them into namespaces like those of the standard libraries. In future, it might be formalised according to LTN 7 [1].

Author

ReubenThomas GaryVaughan

Related efforts


RecentChanges · preferences
edit · history
Last edited April 10, 2013 7:33 am GMT (diff)