开发者

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

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by fact开发者_JS百科s, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

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.


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.


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.


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.


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.


I think this is because Lua is relatively simple and pragmatic. It doesn't try to be the language to build the next operating system, Crysis 3 or a SAP clone, but what it does, it does well, i.e. serving as a scripting language.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜