|
So first off let me say I'm on the side of "lean is better", which means keeping a really minimal runtime. But if the runtime *IS* to be extended, what should the criteria be for selecting the extensions? Let me throw out a straw-man list, others can critique it (or ignore it!) as they wish... 1. Generality. Library routines should apply to as many problem domains as possible. So no adding home mortgage functions to the math library, for example. 2. Non-Triviality. Routines that can be written in 5-10 lines of Lua code don't seem good candidates to me. The example earlier of a "set()" function to create a set from a table (migrate array values to keys) seems to me to fall into that category. [If you go down this road you end up with developers really just stringing together dozens of calls to runtime functions, with the result that the code no longer looks like Lua and the underlying operation is all but lost in the mess.] 3. Performance. Some things are hard to code efficiently in Lua, and routines that handle heavy lifting in C do make some sense. 4. Abstraction. Some operations are inherently platform-dependent in their implementation, even if they can be exposed through a standard interface. [Lua does pretty well on this, but it does inherit some of the failures in this regard of the underlying C runtime (the format of paths passed to the file open functions comes to mind).] [As an aside, imho adding lots of library routines can lead to AWFUL code. First off, inexperienced developers can get lost amongst a huge sea of library routines, fail to find the "ideal" routine and end up writing the code themselves anyway (or worse, bending the wrong routine to the task). Second, inexperienced developers often treat library routines as "magic", particularly when it comes to performance, and end up writing slow code and then blaming the runtime library for not being instantaneous. The bloated Java and .Net libraries are examples of this.] --Tim On Feb 15, 2012, at 2:28 AM, Dirk Laurie wrote: Op 14 februari 2012 03:17 schreef Jay Carlson <nop@nop.com> het volgende: |