Advanced Topics in Software Engineering
Mark Stroetzel Glasberg Jim Bresler Yongmin 'Kevin ' Cho
Introduction
Lua is a powerful light-weight programming language designed to extend applications. Lua started as a small language with modest goals. The language has grown incrementally. As a result, Lua has been re-architected and rewritten several times in the past ten years. The original functional requirements and motivation of the architecture were documented in the paper “Lua-an extensible extension language” [1]. A few other versions of the language were briefly described in “The Evolution of an Extension Language: A History of Lua” [3]. The architecture and implementation was created and is maintained by Roberto Ierusalimschy, Waldemar Celes and Luiz Henrique de Figueiredo at the Computer Graphics Technology Group of the Pontifical Catholic University of Rio de Janeiro in Brazil (PUC-Rio). Lua’s implementation consists of a small library of ANSI C functions that compiles unmodified in all known platforms. The implementation goals are simplicity, efficiency, portability, and the ability to run on small devices with limited capabilities. These implementation goals resulted is a fast language engine with small footprint, making it ideal in embedded systems. This paper reconstructs and documents the architecture of Lua version 5.0.2. Lua 5.0.2 contains approximately 25,000 lines of source code. The code base uses an instance of the compiler reference model, has several identifiable patterns, and is divided into clearly defined modules such as the code interpreter, parser and virtual machine. The language is being used in several projects at Tecgraf, PUC-Rio, University of Illinois at Urbana-Champaign and in several industry companies such as Microsoft, LucasArts Entertainment, and others.
Architectural Requirements
Lua’s main quality attributes, which are simplicity, performance, flexibility, and portability, were driven by the
References: [1] [2] R. Ierusalimschy, L. H. de Figueiredo, W. Celes, “Lua-An Extensible Extension Language”, Software: Practice & Experience 26 pp 635-652 #6 (1996). L. H. de Figueiredo, R. Ierusalimschy, W. Celes, “The Design and Implementation of a Language for extending applications”, Proceedings of XXI Brazilian Seminar on Software and Hardware, pp 273-283 (1994). R. Ierusalimschy, L. H. de Figueiredo, W. Celes, “The Evolution of an Extension Language: A History Of Lua”, Proceedings of V Brazilian Symposium on Programming Languages B-14--B-28 (2001). L. H. de Figueiredo, R. Ierusalimschy, W. Celes, “Lua: An Extensible Embedded Language a Few Metamechanisms Replace a Host of Features”, Dr. Dobb 's Journal 21 #12 pp 26-33. [DDJ] (Dec 1996) J. Gracia-Martin, M. Sutil-Martin, “The Extreme Compiling Pattern Language” Associative Array at Wikipedia, “http://en.wikipedia.org/wiki/Associative_array” R. Ierusalimschy, L. H. de Figueiredo, W. Celes, “Lua 5.0 Reference Manual”, Technical Report MCC-14/03, PUC-Rio, 2003 L. H. de Figueiredo, R. Ierusalimschy, W. Celes, “The Design And Implementation Of A Language For Extending Applications”, Proceedings of XXI Brazilian Seminar on Software and Hardware pp 273-283 (1994). Len Bass, Paul Clements, and Rick Kazman; “Software Architecture in Practice”, second edition, Apr 9, 2003, Addison-Wesley Frank Buschmann, Regine Meunier, Hans Rohnert, Peter Sommerlad, and Michael Stahl; “Pattern-Oriented Software Architecture: A System of Patterns” 1996, Wiley & Sons Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides; “Design Patterns” 1994, Addison-Wesley “The Kepler Project” at http://www.keplerproject.org, 2004, Fábrica Digital and PUC-Rio “tolua” at http://www.tecgraf.puc-rio.br/~celes/tolua/ , 2004, Tecgraf/PUC-Rio “IUP” http://www.tecgraf.org/iup, 2004, Tecgraf/PUC-Rio “LuaSocket” at http://www.tecgraf.org/luasocket, 2004, Fábrica Digital and PUCRio 17 [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] “Luaorb” at http://www.tecgraf.puc-rio.br/luaorb , 2004, Tecgraf/PUC-Rio John R. Levine, Tony Mason, Doug Brown; “Lex & Yacc” 1992, O 'Reilly & Associates David Jeske, “A Fast Multiple-Inheritance Tag Method Implementation in Lua”, at http://www.lua.org/notes/ltn008.html Lua Technical Note 8. Ana Lúcia de Moura, Noemi Rodriguez, and Roberto Ierusalimschy; “Coroutines in Lua” July 2004 Journal of Universal Computer Science, pp 910-925 10(7). Kein-Hong Man. “A No-Frills Introduction to Lua 5 VM Instructions”, November 28th, 2004 Richard P. Brent; “Reducing the retrieval time of scatter storage techniques” 18