lua-users home
lua-l archive

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


> I hate to nay-say Lua on the mailing list, but when
> you have tiny systems like this, dosn't it make
> sense to avoid memory expensive stuff like lua
> string-based hash tables and the overhead of
> interpreting bytecodes?

Often, yes.  One platform I'm currently working on is a 8-bit HC08 with 32k
of flash and a tiny amount of RAM.  Lua on such a system would be totally
stupid, and I wouldn't even attempt it.

But there are small systems I would try it on.  Another platform I'm working
on is 8051-based, but we've extended it with bank switching logic to have a
huge amount of program and data space.  My interest in Lua for such a system
is not to have a high-performance system, but to have a system where
extensions and customizations can be written in a high-level language like
Lua.

More realistically, our next project will be using a 16-bit ColdFire
processor with a large amount of RAM.  There, I expect getting Lua running
there is going to be far easier.

> You can already do interactive development on the
> target. The lua library has the parser and bytecode
> compiler built right in. just dostring() away.

I know; on the CPC4400 project, we embedded Lua into the embedded Ethernet
switch platform and had great fun working interactively.  As a fan of Forth,
this was no big deal for me, but for the folks at work who only knew C,
interactive development blew their minds.

> > I suspect that with careful coding, the Lua compiler
> > would be smaller (both in Lua source and object) than
> > the equivalent C code.
>
> I doubt it.

The goal of having the Lua compiler as a Lua program is really to minimize
the Lua kernel down to the absolute bare minimum, but still have the ability
to do interactive work on it.  As someone who spends probably 85% of my
programming time on very small systems, I fully appreciate that doing what I
want may be some combination of insane and stupid.  And really, I've already
solved the problem-- Forth.  But I like to explore the limits of things, and
seeing if Lua can work on such platforms is one of those limits.  It might
not result in anything useful when I'm done, but the experience should be
fun.

For those interested in the kind of things one can do with a virtual machine
on a tiny 8-bit target, look at ftp://ftp.dunfield.com/avirtual.zip for
inspiration.  It's not Lua-- described is a small, high-performance VM used
to get past a hardware environment that has an extremely restricted address
space.  But the essential ideas here are what I'm going to explore.