[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Questions about writing a C library
- From: RLake@...
- Date: Wed, 24 Mar 2004 00:41:27 +0000
Phil: please don't take this personally :) I am writing
because I have seen so many people following this
path lately, and
Phil Bewig escribe:
> As an exercise in learning to program in
lua, and because I
> think it will be a useful library to have, I am writing a
> library to manipulate linked lists.
In other words, you seek to learn how to program in
Lua by writing
a program in C, a language in which you are presumably
fluent, in order to create a datatype not present
in Lua so that
you could program in Lua as though it were, perhaps,
language in which you are also presumably fluent.
This does not strike me as the best way to learn Lua.
this sort of approach is likely to end up with your
with Lua and ultimately abandoning it for some language
more comfortable with. It rather reminds me of the
marriage in which both partners, although they have
fallen in love
with each other, immediately set out to change the
someone else, someone who they had not fallen in love
can only end in tears.
If you want to learn a new language, you should at
least spend a
little time getting to understand how it fits together
on its own
terms, not as though it were some other language.
Lua does not
have linked lists, but it is still a useful and reasonably
language. Why? Because other programming styles and
fill that particular gap. Not, perhaps, perfectly,
but well enough.
At the same time, Lua provides other facilities not
scripting languages, which simplify solving other
types of problems.
Despite the kitchen-sinkism of Perl, programming languages
just lists of features. A well-designed programming
language is a
coherent whole whose paradigms complement each other;
present because they fit and other things are absent
On a more pragmatic level, if you continue with this
project, I think
you will end up getting very frustrated, because what
you seek to do
probably cannot be done, and certainly cannot be done
Like most scripting environments, Lua is pretty well
a sealed unit.
Internal datatypes are internal, and cannot easily
be extracted and
replaced later. (This is particularly the case for
around garbage collection, for reasons which should
be obvious. How,
for example, would you anticipate freeing a cons node?)
This is not to say that Lua is unwilling to share.
Its C interface
is very well defined and quite easy to use. You just
have to use it
on its own terms.