views:

139

answers:

2

I have a project that needs to create and use COM objects. I found some examples using Javascript on the command-line and it looks like the perfect option for me. They will likely be short scripts (<100 lines) that talk to a COM server and a Postgres database.

Does anyone have a better approach? Is there a good tool that can assist with creating this type of Javascript. Most tools (like aptana) tend to focus on running javascript from a browser, not from the command line. I would really like just a simple IDE with breakpoints and watches or even a simple terminal application that would allow me to type a javascript command and see a result. Any suggestions?

A: 

Have you tried creating a JSCript.Net file in Visual Studio? It should be able to debug Javascript compiled into a .Net assembly, though I'll admit that I haven't tried it.

jsight
+3  A: 

You can run JavaScript on the command line using either Rhino for Java or Windows Script Host.

http://www.mozilla.org/rhino/

http://msdn.microsoft.com/en-us/library/9bbdkx3k%28VS.85%29.aspx

Running JavaScript from the command line will prevent access to browser only objects and the DOM such as: window, document, location, and so forth.

There's also a commandline version of SipderMonkey/TraceMonkey (Mozilla's C-bases engine from Firefox). But, as Austin mentions, one problem with JavaScript is that its standard library is woefully incomplete. It doesn't have any way of input/output for instance, other than through the DOM which only exists in the browser. There are some ECMAScript implementations which add libraries for commandline and even GUI development, though. DMDScript, for example, adds `print`, `println` and `readln` for simple commandline console I/O: http://DigitalMars.Com/dscript/
Jörg W Mittag