Upload
kore-vm
View
5.647
Download
1
Embed Size (px)
DESCRIPTION
Citation preview
A Brief History of Lua
Roberto Ierusalimschy
chief Lua architect
The Beginning (92-93)
• Tecgraf: partnership between PUC-Rio and Petrobras (the Brazilian Oil Company)
• emphasis on development• but in an academic setting
• two programs using "little languages"• with all limitations of little languages
d
Data Entry Programs
• graphical interfaces for legacy Fortran simulation programs
DELData Entry Language
:e gasket "gasket properties" mat s # material d f 0 # distance y f 0 # stress t i 1 # facing type
:p gasket.d > 30 gasket.d < 3000 gasket.y > 335.8 gasket.y < 2576.8
DEL limitations
• decision-making facilities
• arithmetic expressions
• abstraction mechanisms• variables, functions
Programa Gráfico Mestreprogram to visualize geologic profiles
type @track {x:number, y:number=23, z}
type @line {t:@track=@track{x=8}, z:number*}
-- create an object 't1', of type 'track't1 = @track {y=9, x=10, z="hi!"}
l = @line {t=@track{x=t1.y, y=t1.x}, z=[2,3,4]}
SOL - Simple Object Language
• data description language• not totally unlike XML • BibTeX-like syntax
sounds familiar...
SOL limitations
• decision-making facilites
• arithmetic expressions
• abstraction mechanisms
what about a common language for both projects?
What we needed
• a generic configuration language• goal was to configure other applications
• easily embeddable• implemented as a library, to be used by both
projects
• a "complete" language• functions, variables, control structures, etc.
What we needed
• portable• Petrobras had a diverse array of machines
• as simple as possible• we needed to solve our problem
• non-intimidating syntax• for end users (engineers, geologists, etc.)
Lua
• as the old language was called SOL ("Sun" in Portuguese), a friend suggested the name "Lua" ("Moon" in Portuguese) for the new language
Sol x Lua 1.0
• not that different from Sol...
t1 = @track{x = 10.3, y = 25.9, title = "depth"}
Sol x Lua 1.0
t1 = @track{x = 10.3, y = 25.9, title = "depth"}
function track (t) if not t.x then t.x = 0.0 end if type(t.x) ~= "number" then print("invalid 'x' value") end if type(t.y) ~= "number" then print("invalid 'y' value") endend
• but quite different...
Lua 1.0 (1993)
• called 1.0 a posteriori• no expectations of other versions
• the simplest thing that could possibly work• tables implemented as linked lists!
• standard implementation• precompiler with yacc/lex• opcodes for a stack-based virtual machine
• less than 6,000 lines of C code
Lua 1.0
• expectations: to solve our problems with PGM and DEL• could be useful in other Tecgraf products
• fulfilled our expectations• both DEL and PGM used Lua successfully• PGM still in use today in oil platforms
• it was a big success in Tecgraf
• soon, several projects at Tecgraf were using Lua
Lua 1.1 (1994)
• new users brought new demands
• reference manual• a must if you live among your users
• well-defined and well-documented C API• ditto• later, documentation would be crucial for the
spread of Lua
Lua 2.1 (1995)
• several important changes• several incompatibilities!
• cleaner C API• no more direct references from C to Lua
objects
Lua 2.1: Fallbacks
• growing pressure for OO features
• similar to exception-handling with resumption
• delegation• allowed prototype-based OO• inspired by Self
• kind of minimum mechanism to get the label "OO inside"
Lua 2.2 - 2.5 (95 - 96)
• external precompiler• faster load for large programs (metafiles)
• debug facilities
• pattern matching
International Exposure
• Jun 1996 - paper in S:P&E• R. Ierusalimschy, L. H. de Figueiredo, W. Celes, Lua
- an extensible extension language, Software: Practice & Experience 26(6):635-652, 1996.
• Dec 1996 - article in Dr. Dobb's• L. H. de Figueiredo, R. Ierusalimschy, W. Celes,
Lua: an extensible embedded language, Dr. Dobb's Journal 21(12):26-33, 1996.
Beachhead in Games
From: Bret Mogilefsky <[email protected]>To: "'[email protected]'" <[email protected]>Subject: LUA rocks! Question, too.Date: Thu, 9 Jan 1997 13:21:41 -0800
Hi there...
After reading the Dr. Dobbs article on Lua I was very eager to check itout, and so far it has exceeded my expectations in every way! It'selegance and simplicity astound me. Congratulations on developing sucha well-thought out language.
Some background: I am working on an adventure game for the LucasArtsEntertainment Co., and I want to try replacing our older adventure gamescripting language, SCUMM, with Lua.
1998: Grim Fandango LucasArts
• "A tremendous amount of the game was written in Lua" (Bret)
1998 - 2002
• user base grows outside Brazil• shift from inside PUC to outside
• development of a virtual community
• several changes in the language• support for larger programs• functional facilities• several incompatible changes between
versions
"Its user base is also small; there might be only a few tens of thousands of Lua programmers in the world. They're very fond of this language, though, and the imminent explosion of ubiquitous embedded processing (computers in your car, in your plumbing, and in your kitchen appliances) can only work in favor of Lua."
1998
• in Aug 1998, Cameron Laird wrote in SunWorld:
"Its user base is also small; there might be only a few tens of thousands of Lua programmers in the world. They're very fond of this language, though, and the imminent explosion of ubiquitous embedded processing (computers in your car, in your plumbing, and in your kitchen appliances) can only work in favor of Lua."
For us, this "small base" was much larger than we could have imagined!
1998
• in Aug 1998, Cameron Laird wrote in SunWorld:
Lua 3
• several improvements for functional programming• anonymous functions, upvalues
• multiple states• support for Lua processes
• code reorganization• more portable
Lua 4.0 (Nov 2000)
• major change in the API• all functions got a new parameter (the state)• no more C global variables in the code• libraries should not use C globals, too• concurrent C threads can each has its own
state
Lua 4.0
• several other improvements in the API• stack oriented
• no more built-in libraries• all standard libraries defined through the
official API
2001
• March 2001, new site: www.lua.org• gift from Jim Mathies
• few months later, lua-users.org• kept by Lua users
• big plans for 4.1• so big that Lua went straight to 5.0
Lua 5.0
• coroutines
• lexical scoping
• metatables
• boolean type, weak tables, proper tail calls, ...
• module system• incompatibility
Lua 5.1
• incremental garbage collector• demand from games
• better support for modules• more policies• functions to help following "good practice"
• support for dynamic libraries• not portable!• the mother of all (non-portable) libraries• this support cannot be dynamically loaded!
Growth in lines of code
• a proxy for complexity...
0
2000
4000
6000
8000
10000
12000
14000
16000
18000
8/12/91 5/8/94 2/1/97 10/29/99 7/25/02 4/20/05 1/15/08
1.0
1.1
2.1
2.2
2.4
2.5
3.0 3.1
3.2 4.0
5.0
5.1