Lua's most direct competitor in the scripting arena is Python. So it commonly gets compared with Python, however I've heard many times that Lua is very much like Lisp(Scheme) in terms of expressive power and flexibility.
Now I'm a Lua power-user, and know its intricacies in and out, but I've only tried Lisp once or twice, so obviously I'm by no means an expert, so I was wondering what kind of features does Lisp have that Lua is missing, if any?
Edit: Some findings:
Reading Greg Hewgill's suggested article and the Wikipedia article I've found the following points:
Some shared points:
-In Lisp Code you have Lambda, same with Lua
-In Lisp Code and Data are the same, same with Lua (See code example below).
-In Lisp functions are not special, same with Lua.
-In Lisp Everything is stored in a tree fashion, same with Lua (not as obvious but its the case)
-In Lisp you have S-expressions, in Lua the entire enviroment is a table, and tables have the power of S-expressions, so it's probably the same, not sure.
-Both Languages have true tail-calling semantics
-Lisp has only Atoms and Lists, Lua has only Variables and Tables, the end result, and power is the same (I think)
Lisp can do, but require advanced techniques, or can't be done in Lua
-In Lisp you can make operators be anything, this is somewhat possible with Lua, however it requires metatables, and so the operators can be anything for certain closures and objects, but not globally.
-In Lisp you have Macros, In Lua you don't, but you have metatables. I can't think of a trick you could do with Macros that can't be done with Lua's regular syntax, but its a point. (See MetaLua below for an example of a true Macro extension and how this can actually be done in Lua)
-Lisp has prefix notation (+ 1 2 3 4), Lua doesn't have this
-in Lisp, you can freely mix Function parameters "required, optional, keyword, and rest parameters", in Lua there is no distinction between parameters, so you need to check by hand
Lua can do, and I have no idea if Lisp can do it
-In Lua you can swap closures and enviroments (global included) in and out at runtime, can Lisp do this?
-In Lua you can swap metatables (similar to C++ virtual tables, but more powerful) on objects and modify them at any time, during compilation or runtime, can Lisp do this?
-In Lua you have fully functional closures, does Lisp have this?
-In Lua tables can become functors, can Lisps lists do this? (I think the S-expressions allow for this, but not sure)
Lisp-like Macros also has been implemented in Lua as such with MetaLua library:
----------------------------------------------------
-- Lambda-Calculus evaluator (weak head normal form)
----------------------------------------------------
-{ extension "match" }
function replace(var, newval, term)
match term with
| `Var{ v } if v==var -> return newval
| `Var{ _ } -> return term
| `Apply{ f, x } ->
return `Apply{ replace(var, newval, f), replace(var, newval, x) }
| `Lambda{ v, _ } if v==var -> return term
| `Lambda{ v, b } ->
return Lambda{ v, replace(var, newval, b) }
end
end
function reduce_whnf(term)
match term with
| `Apply{ `Lambda { param, body }, arg } ->
local x = replace (param, arg, body)
return reduce_whnf(x)
| _ -> return term
end
end
There are those skeptical that Lua is in fact code and data, so I'll pull an example and quote from the manual:
This below is Code or Data depending on how you look at it, because entry may be anything, it can easily process the data bellow, but that data bellow could also be something more code-like. Anyways I haven't seen any example of Lisp doing something code-data related that Lua can't do just as easily. If an example of Lisp is available I'll try to match it with Lua, if I'm not totally wrong.
entry{
title = "Tecgraf",
org = "Computer Graphics Technology Group, PUC-Rio",
url = "http://www.tecgraf.puc-rio.br/",
contact = "Waldemar Celes",
description = [[
TeCGraf is the result of a partnership between PUC-Rio,
the Pontifical Catholic University of Rio de Janeiro,
and <A HREF="http://www.petrobras.com.br/">PETROBRAS</A>,
the Brazilian Oil Company.
TeCGraf is Lua's birthplace,
and the language has been used there since 1993.
Currently, more than thirty programmers in TeCGraf use
Lua regularly; they have written more than two hundred
thousand lines of code, distributed among dozens of
final products.]]
}
And quoting the book it says:
The interesting thing about this representation is that a file with a sequence of such entries is a Lua program
Also here is a wikibook in which the author duplicates the code samples (in Lua) featured in Paul Graham's "On Lisp". As proof that Lua can do anything Lisp can in the functional programming area. (Disclaimer, remember I'm not a Lisper so I can't back this statement personally)
Here is an SO link to some other cool things Lua can do, that I don't know if Lisp can