Minix 3 and Lua, Berkeley DB, and SQLite



I spent my Saturday experimenting with building open source utility
software under Minix 3. I had mixed results.

Berkeley DB from www.sleepycat.com is a larger product than I remember.
It won't compile because it expects a GNU gcc compatible tool chain on
a Unix target. SQLite from www.sqlite.org won't build for the same
reason.

I had good success building Lua 5.0.2. I made minor mods to change
'gcc' to 'cc', etc. in a 'config' file, as recommended in the INSTALL
file. It built successfully, and some of the Lua test scripts worked.

The 'sieve.lua' test script failed after several iterations. I used
Minix 'chmem' to increase the stack/heap. With each increase,
'sieve.lua' progressed further, until finally it ran to successful
completion after the last stack/heap increase:

# chmem +1000 lua
lua: Stack+malloc area changed from 131072 to 132072 bytes.
# chmem +100000 lua
lua: Stack+malloc area changed from 132072 to 232072 bytes.
# chmem +100000 lua
lua: Stack+malloc area changed from 232072 to 332072 bytes.

VIM 6.3 for Minix 3 recognizes '.lua' script files, so Lua keyword
syntax highlighting works without doing anything special. The Lua
source is attractive. For example, 'sieve.lua' is:

-- the sieve of of Eratosthenes programmed with coroutines
-- typical usage: lua -e N=1000 sieve.lua | column

-- generate all the numbers from 2 to n
function gen (n)
return coroutine.wrap(function ()
for i=2,n do coroutine.yield(i) end
end)
end

-- filter the numbers generated by `g', removing multiples of `p'
function filter (p, g)
return coroutine.wrap(function ()
while 1 do
local n = g()
if n == nil then return end
if math.mod(n, p) ~= 0 then coroutine.yield(n) end
end
end)
end

N=N or 1000 -- from command line
x = gen(N) -- generate primes up to N
while 1 do
local n = x() -- pick a number until done
if n == nil then break end
print(n) -- must be a prime number
x = filter(n, x) -- now remove its multiples
end

Lua seems like a pretty good fit for Minix 3 where an embedded
application will benefit from integration with a scripting language,
and Python is perhaps a little heavy. I credit Lua for distributing
basic ANSI C code and simple make files that do not require GNU tool
chain compatibility. From www.lua.org:

> Lua is a language engine that you can embed into your application.
> This means that, besides syntax and semantics, Lua has an API
> that allows the application to exchange data with Lua programs
> and also to extend Lua with C functions. In this sense, Lua can
> be regarded as a language framework for building domain-specific
> languages.

> Lua is implemented as a small library of C functions, written in
> ANSI C, and compiles unmodified in all known platforms. The
> implementation goals are simplicity, efficiency, portability, and
> low embedding cost. The result is a fast language engine with
> small footprint, making it ideal in embedded systems too.

I enjoyed my Saturday with Minix 3 and Lua. I like what I have seen so
far of the ACK compiler and the ash shell, but I am a little concerned
that the lack of the GNU toolchain and the bash shell is going to make
it challenging to port popular (and perhaps necessary) packages to
Minix 3.

Thanks.

Jim

.



Relevant Pages

  • Shared library support in MINIX 3
    ... I am experimenting with Lua under MINIX 3. ... Lua includes support for calling user written C functions from the Lua ...
    (comp.os.minix)
  • Shared library support in MINIX 3
    ... I am experimenting with Lua under MINIX 3. ... Lua includes support for calling user written C functions from the Lua ...
    (comp.os.minix)
  • Re: Minix 3 and Lua, Berkeley DB, and SQLite
    ... > I enjoyed my Saturday with Minix 3 and Lua. ... that the lack of the GNU toolchain and the bash shell is going to make it challenging to port popular packages to Minix 3. ...
    (comp.os.minix)
  • Re: Languages that dont suck after Perl?
    ... stupid language making me go through so much work just make a simple ... preffering it to Perl at times given some small convenience wrappers. ... I'm happy that when I program in Lua I have a feeling I've mastered ... you have to go character by character to parse them mentally with a naive ...
    (comp.lang.perl.misc)
  • Re: Learning different languages
    ... I've been trying to get my kids to learn a little Python for some ... Simple -- Lua is the extension language for Enigma. ... make new game levels ergo, ...
    (comp.lang.python)