Lua, a lightweight, high-level scripting language designed for embedding into other applications, has just rolled out version 5.5.
One of the key additions is explicit global variable declarations, enabling developers to define globals more clearly and avoid common errors associated with implicit globals. In addition, variables in for-loops are now read-only, reducing unintended side effects in loop constructs.
Memory usage for arrays has been significantly optimized in Lua 5.5. According to devs, implementing more compact arrays reduces the memory footprint of large tables by approximately 60 percent, improving performance for data-intensive applications.
Garbage collection has been improved, too. The introduction of a new generational garbage collector mode improves performance by separating short-lived and long-lived objects. Moreover, major garbage collection cycles are now performed incrementally, reducing pause times and enhancing responsiveness in long-running applications.
On top of that, floating-point values are now printed with enough decimal digits to ensure they can be read back correctly. The release also includes updates to string and UTF-8 handling, such as an expanded utf8.offset function that returns the final position of characters, and support for external strings that use memory not managed by Lua’s own allocator.
Several new utility functions have been added, including luaL_openselectedlibs and luaL_makeseed, which enhance the library-loading and randomization interfaces. Plus, the Lua interpreter (lua.c) now dynamically loads readline support when available, broadening interactive use.
Static binaries see improvements as well; when loading binary chunks in memory, Lua can reuse original memory in specific internal structures. Dump and undump operations now reuse all strings, and the auxiliary buffer reuses its memory when constructing final strings, reducing allocations.
For more information on all changes in Lua 5.5, follow this link.
