lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 28 February 2011 20:03, Kevin Vermeer <> wrote:
> On Mon, Feb 28, 2011 at 2:42 PM, Reuben Thomas <> wrote:
>> On 28 February 2011 19:34, Kevin Vermeer <> wrote:
>> >
>> > Thanks for sweating these details.  I understand that many of your users
>> > may
>> > never go outside of the infinite memory model popular in desktop
>> > programming, but some of us embedded programmers are trying to use Lua
>> > with
>> > 64kB or less of RAM, so those 500 bytes make a big difference!
>> So when you're using Lua in 64Kb of RAM, you still use the package
>> library? Why?
> For the same reasons you use it on whatever machine you have.

So, when you only have 64Kb of memory at your disposal, you have
complicated enough programs that it's worth spending several kB on the
module system? (Stripped, loadlib.o is 5.8Kb on my machine, which
suggests that you're using 10% of your memory (allowing conservatively
for run-time memory usage) just to keep track of the modules you load
into the rest. I must be missing something?

> I could ask you why you don't just use your stdlib library on your system,

I do, but that only helps people who use stdlib.

> This doesn't seem to
> be unfriendly, ugly, or bizarre as you claim it is.

Clearly it is, or I wouldn't have to write the veneer.

> It might be a little inconsistent, but, as Roberto argued, that's a sacrifice that's probably
> acceptable.

No, it's not acceptable, because it doesn't help anyone. Those of us
who have plenty of memory are not well-served by the weird interface
which needs programming around to use in programs (and even Roberto
got it wrong). Those of us who are memory-constrained don't need
loadlib in the first place, and so aren't helped by the memory saved.

> The real issue is that if the language designers chose to spend the 500
> bytes every time the question came up, Lua would soon become as big as
> Python.

Every time what question came up? This is not another little extra of
the sort frequently discussed, whose accumulation soon makes the
language bigger. This is a feature which already exists, but whose
implementation is badly designed.

> Lua's small size is a more important than the table/string nature of
> package.config, and not just to embedded developers.

Lua's small size is important, but not at the expense of its
simplicity. It's a balance that the design mostly gets right. There
are other details from luaconf.h it would be nice to make accessible
LUAI_MAX_NUMBER2STR and so on. There are various ways in which this
could be done, but shoving them all in a long string is not a good
one. The obvious thing to do would be to add similar constants to the
relevant libraries (or _G, for non-library-specific values). It's
consistent and extensible. It will use a few hundred more bytes too,
but that's just the nature of Lua's data structures: one can equally
save hundreds of bytes by removing any other features one doesn't use.