3 ms·
I don't have a lot of experience with Python, is it as easy to call out from and into c code as with Lua? (I am now just guessing as to why a game programmer wo
by martijn_himself 15y ago
I don't have a lot of experience with Python, is it as easy to call out from and into c code as with Lua? (I am now just guessing as to why a game programmer would choose Lua over Python).
- andrewcooke 15y agolua is easier to embed, is smaller, and has better performance. it's also a slightly cleaner language (all other things being equal, i think it is slightly better than python: the handling of tables is more regular; it has better support for continuations; it has tco; and correct scoping). on the downside, the "maps as arrays" approach is a bit clumsy.
- cheald 15y agoLua tables are sort of two-headed beasts. They aren't like PHP's array construct, which is effectively always an ordered dict. In Lua, an ordered list and a dictionary are both expressed by the same type, but are effectively different types. You can even have both an ordered list, and a dictionary in the same table. foo = {1,2,3} This is an ordered list. #foo -> 3 foo = {foo = "bar", baz = "bin"} This is a dictionary. #foo -> 0; the reason for this is that #foo (or more clearly, the length of foo) measures the length of the ordered list portion of a table. If you iterate an ordered list with ipairs(), you will only get the ordered list entries, even if you were to have dictionary data in the same table. This is somewhat unintuitive in the context of other similar languages, but once you have a grasp of it, it makes a lot of sense, and is remarkably elegant.