Re: [Algorithms] My first scripting engine
Brought to you by:
vexxed72
From: John P. <jp...@br...> - 2004-08-05 18:50:03
|
I would also throw in that Lua's C API is significantly less burdensome than python's (IMHO of course). Shawn Hargreaves wrote: >Having spent a while looking at both Lua and Python, I don't actually think >there is much to choose between them in terms of power. > >Lua is marginally smaller/cleaner, while Python is slightly bigger and >offers more types of construct, but if you strip out the various library >modules (as would typically be the case when embedding in a game), the >remaining differences are nowhere near as big as they initial appear. > >In fact, Python without all the standard Python libraries is remarkably >small and clean, while if Lua had an equivalent to the enormous Python >library set, I think the result would look and feel very close to Python! > >Both offer first order function objects, powerful hashed containers, user >defined iterators, a reasonable level of object orientation, and can easily >be extended with C++ types that behave like natural built-in features. > >The most significant differences that I've come across so far are: > >Lua is potentially slightly faster, because it holds numeric data types on >the stack, while in Python everything is an object. In practice the >difference is negligible, though. > >Lua is slightly smaller. > >Python has a very nice slicing syntax for list/string manipulation, which >Lua lacks. > >Python has more flexible syntax for optional or named function parameters. >You can emulate such things in Lua using a table, but the syntax isn't so >nice. > >Lua has better syntax for defining anonymous functions and closures: nice if >you are using a lot of callbacks or functional programming styles. The >Python lambda keyword is horribly restrictive in comparison. > >Python has three main data types: lists, dictionaries, and tuples. Lua has >only one: the table, which is internally implemented as either an array or a >hash table (or both) depending on the type of key. Tough to say which is >better: Python gives the programmer more control, but if you scripts are >going to be written by non-programmers, the Lua approach might be better >because there is less to learn (always use a table, and it will do the right >thing behind the scenes). > > > > |