lua-users home
lua-l archive

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


On 1/11/2015 12:01 AM, John Hind wrote:
I believe a chip with 512k of RAM is good for a lot of real world eLua
applications. <Bogdan Marinescu>

Have you considered doing a Kickstarter like the Python and JavaScript
examples I referenced?

I don't think Lua is taking lot of RAM, all dynamic languages that I know
of need a lot of RAM (for good reasons) . <Bogdan Marinescu>

There is an idea that has been rattling about in my mind for a few years
now, but it may still be a little half-baked. This is that it should be
possible to allocate the bytecodes of functions/closures separately from any
required volatile storage (for example upvalues). The latter would be stored
in RAM, while the bytecodes would be stored as immutable strings (strings in
Lua already being  byte-safe and immutable). Then all you'd need is the
ability to compile the memory allocation functions to allocate strings in
EPROM. Not only does this take the bytecodes (and the strings) out of the
RAM budget, but it also allows string fragment compression/deduplication to
be used on bytecode sequences as well. If source is recompiled and generates
the same bytecode sequence, the deduplication automatically eliminates it
using no more memory. On von Neumann architectures everything would be
allocated from RAM but still benefit from compression, while on
microcontrollers the memory allocation function could be replaced by one
with access to both EPROM and RAM. Garbage collection would also need to be
modified so strings/bytecodes (if allocated in non-volatile memory) are only
collected on demand.
[snip snip]

It can be done, but it may be hard to justify the effort. A more likely solution is simply to choose an appropriate product.

If say a Lua scripted app is likely to hit the limits of a PIC32 with 512KB SRAM, then it would probably make more sense to use an SBC instead. A PIC32 with an FPU would make it easier for me to do calculations and drive a robot arm directly (and Lua scripting will make it much more fun) but I would find an SBC if I wanted to do robot vision. In short, pick parts based on a target application and not the other way round.

Today, a non-FPU PIC32 512KB SRAM is about USD10 for 10+ pieces. Looking at a nice Wikipedia page [1], I can dig a bit and find at Olimex an Allwinner A13 board for EUR18 (qty 1), it has 256MB DDR3 RAM. Both are very affordable.

So although it's possible to modify Lua for optimal SRAM/Flash utilization, I would just pick an SBC if an app is too big for a single IC. IC manufacturing advances wins again. :-)

[1] http://en.wikipedia.org/wiki/Comparison_of_single-board_computers

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia