Is Lua based primarily on well-established programming-language ideas?

17,304

Solution 1

This is a very interesting question. My day job is to study programming languages, and Lua will repay careful study. I would say that about very few other languages (perhaps Icon and CLU). Please note that it is the language as a whole, not the individual features, which makes Lua so worthy of study.

Is this a result of interesting new ideas the implementors had, or is it a result of good execution of well-established ideas?

Both. For the details, your best source for an answer to this question is the paper The Evolution of Lua, which appeared at the Third ACM Symposium on the History of Programming Languages. But I will add a few comments.

  • The use of Lua tables as the only mutable, non-atomic type of data was invented by the Lua team. They were inspired by developments in CLU, and I believe they were aware of similar work in Awk and Icon, but the refinement to this degree is an important contribution of the Lua team.

    Tables also have a very efficient implementation, which was invented by the Lua team.

  • The functional features of Lua have the same semantics as Scheme, but Lua has a unique implementation of first-class functions, which I think they ought to submit for publication in the Journal of Functional Programming.

  • The API for embedding has been greatly refined over the years. Its main distinguishing characteristic is that user-defined abstract types can participate fully in the embedding. This is the property that makes the Lua API superior to the Tcl API, for example. The Lua API has undergone a great deal of refinement over the years, including since its first publication at version 2.5. The Lua designers deserve a great deal of credit here.

  • The garbage-collection technology is standard.

  • Lua coroutines represent a new take on some very old ideas. The new take was considered worthy of publication in ACM Transactions on Programming Languages and Systems, so again I think the Lua team get credit for originality.

  • Lua metatables are related to the Common Lisp metaobject protocol.

I think that Lua's success result from a unique combination of strengths of the Lua team:

  • If you read the HOPL paper, you'll see that the Lua team were well aware of many developments in programming languages and were able to choose from among the best ideas. Most designers of popular scripting languages have been amateurs and have not been nearly so well informed.

  • Lua is superbly designed so that the pieces fit together very nicely, with an excellent power-to-weight ratio. This is the result of a lot of refinement over time, and PUC-Rio was willing for the Lua team to work on the language design and implementation instead of grinding out a huge number of papers. This work could not have been done at a North American university.

  • Lua is superbly engineered. The implementation is just staggeringly good. That's partly great work by great engineers and partly the opportunity to keep revising the design over a 15-year period.

I'll close by asking readers not to underestimate the difficulty of choosing and refining well-established ideas to form a coherent whole. This is extremely difficult work and is seldom recognized as it should be.

Solution 2

Lua supports functional programming and it's based on Prototype-based programming style, which is flexible and powerful.

IMO it's an interesting language.

If you want to read some thoughts about prototype inheritance, I suggest you to
read Steve Yegge's The Universal Design Pattern blog post.

Solution 3

Lua is small, the total code is only tens of thousands lines in ANSI C. (Python has ten times mores lines of code).

Lua is very stable, or say, the language is fixed now.

Lua has good engineering. Its code is easy to read and hack. (also because small)

Its license permits you do whatever you want.

Writing C extensions in Lua is easier than other languages, say Python.

Solution 4

There's a Lambda the Ultimate story, Small is Beautiful: the design of Lua, discussing Robert Ierusalimschy's recent talk at Stanford of the same name. The discussion currently focusses on the merits of having tables as the only container data structure; so far, little has been said on the other part of the talk, dealing with Lua's C interface.

Share:
17,304
Charles Stewart
Author by

Charles Stewart

Freelance scientific copy-editor. You can read my irregular waffles at advogato.org/person/chalst/.

Updated on June 12, 2022

Comments

  • Charles Stewart
    Charles Stewart almost 2 years

    Lua occupies a good place in the space of languages that can be embedded. Are the primary ideas behind Lua's design new ideas from the implementors, or is Lua primarily a well-executed combination of well-established ideas?

    Comparison of properties and features of Lua to other PLs are particularly appropriate.

  • Charles Stewart
    Charles Stewart over 14 years
    So this all counts as good engineering, rather than anything to do with language design?
  • Charles Stewart
    Charles Stewart over 14 years
    Thanks: the link is interesting. Work on Lua began in 1993, 3 years after the release of Self, and 7 years after Borning's "Classes versus prototypes in object-oriented languages". Did Lua introduce new to prototype-based programming?
  • Nick Dandoulakis
    Nick Dandoulakis over 14 years
    @Charles, I've only experimented with prototypes in Lua and I don't really know the answer to your question. Maybe someone else can shade some light on that.
  • Charles Stewart
    Charles Stewart over 14 years
    Sure. It's certainly interests me that I can't think of an earlier prototype-based language that gained wide usage.
  • Nick Dandoulakis
    Nick Dandoulakis over 14 years
    +1: very good answer
  • lhf
    lhf over 14 years
    For the time being, see "The implementation of Lua 5.0" at lua.org/doc/jucs05.pdf We're working on that paper, Norman, but Lua 5.2 is getting our attention right now...
  • Charles Stewart
    Charles Stewart over 14 years
    The TOPLAS paper, Revisiting Coroutines, was discussed on LtU, which for some reason I didn't pay attention to : lambda-the-ultimate.org/node/2868
  • lhf
    lhf over 14 years
    No, there's much good engineering, but there are innovative design decisions, as Norman pointed out. Read the HOPL paper.
  • Jikku Jose
    Jikku Jose about 10 years
    Brilliant, concise and probably the most enlightening write-up I have read on Lua during my short research on the language so far. You should really have this published in a blog so that many will find it helpful.
  • Iain Duncan
    Iain Duncan over 5 years
    Oh man, WHAT IS YOUR DAY JOB? :-)