On 2008-10-31 02:53, slebetman wrote:
>SpiderMonkey (C implementation of the same, but not really usable as a
scripting environment)>
<snip>
Mozilla SpiderMonkeyhttp://www.mozilla.org/js/spidermonkey/
The demo js interpreter that comes with SpiderMonkey is actually
really easy to extend. I managed to add file IO capabilities
(fopen,fread,fgets,fputs,fseek,fclose) in around 250 lines of code.
Sometimes I really regret that I haven't done more C programming. I
couldn't even build the stupid thing with support for the old File
object :-/
When I was experimenting with the SpiderMonkey jsshell, all I had was
the readline() function. Unfortunately this function isn't nearly as
useful as I had hoped - it doesn't recognize the EOF, and it seems to
automagically convert all input to Unicode. I had to resort to writing a
Perl wrapper that passed the number of lines to be read to the js file.
I myself have been thinking of implementing a simple binary module/
package system for SipderMonkeys js interpreter (instead of directly
modifying the interpreter)
I think the interpreter is meant to be embedded anyway, not modified
directly. I think this is what JSDB is doing. If you go ahead with this
and build a usable all-purpose interpreter, count me in as a beta tester.
so that you can simply "require" a module and have it loaded.
There's a load() function in jsshell. It works, but it's very basic and
doesn't do any fancy stuff like path management.
Lots of languages have gone this path,
implementing a very simple interpreter which is turing complete but
can't do much then load features from modules/packages.
A full scripting environment for JS on the command line would be very
exciting. In time, we could even have module repositories like CPAN =)
- Conrad