[ACCEPTED]-JavaScript: Standalone compiler or interpreter for Windows?-windows

Accepted answer
Score: 11

Nobody has mentioned yet, window's own javascript 7 compiler: http://msdn.microsoft.com/en-us/library/vstudio/7435xtz6(v=vs.100).aspx

Microsoft (R) JScript Compiler version 8.00.50727
for Microsoft (R) .NET Framework version 2.0.50727
Copyright (C) Microsoft Corporation 1996-2005. All rights reserved.

jsc [options] <source files> [[options] <source files>...]

                         JScript Compiler Options

                           - OUTPUT FILES -
  /out:<file>              Specify name of binary output file
  /t[arget]:exe            Create a console application (default)
  /t[arget]:winexe         Create a windows application
  /t[arget]:library        Create a library assembly
  /platform:<platform>     Limit which platforms this code can run on; must be x86, Itanium, x64, or anycpu, which is the default

                           - INPUT FILES -
  /autoref[+|-]            Automatically reference assemblies based on imported namespaces and fully-qualified names (on by default)
  /lib:<path>              Specify additional directories to search in for references
  /r[eference]:<file list> Reference metadata from the specified assembly file
                           <file list>: <assembly name>[;<assembly name>...]

                           - RESOURCES -
  /win32res:<file>         Specifies Win32 resource file (.res)
  /res[ource]:<info>       Embeds the specified resource
                           <info>: <filename>[,<name>[,public|private]]
  /linkres[ource]:<info>   Links the specified resource to this assembly
                           <info>: <filename>[,<name>[,public|private]]

                           - CODE GENERATION -
  /debug[+|-]              Emit debugging information
  /fast[+|-]               Disable language features to allow better code generation
  /warnaserror[+|-]        Treat warnings as errors
  /w[arn]:<level>          Set warning level (0-4)

                           - MISCELLANEOUS -
  @<filename>              Read response file for more options
  /?                       Display help
  /help                    Display help
  /d[efine]:<symbols>      Define conditional compilation symbol(s)
  /nologo                  Do not display compiler copyright banner
  /print[+|-]              Provide print() function

                           - ADVANCED -
  /codepage:<id>           Use the specified code page ID to open source files
  /lcid:<id>               Use the specified LCID for messages and default code page
  /nostdlib[+|-]           Do not import standard library (mscorlib.dll) and change autoref default to off
  /utf8output[+|-]         Emit compiler output in UTF-8 character encoding
  /versionsafe[+|-]        Specify default for members not marked 'override' or 'hide'

There are usually a couple of 6 copies lying around on any windows install, but 5 they are not usually in the path, so you 4 have to find them.

The compiler is capable 3 of compiling javascript files into executables 2 that can run on any windows machine with 1 .NET installed.

Score: 10

Node.js works well as an interpreter, even if you 7 do not choose to use it for web applications. It 6 is a framework that runs on the V8 JavaScript 5 engine. It is well documented with a large selection of 4 official and third party modules.

It does require cygwin to run on Windows 3 though (or you can compile it with MingW). There are precompiled 2 binaries, including the required cygwin 1 libraries, available at node-js.prcn.co.cc.

Score: 4

There are several free standalone Javascript 1 interpreters available:

  1. V8 - This is the same Javascript engine used in the Chrome browser.
  2. SpiderMonkey - From Mozilla.
  3. Rhino - A Javascript implementation on Java.
Score: 2

jsdb is nice. I use it within editplus, sometimes within 1 Aptana Studio

Score: 2

You can also, under some circumstances run JScript scripts 3 (Microsoft's Javascript implementation) directly 2 on the command prompt.

But my personal favourite 1 is Rhino, mentioned in the other answer.

Score: 2

Ok, Windows Scripting Host is tool for performing 10 various administrative tasks using Microsoft's 9 Active Scripting and can run scripts in various languages, including 8 JScript, their ECMAScript implementation. There 7 is no much else to say about it, so point 6 your browser to the reference - http://msdn.microsoft.com/en-us/library/shzd7dy4(VS.85).aspx

Forget about 5 compiler, BTW, ECMAScript is interpreted language 4 (JIT compiling is the other issue)

Also, note 3 that ECMAScript standard does not define 2 any standard I/O, so the host program is 1 responsible for providing it.

Score: 1

Perhaps a bit convoluted for what you're 9 looking for but you can use Rhino's JavaScript Compiler to compile 8 JavaScript source code into Java class files 7 which can then be compiled to binary executable 6 programs using the standard GCJ frontend to the GCC compiler suite.

As mentioned 5 by others, the JScript implementation of 4 ECMAScript is available by default on modern 3 Windows installations. Files with a ".js" extension 2 can be double-click executed or run on the 1 command-line using the cscript.exe command.

Score: 1

I also had the same need but eventually 16 found an app called DeskJS (https://deskjs.wordpress.com). It's a free 15 and portable Windows console application 14 that lets you run pure JavaScript code and 13 even load any existing JS files. It supports 12 the basic JS popup boxes implemented in 11 browsers. You can save your commands as 10 JS files that can be run on startup or by 9 dragging-and-dropping them on the app. Plus 8 there's so much more to it like you can 7 create a build system for Sublime Text that 6 can run JS files via cmd, it supports themes 5 for customizing the entire console and snippets 4 which let you save short snippets of JavaScript 3 code for later use. Improvements are still 2 being made on the app together with other 1 native APIs being included.

Score: 0

Have you tried Mozilla XUL & XULRunner? It is quite more complex 6 than being just an interpreter but it runs 5 also on MacOsX & Linux, not only Windows. Firefox 4 and Thunderbird are written using it (yes, Firefox 3 is written in Javascript!). There will be 2 XUL workshop on FalsyValues conference in Warsaw next 1 month - link.

More Related questions